The unified diff between revisions [9a6e8df1..] and [8583f573..] is displayed below. It can also be downloaded as a raw diff.
This diff has been restricted to the following files: 'src/lsc/parser.y'
# # old_revision [9a6e8df1d6b102f467702e274d53d90f9151e2c8] # new_revision [8583f573519b60d2a4dfb35aa4ec8079f05b88c1] # # patch "src/lsc/parser.y" # from [a3d3372576329c2dc4221d54c0a05238eb86dece] # to [9b444a45ad7c17497adb8a9b2982c004a418589f] # ============================================================ --- src/lsc/parser.y a3d3372576329c2dc4221d54c0a05238eb86dece +++ src/lsc/parser.y 9b444a45ad7c17497adb8a9b2982c004a418589f @@ -28,6 +28,8 @@ int main(int argc, char *argv[]) int main(int argc, char *argv[]) { + int rv; + argv++; /* skip over program name */ argc--; if (argc > 0) { @@ -60,15 +62,15 @@ int main(int argc, char *argv[]) err(1, "%s: Failed to open output file", "out.lc"); } - yyparse(); + rv = yyparse(); fclose(binout); fclose(yyin); - return 0; + return rv; } %} -%token TOKFUNCTION TOKFNDEFINT TOKFNDEFEXT TOKCONSTANT +%token TOKFUNCTION TOKFNDEFINT TOKFNDEFINT_V TOKFNDEFEXT TOKCONSTANT %token TOKWHILE TOKIF TOKELSE TOKSWITCH TOKCASE TOKDEFAULT %token TOKBREAK TOKRETURN TOKEQ TOKNE TOKAND TOKOR STRING @@ -86,6 +88,7 @@ int main(int argc, char *argv[]) %type <Tast> fndefint %type <Tast> fndefext %type <Tast> statement +%type <Tast> fndefint_v %type <Tast> assignment %type <Tast> expression %type <Tast> realconstant @@ -142,6 +145,7 @@ fn_list_inner: fn_list_inner: fn_list_inner function { $$ = make_list($2, $1); } | fn_list_inner fndefint { $$ = make_list($2, $1); } + | fn_list_inner fndefint_v { $$ = make_list($2, $1); } | fn_list_inner fndefext { $$ = make_list($2, $1); } | fn_list_inner constant { $$ = make_list($2, $1); } | fn_list_inner realconstant { $$ = make_list($2, $1); } @@ -158,6 +162,11 @@ fndefint: { $$ = make_fndefint($2, $3); } ; +fndefint_v: + TOKFNDEFINT_V IDENTIFIER NUMBER ';' + { $$ = make_fndefint_v($2, $3); } + ; + constant: TOKCONSTANT IDENTIFIER NUMBER ';' { $$ = make_constant($2, $3); } @@ -319,8 +328,11 @@ statement_return: ; statement_return: + TOKRETURN expression + { $$ = make_return_statement($2); } + | TOKRETURN - { $$ = make_return_statement(); } + { $$ = make_return_statement(NULL); } ; statement_break: