From 7c4dd1467e62229689fe15656f4405f617edca1d Mon Sep 17 00:00:00 2001 From: François Pottier Date: Wed, 7 Oct 2015 10:09:33 +0200 Subject: Introduced [other_identifier] as a more elegant way of calling [set_id_type i OtherId]. This causes no change in the automaton. --- cparser/pre_parser.mly | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'cparser/pre_parser.mly') diff --git a/cparser/pre_parser.mly b/cparser/pre_parser.mly index 43b44c13..c036caeb 100644 --- a/cparser/pre_parser.mly +++ b/cparser/pre_parser.mly @@ -106,6 +106,15 @@ general_identifier: | i = TYPEDEF_NAME { i } +(* [other_identifier] is equivalent to [general_identifier], but adds + an instruction that re-classifies this identifier as an [OtherId]. + Because this definition is marked %inline, the function call takes + place when the host production is reduced. *) + +%inline other_identifier: + i = general_identifier + { set_id_type i OtherId } + string_literals_list: | STRING_LITERAL | string_literals_list STRING_LITERAL @@ -161,9 +170,8 @@ postfix_expression: {} | BUILTIN_VA_ARG LPAREN assignment_expression COMMA type_name error { unclosed "(" ")" $startpos($2) $endpos } -| postfix_expression DOT i = general_identifier -| postfix_expression PTR i = general_identifier - { set_id_type i OtherId } +| postfix_expression DOT other_identifier +| postfix_expression PTR other_identifier | postfix_expression INC | postfix_expression DEC | LPAREN type_name RPAREN LBRACE initializer_list COMMA? RBRACE @@ -404,10 +412,9 @@ type_specifier_no_typedef_name: struct_or_union_specifier: | struct_or_union attribute_specifier_list LBRACE struct_declaration_list RBRACE +| struct_or_union attribute_specifier_list other_identifier LBRACE struct_declaration_list RBRACE +| struct_or_union attribute_specifier_list other_identifier {} -| struct_or_union attribute_specifier_list i = general_identifier LBRACE struct_declaration_list RBRACE -| struct_or_union attribute_specifier_list i = general_identifier - { set_id_type i OtherId } | struct_or_union attribute_specifier_list LBRACE struct_declaration_list error { unclosed "{" "}" $startpos($3) $endpos } | struct_or_union attribute_specifier_list general_identifier LBRACE struct_declaration_list error @@ -452,10 +459,9 @@ struct_declarator: enum_specifier: | ENUM attribute_specifier_list LBRACE enumerator_list COMMA? RBRACE +| ENUM attribute_specifier_list other_identifier LBRACE enumerator_list COMMA? RBRACE +| ENUM attribute_specifier_list other_identifier {} -| ENUM attribute_specifier_list i = general_identifier LBRACE enumerator_list COMMA? RBRACE -| ENUM attribute_specifier_list i = general_identifier - { set_id_type i OtherId } | ENUM attribute_specifier_list LBRACE enumerator_list COMMA? error { unclosed "{" "}" $startpos($3) $endpos } | ENUM attribute_specifier_list general_identifier LBRACE enumerator_list COMMA? error @@ -513,8 +519,7 @@ gcc_attribute: { set_id_type i VarId } gcc_attribute_word: -| i = general_identifier - { set_id_type i OtherId } +| other_identifier | CONST | PACKED {} @@ -607,9 +612,8 @@ designator_list: designator: | LBRACK constant_expression RBRACK +| DOT other_identifier {} -| DOT i = general_identifier - { set_id_type i OtherId } (* The grammar of statements is replicated three times. @@ -657,8 +661,7 @@ statement_intern_close: (* [labeled_statement(last_statement)] has the same effect on contexts as [last_statement]. *) labeled_statement(last_statement): -| i = general_identifier COLON last_statement - { set_id_type i OtherId } +| other_identifier COLON last_statement | CASE constant_expression COLON last_statement | DEFAULT COLON last_statement {} @@ -692,8 +695,7 @@ expression_statement(close): {} jump_statement(close): -| GOTO i = general_identifier close SEMICOLON - { set_id_type i OtherId } +| GOTO other_identifier close SEMICOLON | CONTINUE close SEMICOLON | BREAK close SEMICOLON | RETURN expression? close SEMICOLON @@ -797,8 +799,9 @@ asm_operand: {} asm_op_name: -| /*empty*/ {} -| LBRACK i = general_identifier RBRACK { set_id_type i OtherId } +| /*empty*/ +| LBRACK other_identifier RBRACK + {} asm_flags: | string_literals_list -- cgit