diff options
author | Mike Kucera | 2008-04-01 22:01:15 +0000 |
---|---|---|
committer | Mike Kucera | 2008-04-01 22:01:15 +0000 |
commit | a6d874156fba3f9f699e36d253c623d82d647cdc (patch) | |
tree | c7d9de50d1f154eb26ca8f8ba65a3a3e8e66dc32 /lrparser/org.eclipse.cdt.core.lrparser/grammar | |
parent | 30a1ab0388becd4a162bbb4130969ec3d48322ff (diff) | |
download | org.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.g | 2 | ||||
-rw-r--r-- | lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPGrammar.g | 19 |
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 ./ |