From e9ae100975a868a6e0e91a51ce54d243d52ab6c7 Mon Sep 17 00:00:00 2001 From: François Pottier Date: Fri, 23 Oct 2015 12:47:41 +0200 Subject: 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. --- cparser/pre_parser.mly | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'cparser/pre_parser.mly') 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 {} -- cgit