aboutsummaryrefslogtreecommitdiff
path: root/cibic.y
diff options
context:
space:
mode:
Diffstat (limited to 'cibic.y')
-rw-r--r--cibic.y34
1 files changed, 17 insertions, 17 deletions
diff --git a/cibic.y b/cibic.y
index 66337c9..6e25724 100644
--- a/cibic.y
+++ b/cibic.y
@@ -36,25 +36,25 @@ declaration
$$ = cnode_add_loc(cnode_create_typedef(
$2,
cnode_add_loc(cnode_list_wrap(DECLRS, $4), @4)), @$);
- exit_declr();
+ clear_state();
}
| type_specifier ';' {
$$ = cnode_add_loc(cnode_create_decl(
$1,
cnode_list_wrap(INIT_DECLRS, cnode_create_nop())), @$);
- exit_declr();
+ clear_state();
}
| type_specifier init_declarators ';' {
$$ = cnode_add_loc(cnode_create_decl(
$1,
cnode_add_loc(cnode_list_wrap(INIT_DECLRS, $2), @2)), @$);
- exit_declr();
+ clear_state();
}
function_definition
: type_specifier declarator compound_statement {
$$ = cnode_add_loc(cnode_create_func($1, $2, $3), @$);
- exit_declr();
+ clear_state();
}
parameters
@@ -84,22 +84,22 @@ array_initializer
$$ = cnode_list_append(cnode_add_loc($1, @1), $3); }
type_specifier
- : KW_VOID { $$ = cnode_add_loc(cnode_create_type_spec(KW_VOID, 0), @$); enter_declr(); }
- | KW_CHAR { $$ = cnode_add_loc(cnode_create_type_spec(KW_CHAR, 0), @$); enter_declr(); }
- | KW_INT { $$ = cnode_add_loc(cnode_create_type_spec(KW_INT, 0), @$); enter_declr(); }
+ : KW_VOID { $$ = cnode_add_loc(cnode_create_type_spec(KW_VOID, 0), @$); force_id(); }
+ | KW_CHAR { $$ = cnode_add_loc(cnode_create_type_spec(KW_CHAR, 0), @$); force_id(); }
+ | KW_INT { $$ = cnode_add_loc(cnode_create_type_spec(KW_INT, 0), @$); force_id(); }
| struct_or_union identifier '{' struct_fields '}' {
$$ = cnode_add_loc(cnode_create_type_spec($1, 2, $2, cnode_add_loc(cnode_list_wrap(FIELDS, $4), @4)), @$);
- enter_declr();
+ force_id();
}
| struct_or_union '{' struct_fields '}' {
$$ = cnode_add_loc(cnode_create_type_spec($1, 2, cnode_create_nop(), cnode_add_loc(cnode_list_wrap(FIELDS, $3), @3)), @$);
- enter_declr();
+ force_id();
}
| struct_or_union identifier {
$$ = cnode_add_loc(cnode_create_type_spec($1, 2, $2, cnode_create_nop()), @$);
- enter_declr();
+ force_id();
}
- | user_type { $$ = cnode_add_loc(cnode_create_type_spec(USER_TYPE, 1, $1), @$); enter_declr(); }
+ | user_type { $$ = cnode_add_loc(cnode_create_type_spec(USER_TYPE, 1, $1), @$); force_id(); }
user_type
: USER_TYPE { $$ = cnode_add_loc(cnode_create_identifier($1), @$); }
@@ -113,17 +113,17 @@ struct_field
cnode_create_struct_field(
$1,
cnode_add_loc(cnode_list_wrap(DECLRS, $2), @2)), @$);
- exit_declr();
+ clear_state();
}
struct_or_union
- : KW_STRUCT { $$ = KW_STRUCT; enter_struct(); }
- | KW_UNION { $$ = KW_UNION; enter_struct(); }
+ : KW_STRUCT { $$ = KW_STRUCT; force_id(); }
+ | KW_UNION { $$ = KW_UNION; force_id(); }
plain_declaration
: type_specifier declarator {
$$ = cnode_add_loc(cnode_create_plain_decl($1, $2), @$);
- exit_declr();
+ clear_state();
}
direct_declarator
@@ -155,7 +155,7 @@ expression_statement
| expression ';' { $$ = cnode_add_loc(cnode_create_stmt(STMT_EXP, 1, $1), @$); }
compound_statement
- : { exit_declr(); enter_block(); } '{' comp_decls comp_stmts '}' {
+ : { clear_state(); enter_block(); } '{' comp_decls comp_stmts '}' {
$$ = cnode_add_loc(
cnode_create_stmt(STMT_COMP, 2, cnode_add_loc(cnode_list_wrap(COMP_DECLS, $3), @3),
cnode_add_loc(cnode_list_wrap(COMP_STMTS, $4), @4)), @$);
@@ -314,7 +314,7 @@ cast_expression
type_name
: type_specifier abstract_declarator_opt {
$$ = cnode_add_loc(cnode_create_declr(0, 2, $1, $2), @$);
- exit_declr();
+ clear_state();
}
abstract_declarator_opt