From db17e565b9fc704d033cd35d4552d5473d8a1e4e Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Wed, 9 Apr 2008 14:12:20 +0000 Subject: Compound statement expression nested in binary expression, bug 226274. --- .../cdt/core/parser/tests/ast2/AST2Tests.java | 11 +- .../dom/parser/AbstractGNUSourceCodeParser.java | 235 ++---------------- .../core/dom/parser/c/GNUCSourceParser.java | 272 +++----------------- .../core/dom/parser/cpp/GNUCPPSourceParser.java | 274 ++++----------------- 4 files changed, 108 insertions(+), 684 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java index deaff418d0d..0a81ee31c95 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java @@ -4465,4 +4465,13 @@ public class AST2Tests extends AST2BaseTest { parseAndCheckBindings(code, ParserLanguage.C, true); parseAndCheckBindings(code, ParserLanguage.CPP, true); } -} \ No newline at end of file + + // void test() { + // ({1;}) != 0; + // } + public void testCompoundStatementExpression_Bug226274() throws Exception { + final String code = getAboveComment(); + parseAndCheckBindings(code, ParserLanguage.C, true); + parseAndCheckBindings(code, ParserLanguage.CPP, true); + } +} 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 ec1785d4e0a..c8da1fc5084 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 @@ -290,11 +290,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { parsePassed = false; } - /** - * /* (non-Javadoc) - * - * @see org.eclipse.cdt.core.parser.IParser#cancel() - */ public synchronized void cancel() { isCancelled = true; } @@ -325,10 +320,10 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { } /** - * @param bt + * @deprecated */ - protected void throwBacktrack(BacktrackException bt) - throws BacktrackException { + @Deprecated + protected void throwBacktrack(BacktrackException bt) throws BacktrackException { throw bt; } @@ -345,19 +340,8 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { return result; } - /** - * @param syntax_error - * @param offset - * @param length - * @return - */ - protected abstract IASTProblem createProblem(int signal, int offset, - int length); + protected abstract IASTProblem createProblem(int signal, int offset, int length); - /** - * @param string - * @param e - */ protected void logThrowable(String methodName, Throwable e) { if (e != null) { if (log.isTracing()) { @@ -547,21 +531,10 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { return result; } - /** - * @return - */ protected abstract IASTProblemStatement createProblemStatement(); - /** - * @return - */ protected abstract IASTCompoundStatement createCompoundStatement(); - /** - * @return - * @throws EndOfFileException - * @throws BacktrackException - */ protected IASTExpression compoundStatementExpression() throws EndOfFileException, BacktrackException { int startingOffset = consume().getOffset(); // tLPAREN always IASTCompoundStatement compoundStatement = null; @@ -585,22 +558,11 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { return resultExpression; } - /** - * @return - */ protected abstract IGNUASTCompoundStatementExpression createCompoundStatementExpression(); protected IASTExpression expression() throws BacktrackException, EndOfFileException { IToken la = LA(1); int startingOffset = la.getOffset(); - - if (la.getType() == IToken.tLPAREN && LT(2) == IToken.tLBRACE - && supportStatementsInExpressions) { - IASTExpression resultExpression = compoundStatementExpression(); - if (resultExpression != null) - return resultExpression; - } - IASTExpression assignmentExpression = assignmentExpression(); if (LT(1) != IToken.tCOMMA) return assignmentExpression; @@ -620,9 +582,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { return expressionList; } - /** - * @return - */ protected abstract IASTExpressionList createExpressionList(); protected abstract IASTExpression assignmentExpression() @@ -657,19 +616,11 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { return buildBinaryExpression(kind, lhs, rhs, calculateEndOffset(rhs)); } - /** - * @param expression - * @throws BacktrackException - */ protected IASTExpression constantExpression() throws BacktrackException, EndOfFileException { return conditionalExpression(); } - /** - * @param expression - * @throws BacktrackException - */ protected IASTExpression logicalOrExpression() throws BacktrackException, EndOfFileException { IASTExpression firstExpression = logicalAndExpression(); @@ -683,10 +634,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { return firstExpression; } - /** - * @param expression - * @throws BacktrackException - */ protected IASTExpression logicalAndExpression() throws BacktrackException, EndOfFileException { IASTExpression firstExpression = inclusiveOrExpression(); @@ -700,10 +647,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { return firstExpression; } - /** - * @param expression - * @throws BacktrackException - */ protected IASTExpression inclusiveOrExpression() throws BacktrackException, EndOfFileException { IASTExpression firstExpression = exclusiveOrExpression(); @@ -717,10 +660,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { return firstExpression; } - /** - * @param expression - * @throws BacktrackException - */ protected IASTExpression exclusiveOrExpression() throws BacktrackException, EndOfFileException { IASTExpression firstExpression = andExpression(); @@ -734,10 +673,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { return firstExpression; } - /** - * @param expression - * @throws BacktrackException - */ protected IASTExpression andExpression() throws EndOfFileException, BacktrackException { IASTExpression firstExpression = equalityExpression(); while (LT(1) == IToken.tAMPER) { @@ -750,10 +685,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { return firstExpression; } - /** - * @param expression - * @throws BacktrackException - */ protected IASTExpression equalityExpression() throws EndOfFileException, BacktrackException { IASTExpression firstExpression = relationalExpression(); @@ -787,15 +718,8 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { return result; } - /** - * @return - */ protected abstract IASTBinaryExpression createBinaryExpression(); - /** - * @param expression - * @throws BacktrackException - */ protected IASTExpression shiftExpression() throws BacktrackException, EndOfFileException { IASTExpression firstExpression = additiveExpression(); @@ -817,10 +741,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { } } - /** - * @param expression - * @throws BacktrackException - */ protected IASTExpression additiveExpression() throws BacktrackException, EndOfFileException { IASTExpression firstExpression = multiplicativeExpression(); @@ -842,11 +762,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { } } - /** - * @param expression - * @return - * @throws BacktrackException - */ protected IASTExpression conditionalExpression() throws BacktrackException, EndOfFileException { IASTExpression firstExpression = logicalOrExpression(); @@ -878,20 +793,8 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { return firstExpression; } - /** - * @return - */ protected abstract IASTConditionalExpression createConditionalExpression(); - /** - * @param operator - * @param operand - * @param offset - * TODO - * @param lastOffset - * TODO - * @return - */ protected IASTExpression buildUnaryExpression(int operator, IASTExpression operand, int offset, int lastOffset) { IASTUnaryExpression result = createUnaryExpression(); @@ -901,16 +804,8 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { return result; } - /** - * @return - */ protected abstract IASTUnaryExpression createUnaryExpression(); - /** - * @return - * @throws BacktrackException - * @throws EndOfFileException - */ protected IASTExpression unaryAlignofExpression() throws EndOfFileException, BacktrackException { int offset = consume().getOffset(); // t___alignof__ @@ -1031,12 +926,8 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { throws EndOfFileException, BacktrackException; /** - * @param flags - * input flags that are used to make our decision - * @throws FoundDeclaratorException - * @throws - * @throws EndOfFileException - * we could encounter EOF while looking ahead + * @param flags input flags that are used to make our decision + * @throws FoundDeclaratorException encountered EOF while looking ahead */ protected void lookAheadForDeclarator(Flags flags) throws FoundDeclaratorException { if (flags.typeId) @@ -1216,14 +1107,9 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { * enumerator-definition enumerator-definition: enumerator enumerator = * constant-expression enumerator: identifier * - * @param owner - * IParserCallback object that represents the declaration that - * owns this type specifier. - * @throws BacktrackException - * request a backtrack + * @throws BacktrackException request a backtrack */ - protected IASTEnumerationSpecifier enumSpecifier() - throws BacktrackException, EndOfFileException { + protected IASTEnumerationSpecifier enumSpecifier() throws BacktrackException, EndOfFileException { IToken mark = mark(); IASTName name = null; int startOffset = consume().getOffset(); // t_enum @@ -1307,31 +1193,21 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { return null; } - protected abstract IASTStatement statement() throws EndOfFileException, - BacktrackException; - + protected abstract IASTStatement statement() throws EndOfFileException, BacktrackException; protected abstract IASTEnumerator createEnumerator(); - protected abstract IASTEnumerationSpecifier createEnumerationSpecifier(); - protected abstract IASTName createName(); - protected abstract IASTName createName(IToken token); - /** - * @throws BacktrackException - */ - protected IASTExpression condition() throws BacktrackException, - EndOfFileException { + protected IASTExpression condition() throws BacktrackException, EndOfFileException { IASTExpression cond = expression(); return cond; } - public boolean encounteredError() { return !parsePassed; } @@ -1383,12 +1259,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { EndOfFileException; - - /** - * @return - * @throws EndOfFileException - * @throws BacktrackException - */ protected IASTDeclaration asmDeclaration() throws EndOfFileException, BacktrackException { IToken first = consume(); // t_asm @@ -1434,13 +1304,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { return t; } - /** - * @param offset - * @param assembly - * @param lastOffset - * TODO - * @return - */ protected IASTASMDeclaration buildASMDirective(int offset, String assembly, int lastOffset) { IASTASMDeclaration result = createASMDirective(); @@ -1483,7 +1346,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { IToken mark = mark(); IASTExpressionStatement expressionStatement = null; IToken lastTokenOfExpression = null; - BacktrackException savedBt = null; try { IASTExpression expression = expression(); if (LT(1) == IToken.tEOC) @@ -1506,24 +1368,22 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { ds.setDeclaration(d); ((ASTNode) ds).setOffsetAndLength(((ASTNode) d).getOffset(), ((ASTNode) d).getLength()); } catch (BacktrackException b) { - savedBt = b; backup(mark); + if (expressionStatement == null) { + throw b; + } } - // if not ambiguous then return the appropriate node - if (expressionStatement == null && ds != null) { - return ds; + if (expressionStatement == null) { + return ds; } - if (expressionStatement != null && ds == null) { + if (ds == null) { while (true) { if (consume() == lastTokenOfExpression) break; } return expressionStatement; } - if (expressionStatement == null && ds == null) - throwBacktrack(savedBt); - // At this point we know we have an ambiguity. // Attempt to resolve some ambiguities that are easy to detect. @@ -1623,11 +1483,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { protected abstract IASTAmbiguousStatement createAmbiguousStatement(); - /** - * @return - * @throws EndOfFileException - * @throws BacktrackException - */ protected IASTStatement parseLabelStatement() throws EndOfFileException, BacktrackException { IToken labelName = consume(); // tIDENTIFIER @@ -1644,11 +1499,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { return label_statement; } - /** - * @return - * @throws EndOfFileException - * @throws BacktrackException - */ protected IASTStatement parseNullStatement() throws EndOfFileException, BacktrackException { IToken t = consume(); // tSEMI @@ -1658,11 +1508,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { return null_statement; } - /** - * @return - * @throws EndOfFileException - * @throws BacktrackException - */ protected IASTStatement parseGotoStatement() throws EndOfFileException, BacktrackException { int startOffset = consume().getOffset(); // t_goto @@ -1676,11 +1521,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { return goto_statement; } - /** - * @return - * @throws EndOfFileException - * @throws BacktrackException - */ protected IASTStatement parseBreakStatement() throws EndOfFileException, BacktrackException { int startOffset = consume().getOffset(); // t_break @@ -1691,11 +1531,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { return break_statement; } - /** - * @return - * @throws EndOfFileException - * @throws BacktrackException - */ protected IASTStatement parseContinueStatement() throws EndOfFileException, BacktrackException { int startOffset = consume().getOffset(); // t_continue @@ -1706,11 +1541,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { return continue_statement; } - /** - * @return - * @throws EndOfFileException - * @throws BacktrackException - */ protected IASTStatement parseReturnStatement() throws EndOfFileException, BacktrackException { int startOffset; @@ -1754,13 +1584,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { return return_statement; } - /** - * @return - * @throws EndOfFileException - * @throws BacktrackException - */ - protected IASTStatement parseDoStatement() throws EndOfFileException, - BacktrackException { + protected IASTStatement parseDoStatement() throws EndOfFileException, BacktrackException { int startOffset; startOffset = consume().getOffset(); // t_do IASTStatement do_body = statement(); @@ -1803,11 +1627,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { return do_statement; } - /** - * @return - * @throws EndOfFileException - * @throws BacktrackException - */ protected IASTStatement parseWhileStatement() throws EndOfFileException, BacktrackException { int startOffset = consume().getOffset(); consume(IToken.tLPAREN); @@ -1861,26 +1680,13 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { } } - /** - * @return - */ protected abstract IASTProblemExpression createProblemExpression(); - /** - * @return - * @throws EndOfFileException - * @throws BacktrackException - */ protected IASTStatement parseCompoundStatement() throws EndOfFileException, BacktrackException { IASTCompoundStatement compound = compoundStatement(); return compound; } - /** - * @return - * @throws EndOfFileException - * @throws BacktrackException - */ protected IASTStatement parseDefaultStatement() throws EndOfFileException, BacktrackException { int startOffset = consume().getOffset(); // t_default int lastOffset = consume(IToken.tCOLON).getEndOffset(); @@ -1890,11 +1696,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { return df; } - /** - * @return - * @throws EndOfFileException - * @throws BacktrackException - */ protected IASTStatement parseCaseStatement() throws EndOfFileException, BacktrackException { int startOffset = consume().getOffset(); // t_case IASTExpression case_exp = constantExpression(); @@ -2105,7 +1906,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { consume(); break whileLoop2; default: - throwBacktrack(be); + throw be; } } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java index 7746eaf04b2..77171332eba 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java @@ -166,10 +166,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { return null; } - /** - * @param scope - * @return - */ protected IASTInitializer cInitializerClause(List designators) throws EndOfFileException, BacktrackException { IToken la = LA(1); @@ -237,37 +233,23 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { // if we get this far, it means that we have not yet succeeded // try this now instead // assignmentExpression - try { - IASTExpression assignmentExpression = assignmentExpression(); - IASTInitializerExpression result = createInitializerExpression(); - result.setExpression(assignmentExpression); - ((ASTNode) result).setOffsetAndLength( - ((ASTNode) assignmentExpression).getOffset(), - ((ASTNode) assignmentExpression).getLength()); - return result; - } catch (BacktrackException b) { - throwBacktrack(b); - } - return null; + IASTExpression assignmentExpression = assignmentExpression(); + IASTInitializerExpression result = createInitializerExpression(); + result.setExpression(assignmentExpression); + ((ASTNode) result).setOffsetAndLength( + ((ASTNode) assignmentExpression).getOffset(), + ((ASTNode) assignmentExpression).getLength()); + return result; } - /** - * @return - */ protected ICASTDesignatedInitializer createDesignatorInitializer() { return new CASTDesignatedInitializer(); } - /** - * @return - */ protected IASTInitializerList createInitializerList() { return new CASTInitializerList(); } - /** - * @return - */ protected IASTInitializerExpression createInitializerExpression() { return new CASTInitializerExpression(); } @@ -370,23 +352,14 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { return designatorList; } - /** - * @return - */ protected IGCCASTArrayRangeDesignator createArrayRangeDesignator() { return new CASTArrayRangeDesignator(); } - /** - * @return - */ protected ICASTArrayDesignator createArrayDesignator() { return new CASTArrayDesignator(); } - /** - * @return - */ protected ICASTFieldDesignator createFieldDesignator() { return new CASTFieldDesignator(); } @@ -504,16 +477,10 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { return simpleDeclaration; } - /** - * @return - */ protected IASTFunctionDefinition createFunctionDefinition() { return new CASTFunctionDefinition(); } - /** - * @return - */ @Override protected IASTSimpleDeclaration createSimpleDeclaration() { return new CASTSimpleDeclaration(); @@ -614,30 +581,15 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { } } - /** - * @return - */ protected IASTProblemDeclaration createProblemDeclaration() { return new CASTProblemDeclaration(); } - /** - * @param expression - * @throws BacktrackException - */ @Override - protected IASTExpression assignmentExpression() throws EndOfFileException, - BacktrackException { - if (LT(1) == IToken.tLPAREN && LT(2) == IToken.tLBRACE && supportStatementsInExpressions) { - IASTExpression resultExpression = compoundStatementExpression(); - if (resultExpression != null) - return resultExpression; - } - + protected IASTExpression assignmentExpression() throws EndOfFileException, BacktrackException { IASTExpression conditionalExpression = conditionalExpression(); // if the condition not taken, try assignment operators - if (conditionalExpression != null - && conditionalExpression instanceof IASTConditionalExpression) // && + if (conditionalExpression instanceof IASTConditionalExpression) return conditionalExpression; switch (LT(1)) { case IToken.tASSIGN: @@ -666,10 +618,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { return conditionalExpression; } - /** - * @param expression - * @throws BacktrackException - */ @Override protected IASTExpression relationalExpression() throws BacktrackException, EndOfFileException { @@ -708,10 +656,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { } } - /** - * @param expression - * @throws BacktrackException - */ @Override protected IASTExpression multiplicativeExpression() throws BacktrackException, EndOfFileException { @@ -749,73 +693,30 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { * castExpression : unaryExpression | "(" typeId ")" castExpression */ @Override - protected IASTExpression castExpression() throws EndOfFileException, - BacktrackException { - // TO DO: we need proper symbol checkint to ensure type name + protected IASTExpression castExpression() throws EndOfFileException, BacktrackException { if (LT(1) == IToken.tLPAREN) { - IToken mark = mark(); - int startingOffset = mark.getOffset(); + final IToken mark = mark(); + final int startingOffset = mark.getOffset(); consume(); - IASTTypeId typeId = null; - IASTExpression castExpression = null; - boolean proper=false; - IToken startCastExpression=null; - // If this isn't a type name, then we shouldn't be here - boolean needBack = false; - try { - try { - if (!avoidCastExpressionByHeuristics()) { - typeId = typeId(false); - } - if (typeId != null) { - switch (LT(1)) { - case IToken.tRPAREN: - consume(); - proper=true; - startCastExpression=mark(); - castExpression = castExpression(); - break; -// case IToken.tEOC: // support for completion removed -// break; // in favour of another parse tree - default: - needBack = true; -// throw backtrack; - } - } else {needBack = true;} - } catch (BacktrackException bte) { - needBack = true; - } - if (needBack) { - try { - // try a compoundStatementExpression - backup(startCastExpression); - if (typeId != null && proper && LT(1) == IToken.tLPAREN) { - castExpression = compoundStatementExpression(); - mark = null; // clean up mark so that we can garbage collect - return buildTypeIdUnaryExpression(IASTCastExpression.op_cast, - typeId, castExpression, startingOffset, - LT(1) == IToken.tEOC ? LA(1).getEndOffset() : calculateEndOffset(castExpression)); - } - } catch (BacktrackException bte2) {} - - backup(mark); - return unaryExpression(); -// throwBacktrack(bte); - } - return buildTypeIdUnaryExpression(IASTCastExpression.op_cast, - typeId, castExpression, startingOffset, - LT(1) == IToken.tEOC ? LA(1).getEndOffset() : calculateEndOffset(castExpression)); - } catch (BacktrackException b) { + if (!avoidCastExpressionByHeuristics()) { + IASTTypeId typeId = typeId(false); + if (typeId != null && LT(1) == IToken.tRPAREN) { + consume(); + try { + IASTExpression castExpression = castExpression(); + return buildTypeIdUnaryExpression(IASTCastExpression.op_cast, + typeId, castExpression, startingOffset, + LT(1) == IToken.tEOC ? LA(1).getEndOffset() : calculateEndOffset(castExpression)); + } catch (BacktrackException b) { + } + } } + backup(mark); } return unaryExpression(); } - /** - * @param expression - * @throws BacktrackException - */ @Override protected IASTExpression unaryExpression() throws EndOfFileException, BacktrackException { @@ -854,12 +755,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { } } - /** - * @param typeId - * @param startingOffset - * @param op - * @return - */ @Override protected IASTExpression buildTypeIdExpression(int op, IASTTypeId typeId, int startingOffset, int endingOffset) { @@ -871,17 +766,10 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { return result; } - /** - * @return - */ protected IASTTypeIdExpression createTypeIdExpression() { return new CASTTypeIdExpression(); } - /** - * @param expression - * @throws BacktrackException - */ protected IASTExpression postfixExpression() throws EndOfFileException, BacktrackException { @@ -1011,28 +899,14 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { } } - /** - * @return - */ protected IASTFunctionCallExpression createFunctionCallExpression() { return new CASTFunctionCallExpression(); } - /** - * @return - */ protected IASTArraySubscriptExpression createArraySubscriptExpression() { return new CASTArraySubscriptExpression(); } - /** - * @param t - * @param i - * @param offset - * @param lastOffset - * TODO - * @return - */ protected ICASTTypeIdInitializerExpression buildTypeIdInitializerExpression( IASTTypeId t, IASTInitializer i, int offset, int lastOffset) { ICASTTypeIdInitializerExpression result = createTypeIdInitializerExpression(); @@ -1042,24 +916,14 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { return result; } - /** - * @return - */ protected ICASTTypeIdInitializerExpression createTypeIdInitializerExpression() { return new CASTTypeIdInitializerExpression(); } - /** - * @return - */ protected IASTFieldReference createFieldReference() { return new CASTFieldReference(); } - /** - * @param expression - * @throws BacktrackException - */ protected IASTExpression primaryExpression() throws EndOfFileException, BacktrackException { IToken t = null; @@ -1097,6 +961,10 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { ((ASTNode) literalExpression).setOffsetAndLength(t.getOffset(), t.getLength()); return literalExpression; case IToken.tLPAREN: + if (supportStatementsInExpressions && LT(2) == IToken.tLBRACE) { + return compoundStatementExpression(); + } + t = consume(); // TODO - do we need to return a wrapper? IASTExpression lhs = expression(); @@ -1131,16 +999,10 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { } - /** - * @return - */ protected IASTLiteralExpression createLiteralExpression() { return new CASTLiteralExpression(); } - /** - * @return - */ @Override protected IASTIdExpression createIdExpression() { return new CASTIdExpression(); @@ -1190,9 +1052,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { return result; } - /** - * @return - */ protected IASTTypeId createTypeId() { return new CASTTypeId(); } @@ -1203,10 +1062,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { * ptrOperator : "*" (cvQualifier)* | "&" | ::? nestedNameSpecifier "*" * (cvQualifier)* * - * @param owner - * Declarator that this pointer operator corresponds to. - * @throws BacktrackException - * request a backtrack + * @throws BacktrackException to request a backtrack */ protected void consumePointerOperators(List pointerOps) throws EndOfFileException, BacktrackException { @@ -1256,9 +1112,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { } } - /** - * @return - */ protected ICASTPointer createPointer() { return new CASTPointer(); } @@ -1569,9 +1422,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { return declSpec; } - /** - * @return - */ protected ICASTSimpleDeclSpecifier createSimpleTypeSpecifier() { return new CASTSimpleDeclSpecifier(); } @@ -1580,9 +1430,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { return new GCCASTSimpleDeclSpecifier(); } - /** - * @return - */ @Override protected IASTNamedTypeSpecifier createNamedTypeSpecifier() { return new CASTTypedefNameSpecifier(); @@ -1594,13 +1441,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { * classSpecifier : classKey name (baseClause)? "{" (memberSpecification)* * "}" * - * @param owner - * IParserCallback object that represents the declaration that - * owns this classSpecifier - * - * @return TODO - * @throws BacktrackException - * request a backtrack + * @throws BacktrackException to request a backtrack */ protected ICASTCompositeTypeSpecifier structOrUnionSpecifier() throws BacktrackException, EndOfFileException { @@ -1675,17 +1516,11 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { return result; } - /** - * @return - */ @Override protected IASTName createName() { return new CASTName(); } - /** - * @return - */ protected ICASTCompositeTypeSpecifier createCompositeTypeSpecifier() { return new CASTCompositeTypeSpecifier(); } @@ -1720,9 +1555,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { return result; } - /** - * @return - */ protected ICASTElaboratedTypeSpecifier createElaboratedTypeSpecifier() { return new CASTElaboratedTypeSpecifier(); } @@ -2000,31 +1832,18 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { return new CASTArrayDeclarator(); } - /** - * @return - */ protected IASTFieldDeclarator createFieldDeclarator() { return new CASTFieldDeclarator(); } - /** - * @return - */ protected IASTStandardFunctionDeclarator createFunctionDeclarator() { return new CASTFunctionDeclarator(); } - /** - * @return - */ protected ICASTKnRFunctionDeclarator createKnRFunctionDeclarator() { return new CASTKnRFunctionDeclarator(); } - /** - * @param t - * @return - */ @Override protected IASTName createName(IToken t) { IASTName n = new CASTName(t.getCharImage()); @@ -2038,14 +1857,12 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { return n; } - /** - * @return - */ protected IASTDeclarator createDeclarator() { return new CASTDeclarator(); } - protected void consumeArrayModifiers(List arrayMods) + @SuppressWarnings("fallthrough") + protected void consumeArrayModifiers(List arrayMods) throws EndOfFileException, BacktrackException { while (LT(1) == IToken.tLBRACKET) { @@ -2126,16 +1943,10 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { } } - /** - * @return - */ protected ICASTArrayModifier createCArrayModifier() { return new CASTModifiedArrayModifier(); } - /** - * @return - */ protected IASTArrayModifier createArrayModifier() { return new CASTArrayModifier(); } @@ -2492,11 +2303,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { return new CASTAmbiguousExpression(); } - /** - * @return - * @throws EndOfFileException - * @throws BacktrackException - */ protected IASTStatement parseIfStatement() throws EndOfFileException, BacktrackException { IASTIfStatement result = null; IASTIfStatement if_statement = null; @@ -2575,8 +2381,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { .setLength(calculateEndOffset(new_if_statement) - ((ASTNode) if_statement).getOffset()); } else { - if (result == null && if_statement != null) - result = if_statement; if (result == null) result = new_if_statement; if_statement = new_if_statement; @@ -2621,11 +2425,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { calculateEndOffset(castExpression)); } - /** - * @return - * @throws EndOfFileException - * @throws BacktrackException - */ protected IASTStatement parseSwitchStatement() throws EndOfFileException, BacktrackException { int startOffset; startOffset = consume().getOffset(); @@ -2656,11 +2455,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { return switch_statement; } - /** - * @return - * @throws EndOfFileException - * @throws BacktrackException - */ protected IASTStatement parseForStatement() throws EndOfFileException, BacktrackException { int startOffset; startOffset = consume().getOffset(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java index da094cfe676..2c81fb3a9c3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java @@ -391,6 +391,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { IToken l = LA(1); backup(mark); throwBacktrack(first.getOffset(), l.getEndOffset() - first.getOffset()); + break; case IToken.tIDENTIFIER: case IToken.tCOMPLETION: case IToken.tEOC: @@ -541,8 +542,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { * Parse a Pointer Operator. ptrOperator : "*" (cvQualifier)* | "&" | ::? * nestedNameSpecifier "*" (cvQualifier)* * - * @param owner - * Declarator that this pointer operator corresponds to. * @throws BacktrackException * request a backtrack */ @@ -640,9 +639,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { po = newPo; } } - if (po != null) - collection.add(po); - + collection.add(po); continue; } @@ -651,37 +648,22 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { } } - /** - * @param isRestrict - * @return - */ protected ICPPASTPointerToMember createPointerToMember(boolean gnu) { if (gnu) return new GPPASTPointerToMember(); return new CPPASTPointerToMember(); } - /** - * @param isRestrict - * @return - */ protected IASTPointerOperator createPointer(boolean gnu) { if (gnu) return new GPPASTPointer(); return new CPPASTPointer(); } - /** - * @return - */ protected ICPPASTReferenceOperator createReferenceOperator() { return new CPPASTReferenceOperator(); } - /** - * @param expression - * @throws BacktrackException - */ @Override protected IASTExpression assignmentExpression() throws EndOfFileException, BacktrackException { @@ -689,12 +671,12 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { return throwExpression(); } - if (LT(1) == IToken.tLPAREN && LT(2) == IToken.tLBRACE - && supportStatementsInExpressions) { - IASTExpression resultExpression = compoundStatementExpression(); - if (resultExpression != null) - return resultExpression; - } +// if (LT(1) == IToken.tLPAREN && LT(2) == IToken.tLBRACE +// && supportStatementsInExpressions) { +// IASTExpression resultExpression = compoundStatementExpression(); +// if (resultExpression != null) +// return resultExpression; +// } IASTExpression conditionalExpression = conditionalExpression(); // if the condition not taken, try assignment operators @@ -746,10 +728,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { return conditionalExpression; } - /** - * @param expression - * @throws BacktrackException - */ protected IASTExpression throwExpression() throws EndOfFileException, BacktrackException { IToken throwToken = consume(); @@ -764,11 +742,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { throwExpression, throwToken.getOffset(), o); // fix for 95225 } - /** - * @param expression - * @throws BacktrackException - */ - @Override + @SuppressWarnings("fallthrough") + @Override protected IASTExpression relationalExpression() throws BacktrackException, EndOfFileException { IASTExpression firstExpression = shiftExpression(); @@ -779,6 +754,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { && templateIdScopes.peek() == IToken.tLT) { return firstExpression; } + // fall through case IToken.tLT: case IToken.tLTEQUAL: case IToken.tGTEQUAL: @@ -837,10 +813,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { } } - /** - * @param expression - * @throws BacktrackException - */ @Override protected IASTExpression multiplicativeExpression() throws BacktrackException, EndOfFileException { IASTExpression firstExpression = pmExpression(); @@ -873,10 +845,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { } } - /** - * @param expression - * @throws BacktrackException - */ protected IASTExpression pmExpression() throws EndOfFileException, BacktrackException { IASTExpression firstExpression = castExpression(); @@ -910,11 +878,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { */ @Override protected IASTExpression castExpression() throws EndOfFileException, BacktrackException { -// TO DO: we need proper symbol checkint to ensure type name if (LT(1) == IToken.tLPAREN) { - IToken la = LA(1); - int startingOffset = la.getOffset(); - IToken mark = mark(); + final IToken mark = mark(); + final int startingOffset = mark.getOffset(); consume(); final int initialSize= templateIdScopes.size(); @@ -922,38 +888,20 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { templateIdScopes.push(IToken.tLPAREN); try { - IASTTypeId typeId = null; - IToken startCastExpression=null; - - // If this isn't a type name, then we shouldn't be here if (!avoidCastExpressionByHeuristics()) { - typeId = typeId(false); - } - if (typeId != null && LT(1) == IToken.tRPAREN) { - consume(); - startCastExpression=mark(); - if (initialSize > 0) { - templateIdScopes.pop(); - } - try { - IASTExpression castExpression = castExpression(); - - mark = null; // clean up mark so that we can garbage collect - return buildTypeIdUnaryExpression(IASTCastExpression.op_cast, - typeId, castExpression, startingOffset, - calculateEndOffset(castExpression)); - } catch (BacktrackException b) { + IASTTypeId typeId = typeId(false); + if (typeId != null && LT(1) == IToken.tRPAREN) { + consume(); + if (initialSize > 0) { + templateIdScopes.pop(); + } try { - // try a compoundStatementExpression - backup(startCastExpression); - if (LT(1) == IToken.tLPAREN) { - IASTExpression castExpression = compoundStatementExpression(); - mark = null; // clean up mark so that we can garbage collect - return buildTypeIdUnaryExpression(IASTCastExpression.op_cast, - typeId, castExpression, startingOffset, - calculateEndOffset(castExpression)); - } - } catch (BacktrackException bte2) {} + IASTExpression castExpression = castExpression(); + return buildTypeIdUnaryExpression(IASTCastExpression.op_cast, + typeId, castExpression, startingOffset, + calculateEndOffset(castExpression)); + } catch (BacktrackException b) { + } } } backup(mark); @@ -965,12 +913,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { } } return unaryExpression(); + } -} - - /** - * @throws BacktrackException - */ @Override protected IASTTypeId typeId(boolean forNewExpression) throws EndOfFileException { if (!canBeTypeSpecifier()) { @@ -1046,10 +990,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { return new CPPASTTypeId(); } - /** - * @param expression - * @throws BacktrackException - */ protected IASTExpression deleteExpression() throws EndOfFileException, BacktrackException { int startingOffset = LA(1).getOffset(); @@ -1079,17 +1019,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { return deleteExpression; } - /** - * @return - */ protected ICPPASTDeleteExpression createDeleteExpression() { return new CPPASTDeleteExpression(); } /** - * Pazse a new-expression. + * Parse a new-expression. * - * @param expression * @throws BacktrackException * newexpression: ::? new newplacement? newtypeid * newinitializer? ::? new newplacement? ( typeid ) @@ -1186,13 +1122,12 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { if (typeId != null) { lastOffset = calculateEndOffset(typeId); break master_new_loop; - } else { - // Hmmm, so it wasn't typeId after all... Then it is - // CASE: new (typeid-looking-as-placement) - backup(loopMark); - placementParseFailure = true; - continue master_new_loop; } + // Hmmm, so it wasn't typeId after all... Then it is + // CASE: new (typeid-looking-as-placement) + backup(loopMark); + placementParseFailure = true; + continue master_new_loop; } } else { // Tricky cases: first expression in () is parsed as a @@ -1324,17 +1259,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { return result; } - /** - * @return - */ protected ICPPASTNewExpression createNewExpression() { return new CPPASTNewExpression(); } - /** - * @param expression - * @throws BacktrackException - */ @Override protected IASTExpression unaryExpression() throws EndOfFileException, BacktrackException { switch (LT(1)) { @@ -1384,10 +1312,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { } } - /** - * @param expression - * @throws BacktrackException - */ protected IASTExpression postfixExpression() throws EndOfFileException, BacktrackException { IASTExpression firstExpression = null; boolean isTemplate = false; @@ -1697,17 +1621,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { return result; } - /** - * @return - */ protected ICPPASTSimpleTypeConstructorExpression createSimpleTypeConstructorExpression() { return new CPPASTSimpleTypeConstructorExpression(); } - /** - * @param expression - * @throws BacktrackException - */ protected IASTExpression primaryExpression() throws EndOfFileException, BacktrackException { IToken t = null; @@ -1767,6 +1684,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { ((ASTNode) literalExpression).setOffsetAndLength(t.getOffset(), t.getEndOffset() - t.getOffset()); return literalExpression; case IToken.tLPAREN: + if (supportStatementsInExpressions && LT(2) == IToken.tLBRACE) { + return compoundStatementExpression(); + } t = consume(); if (templateIdScopes.size() > 0) { templateIdScopes.push(IToken.tLPAREN); @@ -1811,16 +1731,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { } - /** - * @return - */ protected ICPPASTLiteralExpression createLiteralExpression() { return new CPPASTLiteralExpression(); } - /** - * @return - */ @Override protected IASTIdExpression createIdExpression() { return new CPPASTIdExpression(); @@ -1954,10 +1868,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { * unqualified-id ; using :: unqualified-id ; using-directive: using * namespace ::? nested-name-specifier? namespace-name ; * - * @param container - * Callback object representing the scope these definitions fall - * into. - * @return TODO * @throws BacktrackException * request for a backtrack */ @@ -2034,10 +1944,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { * linkageSpecification : extern "string literal" declaration | extern * "string literal" { declaration-seq } * - * @param container - * Callback object representing the scope these definitions fall - * into. - * @return TODO * @throws BacktrackException * request for a backtrack */ @@ -2088,9 +1994,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { return linkage; } - /** - * @return - */ protected ICPPASTLinkageSpecification createLinkageSpecification() { return new CPPASTLinkageSpecification(); } @@ -2102,10 +2005,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { * declaration explicit-instantiation: template declaration * explicit-specialization: template <>declaration * - * @param container - * Callback object representing the scope these definitions fall - * into. - * @return TODO * @throws BacktrackException * request for a backtrack */ @@ -2244,9 +2143,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { * template-argument template-argument: assignment-expression type-id * id-expression * - * @param templateDeclaration - * Callback's templateDeclaration which serves as a scope to this - * list. * @throws BacktrackException * request for a backtrack */ @@ -2355,9 +2251,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { * namespaceDefinition - usingDirective into usingDeclaration - * explicitInstantiation and explicitSpecialization into templateDeclaration * - * @param container - * IParserCallback object which serves as the owner scope for - * this declaration. * @throws BacktrackException * request a backtrack */ @@ -2376,13 +2269,17 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { case IToken.t_extern: if (LT(2) == IToken.tSTRING) return linkageSpecification(); - default: - if (supportExtendedTemplateSyntax - && (LT(1) == IToken.t_static || LT(1) == IToken.t_inline || LT(1) == IToken.t_extern) - && LT(2) == IToken.t_template) + if (supportExtendedTemplateSyntax && LT(2) == IToken.t_template) + return templateDeclaration(); + break; + case IToken.t_static: + case IToken.t_inline: + if (supportExtendedTemplateSyntax && LT(2) == IToken.t_template) return templateDeclaration(); - return simpleDeclarationStrategyUnion(); + break; } + + return simpleDeclarationStrategyUnion(); } @@ -2395,10 +2292,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { try { after = LA(1); } catch (EndOfFileException eof) { - after = null; } } catch (BacktrackException bt) { - d1 = null; } if (d1 != null) { if( templateCount != 0 ) @@ -2437,9 +2332,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { return d1; } } catch (BacktrackException be) { - d2 = null; if (d1 == null) - throwBacktrack(be); + throw be; } if (d2 == null && d1 != null) { @@ -2466,10 +2360,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { * namespace-definition: namespace identifier { namespace-body } | namespace { * namespace-body } namespace-body: declaration-seq? * - * @param container - * IParserCallback object which serves as the owner scope for - * this declaration. - * @return TODO * @throws BacktrackException * request a backtrack */ @@ -2608,10 +2498,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { return result; } - /** - * @param duple - * @return - */ protected ICPPASTTemplateId createTemplateID(ITokenDuple duple) { ICPPASTTemplateId result = new CPPASTTemplateId(); ((ASTNode) result).setOffsetAndLength(duple.getStartOffset(), duple @@ -2708,13 +2594,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { * append functionDefinition stuff to end of this rule To do: - work in * functionTryBlock * - * @param container - * IParserCallback object which serves as the owner scope for - * this declaration. - * @param tryConstructor - * true == take strategy1 (constructor ) : false == take strategy - * 2 ( pointer to function) - * @return TODO * @throws BacktrackException * request a backtrack */ @@ -2878,9 +2757,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { * meminitializerlist meminitializer: meminitializerid | ( expressionlist? ) * meminitializerid: ::? nestednamespecifier? classname identifier * - * @param declarator - * IParserCallback object that represents the declarator - * (constructor) that owns this initializer * @throws BacktrackException * request a backtrack */ @@ -2936,9 +2812,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { } } - /** - * @return - */ protected ICPPASTConstructorChainInitializer createConstructorChainInitializer() { return new CPPASTConstructorChainInitializer(); } @@ -2946,10 +2819,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { /** * This routine parses a parameter declaration * - * @param containerObject - * The IParserCallback object representing the - * parameterDeclarationClause owning the parm. - * @return TODO * @throws BacktrackException * request a backtrack */ @@ -3394,9 +3263,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { /** * Parse an elaborated type specifier. * - * @param decl - * Declaration which owns the elaborated type - * @return TODO * @throws BacktrackException * request a backtrack */ @@ -3447,11 +3313,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { * Parses the initDeclarator construct of the ANSI C++ spec. initDeclarator : * declarator ("=" initializerClause | "(" expressionList ")")? * - * @param constructInitializers - * TODO - * @param owner - * IParserCallback object that represents the owner declaration - * object. * @return declarator that this parsing produced. * @throws BacktrackException * request a backtrack @@ -3571,10 +3432,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { * parameterDeclarationClause ")" (oldKRParameterDeclaration)* declaratorId : * name * - * @param forNewTypeId - * TODO - * @param container - * IParserCallback object that represents the owner declaration. * @return declarator that this parsing produced. * @throws BacktrackException * request a backtrack @@ -3987,10 +3844,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { * Parse a class/struct/union definition. classSpecifier : classKey name * (baseClause)? "{" (memberSpecification)* "}" * - * @param owner - * IParserCallback object that represents the declaration that - * owns this classSpecifier - * @return TODO * @throws BacktrackException * request a backtrack */ @@ -4129,7 +3982,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { * virtual? ::? nestednamespecifier? classname accessspecifier: private | * protected | public * - * @param classSpecOwner * @throws BacktrackException */ protected void baseSpecifier(ICPPASTCompositeTypeSpecifier astClassSpec) @@ -4214,16 +4066,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { baseSpec.setVisibility(visibility); baseSpec.setName(name); astClassSpec.addBaseSpecifier(baseSpec); - // fall through + break baseSpecifierLoop; default: break baseSpecifierLoop; } } } - /** - * @return - */ protected ICPPASTBaseSpecifier createBaseSpecifier() { return new CPPASTBaseSpecifier(); } @@ -4290,9 +4139,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { } } - /** - * @return - */ protected ICPPASTCatchHandler createCatchHandler() { return new CPPASTCatchHandler(); } @@ -4650,11 +4496,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { } } - /** - * @return - * @throws EndOfFileException - * @throws BacktrackException - */ protected IASTStatement parseTryStatement() throws EndOfFileException, BacktrackException { int startO = consume().getOffset(); IASTStatement tryBlock = compoundStatement(); @@ -4735,10 +4576,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { } - /** - * @param expectSemi TODO - * @return - */ protected IASTNode cppStyleCondition(int expectToken) throws BacktrackException, EndOfFileException { IToken mark = mark(); try { @@ -4754,7 +4591,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { return simpleDeclaration(SimpleDeclarationStrategy.TRY_VARIABLE, true); } catch (BacktrackException b) { failParse(); - throwBacktrack(b); + throw b; } } return null; @@ -4778,11 +4615,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { return new CPPASTAmbiguousStatement(); } - /** - * @return - * @throws EndOfFileException - * @throws BacktrackException - */ protected IASTStatement parseIfStatement() throws EndOfFileException, BacktrackException { ICPPASTIfStatement result = null; ICPPASTIfStatement if_statement = null; @@ -4862,8 +4694,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { if_statement.setElseClause(new_if_statement); ((ASTNode) if_statement).setLength(calculateEndOffset(new_if_statement) - ((ASTNode) if_statement).getOffset()); } else { - if (result == null && if_statement != null) - result = if_statement; if (result == null) result = new_if_statement; if_statement = new_if_statement; @@ -4932,11 +4762,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { calculateEndOffset(castExpression)); } - /** - * @return - * @throws EndOfFileException - * @throws BacktrackException - */ protected IASTStatement parseSwitchStatement() throws EndOfFileException, BacktrackException { int startOffset; startOffset = consume().getOffset(); @@ -4972,11 +4797,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { return switch_statement; } - /** - * @return - * @throws EndOfFileException - * @throws BacktrackException - */ protected IASTStatement parseForStatement() throws EndOfFileException, BacktrackException { int startOffset; startOffset = consume().getOffset(); -- cgit v1.2.3