mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
CORE/UI
First pass of parsing function bodies with X-Reference information. Updated IASTFactory/ISourceElementRequestor to include IASTCodeScope constructs, clients should keep this in mind and update their implementations. TESTS Updated ASTFailedTests::testBug39702() to fail more accurately. Added testSimpleFunctionBody(), testSimpleForLoop() to CompleteParseASTTest.java.
This commit is contained in:
parent
55efa70a8a
commit
619b617056
18 changed files with 566 additions and 177 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2003-09-04 John Camelon
|
||||||
|
Updated ASTFailedTests::testBug39702() to fail more accurately.
|
||||||
|
Added testSimpleFunctionBody(), testSimpleForLoop() to CompleteParseASTTest.java.
|
||||||
|
|
||||||
2003-09-04 Hoda Amer
|
2003-09-04 Hoda Amer
|
||||||
Call to ASTExpression getTypeId() changed to getTypeIdString().
|
Call to ASTExpression getTypeId() changed to getTypeIdString().
|
||||||
|
|
||||||
|
|
|
@ -272,9 +272,7 @@ public class ASTFailedTests extends BaseASTTest
|
||||||
catch (IOException ioe)
|
catch (IOException ioe)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
Iterator declarations = parse(code.toString()).getDeclarations();
|
assertCodeFailsFullParse(code.toString());
|
||||||
IASTDeclaration d = (IASTDeclaration)declarations.next();
|
|
||||||
assertFalse( "Should be 1 declaration, not 2", !declarations.hasNext() );
|
|
||||||
}
|
}
|
||||||
public void testBug39703() throws Exception
|
public void testBug39703() throws Exception
|
||||||
{
|
{
|
||||||
|
|
|
@ -506,7 +506,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
||||||
|
|
||||||
public void testBug41520() throws Exception
|
public void testBug41520() throws Exception
|
||||||
{
|
{
|
||||||
Iterator i = parse( "const int x = 666, y( x );").getDeclarations();
|
Iterator i = parse( "const int x = 666; const int y( x );").getDeclarations();
|
||||||
IASTVariable variableX = (IASTVariable)i.next();
|
IASTVariable variableX = (IASTVariable)i.next();
|
||||||
IASTVariable variableY = (IASTVariable)i.next();
|
IASTVariable variableY = (IASTVariable)i.next();
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
|
@ -552,7 +552,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
||||||
|
|
||||||
public void testIsDestructor() throws Exception
|
public void testIsDestructor() throws Exception
|
||||||
{
|
{
|
||||||
Iterator i = parse( "class A{ public: A(); }; \n A::~A() {}; \n" ).getDeclarations();
|
Iterator i = parse( "class A{ public: ~A(); }; \n A::~A() {}; \n" ).getDeclarations();
|
||||||
IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
||||||
IASTMethod method = (IASTMethod)i.next();
|
IASTMethod method = (IASTMethod)i.next();
|
||||||
assertTrue (method.isDestructor());
|
assertTrue (method.isDestructor());
|
||||||
|
@ -567,4 +567,34 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
||||||
IASTClassSpecifier classB = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)sub.next()).getTypeSpecifier();
|
IASTClassSpecifier classB = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)sub.next()).getTypeSpecifier();
|
||||||
IASTClassSpecifier structA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)( getDeclarations( classB ).next())).getTypeSpecifier();
|
IASTClassSpecifier structA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)( getDeclarations( classB ).next())).getTypeSpecifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testSimpleFunctionBody() throws Exception
|
||||||
|
{
|
||||||
|
Iterator i = parse( "class A { int f1(); }; const int x = 4; int f() { return x; } int A::f1() { return x; }").getDeclarations();
|
||||||
|
IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
||||||
|
IASTMethod method_prototype = (IASTMethod)getDeclarations(classA).next();
|
||||||
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
|
IASTFunction function_f = (IASTFunction) i.next();
|
||||||
|
IASTMethod method_f = (IASTMethod)i.next();
|
||||||
|
assertEquals( method_f.getName(), method_prototype.getName() );
|
||||||
|
assertFalse( i.hasNext() );
|
||||||
|
assertEquals( callback.getReferences().size(), 3 );
|
||||||
|
IASTVariableReference referenceX = (IASTVariableReference) callback.getReferences().get(0);
|
||||||
|
assertEquals( referenceX.getReferencedElement(), x );
|
||||||
|
IASTClassReference referenceA = (IASTClassReference) callback.getReferences().get(1);
|
||||||
|
assertEquals( referenceA.getReferencedElement(), classA );
|
||||||
|
referenceX = (IASTVariableReference) callback.getReferences().get(2);
|
||||||
|
assertEquals( referenceX.getReferencedElement(), x );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void testSimpleForLoop() throws Exception
|
||||||
|
{
|
||||||
|
Iterator i = parse( "const int FIVE = 5; void f() { int x = 0; for( int i = 0; i < FIVE; ++i ) { x += i; } }").getDeclarations();
|
||||||
|
IASTVariable five = (IASTVariable) i.next();
|
||||||
|
IASTFunction f = (IASTFunction) i.next();
|
||||||
|
assertFalse( i.hasNext() );
|
||||||
|
assertEquals( callback.getReferences().size(), 5 );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -524,6 +524,22 @@ public class CompleteParseBaseTest extends TestCase
|
||||||
return forewardDecls;
|
return forewardDecls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterCodeBlock(org.eclipse.cdt.core.parser.ast.IASTScope)
|
||||||
|
*/
|
||||||
|
public void enterCodeBlock(IASTScope scope) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitCodeBlock(org.eclipse.cdt.core.parser.ast.IASTScope)
|
||||||
|
*/
|
||||||
|
public void exitCodeBlock(IASTScope scope) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
protected Iterator getDeclarations(IASTScope scope)
|
protected Iterator getDeclarations(IASTScope scope)
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTMethodReference;
|
import org.eclipse.cdt.core.parser.ast.IASTMethodReference;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
||||||
|
@ -959,4 +960,18 @@ public class DOMBuilder implements ISourceElementRequestor
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterCodeBlock(org.eclipse.cdt.core.parser.ast.IASTScope)
|
||||||
|
*/
|
||||||
|
public void enterCodeBlock(IASTScope scope) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitCodeBlock(org.eclipse.cdt.core.parser.ast.IASTScope)
|
||||||
|
*/
|
||||||
|
public void exitCodeBlock(IASTScope scope) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -36,6 +36,7 @@ import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTMethodReference;
|
import org.eclipse.cdt.core.parser.ast.IASTMethodReference;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
|
||||||
|
@ -416,4 +417,18 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
|
||||||
public void acceptElaboratedForewardDeclaration(IASTElaboratedTypeSpecifier elaboratedType){
|
public void acceptElaboratedForewardDeclaration(IASTElaboratedTypeSpecifier elaboratedType){
|
||||||
indexer.addElaboratedForwardDeclaration(elaboratedType);
|
indexer.addElaboratedForwardDeclaration(elaboratedType);
|
||||||
}
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterCodeBlock(org.eclipse.cdt.core.parser.ast.IASTScope)
|
||||||
|
*/
|
||||||
|
public void enterCodeBlock(IASTScope scope) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitCodeBlock(org.eclipse.cdt.core.parser.ast.IASTScope)
|
||||||
|
*/
|
||||||
|
public void exitCodeBlock(IASTScope scope) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
2003-09-04 John Camelon
|
||||||
|
First pass of parsing function bodies with X-Reference information.
|
||||||
|
Updated IASTFactory/ISourceElementRequestor to include IASTCodeScope
|
||||||
|
constructs, clients should keep this in mind and update their implementations.
|
||||||
|
|
||||||
2003-09-03 Andrew Niefer
|
2003-09-03 Andrew Niefer
|
||||||
fix bug in PST that prevents > 2 constructors
|
fix bug in PST that prevents > 2 constructors
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTMethodReference;
|
import org.eclipse.cdt.core.parser.ast.IASTMethodReference;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
|
||||||
|
@ -60,6 +61,8 @@ public interface ISourceElementRequestor {
|
||||||
|
|
||||||
public void enterFunctionBody( IASTFunction function );
|
public void enterFunctionBody( IASTFunction function );
|
||||||
public void exitFunctionBody( IASTFunction function );
|
public void exitFunctionBody( IASTFunction function );
|
||||||
|
public void enterCodeBlock( IASTScope scope );
|
||||||
|
public void exitCodeBlock( IASTScope scope );
|
||||||
|
|
||||||
public void enterCompilationUnit( IASTCompilationUnit compilationUnit );
|
public void enterCompilationUnit( IASTCompilationUnit compilationUnit );
|
||||||
public void enterInclusion( IASTInclusion inclusion );
|
public void enterInclusion( IASTInclusion inclusion );
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
/*
|
||||||
|
* Created on Sep 2, 2003
|
||||||
|
*
|
||||||
|
* To change the template for this generated file go to
|
||||||
|
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.core.parser.ast;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
* To change the template for this generated type comment go to
|
||||||
|
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||||
|
*/
|
||||||
|
public interface IASTCodeScope extends IASTScope, ISourceElementCallbackDelegate{
|
||||||
|
|
||||||
|
}
|
|
@ -11,7 +11,6 @@
|
||||||
package org.eclipse.cdt.core.parser.ast;
|
package org.eclipse.cdt.core.parser.ast;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
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.ast.IASTClassSpecifier.ClassNameType;
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
|
||||||
|
@ -192,7 +191,14 @@ public interface IASTFactory
|
||||||
|
|
||||||
public IASTAbstractTypeSpecifierDeclaration createTypeSpecDeclaration( IASTScope scope, IASTTypeSpecifier typeSpecifier, IASTTemplate template, int startingOffset, int endingOffset);
|
public IASTAbstractTypeSpecifierDeclaration createTypeSpecDeclaration( IASTScope scope, IASTTypeSpecifier typeSpecifier, IASTTemplate template, int startingOffset, int endingOffset);
|
||||||
|
|
||||||
|
public boolean queryIsTypeName( IASTScope scope, ITokenDuple nameInQuestion );
|
||||||
|
|
||||||
static final String DOUBLE_COLON = "::";
|
static final String DOUBLE_COLON = "::";
|
||||||
static final String TELTA = "~";
|
static final String TELTA = "~";
|
||||||
|
/**
|
||||||
|
* @param scope
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public IASTCodeScope createNewCodeBlock(IASTScope scope);
|
||||||
|
|
||||||
}
|
}
|
|
@ -21,6 +21,7 @@ import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTMethodReference;
|
import org.eclipse.cdt.core.parser.ast.IASTMethodReference;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
|
||||||
|
@ -406,4 +407,20 @@ public class NullSourceElementRequestor implements ISourceElementRequestor
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterCodeBlock(org.eclipse.cdt.core.parser.ast.IASTScope)
|
||||||
|
*/
|
||||||
|
public void enterCodeBlock(IASTScope scope) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitCodeBlock(org.eclipse.cdt.core.parser.ast.IASTScope)
|
||||||
|
*/
|
||||||
|
public void exitCodeBlock(IASTScope scope) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.eclipse.cdt.core.parser.ast.ASTSemanticException;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTArrayModifier;
|
import org.eclipse.cdt.core.parser.ast.IASTArrayModifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
||||||
|
@ -704,12 +705,20 @@ public class Parser implements IParser
|
||||||
{
|
{
|
||||||
backup( mark );
|
backup( mark );
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
simpleDeclaration(
|
simpleDeclaration(
|
||||||
SimpleDeclarationStrategy.TRY_VARIABLE,
|
SimpleDeclarationStrategy.TRY_VARIABLE,
|
||||||
false,
|
false,
|
||||||
scope,
|
scope,
|
||||||
ownerTemplate);
|
ownerTemplate);
|
||||||
}
|
}
|
||||||
|
catch( Backtrack b3 )
|
||||||
|
{
|
||||||
|
backup( mark );
|
||||||
|
throw b3;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -853,7 +862,6 @@ public class Parser implements IParser
|
||||||
sdw.isUnsigned(), sdw.isTypeNamed()));
|
sdw.isUnsigned(), sdw.isTypeNamed()));
|
||||||
} catch( ASTSemanticException se )
|
} catch( ASTSemanticException se )
|
||||||
{
|
{
|
||||||
failParse();
|
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -902,13 +910,11 @@ public class Parser implements IParser
|
||||||
}
|
}
|
||||||
catch (ASTSemanticException e)
|
catch (ASTSemanticException e)
|
||||||
{
|
{
|
||||||
failParse();
|
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
}
|
}
|
||||||
Iterator i = l.iterator();
|
Iterator i = l.iterator();
|
||||||
if (hasFunctionBody && l.size() != 1)
|
if (hasFunctionBody && l.size() != 1)
|
||||||
{
|
{
|
||||||
failParse();
|
|
||||||
throw backtrack; //TODO Should be an IProblem
|
throw backtrack; //TODO Should be an IProblem
|
||||||
}
|
}
|
||||||
if (i.hasNext()) // no need to do this unless we have a declarator
|
if (i.hasNext()) // no need to do this unless we have a declarator
|
||||||
|
@ -928,7 +934,7 @@ public class Parser implements IParser
|
||||||
IASTDeclaration declaration = (IASTDeclaration)i.next();
|
IASTDeclaration declaration = (IASTDeclaration)i.next();
|
||||||
declaration.enterScope( requestor );
|
declaration.enterScope( requestor );
|
||||||
|
|
||||||
handleFunctionBody(declarator);
|
handleFunctionBody((IASTScope)declaration);
|
||||||
((IASTOffsetableElement)declaration).setEndingOffset(
|
((IASTOffsetableElement)declaration).setEndingOffset(
|
||||||
lastToken.getEndOffset());
|
lastToken.getEndOffset());
|
||||||
|
|
||||||
|
@ -948,7 +954,7 @@ public class Parser implements IParser
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
protected void handleFunctionBody(Declarator d) throws Backtrack, EndOfFile
|
protected void handleFunctionBody(IASTScope scope) throws Backtrack, EndOfFile
|
||||||
{
|
{
|
||||||
if ( mode == ParserMode.QUICK_PARSE ) // TODO - Enable parsing within function bodies i.e. mode == ParserMode.QUICK_PARSE)
|
if ( mode == ParserMode.QUICK_PARSE ) // TODO - Enable parsing within function bodies i.e. mode == ParserMode.QUICK_PARSE)
|
||||||
{
|
{
|
||||||
|
@ -971,7 +977,7 @@ public class Parser implements IParser
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
functionBody();
|
functionBody(scope);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -1668,15 +1674,22 @@ public class Parser implements IParser
|
||||||
IToken mark = mark();
|
IToken mark = mark();
|
||||||
|
|
||||||
if (LT(1) == IToken.tCOLONCOLON)
|
if (LT(1) == IToken.tCOLONCOLON)
|
||||||
last = consume();
|
last = consume( IToken.tCOLONCOLON );
|
||||||
// TODO - whacky way to deal with destructors, please revisit
|
// TODO - whacky way to deal with destructors, please revisit
|
||||||
if (LT(1) == IToken.tCOMPL)
|
if (LT(1) == IToken.tCOMPL)
|
||||||
consume();
|
consume();
|
||||||
switch (LT(1))
|
switch (LT(1))
|
||||||
{
|
{
|
||||||
case IToken.tIDENTIFIER :
|
case IToken.tIDENTIFIER :
|
||||||
last = consume();
|
last = consume(IToken.tIDENTIFIER);
|
||||||
|
IToken secondMark = mark();
|
||||||
|
try
|
||||||
|
{
|
||||||
last = consumeTemplateParameters(last);
|
last = consumeTemplateParameters(last);
|
||||||
|
} catch( Backtrack bt )
|
||||||
|
{
|
||||||
|
backup( secondMark );
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
backup(mark);
|
backup(mark);
|
||||||
|
@ -1753,12 +1766,20 @@ public class Parser implements IParser
|
||||||
}
|
}
|
||||||
else if (LT(1) == IToken.tLPAREN)
|
else if (LT(1) == IToken.tLPAREN)
|
||||||
{
|
{
|
||||||
|
IToken mark = mark();
|
||||||
// initializer in constructor
|
// initializer in constructor
|
||||||
|
try
|
||||||
|
{
|
||||||
consume(IToken.tLPAREN); // EAT IT!
|
consume(IToken.tLPAREN); // EAT IT!
|
||||||
IASTExpression astExpression = null;
|
IASTExpression astExpression = null;
|
||||||
astExpression = expression(sdw.getScope());
|
astExpression = expression(sdw.getScope());
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
d.setConstructorExpression(astExpression);
|
d.setConstructorExpression(astExpression);
|
||||||
|
} catch( Backtrack bt )
|
||||||
|
{
|
||||||
|
backup( mark );
|
||||||
|
throw bt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sdw.addDeclarator(d);
|
sdw.addDeclarator(d);
|
||||||
return d;
|
return d;
|
||||||
|
@ -1902,13 +1923,34 @@ public class Parser implements IParser
|
||||||
if( forKR )
|
if( forKR )
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// temporary fix for initializer/function declaration ambiguity
|
// temporary fix for initializer/function declaration ambiguity
|
||||||
if (!LA(2).looksLikeExpression() && strategy != SimpleDeclarationStrategy.TRY_VARIABLE )
|
if (!LA(2).looksLikeExpression() && strategy != SimpleDeclarationStrategy.TRY_VARIABLE )
|
||||||
|
{
|
||||||
|
boolean failed = false;
|
||||||
|
if( LT(2) == IToken.tIDENTIFIER )
|
||||||
|
{
|
||||||
|
IToken newMark = mark();
|
||||||
|
consume( IToken.tLPAREN );
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if( ! astFactory.queryIsTypeName( scope, name() ) )
|
||||||
|
failed = true;
|
||||||
|
} catch( Backtrack b )
|
||||||
|
{
|
||||||
|
failed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
backup( newMark );
|
||||||
|
}
|
||||||
|
if( !failed )
|
||||||
{
|
{
|
||||||
// parameterDeclarationClause
|
// parameterDeclarationClause
|
||||||
d.setIsFunction(true);
|
d.setIsFunction(true);
|
||||||
// TODO need to create a temporary scope object here
|
// TODO need to create a temporary scope object here
|
||||||
consume();
|
consume(IToken.tLPAREN);
|
||||||
boolean seenParameter = false;
|
boolean seenParameter = false;
|
||||||
parameterDeclarationLoop : for (;;)
|
parameterDeclarationLoop : for (;;)
|
||||||
{
|
{
|
||||||
|
@ -1929,6 +1971,7 @@ public class Parser implements IParser
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
parameterDeclaration(d, scope);
|
parameterDeclaration(d, scope);
|
||||||
seenParameter = true;
|
seenParameter = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2550,9 +2593,9 @@ public class Parser implements IParser
|
||||||
*
|
*
|
||||||
* @throws Backtrack request a backtrack
|
* @throws Backtrack request a backtrack
|
||||||
*/
|
*/
|
||||||
protected void functionBody() throws Backtrack
|
protected void functionBody( IASTScope scope ) throws Backtrack
|
||||||
{
|
{
|
||||||
compoundStatement();
|
compoundStatement( scope, false );
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Parses a statement.
|
* Parses a statement.
|
||||||
|
@ -2565,67 +2608,80 @@ public class Parser implements IParser
|
||||||
switch (LT(1))
|
switch (LT(1))
|
||||||
{
|
{
|
||||||
case IToken.t_case :
|
case IToken.t_case :
|
||||||
consume();
|
consume(IToken.t_case);
|
||||||
constantExpression(scope);
|
IASTExpression constant_expression = constantExpression(scope);
|
||||||
|
constant_expression.acceptElement(requestor);
|
||||||
consume(IToken.tCOLON);
|
consume(IToken.tCOLON);
|
||||||
statement(null);
|
statement(scope);
|
||||||
return;
|
return;
|
||||||
case IToken.t_default :
|
case IToken.t_default :
|
||||||
consume();
|
consume(IToken.t_default);
|
||||||
consume(IToken.tCOLON);
|
consume(IToken.tCOLON);
|
||||||
statement(null);
|
statement(scope);
|
||||||
return;
|
return;
|
||||||
case IToken.tLBRACE :
|
case IToken.tLBRACE :
|
||||||
compoundStatement();
|
compoundStatement(scope, true);
|
||||||
return;
|
return;
|
||||||
case IToken.t_if :
|
case IToken.t_if :
|
||||||
consume();
|
consume( IToken.t_if );
|
||||||
consume(IToken.tLPAREN);
|
consume(IToken.tLPAREN);
|
||||||
condition();
|
condition( scope );
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
statement(null);
|
if( LT(1) != IToken.tLBRACE )
|
||||||
|
statement( astFactory.createNewCodeBlock( scope ) );
|
||||||
|
else
|
||||||
|
statement(scope);
|
||||||
if (LT(1) == IToken.t_else)
|
if (LT(1) == IToken.t_else)
|
||||||
{
|
{
|
||||||
consume();
|
consume( IToken.t_else );
|
||||||
statement(null);
|
if( LT(1) != IToken.tLBRACE )
|
||||||
|
statement( astFactory.createNewCodeBlock( scope ) );
|
||||||
|
else
|
||||||
|
statement( scope );
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case IToken.t_switch :
|
case IToken.t_switch :
|
||||||
consume();
|
consume();
|
||||||
consume(IToken.tLPAREN);
|
consume(IToken.tLPAREN);
|
||||||
condition();
|
condition(scope);
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
statement(null);
|
statement(scope);
|
||||||
return;
|
return;
|
||||||
case IToken.t_while :
|
case IToken.t_while :
|
||||||
consume();
|
|
||||||
consume(IToken.tLPAREN);
|
|
||||||
condition();
|
|
||||||
consume(IToken.tRPAREN);
|
|
||||||
statement(null);
|
|
||||||
return;
|
|
||||||
case IToken.t_do :
|
|
||||||
consume();
|
|
||||||
statement(null);
|
|
||||||
consume(IToken.t_while);
|
consume(IToken.t_while);
|
||||||
consume(IToken.tLPAREN);
|
consume(IToken.tLPAREN);
|
||||||
condition();
|
condition(scope);
|
||||||
|
consume(IToken.tRPAREN);
|
||||||
|
if( LT(1) != IToken.tLBRACE )
|
||||||
|
statement(astFactory.createNewCodeBlock(scope));
|
||||||
|
else
|
||||||
|
statement(scope);
|
||||||
|
return;
|
||||||
|
case IToken.t_do :
|
||||||
|
consume(IToken.t_do);
|
||||||
|
if( LT(1) != IToken.tLBRACE )
|
||||||
|
statement(astFactory.createNewCodeBlock(scope));
|
||||||
|
else
|
||||||
|
statement(scope);
|
||||||
|
consume(IToken.t_while);
|
||||||
|
consume(IToken.tLPAREN);
|
||||||
|
condition(scope);
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
return;
|
return;
|
||||||
case IToken.t_for :
|
case IToken.t_for :
|
||||||
consume();
|
consume();
|
||||||
consume(IToken.tLPAREN);
|
consume(IToken.tLPAREN);
|
||||||
forInitStatement();
|
forInitStatement(scope);
|
||||||
if (LT(1) != IToken.tSEMI)
|
if (LT(1) != IToken.tSEMI)
|
||||||
condition();
|
condition(scope);
|
||||||
consume(IToken.tSEMI);
|
consume(IToken.tSEMI);
|
||||||
if (LT(1) != IToken.tRPAREN)
|
if (LT(1) != IToken.tRPAREN)
|
||||||
{
|
{
|
||||||
//TODO get rid of NULL
|
IASTExpression finalExpression = expression(scope);
|
||||||
expression(scope);
|
finalExpression.acceptElement(requestor);
|
||||||
}
|
}
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
statement(null);
|
statement(scope);
|
||||||
return;
|
return;
|
||||||
case IToken.t_break :
|
case IToken.t_break :
|
||||||
consume();
|
consume();
|
||||||
|
@ -2639,8 +2695,8 @@ public class Parser implements IParser
|
||||||
consume();
|
consume();
|
||||||
if (LT(1) != IToken.tSEMI)
|
if (LT(1) != IToken.tSEMI)
|
||||||
{
|
{
|
||||||
//TODO get rid of NULL
|
IASTExpression retVal = expression(scope);
|
||||||
expression(scope);
|
retVal.acceptElement(requestor);
|
||||||
}
|
}
|
||||||
consume(IToken.tSEMI);
|
consume(IToken.tSEMI);
|
||||||
return;
|
return;
|
||||||
|
@ -2651,14 +2707,14 @@ public class Parser implements IParser
|
||||||
return;
|
return;
|
||||||
case IToken.t_try :
|
case IToken.t_try :
|
||||||
consume();
|
consume();
|
||||||
compoundStatement();
|
compoundStatement(scope,true);
|
||||||
while (LT(1) == IToken.t_catch)
|
while (LT(1) == IToken.t_catch)
|
||||||
{
|
{
|
||||||
consume();
|
consume();
|
||||||
consume(IToken.tLPAREN);
|
consume(IToken.tLPAREN);
|
||||||
declaration(null, null); // was exceptionDeclaration
|
declaration(scope, null); // was exceptionDeclaration
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
compoundStatement();
|
compoundStatement(scope, true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case IToken.tSEMI :
|
case IToken.tSEMI :
|
||||||
|
@ -2669,50 +2725,97 @@ public class Parser implements IParser
|
||||||
// label
|
// label
|
||||||
if (LT(1) == IToken.tIDENTIFIER && LT(2) == IToken.tCOLON)
|
if (LT(1) == IToken.tIDENTIFIER && LT(2) == IToken.tCOLON)
|
||||||
{
|
{
|
||||||
consume();
|
consume(IToken.tIDENTIFIER);
|
||||||
consume();
|
consume(IToken.tCOLON);
|
||||||
statement(null);
|
statement(scope);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 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();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
expression(scope);
|
IASTExpression thisExpression = expression(scope);
|
||||||
consume(IToken.tSEMI);
|
consume(IToken.tSEMI);
|
||||||
|
thisExpression.acceptElement( requestor );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch (Backtrack b)
|
catch (Backtrack b)
|
||||||
{
|
{
|
||||||
|
backup( mark );
|
||||||
}
|
}
|
||||||
// declarationStatement
|
// declarationStatement
|
||||||
declaration(null, null);
|
declaration(scope, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws Backtrack
|
* @throws Backtrack
|
||||||
*/
|
*/
|
||||||
protected void condition() throws Backtrack
|
protected void condition( IASTScope scope ) throws Backtrack
|
||||||
{
|
{
|
||||||
// TO DO
|
IASTExpression someExpression = expression( scope );
|
||||||
|
someExpression.acceptElement(requestor);
|
||||||
|
//TODO type-specifier-seq declarator = assignment expression
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws Backtrack
|
* @throws Backtrack
|
||||||
*/
|
*/
|
||||||
protected void forInitStatement() throws Backtrack
|
protected void forInitStatement( IASTScope scope ) throws Backtrack
|
||||||
{
|
{
|
||||||
// TO DO
|
try
|
||||||
|
{
|
||||||
|
simpleDeclarationStrategyUnion(scope,null);
|
||||||
|
}
|
||||||
|
catch( Backtrack bt )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IASTExpression e = expression( scope );
|
||||||
|
e.acceptElement(requestor);
|
||||||
|
}
|
||||||
|
catch( Backtrack b )
|
||||||
|
{
|
||||||
|
failParse();
|
||||||
|
throw b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @throws Backtrack
|
* @throws Backtrack
|
||||||
*/
|
*/
|
||||||
protected void compoundStatement() throws Backtrack
|
protected void compoundStatement( IASTScope scope, boolean createNewScope ) throws Backtrack
|
||||||
{
|
{
|
||||||
consume(IToken.tLBRACE);
|
consume(IToken.tLBRACE);
|
||||||
|
|
||||||
|
IASTCodeScope newScope = null;
|
||||||
|
if( createNewScope )
|
||||||
|
{
|
||||||
|
newScope = astFactory.createNewCodeBlock(scope);
|
||||||
|
newScope.enterScope( requestor );
|
||||||
|
}
|
||||||
|
IToken checkToken = null;
|
||||||
while (LT(1) != IToken.tRBRACE)
|
while (LT(1) != IToken.tRBRACE)
|
||||||
statement(null);
|
{
|
||||||
consume();
|
checkToken = LA(1);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
statement(createNewScope ? newScope : scope );
|
||||||
|
}
|
||||||
|
catch( Backtrack b )
|
||||||
|
{
|
||||||
|
failParse();
|
||||||
|
if( LA(1) == checkToken )
|
||||||
|
errorHandling();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
consume(IToken.tRBRACE);
|
||||||
|
if( createNewScope )
|
||||||
|
newScope.exitScope( requestor );
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param expression
|
* @param expression
|
||||||
|
@ -2757,61 +2860,79 @@ public class Parser implements IParser
|
||||||
* @param expression
|
* @param expression
|
||||||
* @throws Backtrack
|
* @throws Backtrack
|
||||||
*/
|
*/
|
||||||
protected IASTExpression assignmentExpression( IASTScope scope )
|
protected IASTExpression assignmentExpression(IASTScope scope)
|
||||||
throws Backtrack
|
throws Backtrack {
|
||||||
{
|
if (LT(1) == IToken.t_throw) {
|
||||||
if (LT(1) == IToken.t_throw)
|
|
||||||
{
|
|
||||||
return throwExpression(scope);
|
return throwExpression(scope);
|
||||||
}
|
}
|
||||||
IASTExpression conditionalExpression =
|
IASTExpression conditionalExpression = conditionalExpression(scope);
|
||||||
conditionalExpression(scope);
|
|
||||||
// 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()
|
||||||
== IASTExpression.Kind.CONDITIONALEXPRESSION_HARD)
|
== IASTExpression.Kind.CONDITIONALEXPRESSION_HARD)
|
||||||
return conditionalExpression;
|
return conditionalExpression;
|
||||||
switch (LT(1))
|
switch (LT(1)) {
|
||||||
{
|
|
||||||
case IToken.tASSIGN :
|
case IToken.tASSIGN :
|
||||||
return assignmentOperatorExpression( scope,
|
return assignmentOperatorExpression(
|
||||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_NORMAL);
|
scope,
|
||||||
|
IASTExpression.Kind.ASSIGNMENTEXPRESSION_NORMAL,
|
||||||
|
conditionalExpression);
|
||||||
case IToken.tSTARASSIGN :
|
case IToken.tSTARASSIGN :
|
||||||
return assignmentOperatorExpression(scope,
|
return assignmentOperatorExpression(
|
||||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_MULT);
|
scope,
|
||||||
|
IASTExpression.Kind.ASSIGNMENTEXPRESSION_MULT,
|
||||||
|
conditionalExpression);
|
||||||
case IToken.tDIVASSIGN :
|
case IToken.tDIVASSIGN :
|
||||||
return assignmentOperatorExpression(scope,
|
return assignmentOperatorExpression(
|
||||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_DIV);
|
scope,
|
||||||
|
IASTExpression.Kind.ASSIGNMENTEXPRESSION_DIV,
|
||||||
|
conditionalExpression);
|
||||||
case IToken.tMODASSIGN :
|
case IToken.tMODASSIGN :
|
||||||
return assignmentOperatorExpression(scope,
|
return assignmentOperatorExpression(
|
||||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_MOD);
|
scope,
|
||||||
|
IASTExpression.Kind.ASSIGNMENTEXPRESSION_MOD,
|
||||||
|
conditionalExpression);
|
||||||
case IToken.tPLUSASSIGN :
|
case IToken.tPLUSASSIGN :
|
||||||
return assignmentOperatorExpression(scope,
|
return assignmentOperatorExpression(
|
||||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_PLUS);
|
scope,
|
||||||
|
IASTExpression.Kind.ASSIGNMENTEXPRESSION_PLUS,
|
||||||
|
conditionalExpression);
|
||||||
case IToken.tMINUSASSIGN :
|
case IToken.tMINUSASSIGN :
|
||||||
return assignmentOperatorExpression(scope,
|
return assignmentOperatorExpression(
|
||||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_MINUS);
|
scope,
|
||||||
|
IASTExpression.Kind.ASSIGNMENTEXPRESSION_MINUS,
|
||||||
|
conditionalExpression);
|
||||||
case IToken.tSHIFTRASSIGN :
|
case IToken.tSHIFTRASSIGN :
|
||||||
return assignmentOperatorExpression(scope,
|
return assignmentOperatorExpression(
|
||||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_RSHIFT);
|
scope,
|
||||||
|
IASTExpression.Kind.ASSIGNMENTEXPRESSION_RSHIFT,
|
||||||
|
conditionalExpression);
|
||||||
case IToken.tSHIFTLASSIGN :
|
case IToken.tSHIFTLASSIGN :
|
||||||
return assignmentOperatorExpression(scope,
|
return assignmentOperatorExpression(
|
||||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_LSHIFT);
|
scope,
|
||||||
|
IASTExpression.Kind.ASSIGNMENTEXPRESSION_LSHIFT,
|
||||||
|
conditionalExpression);
|
||||||
case IToken.tAMPERASSIGN :
|
case IToken.tAMPERASSIGN :
|
||||||
return assignmentOperatorExpression(scope,
|
return assignmentOperatorExpression(
|
||||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_AND);
|
scope,
|
||||||
|
IASTExpression.Kind.ASSIGNMENTEXPRESSION_AND,
|
||||||
|
conditionalExpression);
|
||||||
case IToken.tXORASSIGN :
|
case IToken.tXORASSIGN :
|
||||||
return assignmentOperatorExpression(scope,
|
return assignmentOperatorExpression(
|
||||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_XOR);
|
scope,
|
||||||
|
IASTExpression.Kind.ASSIGNMENTEXPRESSION_XOR,
|
||||||
|
conditionalExpression);
|
||||||
case IToken.tBITORASSIGN :
|
case IToken.tBITORASSIGN :
|
||||||
return assignmentOperatorExpression(scope,
|
return assignmentOperatorExpression(
|
||||||
IASTExpression.Kind.ASSIGNMENTEXPRESSION_OR);
|
scope,
|
||||||
|
IASTExpression.Kind.ASSIGNMENTEXPRESSION_OR,
|
||||||
|
conditionalExpression);
|
||||||
}
|
}
|
||||||
return conditionalExpression;
|
return conditionalExpression;
|
||||||
}
|
}
|
||||||
protected IASTExpression assignmentOperatorExpression(
|
protected IASTExpression assignmentOperatorExpression(
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
IASTExpression.Kind kind)
|
IASTExpression.Kind kind, IASTExpression lhs )
|
||||||
throws EndOfFile, Backtrack
|
throws EndOfFile, Backtrack
|
||||||
{
|
{
|
||||||
IToken t = consume();
|
IToken t = consume();
|
||||||
|
@ -2822,10 +2943,10 @@ public class Parser implements IParser
|
||||||
return astFactory.createExpression(
|
return astFactory.createExpression(
|
||||||
scope,
|
scope,
|
||||||
kind,
|
kind,
|
||||||
|
lhs,
|
||||||
assignmentExpression,
|
assignmentExpression,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
|
||||||
"", null);
|
"", null);
|
||||||
}
|
}
|
||||||
catch (ASTSemanticException e)
|
catch (ASTSemanticException e)
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* Created on Sep 2, 2003
|
||||||
|
*
|
||||||
|
* To change the template for this generated file go to
|
||||||
|
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
* To change the template for this generated type comment go to
|
||||||
|
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||||
|
*/
|
||||||
|
public class ASTCodeScope extends ASTScope implements IASTCodeScope {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param newScope
|
||||||
|
*/
|
||||||
|
public ASTCodeScope(IContainerSymbol newScope) {
|
||||||
|
super( newScope );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void acceptElement(ISourceElementRequestor requestor) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void enterScope(ISourceElementRequestor requestor) {
|
||||||
|
requestor.enterCodeBlock( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void exitScope(ISourceElementRequestor requestor) {
|
||||||
|
requestor.exitCodeBlock( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -27,6 +27,7 @@ import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTArrayModifier;
|
import org.eclipse.cdt.core.parser.ast.IASTArrayModifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTConstructorMemberInitializer;
|
import org.eclipse.cdt.core.parser.ast.IASTConstructorMemberInitializer;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
||||||
|
@ -102,7 +103,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
// looking for a function
|
// looking for a function
|
||||||
result = startingScope.qualifiedFunctionLookup(name, new LinkedList(parameters));
|
result = startingScope.qualifiedFunctionLookup(name, new LinkedList(parameters));
|
||||||
}else{
|
}else{
|
||||||
// looking for a class
|
// looking for something else
|
||||||
result = startingScope.qualifiedLookup(name, type);
|
result = startingScope.qualifiedLookup(name, type);
|
||||||
}
|
}
|
||||||
if( result != null )
|
if( result != null )
|
||||||
|
@ -1247,15 +1248,6 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
setParameter( symbol, returnType, false, references );
|
setParameter( symbol, returnType, false, references );
|
||||||
setParameters( symbol, references, parameters.iterator() );
|
setParameters( symbol, references, parameters.iterator() );
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ownerScope.addSymbol( symbol );
|
|
||||||
}
|
|
||||||
catch (ParserSymbolTableException e)
|
|
||||||
{
|
|
||||||
throw new ASTSemanticException();
|
|
||||||
}
|
|
||||||
|
|
||||||
// check constructor / destructor if no return type
|
// check constructor / destructor if no return type
|
||||||
if ( returnType.getTypeSpecifier() == null ){
|
if ( returnType.getTypeSpecifier() == null ){
|
||||||
if(parentName.indexOf(DOUBLE_COLON) != -1){
|
if(parentName.indexOf(DOUBLE_COLON) != -1){
|
||||||
|
@ -1268,6 +1260,22 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if( !isConstructor )
|
||||||
|
ownerScope.addSymbol( symbol );
|
||||||
|
else
|
||||||
|
{
|
||||||
|
symbol.setType( TypeInfo.t_constructor );
|
||||||
|
((IDerivableContainerSymbol)ownerScope).addConstructor( symbol );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (ParserSymbolTableException e)
|
||||||
|
{
|
||||||
|
throw new ASTSemanticException();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ASTMethod method = new ASTMethod( symbol, parameters, returnType, exception, startOffset, nameOffset, ownerTemplate, references, isConstructor, isDestructor, isPureVirtual, visibility, constructorChain );
|
ASTMethod method = new ASTMethod( symbol, parameters, returnType, exception, startOffset, nameOffset, ownerTemplate, references, isConstructor, isDestructor, isPureVirtual, visibility, constructorChain );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1642,4 +1650,36 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
}
|
}
|
||||||
return astAlias;
|
return astAlias;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createNewCodeBlock(org.eclipse.cdt.core.parser.ast.IASTScope)
|
||||||
|
*/
|
||||||
|
public IASTCodeScope createNewCodeBlock(IASTScope scope) {
|
||||||
|
IContainerSymbol symbol = scopeToSymbol( scope );
|
||||||
|
|
||||||
|
IContainerSymbol newScope = pst.newContainerSymbol("");
|
||||||
|
newScope.setContainingSymbol(symbol);
|
||||||
|
|
||||||
|
return new ASTCodeScope( newScope );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#queryIsTypeName(org.eclipse.cdt.core.parser.ITokenDuple)
|
||||||
|
*/
|
||||||
|
public boolean queryIsTypeName(IASTScope scope, ITokenDuple nameInQuestion) {
|
||||||
|
ISymbol lookupSymbol = null;
|
||||||
|
try {
|
||||||
|
lookupSymbol =
|
||||||
|
lookupQualifiedName(
|
||||||
|
scopeToSymbol(scope),
|
||||||
|
nameInQuestion,
|
||||||
|
new ArrayList(),
|
||||||
|
false);
|
||||||
|
} catch (ASTSemanticException e) {
|
||||||
|
// won't get thrown
|
||||||
|
}
|
||||||
|
if( lookupSymbol == null ) return false;
|
||||||
|
if( lookupSymbol.isType( TypeInfo.t_type, TypeInfo.t_enumeration ) ) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.core.parser.ast.quick;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
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.ast.ASTAccessVisibility;
|
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||||
|
@ -22,6 +21,7 @@ import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTConstructorMemberInitializer;
|
import org.eclipse.cdt.core.parser.ast.IASTConstructorMemberInitializer;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
||||||
|
@ -276,4 +276,18 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
|
||||||
{
|
{
|
||||||
return new ASTNamespaceAlias( scope, identifier, alias.toString(), startingOffset, nameOffset, endOffset );
|
return new ASTNamespaceAlias( scope, identifier, alias.toString(), startingOffset, nameOffset, endOffset );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createNewCodeBlock(org.eclipse.cdt.core.parser.ast.IASTScope)
|
||||||
|
*/
|
||||||
|
public IASTCodeScope createNewCodeBlock(IASTScope scope) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#queryIsTypeName(org.eclipse.cdt.core.parser.ITokenDuple)
|
||||||
|
*/
|
||||||
|
public boolean queryIsTypeName(IASTScope scope, ITokenDuple nameInQuestion) {
|
||||||
|
return true; // we have no information to say that it is not
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -453,4 +453,20 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
|
||||||
System.out.println("(" + Thread.currentThread() + ") " + log);
|
System.out.println("(" + Thread.currentThread() + ") " + log);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterCodeBlock(org.eclipse.cdt.core.parser.ast.IASTScope)
|
||||||
|
*/
|
||||||
|
public void enterCodeBlock(IASTScope scope) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitCodeBlock(org.eclipse.cdt.core.parser.ast.IASTScope)
|
||||||
|
*/
|
||||||
|
public void exitCodeBlock(IASTScope scope) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
2003-09-04 John Camelon
|
||||||
|
First pass of parsing function bodies with X-Reference information.
|
||||||
|
Updated IASTFactory/ISourceElementRequestor to include IASTCodeScope
|
||||||
|
constructs, clients should keep this in mind and update their implementations.
|
||||||
|
|
||||||
2003-09-04 Alain Magloire
|
2003-09-04 Alain Magloire
|
||||||
|
|
||||||
Faulty logic when checking the build console preferences.
|
Faulty logic when checking the build console preferences.
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTMethodReference;
|
import org.eclipse.cdt.core.parser.ast.IASTMethodReference;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
|
||||||
|
@ -292,4 +293,20 @@ public class SourceElementRequestorAdapter implements ISourceElementRequestor {
|
||||||
public void exitTemplateSpecialization(IASTTemplateSpecialization specialization) {
|
public void exitTemplateSpecialization(IASTTemplateSpecialization specialization) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterCodeBlock(org.eclipse.cdt.core.parser.ast.IASTScope)
|
||||||
|
*/
|
||||||
|
public void enterCodeBlock(IASTScope scope) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitCodeBlock(org.eclipse.cdt.core.parser.ast.IASTScope)
|
||||||
|
*/
|
||||||
|
public void exitCodeBlock(IASTScope scope) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue