diff options
author | Teddy <[email protected]> | 2014-04-06 06:48:41 +0800 |
---|---|---|
committer | Teddy <[email protected]> | 2014-04-06 06:48:41 +0800 |
commit | 4f0f6f064fc5c878bee2f614e1296b14e66fef8d (patch) | |
tree | 2daed305d65773634cb3accb28ecd14133c1ccc9 | |
parent | 25e023cf554b0ccafa113296da090fbb277d576e (diff) |
remove redundant syntax in `cibic.y`complex_pointer
-rw-r--r-- | README.rst | 3 | ||||
-rw-r--r-- | cibic.y | 14 | ||||
-rw-r--r-- | semantics.c | 2 |
3 files changed, 7 insertions, 12 deletions
@@ -10,6 +10,7 @@ Build Requirements Features --------- - Complex pointer support +- Forward declaration +- Sophisticated error reporting - User-friendly AST printing -- More sophisticated error reporting - Small memory footprint @@ -49,7 +49,8 @@ function_definition } parameters - : plain_declaration + : { $$ = NULL; } + | plain_declaration | parameters ',' plain_declaration { $$ = cnode_list_append($1, $3); } declarators @@ -107,11 +108,6 @@ plain_declaration direct_declarator : identifier | '(' declarator ')' { $$ = $2; } - | direct_declarator '(' ')' { - $$ = cnode_add_loc(cnode_create_declr( - DECLR_FUNC, 2, $1, - cnode_list_wrap(PARAMS, cnode_create_nop())), @$); - } | direct_declarator '(' parameters ')' { $$ = cnode_add_loc(cnode_create_declr( DECLR_FUNC, 2, $1, @@ -325,16 +321,14 @@ postfix $$ = cnode_add_loc(cnode_create_exp( POSTFIX_CALL, 1, cnode_add_loc(cnode_list_wrap(ARGS, $2), @2)), @$); } - | '(' ')' { - $$ = cnode_add_loc(cnode_create_exp( - POSTFIX_CALL, 1, cnode_list_wrap(ARGS, NULL)), @$); } | '.' identifier { $$ = cnode_add_loc(cnode_create_exp(POSTFIX_DOT, 1, $2), @$); } | OPT_PTR identifier { $$ = cnode_add_loc(cnode_create_exp(POSTFIX_PTR, 1, $2), @$); } | OPT_INC { $$ = cnode_add_loc(cnode_create_exp(OPT_INC, 0), @$); } | OPT_DEC { $$ = cnode_add_loc(cnode_create_exp(OPT_DEC, 0), @$); } arguments - : assignment_expression + : { $$ = NULL; } + | assignment_expression | arguments ',' assignment_expression { $$ = cnode_list_append($1, $3); } primary_expression diff --git a/semantics.c b/semantics.c index 00f956c..81cbf11 100644 --- a/semantics.c +++ b/semantics.c @@ -481,7 +481,7 @@ CType_t semantics_type_name(CNode *p, CScope_t scope) { CVar_t semantics_params(CNode *p, CScope_t scope) { CHECK_TYPE(p, PARAMS); p = p->chd; - if (p->type == NOP) return NULL; /* void arguments */ + if (!p) return NULL; /* no parameters */ CVar_t params = semantics_p_decl(p, scope), tail = params; #ifdef CIBIC_DEBUG CTable_t tparams = ctable_create(bkdr_hash, ctable_cvar_print); |