mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 14:12:10 +02:00
Corrects handling of backtrack exceptions.
This commit is contained in:
parent
588b7c399d
commit
a1d528d6c7
2 changed files with 27 additions and 34 deletions
|
@ -1564,10 +1564,10 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
decl= declaration(option);
|
decl= declaration(option);
|
||||||
break;
|
break;
|
||||||
} catch (BacktrackException bt2) {
|
} catch (BacktrackException bt2) {
|
||||||
n= bt.getNodeBeforeProblem();
|
n= bt2.getNodeBeforeProblem();
|
||||||
if (n instanceof IASTDeclaration) {
|
if (n instanceof IASTDeclaration) {
|
||||||
decl= (IASTDeclaration) n;
|
decl= (IASTDeclaration) n;
|
||||||
trailingProblem= buildProblemDeclaration(bt.getProblem());
|
trailingProblem= buildProblemDeclaration(bt2.getProblem());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (EndOfFileException e) {
|
} catch (EndOfFileException e) {
|
||||||
|
@ -1727,7 +1727,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
ds = nodeFactory.newDeclarationStatement(d);
|
ds = nodeFactory.newDeclarationStatement(d);
|
||||||
((ASTNode) ds).setOffsetAndLength(((ASTNode) d).getOffset(), ((ASTNode) d).getLength());
|
((ASTNode) ds).setOffsetAndLength(((ASTNode) d).getOffset(), ((ASTNode) d).getLength());
|
||||||
} catch (BacktrackException b) {
|
} catch (BacktrackException b) {
|
||||||
backup(mark);
|
|
||||||
if (expressionStatement == null) {
|
if (expressionStatement == null) {
|
||||||
throw b;
|
throw b;
|
||||||
}
|
}
|
||||||
|
|
|
@ -497,12 +497,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
} else {
|
} else {
|
||||||
// not a type-id - try as expression
|
// not a type-id - try as expression
|
||||||
backup(argStart);
|
backup(argStart);
|
||||||
try {
|
IASTExpression expression = assignmentExpression();
|
||||||
IASTExpression expression = assignmentExpression();
|
list.add(expression);
|
||||||
list.add(expression);
|
|
||||||
} catch (BacktrackException e) {
|
|
||||||
backup(argStart);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LT(1) == IToken.tCOMMA) {
|
if (LT(1) == IToken.tCOMMA) {
|
||||||
|
@ -671,6 +667,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
try {
|
try {
|
||||||
throwExpression = expression();
|
throwExpression = expression();
|
||||||
} catch (BacktrackException bte) {
|
} catch (BacktrackException bte) {
|
||||||
|
backup(throwToken);
|
||||||
|
consume();
|
||||||
}
|
}
|
||||||
int o = throwExpression != null ? calculateEndOffset(throwExpression)
|
int o = throwExpression != null ? calculateEndOffset(throwExpression)
|
||||||
: throwToken.getEndOffset();
|
: throwToken.getEndOffset();
|
||||||
|
@ -1368,7 +1366,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
* request for a backtrack
|
* request for a backtrack
|
||||||
*/
|
*/
|
||||||
protected IASTDeclaration templateDeclaration(DeclarationOptions option) throws EndOfFileException, BacktrackException {
|
protected IASTDeclaration templateDeclaration(DeclarationOptions option) throws EndOfFileException, BacktrackException {
|
||||||
IToken mark = mark();
|
|
||||||
IToken firstToken = null;
|
IToken firstToken = null;
|
||||||
boolean exported = false;
|
boolean exported = false;
|
||||||
boolean encounteredExtraMod = false;
|
boolean encounteredExtraMod = false;
|
||||||
|
@ -1429,29 +1426,24 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return templateSpecialization;
|
return templateSpecialization;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final boolean wasOnTop= onTopInTemplateArgs;
|
||||||
|
onTopInTemplateArgs= true;
|
||||||
|
List<ICPPASTTemplateParameter> parms;
|
||||||
try {
|
try {
|
||||||
final boolean wasOnTop= onTopInTemplateArgs;
|
parms = templateParameterList();
|
||||||
onTopInTemplateArgs= true;
|
consume(IToken.tGT);
|
||||||
List<ICPPASTTemplateParameter> parms;
|
} finally {
|
||||||
try {
|
onTopInTemplateArgs= wasOnTop;
|
||||||
parms = templateParameterList();
|
|
||||||
consume(IToken.tGT);
|
|
||||||
} finally {
|
|
||||||
onTopInTemplateArgs= wasOnTop;
|
|
||||||
}
|
|
||||||
IASTDeclaration d = declaration(option);
|
|
||||||
ICPPASTTemplateDeclaration templateDecl = nodeFactory.newTemplateDeclaration(d);
|
|
||||||
((ASTNode) templateDecl).setOffsetAndLength(firstToken.getOffset(), calculateEndOffset(d) - firstToken.getOffset());
|
|
||||||
templateDecl.setExported(exported);
|
|
||||||
for (int i = 0; i < parms.size(); ++i) {
|
|
||||||
ICPPASTTemplateParameter parm = parms.get(i);
|
|
||||||
templateDecl.addTemplateParamter(parm);
|
|
||||||
}
|
|
||||||
return templateDecl;
|
|
||||||
} catch (BacktrackException bt) {
|
|
||||||
backup(mark);
|
|
||||||
throw bt;
|
|
||||||
}
|
}
|
||||||
|
IASTDeclaration d = declaration(option);
|
||||||
|
ICPPASTTemplateDeclaration templateDecl = nodeFactory.newTemplateDeclaration(d);
|
||||||
|
((ASTNode) templateDecl).setOffsetAndLength(firstToken.getOffset(), calculateEndOffset(d) - firstToken.getOffset());
|
||||||
|
templateDecl.setExported(exported);
|
||||||
|
for (int i = 0; i < parms.size(); ++i) {
|
||||||
|
ICPPASTTemplateParameter parm = parms.get(i);
|
||||||
|
templateDecl.addTemplateParamter(parm);
|
||||||
|
}
|
||||||
|
return templateDecl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1607,11 +1599,14 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
} catch (BacktrackException e) {
|
} catch (BacktrackException e) {
|
||||||
if (option != DeclarationOptions.CPP_MEMBER || declarationMark == null)
|
if (option != DeclarationOptions.CPP_MEMBER || declarationMark == null)
|
||||||
throw e;
|
throw e;
|
||||||
|
BacktrackException orig= new BacktrackException(e); // copy the exception
|
||||||
|
IToken mark= mark();
|
||||||
backup(declarationMark);
|
backup(declarationMark);
|
||||||
try {
|
try {
|
||||||
return usingDeclaration(declarationMark.getOffset());
|
return usingDeclaration(declarationMark.getOffset());
|
||||||
} catch (BacktrackException e2) {
|
} catch (BacktrackException e2) {
|
||||||
throw e; // throw original exception;
|
backup(mark);
|
||||||
|
throw orig; // throw original exception;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2670,8 +2665,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if (!canBeTypeSpecifier()) {
|
if (!canBeTypeSpecifier()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
IToken mark = mark();
|
int startingOffset = mark().getOffset();
|
||||||
int startingOffset = mark.getOffset();
|
|
||||||
IASTDeclSpecifier declSpecifier = null;
|
IASTDeclSpecifier declSpecifier = null;
|
||||||
IASTDeclarator declarator = null;
|
IASTDeclarator declarator = null;
|
||||||
rejectLogicalOperatorInTemplateID++;
|
rejectLogicalOperatorInTemplateID++;
|
||||||
|
|
Loading…
Add table
Reference in a new issue