develop syntax spec

This commit is contained in:
2025-11-17 09:38:37 +09:00
parent 682cbdc216
commit 2abfa54890
2 changed files with 21 additions and 7 deletions

View File

@@ -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
```
param_list := LPAREN (type ID)* RPAREN
lambda := param_list compound
compound := LCURLY (stmt)* expr? RCURLY
```