diff --git a/README.md b/README.md index b942f64..4027b26 100644 --- a/README.md +++ b/README.md @@ -42,9 +42,9 @@ atom := ID | STAR | ANDREF -stmt := defn - | expr ; // expr statement - | return expr ; // return statement +stmt := defn // defn statement + | expr ; // expr statement + | return expr ; // return statement | DOLLAR ID expr ; // assignment statement | if expr compound ; // if statement | if expr compound else compound ; // if-else statement @@ -55,3 +55,47 @@ lambda := param_list compound compound := LCURLY (stmt)* expr? RCURLY ``` + + +## AST Node Spec + +```c +NODE_PROGRAM: + token: PROGRAM + children: NODE_DEFN* +NODE_DEFN: + token: VAL + children: NODE_TYPE, ID, NODE_EXPR? +NODE_TYPE: + token: ID | COMPLEX_TYPE + children: NODE_TYPE, NODE_TYPE + | NODE_TYPE +NODE_EXPR: + token: EXPR + children: NODE_ATOM* + +// ATOM +NODE_NUM: + token: NUM + children: none +NODE_ID: + token: ID + children: none +NODE_STR: + token: STR + children: none +NODE_LAMBDA: + token: LAMBDA + children: NODE_PARAM_LIST, NODE_COMPOUND +NODE_PARAM_LIST: + token: PARAM_LIST + children: (NODE_PARAM)* +NODE_PARAM: + token: PARAM + children: NODE_TYPE, ID +NODE_COMPOUND: + token: COMPOUND + children: NODE_STMT*, NODE_EXPR? + + +``` \ No newline at end of file