summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorTom Harley2019-10-03 02:42:28 +0100
committerTom Harley2019-10-03 02:42:28 +0100
commit64d093247985f759669b7726542291382c1e3fc5 (patch)
tree4b8324373c4b267cd1affcab8a8ece20b920323b /parse.y
parentInitial commit (diff)
downloadsinter-64d093247985f759669b7726542291382c1e3fc5.tar.gz
sinter-64d093247985f759669b7726542291382c1e3fc5.zip

Support + and * operations

Diffstat (limited to 'parse.y')
-rw-r--r--parse.y18
1 files changed, 13 insertions, 5 deletions
diff --git a/parse.y b/parse.y
index 1810c51..2f302fb 100644
--- a/parse.y
+++ b/parse.y
@@ -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); }
%%