Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Kucera2009-04-01 15:03:01 +0000
committerMike Kucera2009-04-01 15:03:01 +0000
commitba9a7cbcfd9efa25ff92cc8ebce98cc960757767 (patch)
treee13495179c6d0012baef6160c99ca6ec24fcc53a /lrparser/org.eclipse.cdt.core.lrparser/grammar
parentb813ee997626ce5e1112679092dacc90ebb46edb (diff)
downloadorg.eclipse.cdt-ba9a7cbcfd9efa25ff92cc8ebce98cc960757767.tar.gz
org.eclipse.cdt-ba9a7cbcfd9efa25ff92cc8ebce98cc960757767.tar.xz
org.eclipse.cdt-ba9a7cbcfd9efa25ff92cc8ebce98cc960757767.zip
added support for nested functions GNU extension to LR parser, added tests suites
Diffstat (limited to 'lrparser/org.eclipse.cdt.core.lrparser/grammar')
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99Grammar.g8
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/grammar/gcc/GCCGrammar.g6
2 files changed, 11 insertions, 3 deletions
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99Grammar.g b/lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99Grammar.g
index 4e76de9747e..bdacb5b9b1d 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99Grammar.g
+++ b/lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99Grammar.g
@@ -979,15 +979,17 @@ declaration_list
-- to avoid a shift/reduce error with the rule for declaration.
-- The symbol table scoped is opened in the rule for function_direct_declarator
function_definition
- ::= declaration_specifiers <openscope-ast> function_declarator function_body
- /. $Build consumeFunctionDefinition(true); $EndBuild ./
+ ::= normal_function_definition
-- this rule is here as a special case (its not C99 spec) just to support implicit int in function definitions
| <openscope-ast> function_declarator function_body
/. $Build consumeFunctionDefinition(false); $EndBuild ./
| declaration_specifiers <openscope-ast> knr_function_declarator <openscope-ast> declaration_list compound_statement
/. $Build consumeFunctionDefinitionKnR(); $EndBuild ./
-
+normal_function_definition
+ ::= declaration_specifiers <openscope-ast> function_declarator function_body
+ /. $Build consumeFunctionDefinition(true); $EndBuild ./
+
-- same syntax as compound_statement but a symbol table scope isn't opened
function_body
::= '{' '}'
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/grammar/gcc/GCCGrammar.g b/lrparser/org.eclipse.cdt.core.lrparser/grammar/gcc/GCCGrammar.g
index 5c3d4fd484e..be071f53086 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/grammar/gcc/GCCGrammar.g
+++ b/lrparser/org.eclipse.cdt.core.lrparser/grammar/gcc/GCCGrammar.g
@@ -103,4 +103,10 @@ designated_initializer
+-- Nested functions
+
+block_item
+ ::= normal_function_definition
+ /. $Build consumeStatementDeclaration(); $EndBuild ./
+
$End \ No newline at end of file

Back to the top