Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Kucera2008-04-01 22:01:15 +0000
committerMike Kucera2008-04-01 22:01:15 +0000
commita6d874156fba3f9f699e36d253c623d82d647cdc (patch)
treec7d9de50d1f154eb26ca8f8ba65a3a3e8e66dc32 /lrparser/org.eclipse.cdt.core.lrparser/grammar
parent30a1ab0388becd4a162bbb4130969ec3d48322ff (diff)
downloadorg.eclipse.cdt-a6d874156fba3f9f699e36d253c623d82d647cdc.tar.gz
org.eclipse.cdt-a6d874156fba3f9f699e36d253c623d82d647cdc.tar.xz
org.eclipse.cdt-a6d874156fba3f9f699e36d253c623d82d647cdc.zip
for loop conditions now work
Diffstat (limited to 'lrparser/org.eclipse.cdt.core.lrparser/grammar')
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99Grammar.g2
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPGrammar.g19
2 files changed, 15 insertions, 6 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 aa933844657..c9795f23fe7 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99Grammar.g
+++ b/lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99Grammar.g
@@ -424,7 +424,7 @@ block_item_list
block_item
::= statement
| declaration
- /. $Build consumeStatementDeclaration(); $EndBuild ./
+ /. $Build consumeStatementDeclarationWithDisambiguation(); $EndBuild ./
expression_statement
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPGrammar.g b/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPGrammar.g
index 516d2a134d7..92566041278 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPGrammar.g
+++ b/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPGrammar.g
@@ -882,6 +882,10 @@ condition
| type_specifier_seq declarator '=' assignment_expression
/. $Build consumeConditionDeclaration(); $EndBuild ./
+condition_opt
+ ::= condition
+ | $empty
+ /. $Build consumeEmpty(); $EndBuild ./
iteration_statement
@@ -889,11 +893,16 @@ iteration_statement
/. $Build consumeStatementWhileLoop(); $EndBuild ./
| 'do' statement 'while' '(' expression ')' ';'
/. $Build consumeStatementDoLoop(); $EndBuild ./
- | 'for' '(' expression_opt ';' expression_opt ';' expression_opt ')' statement
- /. $Build consumeStatementForLoop(); $EndBuild ./
- | 'for' '(' simple_declaration_with_declspec expression_opt ';' expression_opt ')' statement
+ | 'for' '(' for_init_statement condition_opt ';' expression_opt ')' statement
/. $Build consumeStatementForLoop(); $EndBuild ./
-
+
+
+-- I'm sure there are ambiguities here but we won't worry about it
+for_init_statement
+ ::= expression_statement
+ | simple_declaration_with_declspec
+ /. $Build consumeStatementDeclaration(); $EndBuild ./
+
jump_statement
::= 'break' ';'
@@ -912,7 +921,7 @@ jump_statement
-- of the parser test cases expect them to work.
declaration_statement
::= block_declaration
- /. $Build consumeStatementDeclaration(); $EndBuild ./
+ /. $Build consumeStatementDeclarationWithDisambiguation(); $EndBuild ./
| function_definition -- not spec
/. $Build consumeStatementDeclaration(); $EndBuild ./

Back to the top