diff options
| author | Tom Harley | 2019-10-03 02:42:28 +0100 |
|---|---|---|
| committer | Tom Harley | 2019-10-03 02:42:28 +0100 |
| commit | 64d093247985f759669b7726542291382c1e3fc5 (patch) | |
| tree | 4b8324373c4b267cd1affcab8a8ece20b920323b /parse.y | |
| parent | Initial commit (diff) | |
| download | sinter-64d093247985f759669b7726542291382c1e3fc5.tar.gz sinter-64d093247985f759669b7726542291382c1e3fc5.zip | |
Support + and * operations
Diffstat (limited to 'parse.y')
| -rw-r--r-- | parse.y | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -23,21 +23,29 @@ void yyerror(char *s, ...); %token <f> FLOAT %token <i> INT %token <s> ID +%token <s> STRING %token BRANCH %type <u> sexpr +%type <u> lexpr %% cmds: - | cmds sexpr { print_sexpr($2); } + | cmds sexpr { codegen($2); } sexpr: '(' sexpr ';' sexpr ')' { $$ = new_node($2, $4); } | '(' sexpr sexpr ')' { $$ = new_node($2, $3); } - | INT { $$ = new_int($1); } - | FLOAT { $$ = new_float($1); } - | ID { $$ = new_id($1); } - | NIL { $$ = 0; } + | '[' lexpr { $$ = $2; } + | INT { $$ = new_int($1); } + | FLOAT { $$ = new_float($1); } + | ID { $$ = new_id($1); } + | NIL { $$ = 0; } + | STRING { $$ = new_str($1); } + +lexpr: ']' { $$ = 0; } + | sexpr ';' lexpr { $$ = new_node($1, $3); } + | sexpr lexpr { $$ = new_node($1, $2); } %% |
