aboutsummaryrefslogtreecommitdiffstats
path: root/cparser/pre_parser.mly
diff options
context:
space:
mode:
authorFrançois Pottier <francois.pottier@inria.fr>2015-10-07 10:09:33 +0200
committerFrançois Pottier <francois.pottier@inria.fr>2015-10-07 10:24:50 +0200
commit7c4dd1467e62229689fe15656f4405f617edca1d (patch)
tree27be05981f54c7f773bd73d08de22fe401c08302 /cparser/pre_parser.mly
parentd9b17759c9a56a33b7e2d57e0aaaab4951ef222d (diff)
downloadcompcert-kvx-7c4dd1467e62229689fe15656f4405f617edca1d.tar.gz
compcert-kvx-7c4dd1467e62229689fe15656f4405f617edca1d.zip
Introduced [other_identifier] as a more elegant way of calling [set_id_type i OtherId].
This causes no change in the automaton.
Diffstat (limited to 'cparser/pre_parser.mly')
-rw-r--r--cparser/pre_parser.mly41
1 files changed, 22 insertions, 19 deletions
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