develop syntax spec
This commit is contained in:
20
README.md
20
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
|
||||
```
|
||||
|
||||
param_list := LPAREN (type ID)* RPAREN
|
||||
|
||||
lambda := param_list compound
|
||||
|
||||
compound := LCURLY (stmt)* expr? RCURLY
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user