1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-12 18:55:38 +02:00

[72403] Added support for EOC in try blocks and catch handler decls.

This commit is contained in:
Doug Schaefer 2005-06-22 18:56:46 +00:00
parent f12c9261b9
commit 6480af5085

View file

@ -4458,6 +4458,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
protected void catchHandlerSequence(List collection) protected void catchHandlerSequence(List collection)
throws EndOfFileException, BacktrackException { throws EndOfFileException, BacktrackException {
if (LT(1) == IToken.tEOC)
return;
if (LT(1) != IToken.t_catch) { if (LT(1) != IToken.t_catch) {
IToken la = LA(1); IToken la = LA(1);
throwBacktrack(la.getOffset(), la.getLength()); // error, need at throwBacktrack(la.getOffset(), la.getLength()); // error, need at
@ -4479,7 +4482,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
decl = simpleDeclaration( decl = simpleDeclaration(
SimpleDeclarationStrategy.TRY_VARIABLE, true); SimpleDeclarationStrategy.TRY_VARIABLE, true);
} }
consume(IToken.tRPAREN); if (LT(1) != IToken.tEOC)
consume(IToken.tRPAREN);
} catch (BacktrackException bte) { } catch (BacktrackException bte) {
IASTProblem p = failParse(bte); IASTProblem p = failParse(bte);
IASTProblemDeclaration pd = createProblemDeclaration(); IASTProblemDeclaration pd = createProblemDeclaration();
@ -4490,22 +4494,26 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
decl = pd; decl = pd;
} }
IASTStatement compoundStatement = catchBlockCompoundStatement();
ICPPASTCatchHandler handler = createCatchHandler(); ICPPASTCatchHandler handler = createCatchHandler();
((ASTNode) handler).setOffsetAndLength(startOffset,
calculateEndOffset(compoundStatement) - startOffset);
handler.setIsCatchAll(isEllipsis);
if (decl != null) { if (decl != null) {
handler.setDeclaration(decl); handler.setDeclaration(decl);
decl.setParent(handler); decl.setParent(handler);
decl.setPropertyInParent(ICPPASTCatchHandler.DECLARATION); decl.setPropertyInParent(ICPPASTCatchHandler.DECLARATION);
} }
if (compoundStatement != null) {
handler.setCatchBody(compoundStatement); if (LT(1) != IToken.tEOC) {
compoundStatement.setParent(handler); IASTStatement compoundStatement = catchBlockCompoundStatement();
compoundStatement ((ASTNode) handler).setOffsetAndLength(startOffset,
.setPropertyInParent(ICPPASTCatchHandler.CATCH_BODY); calculateEndOffset(compoundStatement) - startOffset);
handler.setIsCatchAll(isEllipsis);
if (compoundStatement != null) {
handler.setCatchBody(compoundStatement);
compoundStatement.setParent(handler);
compoundStatement
.setPropertyInParent(ICPPASTCatchHandler.CATCH_BODY);
}
} }
collection.add(handler); collection.add(handler);
try { try {
@ -5005,7 +5013,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
*/ */
protected IASTStatement parseTryStatement() throws EndOfFileException, protected IASTStatement parseTryStatement() throws EndOfFileException,
BacktrackException { BacktrackException {
int startO = consume().getOffset(); int startO = consume(IToken.t_try).getOffset();
IASTStatement tryBlock = compoundStatement(); IASTStatement tryBlock = compoundStatement();
List catchHandlers = new ArrayList(DEFAULT_CATCH_HANDLER_LIST_SIZE); List catchHandlers = new ArrayList(DEFAULT_CATCH_HANDLER_LIST_SIZE);
catchHandlerSequence(catchHandlers); catchHandlerSequence(catchHandlers);