develop syntax spec
This commit is contained in:
18
README.md
18
README.md
@@ -22,13 +22,15 @@
|
|||||||
|
|
||||||
## Syntax Spec
|
## Syntax Spec
|
||||||
|
|
||||||
```
|
```spec
|
||||||
program := defn*
|
program := defn*
|
||||||
|
|
||||||
defn := VAL type ID ;
|
defn := VAL type ID ;
|
||||||
| VAL type ID expr ;
|
| 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*
|
expr := atom atom*
|
||||||
|
|
||||||
@@ -37,13 +39,19 @@ atom := ID
|
|||||||
| STR
|
| STR
|
||||||
| lambda
|
| lambda
|
||||||
| compound
|
| compound
|
||||||
| reference
|
| STAR
|
||||||
| dereference
|
| ANDREF
|
||||||
|
|
||||||
stmt := defn
|
stmt := defn
|
||||||
| expr ; // expr statement
|
| expr ; // expr statement
|
||||||
| return expr ; // return statement
|
| return expr ; // return statement
|
||||||
| $ ID expr ; // assignment statement
|
| DOLLAR ID expr ; // assignment statement
|
||||||
| if expr compound ; // if statement
|
| if expr compound ; // if statement
|
||||||
| if expr compound else compound ; // if-else 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