From 2abfa548905b9bceca9e46481e5f6aab880bdd64 Mon Sep 17 00:00:00 2001 From: yenru0 Date: Mon, 17 Nov 2025 09:38:37 +0900 Subject: [PATCH] develop syntax spec --- README.md | 20 ++++++++++++++------ test.cval | 8 +++++++- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5491ef2..b942f64 100644 --- a/README.md +++ b/README.md @@ -22,13 +22,15 @@ ## Syntax Spec -``` +```spec program := defn* defn := VAL type ID ; | VAL type ID expr ; -type := ID | [] | [type] | [ type* ARROW type? ] +type := ID | type STAR + | LBRACK RBRACK | LBRACK type RBRACK + | LBRACK type* ARROW type? RBRACK expr := atom atom* @@ -37,13 +39,19 @@ atom := ID | STR | lambda | compound - | reference - | dereference + | STAR + | ANDREF stmt := defn | expr ; // expr statement | return expr ; // return statement - | $ ID expr ; // assignment statement + | DOLLAR ID expr ; // assignment statement | if expr compound ; // if statement | if expr compound else compound ; // if-else statement -``` \ No newline at end of file + +param_list := LPAREN (type ID)* RPAREN + +lambda := param_list compound + +compound := LCURLY (stmt)* expr? RCURLY +``` diff --git a/test.cval b/test.cval index a316d79..91fae59 100644 --- a/test.cval +++ b/test.cval @@ -18,4 +18,10 @@ val [->int] main { fib n }; } -}; \ No newline at end of file +}; + +val [char * int->char]get_char_of(char* s int index) { + return * { + add s index + }; +} \ No newline at end of file