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