From dba806ca25b5bc53b744e2c1c2d72fa3d6cd8e05 Mon Sep 17 00:00:00 2001 From: xleroy Date: Mon, 5 May 2014 08:27:22 +0000 Subject: Support for old-style K&R function definitions. git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2478 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e --- cparser/pre_parser.mly | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'cparser/pre_parser.mly') diff --git a/cparser/pre_parser.mly b/cparser/pre_parser.mly index a33c592..1998248 100644 --- a/cparser/pre_parser.mly +++ b/cparser/pre_parser.mly @@ -648,9 +648,31 @@ function_definition_begin: | Some i -> declare_varname i ) l } +| declaration_specifiers pointer? x=direct_declarator + LPAREN params=identifier_list RPAREN in_context(declaration_list) + { match x with + | (_, Some _) -> $syntaxerror + | (i, None) -> + declare_varname i; + !push_context (); + List.iter declare_varname params + } + +identifier_list: +| id = general_identifier + { set_id_type id VarId; [id] } +| idl = identifier_list COMMA id = general_identifier + { set_id_type id VarId; id :: idl } + +declaration_list: +| /*empty*/ + { } +| declaration_list declaration + { } function_definition: | function_definition_begin LBRACE block_item_list? pop_context RBRACE { } | function_definition_begin LBRACE block_item_list? pop_context error { unclosed "{" "}" $startpos($2) $endpos } + -- cgit v1.2.3