diff options
author | François Pottier <francois.pottier@inria.fr> | 2015-10-23 12:47:41 +0200 |
---|---|---|
committer | François Pottier <francois.pottier@inria.fr> | 2015-10-23 12:47:41 +0200 |
commit | e9ae100975a868a6e0e91a51ce54d243d52ab6c7 (patch) | |
tree | 9fc430d58b3d4fc22461fb447443f6ded21fe13f | |
parent | 89e9eabc2fb752a6535cb375232d0141cc1f4fd3 (diff) | |
download | compcert-e9ae100975a868a6e0e91a51ce54d243d52ab6c7.tar.gz compcert-e9ae100975a868a6e0e91a51ce54d243d52ab6c7.zip |
Added a phantom parameter to [abstract_declarator].
This allows distinguishing two uses of abstract_declarator, within a type_name
and within a parameter_declaration. This provides more static context and
allows giving a better syntax error message, as this allows us know what is
expected next: a closing parenthesis or a comma.
-rw-r--r-- | cparser/pre_parser.mly | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/cparser/pre_parser.mly b/cparser/pre_parser.mly index 1940aaa8..8002d5c4 100644 --- a/cparser/pre_parser.mly +++ b/cparser/pre_parser.mly @@ -567,20 +567,24 @@ parameter_list: parameter_declaration: | declaration_specifiers id=declare_varname(fst(declarator)) { Some id } -| declaration_specifiers abstract_declarator? +| declaration_specifiers abstract_declarator(parameter_declaration)? { None } type_name: -| specifier_qualifier_list(type_name) abstract_declarator? +| specifier_qualifier_list(type_name) abstract_declarator(type_name)? {} -abstract_declarator: +(* The phantom parameter can be [parameter_declaration] or [type_name]. + We take the latter to mean [type_or_name] or [direct_abstract_declarator]. + We need not distinguish these two cases: in both cases, a closing parenthesis + is permitted (and we do not wish to keep track of why it is permitted). *) +abstract_declarator(phantom): | pointer | ioption(pointer) direct_abstract_declarator {} direct_abstract_declarator: -| LPAREN abstract_declarator RPAREN +| LPAREN abstract_declarator(type_name) RPAREN | direct_abstract_declarator? LBRACK type_qualifier_list? optional(assignment_expression, RBRACK) | ioption(direct_abstract_declarator) LPAREN in_context(parameter_type_list?) RPAREN {} |