From dbc7af08fd99e62c078a6671deb88f94855772f1 Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Tue, 21 Jun 2005 21:00:44 +0000 Subject: [PATCH] [98337] Fixed up handling of EOC in while condition. --- .../parser/AbstractGNUSourceCodeParser.java | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java index 9566c1c4b03..adb647cc2d2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java @@ -1946,20 +1946,33 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { int startOffset = consume(IToken.t_while).getOffset(); consume(IToken.tLPAREN); IASTExpression while_condition = condition(); - consume(IToken.tRPAREN); - IASTStatement while_body = statement(); + switch (LT(1)) { + case IToken.tRPAREN: + consume(); + break; + case IToken.tEOC: + break; + default: + throwBacktrack(LA(1)); + } + IASTStatement while_body = null; + if (LT(1) != IToken.tEOC) + while_body = statement(); IASTWhileStatement while_statement = createWhileStatement(); ((ASTNode) while_statement).setOffsetAndLength(startOffset, - calculateEndOffset(while_body) - startOffset); + (while_body != null ? calculateEndOffset(while_body) : LA(1).getEndOffset()) - startOffset); while_statement.setCondition(while_condition); while_condition.setParent(while_statement); while_condition .setPropertyInParent(IASTWhileStatement.CONDITIONEXPRESSION); - while_statement.setBody(while_body); - while_condition.setParent(while_statement); - while_condition.setPropertyInParent(IASTWhileStatement.BODY); - while_body.setParent(while_statement); + + if (while_body != null) { + while_statement.setBody(while_body); + while_body.setParent(while_statement); + while_body.setPropertyInParent(IASTWhileStatement.BODY); + } + return while_statement; }