mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
org.eclipse.cdt.core<BR>
Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=59179<BR> Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=59143<BR> org.eclipse.cdt.core.tests<BR> Updated test clients for IExpressionParser interface changes. <BR> Added QuickParseASTTests.testBug59179().
This commit is contained in:
parent
0634c0b3a2
commit
1a5788e0dc
16 changed files with 284 additions and 225 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2004-04-22 John Camelon
|
||||||
|
Updated test clients for IExpressionParser interface changes.
|
||||||
|
Added QuickParseASTTests.testBug59179().
|
||||||
|
|
||||||
2004-04-22 Andrew Niefer
|
2004-04-22 Andrew Niefer
|
||||||
- added parser/CompleteParseASTTemplateTest.test_14_7_3__12_ExplicitSpecializationOverloadedFunction()
|
- added parser/CompleteParseASTTemplateTest.test_14_7_3__12_ExplicitSpecializationOverloadedFunction()
|
||||||
- added parser/CompleteParseASTTemplateTest.testPartialSpecializationDefinitions()
|
- added parser/CompleteParseASTTemplateTest.testPartialSpecializationDefinitions()
|
||||||
|
|
|
@ -731,7 +731,7 @@ public class CompletionParseTest extends CompleteParseBaseTest {
|
||||||
String stringToCompleteAfter = ( i == 0 ) ? "::" : "::A";
|
String stringToCompleteAfter = ( i == 0 ) ? "::" : "::A";
|
||||||
IASTCompletionNode node = parse( code, code.indexOf( stringToCompleteAfter) + stringToCompleteAfter.length() );
|
IASTCompletionNode node = parse( code, code.indexOf( stringToCompleteAfter) + stringToCompleteAfter.length() );
|
||||||
|
|
||||||
validateCompletionNode(node, ( i == 0 ? "" : "A"), IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE, getCompilationUnit() );
|
validateCompletionNode(node, ( i == 0 ? "" : "A"), IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE, getCompilationUnit(), false );
|
||||||
|
|
||||||
ILookupResult result = node.getCompletionScope().lookup( node.getCompletionPrefix(),
|
ILookupResult result = node.getCompletionScope().lookup( node.getCompletionPrefix(),
|
||||||
new IASTNode.LookupKind[]{ IASTNode.LookupKind.ALL },
|
new IASTNode.LookupKind[]{ IASTNode.LookupKind.ALL },
|
||||||
|
@ -772,13 +772,17 @@ public class CompletionParseTest extends CompleteParseBaseTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param node
|
* @param node
|
||||||
|
* @param hasKeywords TODO
|
||||||
*/
|
*/
|
||||||
protected void validateCompletionNode(IASTCompletionNode node, String prefix, CompletionKind kind, IASTNode context ) {
|
protected void validateCompletionNode(IASTCompletionNode node, String prefix, CompletionKind kind, IASTNode context, boolean hasKeywords ) {
|
||||||
assertNotNull( node );
|
assertNotNull( node );
|
||||||
assertEquals( node.getCompletionPrefix(), prefix);
|
assertEquals( node.getCompletionPrefix(), prefix);
|
||||||
assertEquals( node.getCompletionKind(), kind );
|
assertEquals( node.getCompletionKind(), kind );
|
||||||
assertEquals( node.getCompletionContext(), context );
|
assertEquals( node.getCompletionContext(), context );
|
||||||
assertFalse( node.getKeywords().hasNext() );
|
if( hasKeywords )
|
||||||
|
assertTrue( node.getKeywords().hasNext() );
|
||||||
|
else
|
||||||
|
assertFalse( node.getKeywords().hasNext() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCompletionInFunctionBodyQualifiedName() throws Exception
|
public void testCompletionInFunctionBodyQualifiedName() throws Exception
|
||||||
|
@ -811,7 +815,7 @@ public class CompletionParseTest extends CompleteParseBaseTest {
|
||||||
assertNotNull( namespaceDefinition );
|
assertNotNull( namespaceDefinition );
|
||||||
validateCompletionNode( node,
|
validateCompletionNode( node,
|
||||||
( j == 0 ) ? "" : "D",
|
( j == 0 ) ? "" : "D",
|
||||||
IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE, namespaceDefinition );
|
IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE, namespaceDefinition, false );
|
||||||
|
|
||||||
ILookupResult result = node.getCompletionScope().lookup( node.getCompletionPrefix(),
|
ILookupResult result = node.getCompletionScope().lookup( node.getCompletionPrefix(),
|
||||||
new IASTNode.LookupKind[]{ IASTNode.LookupKind.ALL },
|
new IASTNode.LookupKind[]{ IASTNode.LookupKind.ALL },
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class ExprEvalTest extends TestCase {
|
||||||
|
|
||||||
final NullSourceElementRequestor nullCallback = new NullSourceElementRequestor();
|
final NullSourceElementRequestor nullCallback = new NullSourceElementRequestor();
|
||||||
IExpressionParser parser = InternalParserUtil.createExpressionParser(ParserFactory.createScanner( new StringReader( code ), getClass().getName(), new ScannerInfo(), null, ParserLanguage.CPP, nullCallback, new NullLogService(), null ), ParserLanguage.CPP, null );
|
IExpressionParser parser = InternalParserUtil.createExpressionParser(ParserFactory.createScanner( new StringReader( code ), getClass().getName(), new ScannerInfo(), null, ParserLanguage.CPP, nullCallback, new NullLogService(), null ), ParserLanguage.CPP, null );
|
||||||
IASTExpression expression = parser.expression(null,null);
|
IASTExpression expression = parser.expression(null,null, null);
|
||||||
assertEquals(expectedValue, expression.evaluateExpression());
|
assertEquals(expectedValue, expression.evaluateExpression());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2213,5 +2213,11 @@ public class QuickParseASTTests extends BaseASTTest
|
||||||
{
|
{
|
||||||
parse("int c = a >? b;");
|
parse("int c = a >? b;");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testBug59179() throws Exception
|
||||||
|
{
|
||||||
|
Iterator i = parse( "class __decl main{ int main; };", true, false ).getDeclarations();
|
||||||
|
assertFalse( i.hasNext() );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,3 +1,7 @@
|
||||||
|
2004-04-22 John Camelon
|
||||||
|
Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=59179
|
||||||
|
Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=59143
|
||||||
|
|
||||||
2004-04-22 Andrew Niefer
|
2004-04-22 Andrew Niefer
|
||||||
- modify how ASTTemplateDeclaration.getOwnedDeclaration works
|
- modify how ASTTemplateDeclaration.getOwnedDeclaration works
|
||||||
- fix bug in TemplateEngine.selectTemplateFunctions()
|
- fix bug in TemplateEngine.selectTemplateFunctions()
|
||||||
|
|
|
@ -19,6 +19,8 @@ import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||||
import org.eclipse.cdt.internal.core.parser.DeclarationWrapper;
|
import org.eclipse.cdt.internal.core.parser.DeclarationWrapper;
|
||||||
import org.eclipse.cdt.internal.core.parser.IParserData;
|
import org.eclipse.cdt.internal.core.parser.IParserData;
|
||||||
import org.eclipse.cdt.internal.core.parser.Parser;
|
import org.eclipse.cdt.internal.core.parser.Parser;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -29,10 +31,10 @@ public interface IParserExtension {
|
||||||
public ASTPointerOperator getPointerOperator( ParserLanguage language, int tokenType );
|
public ASTPointerOperator getPointerOperator( ParserLanguage language, int tokenType );
|
||||||
|
|
||||||
public boolean isValidUnaryExpressionStart( int tokenType );
|
public boolean isValidUnaryExpressionStart( int tokenType );
|
||||||
public IASTExpression parseUnaryExpression( IASTScope scope, IParserData data, CompletionKind kind );
|
public IASTExpression parseUnaryExpression( IASTScope scope, IParserData data, CompletionKind kind, Key key );
|
||||||
|
|
||||||
public boolean isValidRelationalExpressionStart( ParserLanguage language, int tokenType );
|
public boolean isValidRelationalExpressionStart( ParserLanguage language, int tokenType );
|
||||||
public IASTExpression parseRelationalExpression( IASTScope scope, IParserData data, CompletionKind kind, IASTExpression lhsExpression );
|
public IASTExpression parseRelationalExpression( IASTScope scope, IParserData data, CompletionKind kind, Key key, IASTExpression lhsExpression );
|
||||||
/**
|
/**
|
||||||
* @param i
|
* @param i
|
||||||
* @return
|
* @return
|
||||||
|
@ -49,7 +51,8 @@ public interface IParserExtension {
|
||||||
* @param parser
|
* @param parser
|
||||||
* @param flags
|
* @param flags
|
||||||
* @param sdw
|
* @param sdw
|
||||||
|
* @param key TODO
|
||||||
* @return TODO
|
* @return TODO
|
||||||
*/
|
*/
|
||||||
public IDeclSpecifierExtensionResult handleDeclSpecifierSequence(IParserData parser, Parser.Flags flags, DeclarationWrapper sdw, CompletionKind kind );
|
public IDeclSpecifierExtensionResult parseDeclSpecifierSequence(IParserData parser, Parser.Flags flags, DeclarationWrapper sdw, CompletionKind kind, Key key );
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ public class CompletionParser extends ContextualParser implements IParser {
|
||||||
else
|
else
|
||||||
kind = CompletionKind.VARIABLE_TYPE;
|
kind = CompletionKind.VARIABLE_TYPE;
|
||||||
return kind;
|
return kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void catchHandlerSequence(IASTScope scope)
|
protected void catchHandlerSequence(IASTScope scope)
|
||||||
throws EndOfFileException, BacktrackException {
|
throws EndOfFileException, BacktrackException {
|
||||||
|
@ -142,7 +142,7 @@ public class CompletionParser extends ContextualParser implements IParser {
|
||||||
if( LT(1) == IToken.tELLIPSIS )
|
if( LT(1) == IToken.tELLIPSIS )
|
||||||
consume( IToken.tELLIPSIS );
|
consume( IToken.tELLIPSIS );
|
||||||
else
|
else
|
||||||
simpleDeclarationStrategyUnion( scope, null, CompletionKind.EXCEPTION_REFERENCE); // was exceptionDeclaration
|
simpleDeclarationStrategyUnion( scope, null, CompletionKind.EXCEPTION_REFERENCE, Key.DECLARATION); // was exceptionDeclaration
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
|
|
||||||
catchBlockCompoundStatement(scope);
|
catchBlockCompoundStatement(scope);
|
||||||
|
|
|
@ -155,10 +155,10 @@ public class ContextualParser extends CompleteParser {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected void setCompletionValues( IASTScope scope, CompletionKind kind, IToken first, IToken last ) throws EndOfFileException{
|
protected void setCompletionValues( IASTScope scope, CompletionKind kind, IToken first, IToken last, Key key ) throws EndOfFileException{
|
||||||
setCompletionScope( scope );
|
setCompletionScope( scope );
|
||||||
setCompletionKind( kind );
|
setCompletionKind( kind );
|
||||||
setCompletionKeywords( Key.EMPTY );
|
setCompletionKeywords(key);
|
||||||
ITokenDuple duple = new TokenDuple( first, last );
|
ITokenDuple duple = new TokenDuple( first, last );
|
||||||
try {
|
try {
|
||||||
setCompletionContext( astFactory.lookupSymbolInContext( scope, duple ) );
|
setCompletionContext( astFactory.lookupSymbolInContext( scope, duple ) );
|
||||||
|
@ -229,4 +229,16 @@ public class ContextualParser extends CompleteParser {
|
||||||
else
|
else
|
||||||
skipOverCompoundStatement();
|
skipOverCompoundStatement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#setCompletionValuesNoContext(org.eclipse.cdt.core.parser.ast.IASTScope, org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind, org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key)
|
||||||
|
*/
|
||||||
|
protected void setCompletionValuesNoContext(IASTScope scope,
|
||||||
|
CompletionKind kind, Key key) throws EndOfFileException {
|
||||||
|
setCompletionScope(scope);
|
||||||
|
setCompletionKeywords(key);
|
||||||
|
setCompletionKind(kind);
|
||||||
|
checkEndOfFile();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.BacktrackException;
|
import org.eclipse.cdt.core.parser.BacktrackException;
|
||||||
|
import org.eclipse.cdt.core.parser.IProblem;
|
||||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTSemanticException;
|
import org.eclipse.cdt.core.parser.ast.ASTSemanticException;
|
||||||
|
@ -382,6 +383,8 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
if( isFunction)
|
if( isFunction)
|
||||||
return createMethodASTNode(declarator, false);
|
return createMethodASTNode(declarator, false);
|
||||||
else
|
else
|
||||||
|
if( declarator.hasFunctionBody() )
|
||||||
|
throw new ASTSemanticException( (IProblem)null );
|
||||||
return createFieldASTNode(declarator, false );
|
return createFieldASTNode(declarator, false );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -389,6 +392,8 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
if (isFunction)
|
if (isFunction)
|
||||||
return createFunctionASTNode(declarator, false);
|
return createFunctionASTNode(declarator, false);
|
||||||
else
|
else
|
||||||
|
if( declarator.hasFunctionBody() )
|
||||||
|
throw new ASTSemanticException( (IProblem)null );
|
||||||
return createVariableASTNode(declarator, false);
|
return createVariableASTNode(declarator, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -308,7 +308,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
|
|
||||||
if( ! completedArg ){
|
if( ! completedArg ){
|
||||||
try{
|
try{
|
||||||
expression = assignmentExpression( scope, CompletionKind.VARIABLE_TYPE );
|
expression = assignmentExpression( scope, CompletionKind.VARIABLE_TYPE, Key.EXPRESSION );
|
||||||
if( expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_EMPTY ){
|
if( expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_EMPTY ){
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
}
|
}
|
||||||
|
@ -320,7 +320,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
}
|
}
|
||||||
if( !completedArg ){
|
if( !completedArg ){
|
||||||
try{
|
try{
|
||||||
ITokenDuple nameDuple = name( scope, null );
|
ITokenDuple nameDuple = name( scope, null, Key.EMPTY );
|
||||||
expression = astFactory.createExpression( scope, IASTExpression.Kind.ID_EXPRESSION,
|
expression = astFactory.createExpression( scope, IASTExpression.Kind.ID_EXPRESSION,
|
||||||
null, null, null, null, nameDuple, EMPTY_STRING, null);
|
null, null, null, null, nameDuple, EMPTY_STRING, null);
|
||||||
list.add( expression );
|
list.add( expression );
|
||||||
|
@ -369,7 +369,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
* @throws BacktrackException request a backtrack
|
* @throws BacktrackException request a backtrack
|
||||||
*/
|
*/
|
||||||
protected IToken templateId(IASTScope scope, CompletionKind kind) throws EndOfFileException, BacktrackException {
|
protected IToken templateId(IASTScope scope, CompletionKind kind) throws EndOfFileException, BacktrackException {
|
||||||
ITokenDuple duple = name(scope, kind );
|
ITokenDuple duple = name(scope, kind, Key.EMPTY );
|
||||||
//IToken last = consumeTemplateParameters(duple.getLastToken());
|
//IToken last = consumeTemplateParameters(duple.getLastToken());
|
||||||
return duple.getLastToken();//last;
|
return duple.getLastToken();//last;
|
||||||
}
|
}
|
||||||
|
@ -384,9 +384,10 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
* : IDENTIFER
|
* : IDENTIFER
|
||||||
* : template-id
|
* : template-id
|
||||||
*
|
*
|
||||||
|
* @param key TODO
|
||||||
* @throws BacktrackException request a backtrack
|
* @throws BacktrackException request a backtrack
|
||||||
*/
|
*/
|
||||||
protected ITokenDuple name(IASTScope scope, IASTCompletionNode.CompletionKind kind ) throws BacktrackException, EndOfFileException {
|
protected ITokenDuple name(IASTScope scope, IASTCompletionNode.CompletionKind kind, Key key ) throws BacktrackException, EndOfFileException {
|
||||||
|
|
||||||
IToken first = LA(1);
|
IToken first = LA(1);
|
||||||
IToken last = null;
|
IToken last = null;
|
||||||
|
@ -414,9 +415,9 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
if( startsWithColonColon )
|
if( startsWithColonColon )
|
||||||
setCompletionValues( scope, kind, getCompliationUnit() );
|
setCompletionValues( scope, kind, getCompliationUnit() );
|
||||||
else if( prev != null )
|
else if( prev != null )
|
||||||
setCompletionValues(scope, kind, first, prev );
|
setCompletionValues(scope, kind, first, prev, Key.EMPTY );
|
||||||
else
|
else
|
||||||
setCompletionValues(scope, kind );
|
setCompletionValuesNoContext(scope, kind, key );
|
||||||
|
|
||||||
last = consumeTemplateArguments(scope, last, argumentList);
|
last = consumeTemplateArguments(scope, last, argumentList);
|
||||||
if( last.getType() == IToken.tGT )
|
if( last.getType() == IToken.tGT )
|
||||||
|
@ -432,7 +433,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
{
|
{
|
||||||
IToken prev = last;
|
IToken prev = last;
|
||||||
last = consume(IToken.tCOLONCOLON);
|
last = consume(IToken.tCOLONCOLON);
|
||||||
setCompletionValues( scope, kind, first, prev );
|
setCompletionValues( scope, kind, first, prev, Key.EMPTY );
|
||||||
|
|
||||||
if (queryLookaheadCapability() && LT(1) == IToken.t_template)
|
if (queryLookaheadCapability() && LT(1) == IToken.t_template)
|
||||||
consume();
|
consume();
|
||||||
|
@ -448,7 +449,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
case IToken.tIDENTIFIER :
|
case IToken.tIDENTIFIER :
|
||||||
prev = last;
|
prev = last;
|
||||||
last = consume();
|
last = consume();
|
||||||
setCompletionValues( scope, kind, first, prev );
|
setCompletionValues( scope, kind, first, prev, Key.EMPTY );
|
||||||
last = consumeTemplateArguments(scope, last, argumentList);
|
last = consumeTemplateArguments(scope, last, argumentList);
|
||||||
if( last.getType() == IToken.tGT )
|
if( last.getType() == IToken.tGT )
|
||||||
hasTemplateId = true;
|
hasTemplateId = true;
|
||||||
|
@ -461,6 +462,13 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param scope
|
||||||
|
* @param kind
|
||||||
|
* @param key
|
||||||
|
*/
|
||||||
|
protected void setCompletionValuesNoContext(IASTScope scope, CompletionKind kind, Key key) throws EndOfFileException {
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @param tokenDuple
|
* @param tokenDuple
|
||||||
*/
|
*/
|
||||||
|
@ -586,7 +594,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
IASTExpression exp = null;
|
IASTExpression exp = null;
|
||||||
if (LT(1) != IToken.tRBRACKET)
|
if (LT(1) != IToken.tRBRACKET)
|
||||||
{
|
{
|
||||||
exp = constantExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
exp = constantExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION );
|
||||||
}
|
}
|
||||||
consume(IToken.tRBRACKET);
|
consume(IToken.tRBRACKET);
|
||||||
IASTArrayModifier arrayMod;
|
IASTArrayModifier arrayMod;
|
||||||
|
@ -686,7 +694,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
nameDuple = name(d.getScope(), CompletionKind.USER_SPECIFIED_NAME );
|
nameDuple = name(d.getScope(), CompletionKind.USER_SPECIFIED_NAME, Key.EMPTY );
|
||||||
}
|
}
|
||||||
catch( BacktrackException bt )
|
catch( BacktrackException bt )
|
||||||
{
|
{
|
||||||
|
@ -724,16 +732,16 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
* @param expression
|
* @param expression
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
*/
|
*/
|
||||||
protected IASTExpression constantExpression(IASTScope scope, CompletionKind kind) throws BacktrackException, EndOfFileException {
|
protected IASTExpression constantExpression(IASTScope scope, CompletionKind kind, Key key) throws BacktrackException, EndOfFileException {
|
||||||
return conditionalExpression(scope,kind);
|
return conditionalExpression(scope,kind,key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTExpression expression(IASTScope scope, CompletionKind kind) throws BacktrackException, EndOfFileException {
|
public IASTExpression expression(IASTScope scope, CompletionKind kind, Key key) throws BacktrackException, EndOfFileException {
|
||||||
IASTExpression assignmentExpression = assignmentExpression(scope,kind);
|
IASTExpression assignmentExpression = assignmentExpression(scope,kind,key);
|
||||||
while (LT(1) == IToken.tCOMMA)
|
while (LT(1) == IToken.tCOMMA)
|
||||||
{
|
{
|
||||||
consume();
|
consume();
|
||||||
IASTExpression secondExpression = assignmentExpression(scope,kind);
|
IASTExpression secondExpression = assignmentExpression(scope,kind,key);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
assignmentExpression =
|
assignmentExpression =
|
||||||
|
@ -762,12 +770,12 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
* @param expression
|
* @param expression
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
*/
|
*/
|
||||||
protected IASTExpression assignmentExpression(IASTScope scope, CompletionKind kind) throws EndOfFileException, BacktrackException {
|
protected IASTExpression assignmentExpression(IASTScope scope, CompletionKind kind, Key key) throws EndOfFileException, BacktrackException {
|
||||||
setCompletionValues(scope, kind, Key.EXPRESSION );
|
setCompletionValues(scope, kind, Key.EXPRESSION );
|
||||||
if (LT(1) == IToken.t_throw) {
|
if (LT(1) == IToken.t_throw) {
|
||||||
return throwExpression(scope);
|
return throwExpression(scope,key);
|
||||||
}
|
}
|
||||||
IASTExpression conditionalExpression = conditionalExpression(scope,kind);
|
IASTExpression conditionalExpression = conditionalExpression(scope,kind,key);
|
||||||
// if the condition not taken, try assignment operators
|
// if the condition not taken, try assignment operators
|
||||||
if (conditionalExpression != null
|
if (conditionalExpression != null
|
||||||
&& conditionalExpression.getExpressionKind()
|
&& conditionalExpression.getExpressionKind()
|
||||||
|
@ -778,57 +786,57 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
return assignmentOperatorExpression(
|
return assignmentOperatorExpression(
|
||||||
scope,
|
scope,
|
||||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_NORMAL,
|
IASTExpression.Kind.ASSIGNMENTEXPRESSION_NORMAL,
|
||||||
conditionalExpression, kind);
|
conditionalExpression, kind,key);
|
||||||
case IToken.tSTARASSIGN :
|
case IToken.tSTARASSIGN :
|
||||||
return assignmentOperatorExpression(
|
return assignmentOperatorExpression(
|
||||||
scope,
|
scope,
|
||||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_MULT,
|
IASTExpression.Kind.ASSIGNMENTEXPRESSION_MULT,
|
||||||
conditionalExpression, kind);
|
conditionalExpression, kind,key);
|
||||||
case IToken.tDIVASSIGN :
|
case IToken.tDIVASSIGN :
|
||||||
return assignmentOperatorExpression(
|
return assignmentOperatorExpression(
|
||||||
scope,
|
scope,
|
||||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_DIV,
|
IASTExpression.Kind.ASSIGNMENTEXPRESSION_DIV,
|
||||||
conditionalExpression, kind);
|
conditionalExpression, kind,key);
|
||||||
case IToken.tMODASSIGN :
|
case IToken.tMODASSIGN :
|
||||||
return assignmentOperatorExpression(
|
return assignmentOperatorExpression(
|
||||||
scope,
|
scope,
|
||||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_MOD,
|
IASTExpression.Kind.ASSIGNMENTEXPRESSION_MOD,
|
||||||
conditionalExpression, kind);
|
conditionalExpression, kind,key);
|
||||||
case IToken.tPLUSASSIGN :
|
case IToken.tPLUSASSIGN :
|
||||||
return assignmentOperatorExpression(
|
return assignmentOperatorExpression(
|
||||||
scope,
|
scope,
|
||||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_PLUS,
|
IASTExpression.Kind.ASSIGNMENTEXPRESSION_PLUS,
|
||||||
conditionalExpression, kind);
|
conditionalExpression, kind,key);
|
||||||
case IToken.tMINUSASSIGN :
|
case IToken.tMINUSASSIGN :
|
||||||
return assignmentOperatorExpression(
|
return assignmentOperatorExpression(
|
||||||
scope,
|
scope,
|
||||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_MINUS,
|
IASTExpression.Kind.ASSIGNMENTEXPRESSION_MINUS,
|
||||||
conditionalExpression, kind);
|
conditionalExpression, kind,key);
|
||||||
case IToken.tSHIFTRASSIGN :
|
case IToken.tSHIFTRASSIGN :
|
||||||
return assignmentOperatorExpression(
|
return assignmentOperatorExpression(
|
||||||
scope,
|
scope,
|
||||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_RSHIFT,
|
IASTExpression.Kind.ASSIGNMENTEXPRESSION_RSHIFT,
|
||||||
conditionalExpression, kind);
|
conditionalExpression, kind,key);
|
||||||
case IToken.tSHIFTLASSIGN :
|
case IToken.tSHIFTLASSIGN :
|
||||||
return assignmentOperatorExpression(
|
return assignmentOperatorExpression(
|
||||||
scope,
|
scope,
|
||||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_LSHIFT,
|
IASTExpression.Kind.ASSIGNMENTEXPRESSION_LSHIFT,
|
||||||
conditionalExpression, kind);
|
conditionalExpression, kind,key);
|
||||||
case IToken.tAMPERASSIGN :
|
case IToken.tAMPERASSIGN :
|
||||||
return assignmentOperatorExpression(
|
return assignmentOperatorExpression(
|
||||||
scope,
|
scope,
|
||||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_AND,
|
IASTExpression.Kind.ASSIGNMENTEXPRESSION_AND,
|
||||||
conditionalExpression, kind);
|
conditionalExpression, kind,key);
|
||||||
case IToken.tXORASSIGN :
|
case IToken.tXORASSIGN :
|
||||||
return assignmentOperatorExpression(
|
return assignmentOperatorExpression(
|
||||||
scope,
|
scope,
|
||||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_XOR,
|
IASTExpression.Kind.ASSIGNMENTEXPRESSION_XOR,
|
||||||
conditionalExpression, kind);
|
conditionalExpression, kind,key);
|
||||||
case IToken.tBITORASSIGN :
|
case IToken.tBITORASSIGN :
|
||||||
return assignmentOperatorExpression(
|
return assignmentOperatorExpression(
|
||||||
scope,
|
scope,
|
||||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_OR,
|
IASTExpression.Kind.ASSIGNMENTEXPRESSION_OR,
|
||||||
conditionalExpression, kind);
|
conditionalExpression, kind,key);
|
||||||
}
|
}
|
||||||
return conditionalExpression;
|
return conditionalExpression;
|
||||||
}
|
}
|
||||||
|
@ -837,13 +845,13 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
* @param expression
|
* @param expression
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
*/
|
*/
|
||||||
protected IASTExpression throwExpression(IASTScope scope) throws EndOfFileException, BacktrackException {
|
protected IASTExpression throwExpression(IASTScope scope, Key key) throws EndOfFileException, BacktrackException {
|
||||||
consume(IToken.t_throw);
|
consume(IToken.t_throw);
|
||||||
setCompletionValues( scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION );
|
setCompletionValues( scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION );
|
||||||
IASTExpression throwExpression = null;
|
IASTExpression throwExpression = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
throwExpression = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
throwExpression = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE, key);
|
||||||
}
|
}
|
||||||
catch (BacktrackException b)
|
catch (BacktrackException b)
|
||||||
{
|
{
|
||||||
|
@ -874,14 +882,14 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
* @return
|
* @return
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
*/
|
*/
|
||||||
protected IASTExpression conditionalExpression(IASTScope scope, CompletionKind kind) throws BacktrackException, EndOfFileException {
|
protected IASTExpression conditionalExpression(IASTScope scope, CompletionKind kind, Key key) throws BacktrackException, EndOfFileException {
|
||||||
IASTExpression firstExpression = logicalOrExpression(scope,kind);
|
IASTExpression firstExpression = logicalOrExpression(scope,kind,key);
|
||||||
if (LT(1) == IToken.tQUESTION)
|
if (LT(1) == IToken.tQUESTION)
|
||||||
{
|
{
|
||||||
consume();
|
consume();
|
||||||
IASTExpression secondExpression = expression(scope,kind);
|
IASTExpression secondExpression = expression(scope,kind, key);
|
||||||
consume(IToken.tCOLON);
|
consume(IToken.tCOLON);
|
||||||
IASTExpression thirdExpression = assignmentExpression(scope,kind);
|
IASTExpression thirdExpression = assignmentExpression(scope,kind,key);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return astFactory.createExpression(
|
return astFactory.createExpression(
|
||||||
|
@ -910,12 +918,12 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
* @param expression
|
* @param expression
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
*/
|
*/
|
||||||
protected IASTExpression logicalOrExpression(IASTScope scope, CompletionKind kind) throws BacktrackException, EndOfFileException {
|
protected IASTExpression logicalOrExpression(IASTScope scope, CompletionKind kind, Key key) throws BacktrackException, EndOfFileException {
|
||||||
IASTExpression firstExpression = logicalAndExpression(scope,kind);
|
IASTExpression firstExpression = logicalAndExpression(scope,kind,key);
|
||||||
while (LT(1) == IToken.tOR)
|
while (LT(1) == IToken.tOR)
|
||||||
{
|
{
|
||||||
consume();
|
consume();
|
||||||
IASTExpression secondExpression = logicalAndExpression(scope,kind);
|
IASTExpression secondExpression = logicalAndExpression(scope,kind,key);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -945,12 +953,12 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
* @param expression
|
* @param expression
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
*/
|
*/
|
||||||
protected IASTExpression logicalAndExpression(IASTScope scope, CompletionKind kind) throws BacktrackException, EndOfFileException {
|
protected IASTExpression logicalAndExpression(IASTScope scope, CompletionKind kind, Key key) throws BacktrackException, EndOfFileException {
|
||||||
IASTExpression firstExpression = inclusiveOrExpression( scope,kind );
|
IASTExpression firstExpression = inclusiveOrExpression( scope,kind,key );
|
||||||
while (LT(1) == IToken.tAND)
|
while (LT(1) == IToken.tAND)
|
||||||
{
|
{
|
||||||
consume();
|
consume();
|
||||||
IASTExpression secondExpression = inclusiveOrExpression( scope,kind );
|
IASTExpression secondExpression = inclusiveOrExpression( scope,kind,key );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
firstExpression =
|
firstExpression =
|
||||||
|
@ -979,12 +987,12 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
* @param expression
|
* @param expression
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
*/
|
*/
|
||||||
protected IASTExpression inclusiveOrExpression(IASTScope scope, CompletionKind kind) throws BacktrackException, EndOfFileException {
|
protected IASTExpression inclusiveOrExpression(IASTScope scope, CompletionKind kind, Key key) throws BacktrackException, EndOfFileException {
|
||||||
IASTExpression firstExpression = exclusiveOrExpression(scope,kind);
|
IASTExpression firstExpression = exclusiveOrExpression(scope,kind,key);
|
||||||
while (LT(1) == IToken.tBITOR)
|
while (LT(1) == IToken.tBITOR)
|
||||||
{
|
{
|
||||||
consume();
|
consume();
|
||||||
IASTExpression secondExpression = exclusiveOrExpression(scope,kind);
|
IASTExpression secondExpression = exclusiveOrExpression(scope,kind,key);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1014,13 +1022,13 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
* @param expression
|
* @param expression
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
*/
|
*/
|
||||||
protected IASTExpression exclusiveOrExpression(IASTScope scope, CompletionKind kind) throws BacktrackException, EndOfFileException {
|
protected IASTExpression exclusiveOrExpression(IASTScope scope, CompletionKind kind, Key key) throws BacktrackException, EndOfFileException {
|
||||||
IASTExpression firstExpression = andExpression( scope,kind );
|
IASTExpression firstExpression = andExpression( scope,kind, key );
|
||||||
while (LT(1) == IToken.tXOR)
|
while (LT(1) == IToken.tXOR)
|
||||||
{
|
{
|
||||||
consume();
|
consume();
|
||||||
|
|
||||||
IASTExpression secondExpression = andExpression( scope,kind );
|
IASTExpression secondExpression = andExpression( scope,kind, key );
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1050,12 +1058,12 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
* @param expression
|
* @param expression
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
*/
|
*/
|
||||||
protected IASTExpression andExpression(IASTScope scope, CompletionKind kind) throws EndOfFileException, BacktrackException {
|
protected IASTExpression andExpression(IASTScope scope, CompletionKind kind, Key key) throws EndOfFileException, BacktrackException {
|
||||||
IASTExpression firstExpression = equalityExpression(scope,kind);
|
IASTExpression firstExpression = equalityExpression(scope,kind, key);
|
||||||
while (LT(1) == IToken.tAMPER)
|
while (LT(1) == IToken.tAMPER)
|
||||||
{
|
{
|
||||||
consume();
|
consume();
|
||||||
IASTExpression secondExpression = equalityExpression(scope,kind);
|
IASTExpression secondExpression = equalityExpression(scope,kind, key);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1106,8 +1114,8 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
* @param expression
|
* @param expression
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
*/
|
*/
|
||||||
protected IASTExpression equalityExpression(IASTScope scope, CompletionKind kind) throws EndOfFileException, BacktrackException {
|
protected IASTExpression equalityExpression(IASTScope scope, CompletionKind kind, Key key) throws EndOfFileException, BacktrackException {
|
||||||
IASTExpression firstExpression = relationalExpression(scope,kind);
|
IASTExpression firstExpression = relationalExpression(scope,kind,key);
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
switch (LT(1))
|
switch (LT(1))
|
||||||
|
@ -1116,7 +1124,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
case IToken.tNOTEQUAL :
|
case IToken.tNOTEQUAL :
|
||||||
IToken t = consume();
|
IToken t = consume();
|
||||||
IASTExpression secondExpression =
|
IASTExpression secondExpression =
|
||||||
relationalExpression(scope,kind);
|
relationalExpression(scope,kind,key);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1151,8 +1159,8 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
* @param expression
|
* @param expression
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
*/
|
*/
|
||||||
protected IASTExpression relationalExpression(IASTScope scope, CompletionKind kind) throws BacktrackException, EndOfFileException {
|
protected IASTExpression relationalExpression(IASTScope scope, CompletionKind kind, Key key) throws BacktrackException, EndOfFileException {
|
||||||
IASTExpression firstExpression = shiftExpression(scope,kind);
|
IASTExpression firstExpression = shiftExpression(scope,kind, key);
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
switch (LT(1))
|
switch (LT(1))
|
||||||
|
@ -1168,7 +1176,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
IToken t = consume();
|
IToken t = consume();
|
||||||
IToken next = LA(1);
|
IToken next = LA(1);
|
||||||
IASTExpression secondExpression =
|
IASTExpression secondExpression =
|
||||||
shiftExpression(scope,kind);
|
shiftExpression(scope,kind, key);
|
||||||
if (next == LA(1))
|
if (next == LA(1))
|
||||||
{
|
{
|
||||||
// we did not consume anything
|
// we did not consume anything
|
||||||
|
@ -1226,7 +1234,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
default :
|
default :
|
||||||
if( extension.isValidRelationalExpressionStart(language, LT(1)))
|
if( extension.isValidRelationalExpressionStart(language, LT(1)))
|
||||||
{
|
{
|
||||||
IASTExpression extensionExpression = extension.parseRelationalExpression(scope, this, kind, firstExpression );
|
IASTExpression extensionExpression = extension.parseRelationalExpression(scope, this, kind, key, firstExpression );
|
||||||
if( extensionExpression != null ) return extensionExpression;
|
if( extensionExpression != null ) return extensionExpression;
|
||||||
}
|
}
|
||||||
return firstExpression;
|
return firstExpression;
|
||||||
|
@ -1238,8 +1246,8 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
* @param expression
|
* @param expression
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
*/
|
*/
|
||||||
public IASTExpression shiftExpression(IASTScope scope, CompletionKind kind) throws BacktrackException, EndOfFileException {
|
public IASTExpression shiftExpression(IASTScope scope, CompletionKind kind, Key key) throws BacktrackException, EndOfFileException {
|
||||||
IASTExpression firstExpression = additiveExpression(scope,kind);
|
IASTExpression firstExpression = additiveExpression(scope,kind,key);
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
switch (LT(1))
|
switch (LT(1))
|
||||||
|
@ -1248,7 +1256,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
case IToken.tSHIFTR :
|
case IToken.tSHIFTR :
|
||||||
IToken t = consume();
|
IToken t = consume();
|
||||||
IASTExpression secondExpression =
|
IASTExpression secondExpression =
|
||||||
additiveExpression(scope,kind);
|
additiveExpression(scope,kind,key);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
firstExpression =
|
firstExpression =
|
||||||
|
@ -1282,8 +1290,8 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
* @param expression
|
* @param expression
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
*/
|
*/
|
||||||
protected IASTExpression additiveExpression(IASTScope scope, CompletionKind kind) throws BacktrackException, EndOfFileException {
|
protected IASTExpression additiveExpression(IASTScope scope, CompletionKind kind, Key key) throws BacktrackException, EndOfFileException {
|
||||||
IASTExpression firstExpression = multiplicativeExpression( scope, kind );
|
IASTExpression firstExpression = multiplicativeExpression( scope, kind, key );
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
switch (LT(1))
|
switch (LT(1))
|
||||||
|
@ -1292,7 +1300,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
case IToken.tMINUS :
|
case IToken.tMINUS :
|
||||||
IToken t = consume();
|
IToken t = consume();
|
||||||
IASTExpression secondExpression =
|
IASTExpression secondExpression =
|
||||||
multiplicativeExpression(scope,kind);
|
multiplicativeExpression(scope,kind,key);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
firstExpression =
|
firstExpression =
|
||||||
|
@ -1326,8 +1334,8 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
* @param expression
|
* @param expression
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
*/
|
*/
|
||||||
protected IASTExpression multiplicativeExpression(IASTScope scope, CompletionKind kind) throws BacktrackException, EndOfFileException {
|
protected IASTExpression multiplicativeExpression(IASTScope scope, CompletionKind kind, Key key) throws BacktrackException, EndOfFileException {
|
||||||
IASTExpression firstExpression = pmExpression(scope,kind);
|
IASTExpression firstExpression = pmExpression(scope,kind,key);
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
switch (LT(1))
|
switch (LT(1))
|
||||||
|
@ -1336,7 +1344,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
case IToken.tDIV :
|
case IToken.tDIV :
|
||||||
case IToken.tMOD :
|
case IToken.tMOD :
|
||||||
IToken t = consume();
|
IToken t = consume();
|
||||||
IASTExpression secondExpression = pmExpression(scope,kind);
|
IASTExpression secondExpression = pmExpression(scope,kind,key);
|
||||||
IASTExpression.Kind expressionKind = null;
|
IASTExpression.Kind expressionKind = null;
|
||||||
switch (t.getType())
|
switch (t.getType())
|
||||||
{
|
{
|
||||||
|
@ -1381,8 +1389,8 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
* @param expression
|
* @param expression
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
*/
|
*/
|
||||||
protected IASTExpression pmExpression(IASTScope scope, CompletionKind kind) throws EndOfFileException, BacktrackException {
|
protected IASTExpression pmExpression(IASTScope scope, CompletionKind kind, Key key) throws EndOfFileException, BacktrackException {
|
||||||
IASTExpression firstExpression = castExpression(scope,kind);
|
IASTExpression firstExpression = castExpression(scope,kind,key);
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
switch (LT(1))
|
switch (LT(1))
|
||||||
|
@ -1391,7 +1399,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
case IToken.tARROWSTAR :
|
case IToken.tARROWSTAR :
|
||||||
IToken t = consume();
|
IToken t = consume();
|
||||||
IASTExpression secondExpression =
|
IASTExpression secondExpression =
|
||||||
castExpression(scope,kind);
|
castExpression(scope,kind,key);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
firstExpression =
|
firstExpression =
|
||||||
|
@ -1426,7 +1434,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
* : unaryExpression
|
* : unaryExpression
|
||||||
* | "(" typeId ")" castExpression
|
* | "(" typeId ")" castExpression
|
||||||
*/
|
*/
|
||||||
protected IASTExpression castExpression(IASTScope scope, CompletionKind kind) throws EndOfFileException, BacktrackException {
|
protected IASTExpression castExpression(IASTScope scope, CompletionKind kind, Key key) throws EndOfFileException, BacktrackException {
|
||||||
// TO DO: we need proper symbol checkint to ensure type name
|
// TO DO: we need proper symbol checkint to ensure type name
|
||||||
if (LT(1) == IToken.tLPAREN)
|
if (LT(1) == IToken.tLPAREN)
|
||||||
{
|
{
|
||||||
|
@ -1441,7 +1449,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
typeId = typeId(scope, false, ((kind == CompletionKind.SINGLE_NAME_REFERENCE )? kind : CompletionKind.TYPE_REFERENCE));
|
typeId = typeId(scope, false, ((kind == CompletionKind.SINGLE_NAME_REFERENCE )? kind : CompletionKind.TYPE_REFERENCE));
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
if( templateIdScopes != null ){ templateIdScopes.pop(); popped = true;}
|
if( templateIdScopes != null ){ templateIdScopes.pop(); popped = true;}
|
||||||
IASTExpression castExpression = castExpression(scope,kind);
|
IASTExpression castExpression = castExpression(scope,kind,key);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return astFactory.createExpression(
|
return astFactory.createExpression(
|
||||||
|
@ -1468,7 +1476,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
if( templateIdScopes != null && !popped ){ templateIdScopes.pop(); }
|
if( templateIdScopes != null && !popped ){ templateIdScopes.pop(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return unaryExpression(scope,kind);
|
return unaryExpression(scope,kind, key);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1490,7 +1498,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
name = name(scope, completionKind );
|
name = name(scope, completionKind, Key.EMPTY );
|
||||||
kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
|
kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1537,7 +1545,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
case IToken.tIDENTIFIER :
|
case IToken.tIDENTIFIER :
|
||||||
if( encounteredType ) break simpleMods;
|
if( encounteredType ) break simpleMods;
|
||||||
encounteredType = true;
|
encounteredType = true;
|
||||||
name = name(scope, completionKind );
|
name = name(scope, completionKind, Key.EMPTY );
|
||||||
kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
|
kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1621,7 +1629,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
consume();
|
consume();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
name = name(scope, completionKind );
|
name = name(scope, completionKind, Key.EMPTY );
|
||||||
kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
|
kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
|
||||||
} catch( BacktrackException b )
|
} catch( BacktrackException b )
|
||||||
{
|
{
|
||||||
|
@ -1674,7 +1682,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
* @param expression
|
* @param expression
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
*/
|
*/
|
||||||
protected IASTExpression deleteExpression(IASTScope scope, CompletionKind kind) throws EndOfFileException, BacktrackException {
|
protected IASTExpression deleteExpression(IASTScope scope, CompletionKind kind, Key key) throws EndOfFileException, BacktrackException {
|
||||||
if (LT(1) == IToken.tCOLONCOLON)
|
if (LT(1) == IToken.tCOLONCOLON)
|
||||||
{
|
{
|
||||||
// global scope
|
// global scope
|
||||||
|
@ -1691,7 +1699,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
consume(IToken.tRBRACKET);
|
consume(IToken.tRBRACKET);
|
||||||
vectored = true;
|
vectored = true;
|
||||||
}
|
}
|
||||||
IASTExpression castExpression = castExpression(scope,kind);
|
IASTExpression castExpression = castExpression(scope,kind,key);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return astFactory.createExpression(
|
return astFactory.createExpression(
|
||||||
|
@ -1731,7 +1739,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
* directnewdeclarator [ constantexpression ]
|
* directnewdeclarator [ constantexpression ]
|
||||||
* newinitializer: ( expressionlist? )
|
* newinitializer: ( expressionlist? )
|
||||||
*/
|
*/
|
||||||
protected IASTExpression newExpression(IASTScope scope) throws BacktrackException, EndOfFileException {
|
protected IASTExpression newExpression(IASTScope scope, Key key) throws BacktrackException, EndOfFileException {
|
||||||
setCompletionValues(scope, CompletionKind.NEW_TYPE_REFERENCE, Key.EMPTY);
|
setCompletionValues(scope, CompletionKind.NEW_TYPE_REFERENCE, Key.EMPTY);
|
||||||
if (LT(1) == IToken.tCOLONCOLON)
|
if (LT(1) == IToken.tCOLONCOLON)
|
||||||
{
|
{
|
||||||
|
@ -1757,7 +1765,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
// Try to consume placement list
|
// Try to consume placement list
|
||||||
// Note: since expressionList and expression are the same...
|
// Note: since expressionList and expression are the same...
|
||||||
backtrackMarker = mark();
|
backtrackMarker = mark();
|
||||||
newPlacementExpressions.add(expression(scope, CompletionKind.SINGLE_NAME_REFERENCE));
|
newPlacementExpressions.add(expression(scope, CompletionKind.SINGLE_NAME_REFERENCE, key));
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
if( templateIdScopes != null ){ templateIdScopes.pop(); } //pop 1st Parent
|
if( templateIdScopes != null ){ templateIdScopes.pop(); } //pop 1st Parent
|
||||||
placementParseFailure = false;
|
placementParseFailure = false;
|
||||||
|
@ -1883,7 +1891,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
|
|
||||||
if( templateIdScopes != null ){ templateIdScopes.push( new Integer( IToken.tLBRACKET ) ); }
|
if( templateIdScopes != null ){ templateIdScopes.push( new Integer( IToken.tLBRACKET ) ); }
|
||||||
|
|
||||||
newTypeIdExpressions.add(assignmentExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE));
|
newTypeIdExpressions.add(assignmentExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE,key));
|
||||||
consume(IToken.tRBRACKET);
|
consume(IToken.tRBRACKET);
|
||||||
|
|
||||||
if( templateIdScopes != null ){ templateIdScopes.pop(); }
|
if( templateIdScopes != null ){ templateIdScopes.pop(); }
|
||||||
|
@ -1897,7 +1905,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
if( templateIdScopes != null ){ templateIdScopes.push( new Integer( IToken.tLPAREN ) ); }
|
if( templateIdScopes != null ){ templateIdScopes.push( new Integer( IToken.tLPAREN ) ); }
|
||||||
|
|
||||||
if ( queryLookaheadCapability() && (LT(1) != IToken.tRPAREN))
|
if ( queryLookaheadCapability() && (LT(1) != IToken.tRPAREN))
|
||||||
newInitializerExpressions.add(expression(scope, CompletionKind.CONSTRUCTOR_REFERENCE));
|
newInitializerExpressions.add(expression(scope, CompletionKind.CONSTRUCTOR_REFERENCE, key));
|
||||||
|
|
||||||
setCurrentFunctionName( EMPTY_STRING );
|
setCurrentFunctionName( EMPTY_STRING );
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
|
@ -1932,41 +1940,41 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
* @param expression
|
* @param expression
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
*/
|
*/
|
||||||
public IASTExpression unaryExpression(IASTScope scope, CompletionKind kind) throws EndOfFileException, BacktrackException {
|
public IASTExpression unaryExpression(IASTScope scope, CompletionKind kind, Key key) throws EndOfFileException, BacktrackException {
|
||||||
switch (LT(1))
|
switch (LT(1))
|
||||||
{
|
{
|
||||||
case IToken.tSTAR :
|
case IToken.tSTAR :
|
||||||
consume();
|
consume();
|
||||||
return unaryOperatorCastExpression(scope,
|
return unaryOperatorCastExpression(scope,
|
||||||
IASTExpression.Kind.UNARY_STAR_CASTEXPRESSION,kind);
|
IASTExpression.Kind.UNARY_STAR_CASTEXPRESSION,kind,key);
|
||||||
case IToken.tAMPER :
|
case IToken.tAMPER :
|
||||||
consume();
|
consume();
|
||||||
return unaryOperatorCastExpression(scope,
|
return unaryOperatorCastExpression(scope,
|
||||||
IASTExpression.Kind.UNARY_AMPSND_CASTEXPRESSION,kind);
|
IASTExpression.Kind.UNARY_AMPSND_CASTEXPRESSION,kind,key);
|
||||||
case IToken.tPLUS :
|
case IToken.tPLUS :
|
||||||
consume();
|
consume();
|
||||||
return unaryOperatorCastExpression(scope,
|
return unaryOperatorCastExpression(scope,
|
||||||
IASTExpression.Kind.UNARY_PLUS_CASTEXPRESSION,kind);
|
IASTExpression.Kind.UNARY_PLUS_CASTEXPRESSION,kind,key);
|
||||||
case IToken.tMINUS :
|
case IToken.tMINUS :
|
||||||
consume();
|
consume();
|
||||||
return unaryOperatorCastExpression(scope,
|
return unaryOperatorCastExpression(scope,
|
||||||
IASTExpression.Kind.UNARY_MINUS_CASTEXPRESSION,kind);
|
IASTExpression.Kind.UNARY_MINUS_CASTEXPRESSION,kind,key);
|
||||||
case IToken.tNOT :
|
case IToken.tNOT :
|
||||||
consume();
|
consume();
|
||||||
return unaryOperatorCastExpression(scope,
|
return unaryOperatorCastExpression(scope,
|
||||||
IASTExpression.Kind.UNARY_NOT_CASTEXPRESSION,kind);
|
IASTExpression.Kind.UNARY_NOT_CASTEXPRESSION,kind,key);
|
||||||
case IToken.tCOMPL :
|
case IToken.tCOMPL :
|
||||||
consume();
|
consume();
|
||||||
return unaryOperatorCastExpression(scope,
|
return unaryOperatorCastExpression(scope,
|
||||||
IASTExpression.Kind.UNARY_TILDE_CASTEXPRESSION,kind);
|
IASTExpression.Kind.UNARY_TILDE_CASTEXPRESSION,kind,key);
|
||||||
case IToken.tINCR :
|
case IToken.tINCR :
|
||||||
consume();
|
consume();
|
||||||
return unaryOperatorCastExpression(scope,
|
return unaryOperatorCastExpression(scope,
|
||||||
IASTExpression.Kind.UNARY_INCREMENT,kind);
|
IASTExpression.Kind.UNARY_INCREMENT,kind,key);
|
||||||
case IToken.tDECR :
|
case IToken.tDECR :
|
||||||
consume();
|
consume();
|
||||||
return unaryOperatorCastExpression(scope,
|
return unaryOperatorCastExpression(scope,
|
||||||
IASTExpression.Kind.UNARY_DECREMENT,kind);
|
IASTExpression.Kind.UNARY_DECREMENT,kind,key);
|
||||||
case IToken.t_sizeof :
|
case IToken.t_sizeof :
|
||||||
consume(IToken.t_sizeof);
|
consume(IToken.t_sizeof);
|
||||||
IToken mark = LA(1);
|
IToken mark = LA(1);
|
||||||
|
@ -1983,12 +1991,12 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
catch (BacktrackException bt)
|
catch (BacktrackException bt)
|
||||||
{
|
{
|
||||||
backup(mark);
|
backup(mark);
|
||||||
unaryExpression = unaryExpression(scope,kind);
|
unaryExpression = unaryExpression(scope,kind, key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unaryExpression = unaryExpression(scope,kind);
|
unaryExpression = unaryExpression(scope,kind, key);
|
||||||
}
|
}
|
||||||
if (d != null & unaryExpression == null)
|
if (d != null & unaryExpression == null)
|
||||||
try
|
try
|
||||||
|
@ -2033,29 +2041,29 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
else
|
else
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
case IToken.t_new :
|
case IToken.t_new :
|
||||||
return newExpression(scope);
|
return newExpression(scope,key);
|
||||||
case IToken.t_delete :
|
case IToken.t_delete :
|
||||||
return deleteExpression(scope,kind);
|
return deleteExpression(scope,kind,key);
|
||||||
case IToken.tCOLONCOLON :
|
case IToken.tCOLONCOLON :
|
||||||
if( queryLookaheadCapability(2))
|
if( queryLookaheadCapability(2))
|
||||||
{
|
{
|
||||||
switch (LT(2))
|
switch (LT(2))
|
||||||
{
|
{
|
||||||
case IToken.t_new :
|
case IToken.t_new :
|
||||||
return newExpression(scope);
|
return newExpression(scope,key);
|
||||||
case IToken.t_delete :
|
case IToken.t_delete :
|
||||||
return deleteExpression(scope,kind);
|
return deleteExpression(scope,kind,key);
|
||||||
default :
|
default :
|
||||||
return postfixExpression(scope,kind);
|
return postfixExpression(scope,kind,key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default :
|
default :
|
||||||
if( extension.isValidUnaryExpressionStart( LT(1)))
|
if( extension.isValidUnaryExpressionStart( LT(1)))
|
||||||
{
|
{
|
||||||
IASTExpression extensionExpression = extension.parseUnaryExpression(scope,this,kind);
|
IASTExpression extensionExpression = extension.parseUnaryExpression(scope,this,kind, key);
|
||||||
if( extensionExpression != null ) return extensionExpression;
|
if( extensionExpression != null ) return extensionExpression;
|
||||||
}
|
}
|
||||||
return postfixExpression(scope,kind);
|
return postfixExpression(scope,kind,key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2063,7 +2071,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
* @param expression
|
* @param expression
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
*/
|
*/
|
||||||
protected IASTExpression postfixExpression(IASTScope scope, CompletionKind kind) throws EndOfFileException, BacktrackException {
|
protected IASTExpression postfixExpression(IASTScope scope, CompletionKind kind, Key key) throws EndOfFileException, BacktrackException {
|
||||||
IASTExpression firstExpression = null;
|
IASTExpression firstExpression = null;
|
||||||
boolean isTemplate = false;
|
boolean isTemplate = false;
|
||||||
|
|
||||||
|
@ -2072,7 +2080,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
{
|
{
|
||||||
case IToken.t_typename :
|
case IToken.t_typename :
|
||||||
consume(IToken.t_typename);
|
consume(IToken.t_typename);
|
||||||
ITokenDuple nestedName = name(scope, CompletionKind.TYPE_REFERENCE);
|
ITokenDuple nestedName = name(scope, CompletionKind.TYPE_REFERENCE, Key.EMPTY);
|
||||||
boolean templateTokenConsumed = false;
|
boolean templateTokenConsumed = false;
|
||||||
if( LT(1) == IToken.t_template )
|
if( LT(1) == IToken.t_template )
|
||||||
{
|
{
|
||||||
|
@ -2093,7 +2101,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
}
|
}
|
||||||
consume( IToken.tLPAREN );
|
consume( IToken.tLPAREN );
|
||||||
if( templateIdScopes != null ){ templateIdScopes.push( new Integer( IToken.tLPAREN ) ); }
|
if( templateIdScopes != null ){ templateIdScopes.push( new Integer( IToken.tLPAREN ) ); }
|
||||||
IASTExpression expressionList = expression( scope, CompletionKind.TYPE_REFERENCE );
|
IASTExpression expressionList = expression( scope, CompletionKind.TYPE_REFERENCE, key );
|
||||||
consume( IToken.tRPAREN );
|
consume( IToken.tRPAREN );
|
||||||
if( templateIdScopes != null ){ templateIdScopes.pop(); }
|
if( templateIdScopes != null ){ templateIdScopes.pop(); }
|
||||||
try {
|
try {
|
||||||
|
@ -2119,72 +2127,72 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
case IToken.t_char :
|
case IToken.t_char :
|
||||||
firstExpression =
|
firstExpression =
|
||||||
simpleTypeConstructorExpression(scope,
|
simpleTypeConstructorExpression(scope,
|
||||||
IASTExpression.Kind.POSTFIX_SIMPLETYPE_CHAR);
|
IASTExpression.Kind.POSTFIX_SIMPLETYPE_CHAR,key);
|
||||||
break;
|
break;
|
||||||
case IToken.t_wchar_t :
|
case IToken.t_wchar_t :
|
||||||
firstExpression =
|
firstExpression =
|
||||||
simpleTypeConstructorExpression(scope,
|
simpleTypeConstructorExpression(scope,
|
||||||
IASTExpression.Kind.POSTFIX_SIMPLETYPE_WCHART);
|
IASTExpression.Kind.POSTFIX_SIMPLETYPE_WCHART,key);
|
||||||
break;
|
break;
|
||||||
case IToken.t_bool :
|
case IToken.t_bool :
|
||||||
firstExpression =
|
firstExpression =
|
||||||
simpleTypeConstructorExpression(scope,
|
simpleTypeConstructorExpression(scope,
|
||||||
IASTExpression.Kind.POSTFIX_SIMPLETYPE_BOOL);
|
IASTExpression.Kind.POSTFIX_SIMPLETYPE_BOOL,key);
|
||||||
break;
|
break;
|
||||||
case IToken.t_short :
|
case IToken.t_short :
|
||||||
firstExpression =
|
firstExpression =
|
||||||
simpleTypeConstructorExpression(scope,
|
simpleTypeConstructorExpression(scope,
|
||||||
IASTExpression.Kind.POSTFIX_SIMPLETYPE_SHORT);
|
IASTExpression.Kind.POSTFIX_SIMPLETYPE_SHORT,key);
|
||||||
break;
|
break;
|
||||||
case IToken.t_int :
|
case IToken.t_int :
|
||||||
firstExpression =
|
firstExpression =
|
||||||
simpleTypeConstructorExpression(scope,
|
simpleTypeConstructorExpression(scope,
|
||||||
IASTExpression.Kind.POSTFIX_SIMPLETYPE_INT);
|
IASTExpression.Kind.POSTFIX_SIMPLETYPE_INT,key);
|
||||||
break;
|
break;
|
||||||
case IToken.t_long :
|
case IToken.t_long :
|
||||||
firstExpression =
|
firstExpression =
|
||||||
simpleTypeConstructorExpression(scope,
|
simpleTypeConstructorExpression(scope,
|
||||||
IASTExpression.Kind.POSTFIX_SIMPLETYPE_LONG);
|
IASTExpression.Kind.POSTFIX_SIMPLETYPE_LONG,key);
|
||||||
break;
|
break;
|
||||||
case IToken.t_signed :
|
case IToken.t_signed :
|
||||||
firstExpression =
|
firstExpression =
|
||||||
simpleTypeConstructorExpression(scope,
|
simpleTypeConstructorExpression(scope,
|
||||||
IASTExpression.Kind.POSTFIX_SIMPLETYPE_SIGNED);
|
IASTExpression.Kind.POSTFIX_SIMPLETYPE_SIGNED,key);
|
||||||
break;
|
break;
|
||||||
case IToken.t_unsigned :
|
case IToken.t_unsigned :
|
||||||
firstExpression =
|
firstExpression =
|
||||||
simpleTypeConstructorExpression(scope,
|
simpleTypeConstructorExpression(scope,
|
||||||
IASTExpression.Kind.POSTFIX_SIMPLETYPE_UNSIGNED);
|
IASTExpression.Kind.POSTFIX_SIMPLETYPE_UNSIGNED,key);
|
||||||
break;
|
break;
|
||||||
case IToken.t_float :
|
case IToken.t_float :
|
||||||
firstExpression =
|
firstExpression =
|
||||||
simpleTypeConstructorExpression(scope,
|
simpleTypeConstructorExpression(scope,
|
||||||
IASTExpression.Kind.POSTFIX_SIMPLETYPE_FLOAT);
|
IASTExpression.Kind.POSTFIX_SIMPLETYPE_FLOAT,key);
|
||||||
break;
|
break;
|
||||||
case IToken.t_double :
|
case IToken.t_double :
|
||||||
firstExpression =
|
firstExpression =
|
||||||
simpleTypeConstructorExpression( scope,
|
simpleTypeConstructorExpression( scope,
|
||||||
IASTExpression.Kind.POSTFIX_SIMPLETYPE_DOUBLE);
|
IASTExpression.Kind.POSTFIX_SIMPLETYPE_DOUBLE,key);
|
||||||
break;
|
break;
|
||||||
case IToken.t_dynamic_cast :
|
case IToken.t_dynamic_cast :
|
||||||
firstExpression =
|
firstExpression =
|
||||||
specialCastExpression(scope,
|
specialCastExpression(scope,
|
||||||
IASTExpression.Kind.POSTFIX_DYNAMIC_CAST);
|
IASTExpression.Kind.POSTFIX_DYNAMIC_CAST,key);
|
||||||
break;
|
break;
|
||||||
case IToken.t_static_cast :
|
case IToken.t_static_cast :
|
||||||
firstExpression =
|
firstExpression =
|
||||||
specialCastExpression(scope,
|
specialCastExpression(scope,
|
||||||
IASTExpression.Kind.POSTFIX_STATIC_CAST);
|
IASTExpression.Kind.POSTFIX_STATIC_CAST,key);
|
||||||
break;
|
break;
|
||||||
case IToken.t_reinterpret_cast :
|
case IToken.t_reinterpret_cast :
|
||||||
firstExpression =
|
firstExpression =
|
||||||
specialCastExpression(scope,
|
specialCastExpression(scope,
|
||||||
IASTExpression.Kind.POSTFIX_REINTERPRET_CAST);
|
IASTExpression.Kind.POSTFIX_REINTERPRET_CAST,key);
|
||||||
break;
|
break;
|
||||||
case IToken.t_const_cast :
|
case IToken.t_const_cast :
|
||||||
firstExpression =
|
firstExpression =
|
||||||
specialCastExpression(scope,
|
specialCastExpression(scope,
|
||||||
IASTExpression.Kind.POSTFIX_CONST_CAST);
|
IASTExpression.Kind.POSTFIX_CONST_CAST,key);
|
||||||
break;
|
break;
|
||||||
case IToken.t_typeid :
|
case IToken.t_typeid :
|
||||||
consume();
|
consume();
|
||||||
|
@ -2200,7 +2208,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
catch (BacktrackException b)
|
catch (BacktrackException b)
|
||||||
{
|
{
|
||||||
isTypeId = false;
|
isTypeId = false;
|
||||||
lhs = expression(scope, CompletionKind.TYPE_REFERENCE);
|
lhs = expression(scope, CompletionKind.TYPE_REFERENCE, key);
|
||||||
}
|
}
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
if( templateIdScopes != null ){ templateIdScopes.pop(); }
|
if( templateIdScopes != null ){ templateIdScopes.pop(); }
|
||||||
|
@ -2229,7 +2237,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
firstExpression = primaryExpression(scope, kind);
|
firstExpression = primaryExpression(scope, kind, key);
|
||||||
}
|
}
|
||||||
IASTExpression secondExpression = null;
|
IASTExpression secondExpression = null;
|
||||||
for (;;)
|
for (;;)
|
||||||
|
@ -2240,7 +2248,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
// array access
|
// array access
|
||||||
consume(IToken.tLBRACKET);
|
consume(IToken.tLBRACKET);
|
||||||
if( templateIdScopes != null ){ templateIdScopes.push( new Integer( IToken.tLBRACKET ) ); }
|
if( templateIdScopes != null ){ templateIdScopes.push( new Integer( IToken.tLBRACKET ) ); }
|
||||||
secondExpression = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
secondExpression = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE, key);
|
||||||
consume(IToken.tRBRACKET);
|
consume(IToken.tRBRACKET);
|
||||||
if( templateIdScopes != null ){ templateIdScopes.pop(); }
|
if( templateIdScopes != null ){ templateIdScopes.pop(); }
|
||||||
try
|
try
|
||||||
|
@ -2283,7 +2291,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
|
|
||||||
if( templateIdScopes != null ){ templateIdScopes.push( new Integer( IToken.tLPAREN ) ); }
|
if( templateIdScopes != null ){ templateIdScopes.push( new Integer( IToken.tLPAREN ) ); }
|
||||||
setCompletionValues(scope, CompletionKind.FUNCTION_REFERENCE, context );
|
setCompletionValues(scope, CompletionKind.FUNCTION_REFERENCE, context );
|
||||||
secondExpression = expression(scope, CompletionKind.FUNCTION_REFERENCE);
|
secondExpression = expression(scope, CompletionKind.FUNCTION_REFERENCE, key);
|
||||||
setCurrentFunctionName( EMPTY_STRING );
|
setCurrentFunctionName( EMPTY_STRING );
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
if( templateIdScopes != null ){ templateIdScopes.pop(); }
|
if( templateIdScopes != null ){ templateIdScopes.pop(); }
|
||||||
|
@ -2370,7 +2378,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
|
|
||||||
setCompletionValues(scope, CompletionKind.MEMBER_REFERENCE, KeywordSets.Key.EMPTY, firstExpression, isTemplate );
|
setCompletionValues(scope, CompletionKind.MEMBER_REFERENCE, KeywordSets.Key.EMPTY, firstExpression, isTemplate );
|
||||||
|
|
||||||
secondExpression = primaryExpression(scope, CompletionKind.MEMBER_REFERENCE);
|
secondExpression = primaryExpression(scope, CompletionKind.MEMBER_REFERENCE, key);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -2408,7 +2416,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
}
|
}
|
||||||
|
|
||||||
setCompletionValues(scope, CompletionKind.MEMBER_REFERENCE, KeywordSets.Key.EMPTY, firstExpression, isTemplate );
|
setCompletionValues(scope, CompletionKind.MEMBER_REFERENCE, KeywordSets.Key.EMPTY, firstExpression, isTemplate );
|
||||||
secondExpression = primaryExpression(scope, CompletionKind.MEMBER_REFERENCE);
|
secondExpression = primaryExpression(scope, CompletionKind.MEMBER_REFERENCE, key);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -2466,11 +2474,11 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
LA(1);
|
LA(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IASTExpression simpleTypeConstructorExpression(IASTScope scope, Kind type ) throws EndOfFileException, BacktrackException {
|
protected IASTExpression simpleTypeConstructorExpression(IASTScope scope, Kind type, Key key ) throws EndOfFileException, BacktrackException {
|
||||||
String typeName = consume().getImage();
|
String typeName = consume().getImage();
|
||||||
consume(IToken.tLPAREN);
|
consume(IToken.tLPAREN);
|
||||||
setCurrentFunctionName( typeName );
|
setCurrentFunctionName( typeName );
|
||||||
IASTExpression inside = expression(scope, CompletionKind.CONSTRUCTOR_REFERENCE);
|
IASTExpression inside = expression(scope, CompletionKind.CONSTRUCTOR_REFERENCE, key);
|
||||||
setCurrentFunctionName( EMPTY_STRING );
|
setCurrentFunctionName( EMPTY_STRING );
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
try
|
try
|
||||||
|
@ -2499,7 +2507,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
* @param expression
|
* @param expression
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
*/
|
*/
|
||||||
protected IASTExpression primaryExpression(IASTScope scope, CompletionKind kind) throws EndOfFileException, BacktrackException {
|
protected IASTExpression primaryExpression(IASTScope scope, CompletionKind kind, Key key) throws EndOfFileException, BacktrackException {
|
||||||
IToken t = null;
|
IToken t = null;
|
||||||
switch (LT(1))
|
switch (LT(1))
|
||||||
{
|
{
|
||||||
|
@ -2633,7 +2641,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
case IToken.tLPAREN :
|
case IToken.tLPAREN :
|
||||||
consume();
|
consume();
|
||||||
if( templateIdScopes != null ){ templateIdScopes.push( new Integer( IToken.tLPAREN ) ); }
|
if( templateIdScopes != null ){ templateIdScopes.push( new Integer( IToken.tLPAREN ) ); }
|
||||||
IASTExpression lhs = expression(scope, kind);
|
IASTExpression lhs = expression(scope, kind, key);
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
if( templateIdScopes != null ){ templateIdScopes.pop(); }
|
if( templateIdScopes != null ){ templateIdScopes.pop(); }
|
||||||
try
|
try
|
||||||
|
@ -2663,7 +2671,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
IToken mark = mark();
|
IToken mark = mark();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
duple = name(scope, kind);
|
duple = name(scope, kind, key);
|
||||||
}
|
}
|
||||||
catch( BacktrackException bt )
|
catch( BacktrackException bt )
|
||||||
{
|
{
|
||||||
|
@ -2787,9 +2795,9 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
throw new EndOfFileException();
|
throw new EndOfFileException();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IASTExpression assignmentOperatorExpression(IASTScope scope, IASTExpression.Kind kind, IASTExpression lhs, CompletionKind completionKind) throws EndOfFileException, BacktrackException {
|
protected IASTExpression assignmentOperatorExpression(IASTScope scope, IASTExpression.Kind kind, IASTExpression lhs, CompletionKind completionKind, Key key) throws EndOfFileException, BacktrackException {
|
||||||
consume();
|
consume();
|
||||||
IASTExpression assignmentExpression = assignmentExpression(scope,completionKind);
|
IASTExpression assignmentExpression = assignmentExpression(scope,completionKind, key);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -2821,12 +2829,12 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
protected void setCompletionValues(IASTScope scope, CompletionKind kind, Key key, IASTExpression firstExpression, boolean isTemplate) throws EndOfFileException {
|
protected void setCompletionValues(IASTScope scope, CompletionKind kind, Key key, IASTExpression firstExpression, boolean isTemplate) throws EndOfFileException {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setCompletionValues( IASTScope scope, CompletionKind kind, IToken first, IToken last ) throws EndOfFileException {
|
protected void setCompletionValues( IASTScope scope, CompletionKind kind, IToken first, IToken last, Key key ) throws EndOfFileException {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected IASTExpression unaryOperatorCastExpression(IASTScope scope, IASTExpression.Kind kind, CompletionKind completionKind) throws EndOfFileException, BacktrackException {
|
protected IASTExpression unaryOperatorCastExpression(IASTScope scope, IASTExpression.Kind kind, CompletionKind completionKind, Key key) throws EndOfFileException, BacktrackException {
|
||||||
IASTExpression castExpression = castExpression(scope,completionKind);
|
IASTExpression castExpression = castExpression(scope,completionKind,key);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return astFactory.createExpression(
|
return astFactory.createExpression(
|
||||||
|
@ -2848,13 +2856,13 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IASTExpression specialCastExpression(IASTScope scope, IASTExpression.Kind kind) throws EndOfFileException, BacktrackException {
|
protected IASTExpression specialCastExpression(IASTScope scope, IASTExpression.Kind kind, Key key) throws EndOfFileException, BacktrackException {
|
||||||
consume();
|
consume();
|
||||||
consume(IToken.tLT);
|
consume(IToken.tLT);
|
||||||
IASTTypeId duple = typeId(scope, false, CompletionKind.TYPE_REFERENCE);
|
IASTTypeId duple = typeId(scope, false, CompletionKind.TYPE_REFERENCE);
|
||||||
consume(IToken.tGT);
|
consume(IToken.tGT);
|
||||||
consume(IToken.tLPAREN);
|
consume(IToken.tLPAREN);
|
||||||
IASTExpression lhs = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
IASTExpression lhs = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE, key);
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,6 +30,9 @@ import org.eclipse.cdt.core.parser.ast.gcc.IASTGCCSimpleTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
||||||
import org.eclipse.cdt.internal.core.parser.Parser.Flags;
|
import org.eclipse.cdt.internal.core.parser.Parser.Flags;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.complete.gcc.ASTGCCSimpleTypeSpecifier;
|
import org.eclipse.cdt.internal.core.parser.ast.complete.gcc.ASTGCCSimpleTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -75,14 +78,14 @@ public class GCCParserExtension implements IParserExtension {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.extension.IParserExtension#parseUnaryExpression(org.eclipse.cdt.internal.core.parser.IParserData)
|
* @see org.eclipse.cdt.core.parser.extension.IParserExtension#parseUnaryExpression(org.eclipse.cdt.internal.core.parser.IParserData)
|
||||||
*/
|
*/
|
||||||
public IASTExpression parseUnaryExpression(IASTScope scope, IParserData data, IASTCompletionNode.CompletionKind kind) {
|
public IASTExpression parseUnaryExpression(IASTScope scope, IParserData data, IASTCompletionNode.CompletionKind kind, KeywordSets.Key key) {
|
||||||
try {
|
try {
|
||||||
switch( data.LT(1))
|
switch( data.LT(1))
|
||||||
{
|
{
|
||||||
case IGCCToken.t___alignof__:
|
case IGCCToken.t___alignof__:
|
||||||
return performUnaryExpression( data, scope, kind, UnaryExpressionKind.ALIGNOF );
|
return performUnaryExpression( data, scope, kind, key, UnaryExpressionKind.ALIGNOF );
|
||||||
case IGCCToken.t_typeof:
|
case IGCCToken.t_typeof:
|
||||||
return performUnaryExpression( data, scope, kind, UnaryExpressionKind.TYPEOF );
|
return performUnaryExpression( data, scope, kind, key, UnaryExpressionKind.TYPEOF );
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -110,10 +113,11 @@ public class GCCParserExtension implements IParserExtension {
|
||||||
* @param data
|
* @param data
|
||||||
* @param scope
|
* @param scope
|
||||||
* @param kind
|
* @param kind
|
||||||
|
* @param key TODO
|
||||||
* @param type TODO
|
* @param type TODO
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected IASTExpression performUnaryExpression(IParserData data, IASTScope scope, CompletionKind kind, UnaryExpressionKind type) {
|
protected IASTExpression performUnaryExpression(IParserData data, IASTScope scope, CompletionKind kind, KeywordSets.Key key, UnaryExpressionKind type) {
|
||||||
IToken startingPoint = null;
|
IToken startingPoint = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -145,12 +149,12 @@ public class GCCParserExtension implements IParserExtension {
|
||||||
{
|
{
|
||||||
data.backup(mark);
|
data.backup(mark);
|
||||||
d = null;
|
d = null;
|
||||||
unaryExpression = data.unaryExpression(scope,kind);
|
unaryExpression = data.unaryExpression(scope,kind, key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unaryExpression = data.unaryExpression(scope,kind);
|
unaryExpression = data.unaryExpression(scope,kind, key);
|
||||||
}
|
}
|
||||||
if (d != null & unaryExpression == null)
|
if (d != null & unaryExpression == null)
|
||||||
try
|
try
|
||||||
|
@ -237,7 +241,7 @@ public class GCCParserExtension implements IParserExtension {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.extension.IParserExtension#handleDeclSpecifierSequence(org.eclipse.cdt.internal.core.parser.IParserData, org.eclipse.cdt.core.model.Flags, org.eclipse.cdt.internal.core.parser.DeclarationWrapper)
|
* @see org.eclipse.cdt.core.parser.extension.IParserExtension#handleDeclSpecifierSequence(org.eclipse.cdt.internal.core.parser.IParserData, org.eclipse.cdt.core.model.Flags, org.eclipse.cdt.internal.core.parser.DeclarationWrapper)
|
||||||
*/
|
*/
|
||||||
public IDeclSpecifierExtensionResult handleDeclSpecifierSequence(IParserData data, Parser.Flags flags, DeclarationWrapper sdw, CompletionKind kind) {
|
public IDeclSpecifierExtensionResult parseDeclSpecifierSequence(IParserData data, Parser.Flags flags, DeclarationWrapper sdw, CompletionKind kind, Key key) {
|
||||||
IToken startingPoint = null;
|
IToken startingPoint = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -252,7 +256,7 @@ public class GCCParserExtension implements IParserExtension {
|
||||||
switch( data.LT(1))
|
switch( data.LT(1))
|
||||||
{
|
{
|
||||||
case IGCCToken.t_typeof:
|
case IGCCToken.t_typeof:
|
||||||
IASTExpression typeOfExpression = performUnaryExpression( data, sdw.getScope(), kind, UnaryExpressionKind.TYPEOF );
|
IASTExpression typeOfExpression = performUnaryExpression( data, sdw.getScope(), kind, key, UnaryExpressionKind.TYPEOF );
|
||||||
if( typeOfExpression != null )
|
if( typeOfExpression != null )
|
||||||
{
|
{
|
||||||
sdw.setSimpleType( IASTGCCSimpleTypeSpecifier.Type.TYPEOF );
|
sdw.setSimpleType( IASTGCCSimpleTypeSpecifier.Type.TYPEOF );
|
||||||
|
@ -332,7 +336,7 @@ public class GCCParserExtension implements IParserExtension {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.extension.IParserExtension#parseRelationalExpression(org.eclipse.cdt.core.parser.ast.IASTScope, org.eclipse.cdt.internal.core.parser.IParserData, org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind)
|
* @see org.eclipse.cdt.core.parser.extension.IParserExtension#parseRelationalExpression(org.eclipse.cdt.core.parser.ast.IASTScope, org.eclipse.cdt.internal.core.parser.IParserData, org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind)
|
||||||
*/
|
*/
|
||||||
public IASTExpression parseRelationalExpression(IASTScope scope, IParserData data, CompletionKind kind, IASTExpression lhsExpression) {
|
public IASTExpression parseRelationalExpression(IASTScope scope, IParserData data, CompletionKind kind, KeywordSets.Key key, IASTExpression lhsExpression) {
|
||||||
if( data.getParserLanguage() == ParserLanguage.C ) return null;
|
if( data.getParserLanguage() == ParserLanguage.C ) return null;
|
||||||
IToken mark = null;
|
IToken mark = null;
|
||||||
try {
|
try {
|
||||||
|
@ -359,7 +363,7 @@ public class GCCParserExtension implements IParserExtension {
|
||||||
}
|
}
|
||||||
|
|
||||||
IToken next = data.LA(1);
|
IToken next = data.LA(1);
|
||||||
IASTExpression secondExpression = data.shiftExpression(scope,kind);
|
IASTExpression secondExpression = data.shiftExpression(scope,kind, key);
|
||||||
if (next == data.LA(1))
|
if (next == data.LA(1))
|
||||||
{
|
{
|
||||||
// we did not consume anything
|
// we did not consume anything
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.eclipse.cdt.core.parser.IFilenameProvider;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -25,12 +26,12 @@ public interface IExpressionParser extends IFilenameProvider {
|
||||||
/**
|
/**
|
||||||
* Request a parse from a pre-configured parser to parse an expression.
|
* Request a parse from a pre-configured parser to parse an expression.
|
||||||
*
|
*
|
||||||
|
* @param key TODO
|
||||||
* @param expression Optional parameter representing an expression object that
|
* @param expression Optional parameter representing an expression object that
|
||||||
* your particular IParserCallback instance would appreciate
|
* your particular IParserCallback instance would appreciate
|
||||||
*
|
|
||||||
* @throws BacktrackException thrown if the Scanner/Stream provided does not yield a valid
|
* @throws BacktrackException thrown if the Scanner/Stream provided does not yield a valid
|
||||||
* expression
|
* expression
|
||||||
*/
|
*/
|
||||||
public IASTExpression expression(IASTScope scope, IASTCompletionNode.CompletionKind kind) throws BacktrackException, EndOfFileException;
|
public IASTExpression expression(IASTScope scope, IASTCompletionNode.CompletionKind kind, Key key) throws BacktrackException, EndOfFileException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ import org.eclipse.cdt.core.parser.ast.IASTFactory;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key;
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*
|
*
|
||||||
|
@ -92,9 +94,10 @@ public interface IParserData {
|
||||||
/**
|
/**
|
||||||
* @param scope
|
* @param scope
|
||||||
* @param kind
|
* @param kind
|
||||||
|
* @param key TODO
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public IASTExpression unaryExpression(IASTScope scope, CompletionKind kind) throws EndOfFileException, BacktrackException;
|
public IASTExpression unaryExpression(IASTScope scope, CompletionKind kind, KeywordSets.Key key) throws EndOfFileException, BacktrackException;
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -106,7 +109,8 @@ public interface IParserData {
|
||||||
/**
|
/**
|
||||||
* @param scope
|
* @param scope
|
||||||
* @param kind
|
* @param kind
|
||||||
|
* @param key TODO
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public IASTExpression shiftExpression(IASTScope scope, CompletionKind kind) throws BacktrackException, EndOfFileException;
|
public IASTExpression shiftExpression(IASTScope scope, CompletionKind kind, Key key) throws BacktrackException, EndOfFileException;
|
||||||
}
|
}
|
|
@ -22,7 +22,6 @@ import org.eclipse.cdt.core.parser.IScanner;
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
import org.eclipse.cdt.core.parser.IToken;
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||||
import org.eclipse.cdt.core.parser.OffsetLimitReachedException;
|
|
||||||
import org.eclipse.cdt.core.parser.ParseError;
|
import org.eclipse.cdt.core.parser.ParseError;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
|
@ -244,7 +243,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
// optional :: and nested classes handled in name
|
// optional :: and nested classes handled in name
|
||||||
ITokenDuple duple = null;
|
ITokenDuple duple = null;
|
||||||
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON)
|
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON)
|
||||||
duple = name(scope, CompletionKind.NAMESPACE_REFERENCE);
|
duple = name(scope, CompletionKind.NAMESPACE_REFERENCE, Key.EMPTY);
|
||||||
else
|
else
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
if (LT(1) == IToken.tSEMI)
|
if (LT(1) == IToken.tSEMI)
|
||||||
|
@ -286,7 +285,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON)
|
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON)
|
||||||
{
|
{
|
||||||
// optional :: and nested classes handled in name
|
// optional :: and nested classes handled in name
|
||||||
name = name(scope, CompletionKind.TYPE_REFERENCE);
|
name = name(scope, CompletionKind.TYPE_REFERENCE, Key.EMPTY);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -762,7 +761,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
default :
|
default :
|
||||||
simpleDeclarationStrategyUnion(scope, ownerTemplate, overideKind );
|
simpleDeclarationStrategyUnion(scope, ownerTemplate, overideKind, Key.DECLARATION );
|
||||||
}
|
}
|
||||||
setCompletionValues(scope, kind, Key.DECLARATION );
|
setCompletionValues(scope, kind, Key.DECLARATION );
|
||||||
}
|
}
|
||||||
|
@ -777,7 +776,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
|
|
||||||
protected void simpleDeclarationStrategyUnion(
|
protected void simpleDeclarationStrategyUnion(
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
IASTTemplate ownerTemplate, CompletionKind overide)
|
IASTTemplate ownerTemplate, CompletionKind overrideKind, Key overrideKey)
|
||||||
throws EndOfFileException, BacktrackException
|
throws EndOfFileException, BacktrackException
|
||||||
{
|
{
|
||||||
IToken mark = mark();
|
IToken mark = mark();
|
||||||
|
@ -787,7 +786,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
simpleDeclaration(
|
simpleDeclaration(
|
||||||
SimpleDeclarationStrategy.TRY_CONSTRUCTOR,
|
SimpleDeclarationStrategy.TRY_CONSTRUCTOR,
|
||||||
scope,
|
scope,
|
||||||
ownerTemplate, overide, false);
|
ownerTemplate, overrideKind, false, overrideKey);
|
||||||
// try it first with the original strategy
|
// try it first with the original strategy
|
||||||
}
|
}
|
||||||
catch (BacktrackException bt)
|
catch (BacktrackException bt)
|
||||||
|
@ -800,7 +799,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
simpleDeclaration(
|
simpleDeclaration(
|
||||||
SimpleDeclarationStrategy.TRY_FUNCTION,
|
SimpleDeclarationStrategy.TRY_FUNCTION,
|
||||||
scope,
|
scope,
|
||||||
ownerTemplate, overide, false);
|
ownerTemplate, overrideKind, false, overrideKey);
|
||||||
}
|
}
|
||||||
catch( BacktrackException bt2 )
|
catch( BacktrackException bt2 )
|
||||||
{
|
{
|
||||||
|
@ -811,7 +810,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
simpleDeclaration(
|
simpleDeclaration(
|
||||||
SimpleDeclarationStrategy.TRY_VARIABLE,
|
SimpleDeclarationStrategy.TRY_VARIABLE,
|
||||||
scope,
|
scope,
|
||||||
ownerTemplate, overide, false);
|
ownerTemplate, overrideKind, false, overrideKey);
|
||||||
}
|
}
|
||||||
catch( BacktrackException b3 )
|
catch( BacktrackException b3 )
|
||||||
{
|
{
|
||||||
|
@ -908,7 +907,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
if( identifier == null )
|
if( identifier == null )
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
|
|
||||||
ITokenDuple duple = name(scope, CompletionKind.NAMESPACE_REFERENCE);
|
ITokenDuple duple = name(scope, CompletionKind.NAMESPACE_REFERENCE, Key.EMPTY);
|
||||||
consume( IToken.tSEMI );
|
consume( IToken.tSEMI );
|
||||||
setCompletionValues(scope, kind, Key.DECLARATION );
|
setCompletionValues(scope, kind, Key.DECLARATION );
|
||||||
try
|
try
|
||||||
|
@ -948,7 +947,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
protected void simpleDeclaration(
|
protected void simpleDeclaration(
|
||||||
SimpleDeclarationStrategy strategy,
|
SimpleDeclarationStrategy strategy,
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
IASTTemplate ownerTemplate, CompletionKind overideKind, boolean fromCatchHandler)
|
IASTTemplate ownerTemplate, CompletionKind overideKind, boolean fromCatchHandler, Key overrideKey)
|
||||||
throws BacktrackException, EndOfFileException
|
throws BacktrackException, EndOfFileException
|
||||||
{
|
{
|
||||||
IToken firstToken = LA(1);
|
IToken firstToken = LA(1);
|
||||||
|
@ -959,7 +958,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
|
|
||||||
CompletionKind completionKindForDeclaration = getCompletionKindForDeclaration(scope, overideKind);
|
CompletionKind completionKindForDeclaration = getCompletionKindForDeclaration(scope, overideKind);
|
||||||
setCompletionValues( scope, completionKindForDeclaration, Key.DECL_SPECIFIER_SEQUENCE );
|
setCompletionValues( scope, completionKindForDeclaration, Key.DECL_SPECIFIER_SEQUENCE );
|
||||||
declSpecifierSeq(sdw, false, strategy == SimpleDeclarationStrategy.TRY_CONSTRUCTOR, completionKindForDeclaration );
|
declSpecifierSeq(sdw, false, strategy == SimpleDeclarationStrategy.TRY_CONSTRUCTOR, completionKindForDeclaration, overrideKey );
|
||||||
if (sdw.getTypeSpecifier() == null && sdw.getSimpleType() != IASTSimpleTypeSpecifier.Type.UNSPECIFIED )
|
if (sdw.getTypeSpecifier() == null && sdw.getSimpleType() != IASTSimpleTypeSpecifier.Type.UNSPECIFIED )
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1088,16 +1087,20 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
astFactory.createTypeSpecDeclaration(
|
if( sdw.getTypeSpecifier() != null )
|
||||||
sdw.getScope(),
|
{
|
||||||
sdw.getTypeSpecifier(),
|
astFactory.createTypeSpecDeclaration(
|
||||||
ownerTemplate,
|
sdw.getScope(),
|
||||||
sdw.getStartingOffset(),
|
sdw.getTypeSpecifier(),
|
||||||
sdw.getStartingLine(), lastToken.getEndOffset(), lastToken.getLineNumber(),
|
ownerTemplate,
|
||||||
sdw.isFriend())
|
sdw.getStartingOffset(),
|
||||||
.acceptElement(requestor);
|
sdw.getStartingLine(), lastToken.getEndOffset(), lastToken.getLineNumber(),
|
||||||
|
sdw.isFriend())
|
||||||
|
.acceptElement(requestor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e1)
|
catch (Exception e1)
|
||||||
{
|
{
|
||||||
|
@ -1107,7 +1110,9 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
protected abstract void handleFunctionBody(IASTScope scope) throws BacktrackException, EndOfFileException;
|
|
||||||
|
|
||||||
|
protected abstract void handleFunctionBody(IASTScope scope) throws BacktrackException, EndOfFileException;
|
||||||
|
|
||||||
protected void skipOverCompoundStatement() throws BacktrackException, EndOfFileException
|
protected void skipOverCompoundStatement() throws BacktrackException, EndOfFileException
|
||||||
{
|
{
|
||||||
|
@ -1152,12 +1157,12 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
ITokenDuple duple = name(scope, CompletionKind.SINGLE_NAME_REFERENCE );
|
ITokenDuple duple = name(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EMPTY );
|
||||||
|
|
||||||
consume(IToken.tLPAREN);
|
consume(IToken.tLPAREN);
|
||||||
IASTExpression expressionList = null;
|
IASTExpression expressionList = null;
|
||||||
|
|
||||||
expressionList = expression(d.getDeclarationWrapper().getScope(), CompletionKind.SINGLE_NAME_REFERENCE);
|
expressionList = expression(d.getDeclarationWrapper().getScope(), CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION);
|
||||||
|
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
|
|
||||||
|
@ -1199,7 +1204,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
|
|
||||||
DeclarationWrapper sdw =
|
DeclarationWrapper sdw =
|
||||||
new DeclarationWrapper(scope, current.getOffset(), current.getLineNumber(), null);
|
new DeclarationWrapper(scope, current.getOffset(), current.getLineNumber(), null);
|
||||||
declSpecifierSeq(sdw, true, false, CompletionKind.ARGUMENT_TYPE);
|
declSpecifierSeq(sdw, true, false, CompletionKind.ARGUMENT_TYPE, Key.DECL_SPECIFIER_SEQUENCE );
|
||||||
if (sdw.getTypeSpecifier() == null
|
if (sdw.getTypeSpecifier() == null
|
||||||
&& sdw.getSimpleType()
|
&& sdw.getSimpleType()
|
||||||
!= IASTSimpleTypeSpecifier.Type.UNSPECIFIED)
|
!= IASTSimpleTypeSpecifier.Type.UNSPECIFIED)
|
||||||
|
@ -1303,7 +1308,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param flags input flags that are used to make our decision
|
* @param flags input flags that are used to make our decision
|
||||||
* @return whether or not this looks like a constructor (true or false)
|
* @return whether or not this looks like a constructor (true or false)
|
||||||
* @throws EndOfFileException we could encounter EOF while looking ahead
|
* @throws EndOfFileException we could encounter EOF while looking ahead
|
||||||
*/
|
*/
|
||||||
private boolean lookAheadForConstructorOrConversion(Flags flags, DeclarationWrapper sdw, CompletionKind kind )
|
private boolean lookAheadForConstructorOrConversion(Flags flags, DeclarationWrapper sdw, CompletionKind kind )
|
||||||
|
@ -1325,6 +1330,11 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
backup( mark );
|
backup( mark );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
catch ( EndOfFileException eof )
|
||||||
|
{
|
||||||
|
backup( mark );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ITokenDuple duple = d.getNameDuple();
|
ITokenDuple duple = d.getNameDuple();
|
||||||
if( duple == null )
|
if( duple == null )
|
||||||
|
@ -1366,7 +1376,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
private boolean lookAheadForDeclarator(Flags flags) throws EndOfFileException
|
private boolean lookAheadForDeclarator(Flags flags) throws EndOfFileException
|
||||||
{
|
{
|
||||||
return flags.haveEncounteredTypename()
|
return flags.haveEncounteredTypename()
|
||||||
&& ((LT(2) != IToken.tIDENTIFIER
|
&& ( (LT(2) != IToken.tIDENTIFIER
|
||||||
|| (LT(3) != IToken.tLPAREN && LT(3) != IToken.tASSIGN))
|
|| (LT(3) != IToken.tLPAREN && LT(3) != IToken.tASSIGN))
|
||||||
&& !LA(2).isPointer());
|
&& !LA(2).isPointer());
|
||||||
}
|
}
|
||||||
|
@ -1397,7 +1407,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
protected void declSpecifierSeq(
|
protected void declSpecifierSeq(
|
||||||
DeclarationWrapper sdw,
|
DeclarationWrapper sdw,
|
||||||
boolean parm,
|
boolean parm,
|
||||||
boolean tryConstructor, CompletionKind kind )
|
boolean tryConstructor, CompletionKind kind, Key key )
|
||||||
throws BacktrackException, EndOfFileException
|
throws BacktrackException, EndOfFileException
|
||||||
{
|
{
|
||||||
Flags flags = new Flags(parm, tryConstructor);
|
Flags flags = new Flags(parm, tryConstructor);
|
||||||
|
@ -1576,7 +1586,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
consume(IToken.t_typename );
|
consume(IToken.t_typename );
|
||||||
IToken first = LA(1);
|
IToken first = LA(1);
|
||||||
IToken last = null;
|
IToken last = null;
|
||||||
last = name(sdw.getScope(), CompletionKind.TYPE_REFERENCE).getLastToken();
|
last = name(sdw.getScope(), CompletionKind.TYPE_REFERENCE, Key.EMPTY).getLastToken();
|
||||||
if (LT(1) == IToken.t_template)
|
if (LT(1) == IToken.t_template)
|
||||||
{
|
{
|
||||||
consume(IToken.t_template);
|
consume(IToken.t_template);
|
||||||
|
@ -1623,8 +1633,8 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
setCompletionValues(sdw.getScope(), kind, key );
|
||||||
ITokenDuple d = name(sdw.getScope(), kind );
|
ITokenDuple d = name(sdw.getScope(), kind, key );
|
||||||
sdw.setTypeName(d);
|
sdw.setTypeName(d);
|
||||||
sdw.setSimpleType( IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME );
|
sdw.setSimpleType( IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME );
|
||||||
flags.setEncounteredTypename(true);
|
flags.setEncounteredTypename(true);
|
||||||
|
@ -1661,7 +1671,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
default :
|
default :
|
||||||
if( extension.canHandleDeclSpecifierSequence( LT(1)))
|
if( extension.canHandleDeclSpecifierSequence( LT(1)))
|
||||||
{
|
{
|
||||||
IParserExtension.IDeclSpecifierExtensionResult declSpecExtResult = extension.handleDeclSpecifierSequence( this, flags, sdw, kind );
|
IParserExtension.IDeclSpecifierExtensionResult declSpecExtResult = extension.parseDeclSpecifierSequence( this, flags, sdw, kind, key );
|
||||||
if( declSpecExtResult != null )
|
if( declSpecExtResult != null )
|
||||||
{
|
{
|
||||||
flags = declSpecExtResult.getFlags();
|
flags = declSpecExtResult.getFlags();
|
||||||
|
@ -1716,7 +1726,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
}
|
}
|
||||||
|
|
||||||
ITokenDuple d = name(sdw.getScope(), completionKind);
|
ITokenDuple d = name(sdw.getScope(), completionKind, Key.EMPTY);
|
||||||
IASTTypeSpecifier elaboratedTypeSpec = null;
|
IASTTypeSpecifier elaboratedTypeSpec = null;
|
||||||
final boolean isForewardDecl = ( LT(1) == IToken.tSEMI );
|
final boolean isForewardDecl = ( LT(1) == IToken.tSEMI );
|
||||||
|
|
||||||
|
@ -1800,7 +1810,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
consume(IToken.tLPAREN); // EAT IT!
|
consume(IToken.tLPAREN); // EAT IT!
|
||||||
setCompletionValues(scope,CompletionKind.SINGLE_NAME_REFERENCE,Key.EMPTY);
|
setCompletionValues(scope,CompletionKind.SINGLE_NAME_REFERENCE,Key.EMPTY);
|
||||||
IASTExpression astExpression = null;
|
IASTExpression astExpression = null;
|
||||||
astExpression = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
astExpression = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION);
|
||||||
setCompletionValues(scope,CompletionKind.NO_SUCH_KIND,Key.EMPTY);
|
setCompletionValues(scope,CompletionKind.NO_SUCH_KIND,Key.EMPTY);
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
d.setConstructorExpression(astExpression);
|
d.setConstructorExpression(astExpression);
|
||||||
|
@ -1872,7 +1882,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
// assignmentExpression
|
// assignmentExpression
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IASTExpression assignmentExpression = assignmentExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
IASTExpression assignmentExpression = assignmentExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return astFactory.createInitializerClause(
|
return astFactory.createInitializerClause(
|
||||||
|
@ -1952,7 +1962,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IASTExpression assignmentExpression =
|
IASTExpression assignmentExpression =
|
||||||
assignmentExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
assignmentExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -2001,7 +2011,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
else if( LT(1) == IToken.tLBRACKET )
|
else if( LT(1) == IToken.tLBRACKET )
|
||||||
{
|
{
|
||||||
consume( IToken.tLBRACKET );
|
consume( IToken.tLBRACKET );
|
||||||
constantExpression = expression( scope, CompletionKind.SINGLE_NAME_REFERENCE );
|
constantExpression = expression( scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION );
|
||||||
consume( IToken.tRBRACKET );
|
consume( IToken.tRBRACKET );
|
||||||
kind = IASTDesignator.DesignatorKind.SUBSCRIPT;
|
kind = IASTDesignator.DesignatorKind.SUBSCRIPT;
|
||||||
}
|
}
|
||||||
|
@ -2076,7 +2086,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if( ! astFactory.queryIsTypeName( parameterScope, name(parameterScope, CompletionKind.TYPE_REFERENCE ) ) )
|
if( ! astFactory.queryIsTypeName( parameterScope, name(parameterScope, CompletionKind.TYPE_REFERENCE, Key.EMPTY ) ) )
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -2232,7 +2242,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
continue;
|
continue;
|
||||||
case IToken.tCOLON :
|
case IToken.tCOLON :
|
||||||
consume(IToken.tCOLON);
|
consume(IToken.tCOLON);
|
||||||
IASTExpression exp = constantExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
IASTExpression exp = constantExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION );
|
||||||
d.setBitFieldExpression(exp);
|
d.setBitFieldExpression(exp);
|
||||||
default :
|
default :
|
||||||
break;
|
break;
|
||||||
|
@ -2258,7 +2268,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ITokenDuple duple = name(d.getDeclarationWrapper().getScope(), kind );
|
ITokenDuple duple = name(d.getDeclarationWrapper().getScope(), kind, Key.EMPTY );
|
||||||
d.setName(duple);
|
d.setName(duple);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2375,7 +2385,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
if (LT(1) == IToken.tASSIGN)
|
if (LT(1) == IToken.tASSIGN)
|
||||||
{
|
{
|
||||||
consume(IToken.tASSIGN);
|
consume(IToken.tASSIGN);
|
||||||
initialValue = constantExpression(sdw.getScope(), CompletionKind.SINGLE_NAME_REFERENCE);
|
initialValue = constantExpression(sdw.getScope(), CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LT(1) == IToken.tRBRACE)
|
if (LT(1) == IToken.tRBRACE)
|
||||||
|
@ -2485,7 +2495,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
setCompletionValues(sdw.getScope(), completionKind, Key.EMPTY );
|
setCompletionValues(sdw.getScope(), completionKind, Key.EMPTY );
|
||||||
// class name
|
// class name
|
||||||
if (LT(1) == IToken.tIDENTIFIER)
|
if (LT(1) == IToken.tIDENTIFIER)
|
||||||
duple = name( sdw.getScope(), completionKind );
|
duple = name( sdw.getScope(), completionKind, Key.EMPTY );
|
||||||
if (duple != null && !duple.isIdentifier())
|
if (duple != null && !duple.isIdentifier())
|
||||||
nameType = ClassNameType.TEMPLATE;
|
nameType = ClassNameType.TEMPLATE;
|
||||||
if (LT(1) != IToken.tCOLON && LT(1) != IToken.tLBRACE)
|
if (LT(1) != IToken.tCOLON && LT(1) != IToken.tLBRACE)
|
||||||
|
@ -2634,7 +2644,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
break;
|
break;
|
||||||
case IToken.tCOLONCOLON :
|
case IToken.tCOLONCOLON :
|
||||||
case IToken.tIDENTIFIER :
|
case IToken.tIDENTIFIER :
|
||||||
nameDuple = name(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE );
|
nameDuple = name(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, Key.EMPTY );
|
||||||
break;
|
break;
|
||||||
case IToken.tCOMMA :
|
case IToken.tCOMMA :
|
||||||
try
|
try
|
||||||
|
@ -2705,7 +2715,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
{
|
{
|
||||||
case IToken.t_case :
|
case IToken.t_case :
|
||||||
consume(IToken.t_case);
|
consume(IToken.t_case);
|
||||||
IASTExpression constant_expression = constantExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
IASTExpression constant_expression = constantExpression(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION );
|
||||||
constant_expression.acceptElement(requestor);
|
constant_expression.acceptElement(requestor);
|
||||||
consume(IToken.tCOLON);
|
consume(IToken.tCOLON);
|
||||||
statement(scope);
|
statement(scope);
|
||||||
|
@ -2773,7 +2783,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
consume(IToken.tSEMI);
|
consume(IToken.tSEMI);
|
||||||
if (LT(1) != IToken.tRPAREN)
|
if (LT(1) != IToken.tRPAREN)
|
||||||
{
|
{
|
||||||
IASTExpression finalExpression = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
IASTExpression finalExpression = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.DECLARATION);
|
||||||
finalExpression.acceptElement(requestor);
|
finalExpression.acceptElement(requestor);
|
||||||
}
|
}
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
|
@ -2791,7 +2801,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
consume();
|
consume();
|
||||||
if (LT(1) != IToken.tSEMI)
|
if (LT(1) != IToken.tSEMI)
|
||||||
{
|
{
|
||||||
IASTExpression retVal = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
IASTExpression retVal = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION);
|
||||||
retVal.acceptElement(requestor);
|
retVal.acceptElement(requestor);
|
||||||
}
|
}
|
||||||
consume(IToken.tSEMI);
|
consume(IToken.tSEMI);
|
||||||
|
@ -2813,26 +2823,20 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
// can be many things:
|
// can be many things:
|
||||||
// label
|
// label
|
||||||
|
|
||||||
try
|
if (queryLookaheadCapability(2) && LT(1) == IToken.tIDENTIFIER && LT(2) == IToken.tCOLON)
|
||||||
{
|
{
|
||||||
if (LT(1) == IToken.tIDENTIFIER && LT(2) == IToken.tCOLON)
|
consume(IToken.tIDENTIFIER);
|
||||||
{
|
consume(IToken.tCOLON);
|
||||||
consume(IToken.tIDENTIFIER);
|
statement(scope);
|
||||||
consume(IToken.tCOLON);
|
return;
|
||||||
statement(scope);
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
}catch( OffsetLimitReachedException olre )
|
|
||||||
{
|
|
||||||
// ok
|
|
||||||
}
|
|
||||||
// expressionStatement
|
// expressionStatement
|
||||||
// Note: the function style cast ambiguity is handled in expression
|
// Note: the function style cast ambiguity is handled in expression
|
||||||
// Since it only happens when we are in a statement
|
// Since it only happens when we are in a statement
|
||||||
IToken mark = mark();
|
IToken mark = mark();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IASTExpression expressionStatement = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE);
|
IASTExpression expressionStatement = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.STATEMENT);
|
||||||
consume(IToken.tSEMI);
|
consume(IToken.tSEMI);
|
||||||
expressionStatement.acceptElement( requestor );
|
expressionStatement.acceptElement( requestor );
|
||||||
return;
|
return;
|
||||||
|
@ -2858,7 +2862,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
if( LT(1) == IToken.tELLIPSIS )
|
if( LT(1) == IToken.tELLIPSIS )
|
||||||
consume( IToken.tELLIPSIS );
|
consume( IToken.tELLIPSIS );
|
||||||
else
|
else
|
||||||
simpleDeclaration( SimpleDeclarationStrategy.TRY_VARIABLE, scope, null, CompletionKind.EXCEPTION_REFERENCE, true); // was exceptionDeclaration
|
simpleDeclaration( SimpleDeclarationStrategy.TRY_VARIABLE, scope, null, CompletionKind.EXCEPTION_REFERENCE, true, Key.DECL_SPECIFIER_SEQUENCE );
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
|
|
||||||
catchBlockCompoundStatement(scope);
|
catchBlockCompoundStatement(scope);
|
||||||
|
@ -2896,7 +2900,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
*/
|
*/
|
||||||
protected void condition( IASTScope scope ) throws BacktrackException, EndOfFileException
|
protected void condition( IASTScope scope ) throws BacktrackException, EndOfFileException
|
||||||
{
|
{
|
||||||
IASTExpression someExpression = expression( scope, CompletionKind.SINGLE_NAME_REFERENCE );
|
IASTExpression someExpression = expression( scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION );
|
||||||
someExpression.acceptElement(requestor);
|
someExpression.acceptElement(requestor);
|
||||||
//TODO type-specifier-seq declarator = assignment expression
|
//TODO type-specifier-seq declarator = assignment expression
|
||||||
}
|
}
|
||||||
|
@ -2909,7 +2913,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
IToken mark = mark();
|
IToken mark = mark();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IASTExpression e = expression( scope, CompletionKind.SINGLE_NAME_REFERENCE );
|
IASTExpression e = expression( scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.DECLARATION );
|
||||||
e.acceptElement(requestor);
|
e.acceptElement(requestor);
|
||||||
|
|
||||||
consume( IToken.tSEMI );
|
consume( IToken.tSEMI );
|
||||||
|
@ -2919,7 +2923,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
backup( mark );
|
backup( mark );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
simpleDeclarationStrategyUnion(scope,null, null);
|
simpleDeclarationStrategyUnion(scope,null, null,null);
|
||||||
}
|
}
|
||||||
catch( BacktrackException b )
|
catch( BacktrackException b )
|
||||||
{
|
{
|
||||||
|
|
|
@ -2432,7 +2432,7 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
parser = InternalParserUtil.createExpressionParser(trial, scannerData.getLanguage(), NULL_LOG_SERVICE);
|
parser = InternalParserUtil.createExpressionParser(trial, scannerData.getLanguage(), NULL_LOG_SERVICE);
|
||||||
try {
|
try {
|
||||||
IASTExpression exp = parser.expression(null, null);
|
IASTExpression exp = parser.expression(null, null, null);
|
||||||
if( exp.evaluateExpression() == 0 )
|
if( exp.evaluateExpression() == 0 )
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -189,7 +189,7 @@ public class KeywordSets {
|
||||||
private static final Set STATEMENT_CPP;
|
private static final Set STATEMENT_CPP;
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
STATEMENT_CPP = new TreeSet( STATEMENT_C );
|
STATEMENT_CPP = new TreeSet( DECLARATION_CPP );
|
||||||
STATEMENT_CPP.add( Keywords.TRY );
|
STATEMENT_CPP.add( Keywords.TRY );
|
||||||
//TODO finish this
|
//TODO finish this
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue