From 6480af5085aa01efbdb19f3055c8823a5be02c68 Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Wed, 22 Jun 2005 18:56:46 +0000 Subject: [PATCH] [72403] Added support for EOC in try blocks and catch handler decls. --- .../dom/parser/cpp/GNUCPPSourceParser.java | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) 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 c03a1f1eda3..12001a3387b 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 @@ -4458,6 +4458,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { protected void catchHandlerSequence(List collection) throws EndOfFileException, BacktrackException { + if (LT(1) == IToken.tEOC) + return; + if (LT(1) != IToken.t_catch) { IToken la = LA(1); throwBacktrack(la.getOffset(), la.getLength()); // error, need at @@ -4479,7 +4482,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { decl = simpleDeclaration( SimpleDeclarationStrategy.TRY_VARIABLE, true); } - consume(IToken.tRPAREN); + if (LT(1) != IToken.tEOC) + consume(IToken.tRPAREN); } catch (BacktrackException bte) { IASTProblem p = failParse(bte); IASTProblemDeclaration pd = createProblemDeclaration(); @@ -4490,22 +4494,26 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { decl = pd; } - IASTStatement compoundStatement = catchBlockCompoundStatement(); ICPPASTCatchHandler handler = createCatchHandler(); - ((ASTNode) handler).setOffsetAndLength(startOffset, - calculateEndOffset(compoundStatement) - startOffset); - handler.setIsCatchAll(isEllipsis); if (decl != null) { handler.setDeclaration(decl); decl.setParent(handler); decl.setPropertyInParent(ICPPASTCatchHandler.DECLARATION); } - if (compoundStatement != null) { - handler.setCatchBody(compoundStatement); - compoundStatement.setParent(handler); - compoundStatement - .setPropertyInParent(ICPPASTCatchHandler.CATCH_BODY); + + if (LT(1) != IToken.tEOC) { + IASTStatement compoundStatement = catchBlockCompoundStatement(); + ((ASTNode) handler).setOffsetAndLength(startOffset, + calculateEndOffset(compoundStatement) - startOffset); + handler.setIsCatchAll(isEllipsis); + if (compoundStatement != null) { + handler.setCatchBody(compoundStatement); + compoundStatement.setParent(handler); + compoundStatement + .setPropertyInParent(ICPPASTCatchHandler.CATCH_BODY); + } } + collection.add(handler); try { @@ -5005,7 +5013,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { */ protected IASTStatement parseTryStatement() throws EndOfFileException, BacktrackException { - int startO = consume().getOffset(); + int startO = consume(IToken.t_try).getOffset(); IASTStatement tryBlock = compoundStatement(); List catchHandlers = new ArrayList(DEFAULT_CATCH_HANDLER_LIST_SIZE); catchHandlerSequence(catchHandlers);