minor implementation for parser
(simple type and defn)
This commit is contained in:
55
README.md
55
README.md
@@ -22,7 +22,7 @@
|
||||
|
||||
## Syntax Spec
|
||||
|
||||
```spec
|
||||
```c
|
||||
program := defn*
|
||||
|
||||
defn := VAL type ID ;
|
||||
@@ -55,3 +55,56 @@ lambda := param_list compound
|
||||
|
||||
compound := LCURLY (stmt)* expr? RCURLY
|
||||
```
|
||||
|
||||
### AST Spec
|
||||
|
||||
```c
|
||||
NODE_PROGRAM:
|
||||
token: PROGRAM
|
||||
children: NODE_DEFN*
|
||||
|
||||
NODE_DEFN:
|
||||
token: VAL
|
||||
children: NODE_TYPE, TOKEN_ID, (NODE_EXPR)?
|
||||
children_count: 2 | 3
|
||||
|
||||
NODE_TYPE_SIMPLE:
|
||||
token: ID
|
||||
children: NODE_ID NODE_TYPE_STAR*
|
||||
children_count: 1+
|
||||
NODE_TYPE_COMPLEX:
|
||||
token: COMPLEX_TYPE
|
||||
children: NODE_TYPE_PARAM NODE_TYPE_OUT
|
||||
NODE_TYPE_PARAM
|
||||
token: TYPE_PARAM
|
||||
children: (NODE_TYPE | NODE_TYPE_COMPLEX)*
|
||||
children_count: 0+
|
||||
NODE_TYPE_OUT
|
||||
token: TYPE_OUT
|
||||
children: (NODE_TYPE | NODE_TYPE_COMPLEX)?
|
||||
|
||||
NODE_EXPR:
|
||||
token: EXPR
|
||||
children: (atom)+
|
||||
// atom definition
|
||||
NODE_NUM:
|
||||
token: NUM
|
||||
NODE_STR:
|
||||
token: STR
|
||||
NODE_LAMBDA:
|
||||
token: LAMBDA
|
||||
children: NODE_PARAM_LIST NODE_COMPOUND
|
||||
NODE_COMPOUND:
|
||||
token: COMPOUND
|
||||
children: (NODE_STMT)* (NODE_EXPR)?
|
||||
children_count: 0+
|
||||
|
||||
|
||||
NODE_PARAM_LIST:
|
||||
token: PARAM_LIST
|
||||
children: NODE_PARAM*
|
||||
NODE_PARAM:
|
||||
token: PARAM
|
||||
children: NODE_TYPE, TOKEN_ID
|
||||
|
||||
```
|
||||
Reference in New Issue
Block a user