diff options
-rw-r--r-- | c.y | 22 | ||||
-rw-r--r-- | test/t1.c | 2 |
2 files changed, 16 insertions, 8 deletions
@@ -35,9 +35,9 @@ struct node *root_node; %left NOT NEGATE DEREF ADDROF %type <id> ID NUM ADDOP MULOP RELOP BOOLOP -%type <node> toplevel toplevel_decl var_decl func_decl parameter_list parameter block -%type <node> statement statement_list open_statement matched_statement other_statement -%type <node> expression atom_expr expression_list +%type <node> toplevel toplevel_decl var_decl func_decl parameter_list parameter_list_rest +%type <node> parameter block statement statement_list open_statement matched_statement +%type <node> other_statement expression atom_expr expression_list %type <type> type INT VOID %union { @@ -85,11 +85,19 @@ type: type PTR { $$ = type_ptr($1); } | INT { $$ = type_int(16); } | VOID { $$ = type_void(); } ; -parameter_list: parameter { - $$ = node_make_2(N_LIST, $1, node_make_0(N_LIST_END)); +parameter_list: { + $$ = node_make_0(N_LIST_END); } - | parameter ',' parameter_list { - $$ = node_make_2(N_LIST, $1, $3); + | parameter parameter_list_rest { + $$ = node_make_2(N_LIST, $1, $2); + } ; + +parameter_list_rest: + { + $$ = node_make_0(N_LIST_END); + } + | ',' parameter parameter_list_rest { + $$ = node_make_2(N_LIST, $2, $3); } ; parameter: type ID { @@ -14,7 +14,7 @@ int fibo(int n) { return b; } -void main(int argc, int **argv) { +void main() { int a = 1; int b = 2 + a * 3; glob = glob + 1; |