aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeddy <[email protected]>2014-04-06 06:48:41 +0800
committerTeddy <[email protected]>2014-04-06 06:48:41 +0800
commit4f0f6f064fc5c878bee2f614e1296b14e66fef8d (patch)
tree2daed305d65773634cb3accb28ecd14133c1ccc9
parent25e023cf554b0ccafa113296da090fbb277d576e (diff)
remove redundant syntax in `cibic.y`complex_pointer
-rw-r--r--README.rst3
-rw-r--r--cibic.y14
-rw-r--r--semantics.c2
3 files changed, 7 insertions, 12 deletions
diff --git a/README.rst b/README.rst
index 4facfd1..3082c02 100644
--- a/README.rst
+++ b/README.rst
@@ -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
diff --git a/cibic.y b/cibic.y
index cfc26df..5d707b7 100644
--- a/cibic.y
+++ b/cibic.y
@@ -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);