summaryrefslogtreecommitdiff
path: root/cparser/pre_parser.mly
diff options
context:
space:
mode:
authorGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2014-05-05 08:27:22 +0000
committerGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2014-05-05 08:27:22 +0000
commitdba806ca25b5bc53b744e2c1c2d72fa3d6cd8e05 (patch)
treeefdded5c1b088beb82043d0bb2a7003726205ab2 /cparser/pre_parser.mly
parentf3a4e6b8796f8358ff85a7a50d1a14fe0e5642b1 (diff)
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
Diffstat (limited to 'cparser/pre_parser.mly')
-rw-r--r--cparser/pre_parser.mly22
1 files changed, 22 insertions, 0 deletions
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 }
+