From 22eb93f0e4b6acccdca274b53db680aee2be910d Mon Sep 17 00:00:00 2001 From: John Camelon Date: Fri, 13 Jun 2003 20:03:15 +0000 Subject: [PATCH] 2003-06-13 John Camelon Added Class/Base infrastructure to public interfaces & requestor callback. Moved many internal interfaces to external packages. Organized imports. --- .../cdt/internal/core/dom/ClassSpecifier.java | 8 +- .../cdt/internal/core/dom/DOMBuilder.java | 138 +-- .../cdt/internal/core/dom/DeclSpecifier.java | 54 +- .../core/dom/EnumerationSpecifier.java | 8 +- .../cdt/internal/core/dom/Expression.java | 4 +- .../core/dom/LineNumberedDOMBuilder.java | 166 --- .../eclipse/cdt/internal/core/dom/Name.java | 7 +- .../core/dom/TemplateDeclaration.java | 13 +- .../cdt/internal/core/dom/UsingDirective.java | 1 - core/org.eclipse.cdt.core/parser/ChangeLog | 5 + .../core/parser/IMacroDescriptor.java | 2 +- .../core/parser/IParserCallback.java | 49 +- .../org/eclipse/cdt/core/parser/IScanner.java | 6 +- .../core/parser/IScannerContext.java | 2 +- .../core/parser/ISourceElementRequestor.java | 10 +- .../org/eclipse/cdt/core/parser/IToken.java | 302 +++++ .../core/parser/ScannerException.java | 2 +- .../core/parser/ast/IASTClassSpecifier.java | 4 +- .../ast/IASTElaboratedTypeSpecifier.java | 19 + .../parser/ast/IASTEnumerationSpecifier.java | 19 + .../cdt/core/parser/ast/IASTFactory.java | 14 + ...mSpecifier.java => IASTTypeSpecifier.java} | 2 +- .../internal/core/parser/BranchTracker.java | 2 + .../internal/core/parser/ContextStack.java | 2 + .../core/parser/ExpressionEvaluator.java | 76 +- .../internal/core/parser/MacroDescriptor.java | 5 +- .../cdt/internal/core/parser/Name.java | 22 +- .../parser/NullSourceElementRequestor.java | 89 +- .../cdt/internal/core/parser/Parser.java | 1095 +++++++++-------- .../internal/core/parser/ParserException.java | 4 +- .../cdt/internal/core/parser/Scanner.java | 390 +++--- .../internal/core/parser/ScannerContext.java | 1 + .../cdt/internal/core/parser/Token.java | 219 +--- .../cdt/internal/core/parser/TokenDuple.java | 22 +- .../parser/ast/full/ASTClassSpecifier.java | 9 + .../parser/ast/full/FullParseASTFactory.java | 31 +- .../parser/ast/quick/ASTBaseSpecifier.java | 57 + .../parser/ast/quick/ASTClassSpecifier.java | 160 +++ .../parser/ast/quick/IASTQClassSpecifier.java | 23 + .../ast/quick/QuickParseASTFactory.java | 24 + 40 files changed, 1744 insertions(+), 1322 deletions(-) delete mode 100644 core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/LineNumberedDOMBuilder.java rename core/org.eclipse.cdt.core/parser/org/eclipse/cdt/{internal => }/core/parser/IMacroDescriptor.java (91%) rename core/org.eclipse.cdt.core/parser/org/eclipse/cdt/{internal => }/core/parser/IParserCallback.java (75%) rename core/org.eclipse.cdt.core/parser/org/eclipse/cdt/{internal => }/core/parser/IScannerContext.java (95%) create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java rename core/org.eclipse.cdt.core/parser/org/eclipse/cdt/{internal => }/core/parser/ScannerException.java (94%) create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTElaboratedTypeSpecifier.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTEnumerationSpecifier.java rename core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/{IASTEnumSpecifier.java => IASTTypeSpecifier.java} (94%) create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTBaseSpecifier.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTClassSpecifier.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/IASTQClassSpecifier.java diff --git a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/ClassSpecifier.java b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/ClassSpecifier.java index 36444eb5f4d..943ed6adc28 100644 --- a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/ClassSpecifier.java +++ b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/ClassSpecifier.java @@ -4,8 +4,8 @@ import java.util.Collections; import java.util.LinkedList; import java.util.List; +import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.internal.core.parser.Name; -import org.eclipse.cdt.internal.core.parser.Token; public class ClassSpecifier extends TypeSpecifier implements IScope, IOffsetable, IAccessable { @@ -13,7 +13,7 @@ public class ClassSpecifier extends TypeSpecifier implements IScope, IOffsetable private ClassKey key = new ClassKey(); private int startingOffset = 0, totalLength = 0; private int topLine = 0, bottomLine = 0; - private Token classKeyToken = null; + private IToken classKeyToken = null; public int getClassKey() { return key.getClassKey(); } @@ -88,7 +88,7 @@ public class ClassSpecifier extends TypeSpecifier implements IScope, IOffsetable * Returns the classKeyToken. * @return Token */ - public Token getClassKeyToken() { + public IToken getClassKeyToken() { return classKeyToken; } @@ -96,7 +96,7 @@ public class ClassSpecifier extends TypeSpecifier implements IScope, IOffsetable * Sets the classKeyToken. * @param classKeyToken The classKeyToken to set */ - public void setClassKeyToken(Token classKeyToken) { + public void setClassKeyToken(IToken classKeyToken) { this.classKeyToken = classKeyToken; } diff --git a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java index 1cec624ab21..cdfc7399a0b 100644 --- a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java +++ b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java @@ -2,14 +2,15 @@ package org.eclipse.cdt.internal.core.dom; import org.eclipse.cdt.core.parser.IParser; +import org.eclipse.cdt.core.parser.IParserCallback; import org.eclipse.cdt.core.parser.IProblem; import org.eclipse.cdt.core.parser.ISourceElementRequestor; +import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.core.parser.ast.IASTASMDefinition; import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier; import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit; import org.eclipse.cdt.core.parser.ast.IASTConstructor; -import org.eclipse.cdt.core.parser.ast.IASTEnumSpecifier; -import org.eclipse.cdt.core.parser.ast.IASTEnumerator; +import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier; import org.eclipse.cdt.core.parser.ast.IASTField; import org.eclipse.cdt.core.parser.ast.IASTFunction; import org.eclipse.cdt.core.parser.ast.IASTInclusion; @@ -24,9 +25,7 @@ import org.eclipse.cdt.core.parser.ast.IASTTypedef; import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration; import org.eclipse.cdt.core.parser.ast.IASTUsingDirective; import org.eclipse.cdt.core.parser.ast.IASTVariable; -import org.eclipse.cdt.internal.core.parser.IParserCallback; import org.eclipse.cdt.internal.core.parser.Name; -import org.eclipse.cdt.internal.core.parser.Token; /** * This is the parser callback that creates objects in the DOM. @@ -59,21 +58,21 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor /** * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#classBegin(java.lang.String, org.eclipse.cdt.internal.core.newparser.Token) */ - public Object classSpecifierBegin(Object container, Token classKey) { + public Object classSpecifierBegin(Object container, IToken classKey) { TypeSpecifier.IOwner decl = (TypeSpecifier.IOwner)container; int kind = ClassKey.t_struct; int visibility = AccessSpecifier.v_public; switch (classKey.getType()) { - case Token.t_class: + case IToken.t_class: kind = ClassKey.t_class; visibility = AccessSpecifier.v_private; break; - case Token.t_struct: + case IToken.t_struct: kind = ClassKey.t_struct; break; - case Token.t_union: + case IToken.t_union: kind = ClassKey.t_union; break; } @@ -98,7 +97,7 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor /** * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#classEnd() */ - public void classSpecifierEnd(Object classSpecifier, Token closingBrace) { + public void classSpecifierEnd(Object classSpecifier, IToken closingBrace) { ClassSpecifier c = (ClassSpecifier)classSpecifier; c.setTotalLength( closingBrace.getOffset() + closingBrace.getLength() - c.getStartingOffset() ); domScopes.pop(); @@ -144,7 +143,7 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor /** * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#declSpecifier(org.eclipse.cdt.internal.core.newparser.Token) */ - public void simpleDeclSpecifier(Object Container, Token specifier) { + public void simpleDeclSpecifier(Object Container, IToken specifier) { DeclSpecifier.IContainer decl = (DeclSpecifier.IContainer)Container; DeclSpecifier declSpec = decl.getDeclSpecifier(); declSpec.setType( specifier ); @@ -155,7 +154,7 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor /** * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#expressionOperator(org.eclipse.cdt.internal.core.newparser.Token) */ - public void expressionOperator(Object expression, Token operator){ + public void expressionOperator(Object expression, IToken operator){ Expression e = (Expression)expression; e.add( operator ); } @@ -163,7 +162,7 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor /** * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#expressionTerminal(org.eclipse.cdt.internal.core.newparser.Token) */ - public void expressionTerminal(Object expression, Token terminal){ + public void expressionTerminal(Object expression, IToken terminal){ Expression e = (Expression)expression; e.add( terminal ); } @@ -216,7 +215,7 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor /** * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#simpleDeclarationBegin(org.eclipse.cdt.internal.core.newparser.Token) */ - public Object simpleDeclarationBegin(Object container, Token firstToken) { + public Object simpleDeclarationBegin(Object container, IToken firstToken) { SimpleDeclaration decl = new SimpleDeclaration( getCurrentDOMScope() ); if( getCurrentDOMScope() instanceof IAccessable ) decl.setAccessSpecifier(new AccessSpecifier( ((IAccessable)getCurrentDOMScope()).getVisibility() )); @@ -227,7 +226,7 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor /** * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#simpleDeclarationEnd(org.eclipse.cdt.internal.core.newparser.Token) */ - public void simpleDeclarationEnd(Object declaration, Token lastToken) { + public void simpleDeclarationEnd(Object declaration, IToken lastToken) { SimpleDeclaration decl = (SimpleDeclaration)declaration; IOffsetable offsetable = (IOffsetable)decl; offsetable.setTotalLength( lastToken.getOffset() + lastToken.getLength() - offsetable.getStartingOffset()); @@ -252,14 +251,14 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor /** * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#nameBegin(org.eclipse.cdt.internal.core.newparser.Token) */ - public void nameBegin(Token firstToken) { + public void nameBegin(IToken firstToken) { currName = new Name(firstToken); } /** * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#nameEnd(org.eclipse.cdt.internal.core.newparser.Token) */ - public void nameEnd(Token lastToken) { + public void nameEnd(IToken lastToken) { currName.setEnd(lastToken); } @@ -281,18 +280,18 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor bs.setVirtual( virtual ); } - public void baseSpecifierVisibility( Object baseSpecifier, Token visibility ) + public void baseSpecifierVisibility( Object baseSpecifier, IToken visibility ) { int access = AccessSpecifier.v_public; - switch( visibility.type ) + switch( visibility.getType() ) { - case Token.t_public: + case IToken.t_public: access = AccessSpecifier.v_public; break; - case Token.t_protected: + case IToken.t_protected: access = AccessSpecifier.v_protected; break; - case Token.t_private: + case IToken.t_private: access = AccessSpecifier.v_private; break; default: @@ -353,20 +352,20 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor /** * @see org.eclipse.cdt.internal.core.parser.IParserCallback#elaboratedTypeSpecifierBegin(java.lang.Object) */ - public Object elaboratedTypeSpecifierBegin(Object container, Token classKey) { + public Object elaboratedTypeSpecifierBegin(Object container, IToken classKey) { int kind = ClassKey.t_struct; switch (classKey.getType()) { - case Token.t_class: + case IToken.t_class: kind = ClassKey.t_class; break; - case Token.t_struct: + case IToken.t_struct: kind = ClassKey.t_struct; break; - case Token.t_union: + case IToken.t_union: kind = ClassKey.t_union; break; - case Token.t_enum: + case IToken.t_enum: kind = ClassKey.t_enum; break; } @@ -409,17 +408,17 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#classMemberVisibility(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) */ - public void classMemberVisibility(Object classSpecifier, Token visibility) { + public void classMemberVisibility(Object classSpecifier, IToken visibility) { ClassSpecifier spec = (ClassSpecifier)classSpecifier; switch( visibility.getType() ) { - case Token.t_public: + case IToken.t_public: spec.setVisibility( AccessSpecifier.v_public ); break; - case Token.t_protected: + case IToken.t_protected: spec.setVisibility( AccessSpecifier.v_protected ); break; - case Token.t_private: + case IToken.t_private: spec.setVisibility( AccessSpecifier.v_private ); break; } @@ -453,14 +452,14 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#pointerOperatorType(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) */ - public void pointerOperatorType(Object ptrOperator, Token type) { + public void pointerOperatorType(Object ptrOperator, IToken type) { PointerOperator ptrOp = (PointerOperator)ptrOperator; switch( type.getType() ) { - case Token.tSTAR: + case IToken.tSTAR: ptrOp.setType( PointerOperator.t_pointer ); break; - case Token.tAMPER: + case IToken.tAMPER: ptrOp.setType( PointerOperator.t_reference ); break; default: @@ -471,14 +470,14 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#pointerOperatorCVModifier(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) */ - public void pointerOperatorCVModifier(Object ptrOperator, Token modifier) { + public void pointerOperatorCVModifier(Object ptrOperator, IToken modifier) { PointerOperator ptrOp = (PointerOperator)ptrOperator; switch( modifier.getType() ) { - case Token.t_const: + case IToken.t_const: ptrOp.setConst(true); break; - case Token.t_volatile: + case IToken.t_volatile: ptrOp.setVolatile( true ); break; default: @@ -489,14 +488,14 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#declaratorCVModifier(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) */ - public void declaratorCVModifier(Object declarator, Token modifier) { + public void declaratorCVModifier(Object declarator, IToken modifier) { Declarator decl = (Declarator)declarator; switch( modifier.getType() ) { - case Token.t_const: + case IToken.t_const: decl.setConst(true); break; - case Token.t_volatile: + case IToken.t_volatile: decl.setVolatile( true ); break; default: @@ -544,7 +543,7 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationBegin(java.lang.Object) */ - public Object namespaceDefinitionBegin(Object container, Token namespace) { + public Object namespaceDefinitionBegin(Object container, IToken namespace) { // IScope ownerScope = (IScope)container; // NamespaceDefinition namespaceDef = new NamespaceDefinition(ownerScope); // namespaceDef.setStartToken(namespace); @@ -570,7 +569,7 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationEnd(java.lang.Object) */ - public void namespaceDefinitionEnd(Object namespace, Token closingBrace) { + public void namespaceDefinitionEnd(Object namespace, IToken closingBrace) { // NamespaceDefinition ns = (NamespaceDefinition)namespace; // ns.setTotalLength( closingBrace.getOffset() + closingBrace.getLength() - ns.getStartingOffset() ); // ns.getOwnerScope().addDeclaration(ns); @@ -662,7 +661,7 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierBegin(java.lang.Object) */ - public Object enumSpecifierBegin(Object container, Token enumKey) { + public Object enumSpecifierBegin(Object container, IToken enumKey) { TypeSpecifier.IOwner decl = (TypeSpecifier.IOwner)container; EnumerationSpecifier es = new EnumerationSpecifier( decl ); es.setStartToken(enumKey); @@ -690,7 +689,7 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierEnd(java.lang.Object) */ - public void enumSpecifierEnd(Object enumSpec, Token closingBrace) { + public void enumSpecifierEnd(Object enumSpec, IToken closingBrace) { IOffsetable offsetable = (IOffsetable)enumSpec; offsetable.setTotalLength( closingBrace.getOffset() + closingBrace.getLength() - offsetable.getStartingOffset()); } @@ -717,7 +716,7 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionEnd(java.lang.Object) */ - public void enumeratorEnd(Object enumDefn, Token lastToken) { + public void enumeratorEnd(Object enumDefn, IToken lastToken) { IOffsetable offsetable = (IOffsetable)enumDefn; offsetable.setTotalLength( lastToken.getOffset() + lastToken.getLength() - offsetable.getStartingOffset()); } @@ -838,7 +837,7 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateDeclarationBegin(java.lang.Object, boolean) */ - public Object templateDeclarationBegin(Object container, Token exported) { + public Object templateDeclarationBegin(Object container, IToken exported) { TemplateDeclaration d = new TemplateDeclaration( (IScope)getCurrentDOMScope(), exported ); if( getCurrentDOMScope() instanceof IAccessable ) d.setVisibility( ((IAccessable)container).getVisibility() ); @@ -857,7 +856,7 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateDeclarationEnd(java.lang.Object) */ - public void templateDeclarationEnd(Object templateDecl, Token lastToken) { + public void templateDeclarationEnd(Object templateDecl, IToken lastToken) { TemplateDeclaration decl = (TemplateDeclaration)domScopes.pop(); decl.setLastToken(lastToken); decl.getOwnerScope().addDeclaration(decl); @@ -867,18 +866,18 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateTypeParameterBegin(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) */ - public Object templateTypeParameterBegin(Object templDecl, Token kind) { + public Object templateTypeParameterBegin(Object templDecl, IToken kind) { TemplateParameterList list = (TemplateParameterList)templDecl; int k; switch( kind.getType() ) { - case Token.t_class: + case IToken.t_class: k = TemplateParameter.k_class; break; - case Token.t_typename: + case IToken.t_typename: k= TemplateParameter.k_typename; break; - case Token.t_template: + case IToken.t_template: k= TemplateParameter.k_template; break; default: @@ -1050,30 +1049,6 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor // TODO Auto-generated method stub } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterEnumSpecifier(org.eclipse.cdt.core.parser.ast.IASTEnumSpecifier) - */ - public void enterEnumSpecifier(IASTEnumSpecifier enumSpec) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptEnumerator(org.eclipse.cdt.core.parser.ast.IASTEnumerator) - */ - public void acceptEnumerator(IASTEnumerator enumerator) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitEnumSpecifier(org.eclipse.cdt.core.parser.ast.IASTEnumSpecifier) - */ - public void exitEnumSpecifier(IASTEnumSpecifier enumSpec) { - // TODO Auto-generated method stub - - } - /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterFunctionBody(org.eclipse.cdt.core.parser.ast.IASTFunction) */ @@ -1272,4 +1247,19 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor { return domScopes.peek(); } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptEnumerationSpecifier(org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier) + */ + public void acceptEnumerationSpecifier(IASTEnumerationSpecifier enumeration) { + // TODO Auto-generated method stub + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptClassReference(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier, int) + */ + public void acceptClassReference(IASTClassSpecifier classSpecifier, int referenceOffset) { + // TODO Auto-generated method stub + + } } \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DeclSpecifier.java b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DeclSpecifier.java index 7c607d7236d..622243a1431 100644 --- a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DeclSpecifier.java +++ b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DeclSpecifier.java @@ -2,8 +2,8 @@ package org.eclipse.cdt.internal.core.dom; import java.util.List; +import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.internal.core.parser.Name; -import org.eclipse.cdt.internal.core.parser.Token; /** * @author jcamelon @@ -168,81 +168,81 @@ public class DeclSpecifier { public static final int t_double = 6; public static final int t_void = 7; - public void setType(Token token) { + public void setType(IToken token) { switch (token.getType()) { - case Token.t_typename: + case IToken.t_typename: setTypename(true); break; - case Token.t_auto : + case IToken.t_auto : setAuto(true); break; - case Token.t_register : + case IToken.t_register : setRegister(true); break; - case Token.t_static : + case IToken.t_static : setStatic(true); break; - case Token.t_extern : + case IToken.t_extern : setExtern(true); break; - case Token.t_mutable : + case IToken.t_mutable : setMutable(true); break; - case Token.t_inline : + case IToken.t_inline : setInline(true); break; - case Token.t_virtual : + case IToken.t_virtual : setVirtual(true); break; - case Token.t_explicit : + case IToken.t_explicit : setExplicit(true); break; - case Token.t_typedef : + case IToken.t_typedef : setTypedef(true); break; - case Token.t_friend : + case IToken.t_friend : setFriend(true); break; - case Token.t_const : + case IToken.t_const : setConst(true); break; - case Token.t_volatile : + case IToken.t_volatile : setVolatile(true); break; - case Token.t_char : + case IToken.t_char : setType(DeclSpecifier.t_char); break; - case Token.t_wchar_t : + case IToken.t_wchar_t : setType(DeclSpecifier.t_wchar_t); break; - case Token.t_bool : + case IToken.t_bool : setType(DeclSpecifier.t_bool); break; - case Token.t_short : + case IToken.t_short : setShort(true); break; - case Token.t_int : + case IToken.t_int : setType(DeclSpecifier.t_int); break; - case Token.t_long : + case IToken.t_long : setLong(true); break; - case Token.t_signed : + case IToken.t_signed : setUnsigned(false); break; - case Token.t_unsigned : + case IToken.t_unsigned : setUnsigned(true); break; - case Token.t_float : + case IToken.t_float : setType(DeclSpecifier.t_float); break; - case Token.t_double : + case IToken.t_double : setType(DeclSpecifier.t_double); break; - case Token.t_void : + case IToken.t_void : setType(DeclSpecifier.t_void); break; - case Token.tIDENTIFIER : + case IToken.tIDENTIFIER : setType(DeclSpecifier.t_type); break; } diff --git a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/EnumerationSpecifier.java b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/EnumerationSpecifier.java index 909eb2acc7b..5923a0f90c4 100644 --- a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/EnumerationSpecifier.java +++ b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/EnumerationSpecifier.java @@ -16,8 +16,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.internal.core.parser.Name; -import org.eclipse.cdt.internal.core.parser.Token; /** * @author jcamelon @@ -32,7 +32,7 @@ public class EnumerationSpecifier extends TypeSpecifier implements IOffsetable { private Name name = null; private List enumeratorDefinitions = new ArrayList(); private int startingOffset = 0, totalLength = 0; - private Token startToken = null; + private IToken startToken = null; public void addEnumeratorDefinition( EnumeratorDefinition def ) { @@ -94,7 +94,7 @@ public class EnumerationSpecifier extends TypeSpecifier implements IOffsetable { * Returns the startToken. * @return Token */ - public Token getStartToken() { + public IToken getStartToken() { return startToken; } @@ -102,7 +102,7 @@ public class EnumerationSpecifier extends TypeSpecifier implements IOffsetable { * Sets the startToken. * @param startToken The startToken to set */ - public void setStartToken(Token startToken) { + public void setStartToken(IToken startToken) { this.startToken = startToken; } diff --git a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/Expression.java b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/Expression.java index 95612799c64..11aec1d6319 100644 --- a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/Expression.java +++ b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/Expression.java @@ -15,8 +15,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.internal.core.parser.Name; -import org.eclipse.cdt.internal.core.parser.Token; /** * @author jcamelon @@ -26,7 +26,7 @@ public class Expression { private List tokens = new ArrayList(); - public void add( Token t ) + public void add( IToken t ) { tokens.add( t ); } diff --git a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/LineNumberedDOMBuilder.java b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/LineNumberedDOMBuilder.java deleted file mode 100644 index bd7692e7c4b..00000000000 --- a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/LineNumberedDOMBuilder.java +++ /dev/null @@ -1,166 +0,0 @@ -/********************************************************************** - * Copyright (c) 2002,2003 Rational Software Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v0.5 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v05.html - * - * Contributors: - * IBM Rational Software - Initial API and implementation -***********************************************************************/ -package org.eclipse.cdt.internal.core.dom; - -import org.eclipse.cdt.internal.core.parser.Token; - -/** - * @author jcamelon - */ -public class LineNumberedDOMBuilder extends DOMBuilder { - - protected LineNumberedDOMBuilder() - { - } - - protected void setLineNumber( IOffsetable element, int offset, boolean topLine ) - { - try - { - if( topLine ) - element.setTopLine( parser.getLineNumberForOffset( offset )); - else - element.setBottomLine( parser.getLineNumberForOffset( offset )); - } - catch( NoSuchMethodException nsm ) - { - System.out.println( "Incorrect parser setup to get line numbers"); - } - } - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.parser.IParserCallback#classSpecifierBegin(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) - */ - public Object classSpecifierBegin(Object container, Token classKey) { - Object returnValue = super.classSpecifierBegin(container, classKey); - setLineNumber( (IOffsetable)returnValue, classKey.getOffset(), true ); - return returnValue; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.parser.IParserCallback#classSpecifierEnd(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) - */ - public void classSpecifierEnd(Object classSpecifier, Token closingBrace) { - super.classSpecifierEnd(classSpecifier, closingBrace); - setLineNumber( (IOffsetable)classSpecifier, closingBrace.getOffset() + closingBrace.getLength(), false ); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumeratorEnd(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) - */ - public void enumeratorEnd(Object enumDefn, Token lastToken) { - super.enumeratorEnd(enumDefn, lastToken); - setLineNumber( (IOffsetable)enumDefn, lastToken.getOffset() + lastToken.getLength(), false ); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumeratorId(java.lang.Object) - */ - public void enumeratorId(Object enumDefn) { - super.enumeratorId(enumDefn); - setLineNumber( (IOffsetable)enumDefn, currName.getStartOffset(), true ); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierBegin(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) - */ - public Object enumSpecifierBegin(Object container, Token enumKey) { - Object returnValue = super.enumSpecifierBegin(container, enumKey); - setLineNumber( (IOffsetable)returnValue, enumKey.getOffset(), true); - return returnValue; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierEnd(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) - */ - public void enumSpecifierEnd(Object enumSpec, Token closingBrace) { - super.enumSpecifierEnd(enumSpec, closingBrace); - setLineNumber( (IOffsetable)enumSpec, closingBrace.getOffset() + closingBrace.getLength(), false); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.parser.IParserCallback#inclusionBegin(java.lang.String, int, int) - */ - public Object inclusionBegin( - String includeFile, - int offset, - int inclusionBeginOffset, boolean local) { - Object inclusion = super.inclusionBegin(includeFile, offset, inclusionBeginOffset, local); - setLineNumber( (IOffsetable)inclusion, inclusionBeginOffset, true ); - setLineNumber( (IOffsetable)inclusion, offset + includeFile.length() + 1, false ); - return inclusion; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.parser.IParserCallback#macro(java.lang.String, int, int, int) - */ - public Object macro( - String macroName, - int offset, - int macroBeginOffset, - int macroEndOffset) { - Object macro = super.macro(macroName, offset, macroBeginOffset, macroEndOffset); - setLineNumber( (IOffsetable) macro, macroBeginOffset, true ); - setLineNumber( (IOffsetable) macro, macroEndOffset, false ); - return macro; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDefinitionBegin(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) - */ - public Object namespaceDefinitionBegin(Object container, Token namespace) { - Object namespaceDef = super.namespaceDefinitionBegin(container, namespace); - setLineNumber( (IOffsetable)namespaceDef, namespace.getOffset(), true); - return namespaceDef; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDefinitionEnd(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) - */ - public void namespaceDefinitionEnd(Object namespace, Token closingBrace) { - super.namespaceDefinitionEnd(namespace, closingBrace); - setLineNumber( (IOffsetable)namespace, closingBrace.getOffset() + closingBrace.getLength(), false); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.parser.IParserCallback#simpleDeclarationBegin(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) - */ - public Object simpleDeclarationBegin(Object container, Token firstToken) { - Object retval = super.simpleDeclarationBegin(container, firstToken); - setLineNumber( (IOffsetable)retval, firstToken.getOffset(), true ); - return retval; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.parser.IParserCallback#simpleDeclarationEnd(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) - */ - public void simpleDeclarationEnd(Object declaration, Token lastToken) { - super.simpleDeclarationEnd(declaration, lastToken); - setLineNumber( (IOffsetable)declaration, lastToken.getOffset() + lastToken.getLength(), false ); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateDeclarationBegin(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) - */ - public Object templateDeclarationBegin(Object container, Token exported) { - Object template = super.templateDeclarationBegin(container, exported); - setLineNumber( (IOffsetable)template, exported.getOffset(), true ); - return template; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateDeclarationEnd(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) - */ - public void templateDeclarationEnd(Object templateDecl, Token lastToken) { - super.templateDeclarationEnd(templateDecl, lastToken); - setLineNumber( (IOffsetable)templateDecl, lastToken.getOffset() + lastToken.getLength(), false); - } - -} diff --git a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/Name.java b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/Name.java index dafaf932a1d..ee2d413d523 100644 --- a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/Name.java +++ b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/Name.java @@ -1,5 +1,6 @@ package org.eclipse.cdt.internal.core.dom; +import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.internal.core.parser.Token; @@ -37,14 +38,14 @@ public class Name { Token t = nameStart; StringBuffer buffer = new StringBuffer(); buffer.append( t.getImage() ); - if( t.getType() == Token.t_operator ) + if( t.getType() == IToken.t_operator ) buffer.append( " " ); while (t != nameEnd) { t = t.getNext(); buffer.append( t.getImage() ); - if (t.getType() == Token.t_operator) buffer.append( " " ); + if (t.getType() == IToken.t_operator) buffer.append( " " ); } return buffer.toString(); @@ -57,7 +58,7 @@ public class Name { /** * @return */ - public Token getNameStart() { + public IToken getNameStart() { return nameStart; } diff --git a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/TemplateDeclaration.java b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/TemplateDeclaration.java index 8af16a4fe48..b03eb12e77a 100644 --- a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/TemplateDeclaration.java +++ b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/TemplateDeclaration.java @@ -16,6 +16,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.internal.core.parser.Token; /** @@ -26,15 +27,15 @@ public class TemplateDeclaration extends Declaration implements IScope, IAccessa private final boolean exported; private AccessSpecifier visibility = null; - private Token firstToken, lastToken; + private IToken firstToken, lastToken; private List declarations = new ArrayList(); private TemplateParameterList templateParms = null; - public TemplateDeclaration( IScope ownerScope, Token exported ) + public TemplateDeclaration( IScope ownerScope, IToken exported ) { super( ownerScope ); this.firstToken = exported; - this.exported = exported.getType() == Token.t_export ? true : false; + this.exported = exported.getType() == IToken.t_export ? true : false; } /* (non-Javadoc) @@ -75,14 +76,14 @@ public class TemplateDeclaration extends Declaration implements IScope, IAccessa /** * @return */ - public Token getFirstToken() { + public IToken getFirstToken() { return firstToken; } /** * @return */ - public Token getLastToken() { + public IToken getLastToken() { return lastToken; } @@ -97,7 +98,7 @@ public class TemplateDeclaration extends Declaration implements IScope, IAccessa /** * @param token */ - public void setLastToken(Token token) { + public void setLastToken(IToken token) { lastToken = token; setTotalLength( getLastToken().getOffset() + getLastToken().getLength() - getStartingOffset() ); } diff --git a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/UsingDirective.java b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/UsingDirective.java index 3ac7b015c80..d13028e648f 100644 --- a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/UsingDirective.java +++ b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/UsingDirective.java @@ -12,7 +12,6 @@ ***********************************************************************/ package org.eclipse.cdt.internal.core.dom; -import org.eclipse.cdt.internal.core.parser.Name; /** diff --git a/core/org.eclipse.cdt.core/parser/ChangeLog b/core/org.eclipse.cdt.core/parser/ChangeLog index 19cc6b4165f..46425489693 100644 --- a/core/org.eclipse.cdt.core/parser/ChangeLog +++ b/core/org.eclipse.cdt.core/parser/ChangeLog @@ -1,3 +1,8 @@ +2003-06-13 John Camelon + Added Class/Base infrastructure to public interfaces & requestor callback. + Moved many internal interfaces to external packages. + Organized imports. + 2003-06-13 Victor Mozgin Renamed NullParserCallback into NullSourceElementRequester. NullSourceElementRequester now dummy-implements both IParserCallback and ISourceElementRequester. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/IMacroDescriptor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IMacroDescriptor.java similarity index 91% rename from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/IMacroDescriptor.java rename to core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IMacroDescriptor.java index 9c9fba8e3dc..447e0850d84 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/IMacroDescriptor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IMacroDescriptor.java @@ -1,4 +1,4 @@ -package org.eclipse.cdt.internal.core.parser; +package org.eclipse.cdt.core.parser; import java.util.List; /** * @author jcamelon diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/IParserCallback.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IParserCallback.java similarity index 75% rename from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/IParserCallback.java rename to core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IParserCallback.java index b4bf7ea1b90..089714733e9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/IParserCallback.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IParserCallback.java @@ -8,9 +8,8 @@ * Contributors: * Rational Software - initial implementation ******************************************************************************/ -package org.eclipse.cdt.internal.core.parser; +package org.eclipse.cdt.core.parser; -import org.eclipse.cdt.core.parser.IParser; public interface IParserCallback { @@ -23,23 +22,23 @@ public interface IParserCallback { public void inclusionEnd(Object inclusion); public Object macro(String macroName, int macroNameOffset, int macroBeginOffset, int macroEndOffset); - public Object simpleDeclarationBegin(Object Container, Token firstToken); - public void simpleDeclSpecifier(Object Container, Token specifier); + public Object simpleDeclarationBegin(Object Container, IToken firstToken); + public void simpleDeclSpecifier(Object Container, IToken specifier); public void simpleDeclSpecifierName( Object declaration ); public void simpleDeclSpecifierType( Object declaration, Object type ); - public void simpleDeclarationEnd(Object declaration, Token lastToken); + public void simpleDeclarationEnd(Object declaration, IToken lastToken); public Object parameterDeclarationBegin( Object Container ); public void parameterDeclarationEnd( Object declaration ); - public void nameBegin(Token firstToken); - public void nameEnd(Token lastToken); + public void nameBegin(IToken firstToken); + public void nameEnd(IToken lastToken); public Object declaratorBegin(Object container); public void declaratorId(Object declarator); public void declaratorAbort( Object declarator ); public void declaratorPureVirtual( Object declarator ); - public void declaratorCVModifier( Object declarator, Token modifier ); + public void declaratorCVModifier( Object declarator, IToken modifier ); public void declaratorThrowsException( Object declarator ); public void declaratorThrowExceptionName( Object declarator ); public void declaratorEnd(Object declarator); @@ -48,9 +47,9 @@ public interface IParserCallback { public void arrayDeclaratorEnd( Object arrayQualifier ); public Object pointerOperatorBegin( Object container ); - public void pointerOperatorType( Object ptrOperator, Token type ); + public void pointerOperatorType( Object ptrOperator, IToken type ); public void pointerOperatorName( Object ptrOperator ); - public void pointerOperatorCVModifier( Object ptrOperator, Token modifier ); + public void pointerOperatorCVModifier( Object ptrOperator, IToken modifier ); public void pointerOperatorAbort( Object ptrOperator ); public void pointerOperatorEnd( Object ptrOperator ); @@ -60,33 +59,33 @@ public interface IParserCallback { public Object functionBodyBegin(Object declaration); public void functionBodyEnd(Object functionBody); - public Object classSpecifierBegin(Object container, Token classKey); + public Object classSpecifierBegin(Object container, IToken classKey); public void classSpecifierName(Object classSpecifier); public void classSpecifierAbort( Object classSpecifier ); - public void classMemberVisibility( Object classSpecifier, Token visibility ); - public void classSpecifierEnd(Object classSpecifier, Token closingBrace ); + public void classMemberVisibility( Object classSpecifier, IToken visibility ); + public void classSpecifierEnd(Object classSpecifier, IToken closingBrace ); public Object baseSpecifierBegin( Object containingClassSpec ); public void baseSpecifierName( Object baseSpecifier ); - public void baseSpecifierVisibility( Object baseSpecifier, Token visibility ); + public void baseSpecifierVisibility( Object baseSpecifier, IToken visibility ); public void baseSpecifierVirtual( Object baseSpecifier, boolean virtual ); public void baseSpecifierEnd( Object baseSpecifier ); public Object expressionBegin( Object container ); - public void expressionOperator(Object expression, Token operator); - public void expressionTerminal(Object expression, Token terminal); + public void expressionOperator(Object expression, IToken operator); + public void expressionTerminal(Object expression, IToken terminal); public void expressionName( Object expression ); public void expressionAbort( Object expression ); public void expressionEnd(Object expression ); - public Object elaboratedTypeSpecifierBegin( Object container, Token classKey ); + public Object elaboratedTypeSpecifierBegin( Object container, IToken classKey ); public void elaboratedTypeSpecifierName( Object elab ); public void elaboratedTypeSpecifierEnd( Object elab ); - public Object namespaceDefinitionBegin( Object container, Token namespace ); + public Object namespaceDefinitionBegin( Object container, IToken namespace ); public void namespaceDefinitionId( Object namespace ); public void namespaceDefinitionAbort( Object namespace ); - public void namespaceDefinitionEnd( Object namespace, Token closingBrace ); + public void namespaceDefinitionEnd( Object namespace, IToken closingBrace ); public Object linkageSpecificationBegin( Object container, String literal ); public void linkageSpecificationEnd( Object linkageSpec ); @@ -101,14 +100,14 @@ public interface IParserCallback { public void usingDeclarationAbort( Object declaration ); public void usingDeclarationEnd( Object declaration ); - public Object enumSpecifierBegin( Object container, Token enumKey ); + public Object enumSpecifierBegin( Object container, IToken enumKey ); public void enumSpecifierId( Object enumSpec ); public void enumSpecifierAbort( Object enumSpec ); - public void enumSpecifierEnd( Object enumSpec, Token closingBrace ); + public void enumSpecifierEnd( Object enumSpec, IToken closingBrace ); public Object enumeratorBegin( Object enumSpec ); public void enumeratorId( Object enumDefn ); - public void enumeratorEnd( Object enumDefn, Token lastToken ); + public void enumeratorEnd( Object enumDefn, IToken lastToken ); public void asmDefinition( Object container, String assemblyCode ); @@ -129,14 +128,14 @@ public interface IParserCallback { public Object explicitSpecializationBegin( Object container ); public void explicitSpecializationEnd( Object instantiation ); - public Object templateDeclarationBegin( Object container, Token firstToken ); + public Object templateDeclarationBegin( Object container, IToken firstToken ); public void templateDeclarationAbort( Object templateDecl ); - public void templateDeclarationEnd( Object templateDecl, Token lastToken ); + public void templateDeclarationEnd( Object templateDecl, IToken lastToken ); public Object templateParameterListBegin( Object declaration ); public void templateParameterListEnd( Object parameterList ); - public Object templateTypeParameterBegin( Object templDecl, Token kind ); + public Object templateTypeParameterBegin( Object templDecl, IToken kind ); public void templateTypeParameterName( Object typeParm ); public void templateTypeParameterAbort( Object typeParm ); public void templateTypeParameterInitialTypeId( Object typeParm ); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScanner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScanner.java index abb56ac8466..aa4b268cda8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScanner.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScanner.java @@ -4,11 +4,7 @@ import java.io.Reader; import java.util.List; import org.eclipse.cdt.core.parser.ast.IASTFactory; -import org.eclipse.cdt.internal.core.parser.IMacroDescriptor; -import org.eclipse.cdt.internal.core.parser.IParserCallback; import org.eclipse.cdt.internal.core.parser.Parser; -import org.eclipse.cdt.internal.core.parser.ScannerException; -import org.eclipse.cdt.internal.core.parser.Token; /** * @author jcamelon @@ -29,7 +25,7 @@ public interface IScanner { public void addIncludePath(String includePath); public void overwriteIncludePath( List newIncludePaths ); - public Token nextToken() throws ScannerException, Parser.EndOfFile; + public IToken nextToken() throws ScannerException, Parser.EndOfFile; public int getLineNumberForOffset(int offset) throws NoSuchMethodException; public void setCppNature( boolean value ); public void mapLineNumbers( boolean value ); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/IScannerContext.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScannerContext.java similarity index 95% rename from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/IScannerContext.java rename to core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScannerContext.java index 7be02496d8e..cf9ea77edc0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/IScannerContext.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScannerContext.java @@ -1,4 +1,4 @@ -package org.eclipse.cdt.internal.core.parser; +package org.eclipse.cdt.core.parser; import java.io.IOException; import java.io.Reader; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ISourceElementRequestor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ISourceElementRequestor.java index 4000a8e454e..fcbdb604c39 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ISourceElementRequestor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ISourceElementRequestor.java @@ -14,8 +14,7 @@ import org.eclipse.cdt.core.parser.ast.IASTASMDefinition; import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier; import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit; import org.eclipse.cdt.core.parser.ast.IASTConstructor; -import org.eclipse.cdt.core.parser.ast.IASTEnumSpecifier; -import org.eclipse.cdt.core.parser.ast.IASTEnumerator; +import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier; import org.eclipse.cdt.core.parser.ast.IASTField; import org.eclipse.cdt.core.parser.ast.IASTFunction; import org.eclipse.cdt.core.parser.ast.IASTInclusion; @@ -46,10 +45,7 @@ public interface ISourceElementRequestor { public void acceptUsingDeclaration( IASTUsingDeclaration usageDeclaration ); public void acceptASMDefinition( IASTASMDefinition asmDefinition ); public void acceptTypedef( IASTTypedef typedef ); - - public void enterEnumSpecifier( IASTEnumSpecifier enumSpec ); - public void acceptEnumerator( IASTEnumerator enumerator ); - public void exitEnumSpecifier( IASTEnumSpecifier enumSpec ); + public void acceptEnumerationSpecifier( IASTEnumerationSpecifier enumeration ); public void enterFunctionBody( IASTFunction function ); public void exitFunctionBody( IASTFunction function ); @@ -70,6 +66,8 @@ public interface ISourceElementRequestor { public void acceptField( IASTField field ); public void acceptConstructor( IASTConstructor constructor ); + public void acceptClassReference( IASTClassSpecifier classSpecifier, int referenceOffset ); + public void exitTemplateDeclaration( IASTTemplateDeclaration declaration ); public void exitTemplateSpecialization( IASTTemplateSpecialization specialization ); public void exitTemplateExplicitInstantiation( IASTTemplateInstantiation instantiation ); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java new file mode 100644 index 00000000000..5e0182abbdc --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java @@ -0,0 +1,302 @@ +/********************************************************************** + * Copyright (c) 2002,2003 Rational Software Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation +***********************************************************************/ +package org.eclipse.cdt.core.parser; + +import org.eclipse.cdt.internal.core.parser.Token; + +/** + * @author jcamelon + * + */ +public interface IToken { + public abstract String toString(); + public abstract int getType(); + public abstract String getImage(); + public abstract int getOffset(); + public abstract int getLength(); + public abstract int getEndOffset(); + public abstract int getDelta(IToken other); + public abstract Token getNext(); + public abstract void setNext(Token t); + public abstract boolean looksLikeExpression(); + public abstract boolean isPointer(); + public abstract boolean isOperator(); + // Token types + static public final int tIDENTIFIER = 1; + + static public final int tINTEGER = 2; + + static public final int tCOLONCOLON = 3; + + static public final int tCOLON = 4; + + static public final int tSEMI = 5; + + static public final int tCOMMA = 6; + + static public final int tQUESTION = 7; + + static public final int tLPAREN = 8; + + static public final int tRPAREN = 9; + + static public final int tLBRACKET = 10; + + static public final int tRBRACKET = 11; + + static public final int tLBRACE = 12; + + static public final int tRBRACE = 13; + + static public final int tPLUSASSIGN = 14; + + static public final int tINCR = 15; + + static public final int tPLUS = 16; + + static public final int tMINUSASSIGN = 17; + + static public final int tDECR = 18; + + static public final int tARROWSTAR = 19; + + static public final int tARROW = 20; + + static public final int tMINUS = 21; + + static public final int tSTARASSIGN = 22; + + static public final int tSTAR = 23; + + static public final int tMODASSIGN = 24; + + static public final int tMOD = 25; + + static public final int tXORASSIGN = 26; + + static public final int tXOR = 27; + + static public final int tAMPERASSIGN = 28; + + static public final int tAND = 29; + + static public final int tAMPER = 30; + + static public final int tBITORASSIGN = 31; + + static public final int tOR = 32; + + static public final int tBITOR = 33; + + static public final int tCOMPL = 34; + + static public final int tNOTEQUAL = 35; + + static public final int tNOT = 36; + + static public final int tEQUAL = 37; + + static public final int tASSIGN = 38; + + static public final int tSHIFTL = 40; + + static public final int tLTEQUAL = 41; + + static public final int tLT = 42; + + static public final int tSHIFTRASSIGN = 43; + + static public final int tSHIFTR = 44; + + static public final int tGTEQUAL = 45; + + static public final int tGT = 46; + + static public final int tSHIFTLASSIGN = 47; + + static public final int tELIPSE = 48; + + static public final int tDOTSTAR = 49; + + static public final int tDOT = 50; + + static public final int tDIVASSIGN = 51; + + static public final int tDIV = 52; + + static public final int tCLASSNAME = 53; + + static public final int t_and = 54; + + static public final int t_and_eq = 55; + + static public final int t_asm = 56; + + static public final int t_auto = 57; + + static public final int t_bitand = 58; + + static public final int t_bitor = 59; + + static public final int t_bool = 60; + + static public final int t_break = 61; + + static public final int t_case = 62; + + static public final int t_catch = 63; + + static public final int t_char = 64; + + static public final int t_class = 65; + + static public final int t_compl = 66; + + static public final int t_const = 67; + + static public final int t_const_cast = 69; + + static public final int t_continue = 70; + + static public final int t_default = 71; + + static public final int t_delete = 72; + + static public final int t_do = 73; + + static public final int t_double = 74; + + static public final int t_dynamic_cast = 75; + + static public final int t_else = 76; + + static public final int t_enum = 77; + + static public final int t_explicit = 78; + + static public final int t_export = 79; + + static public final int t_extern = 80; + + static public final int t_false = 81; + + static public final int t_float = 82; + + static public final int t_for = 83; + + static public final int t_friend = 84; + + static public final int t_goto = 85; + + static public final int t_if = 86; + + static public final int t_inline = 87; + + static public final int t_int = 88; + + static public final int t_long = 89; + + static public final int t_mutable = 90; + + static public final int t_namespace = 91; + + static public final int t_new = 92; + + static public final int t_not = 93; + + static public final int t_not_eq = 94; + + static public final int t_operator = 95; + + static public final int t_or = 96; + + static public final int t_or_eq = 97; + + static public final int t_private = 98; + + static public final int t_protected = 99; + + static public final int t_public = 100; + + static public final int t_register = 101; + + static public final int t_reinterpret_cast = 102; + + static public final int t_return = 103; + + static public final int t_short = 104; + + static public final int t_sizeof = 105; + + static public final int t_static = 106; + + static public final int t_static_cast = 107; + + static public final int t_signed = 108; + + static public final int t_struct = 109; + + static public final int t_switch = 110; + + static public final int t_template = 111; + + static public final int t_this = 112; + + static public final int t_throw = 113; + + static public final int t_true = 114; + + static public final int t_try = 115; + + static public final int t_typedef = 116; + + static public final int t_typeid = 117; + + static public final int t_typename = 118; + + static public final int t_union = 119; + + static public final int t_unsigned = 120; + + static public final int t_using = 121; + + static public final int t_virtual = 122; + + static public final int t_void = 123; + + static public final int t_volatile = 124; + + static public final int t_wchar_t = 125; + + static public final int t_while = 126; + + static public final int t_xor = 127; + + static public final int t_xor_eq = 128; + + static public final int tSTRING = 129; + + static public final int tFLOATINGPT = 130; + + static public final int tLSTRING = 131; + + static public final int tCHAR = 132; + + static public final int t__Bool = 133; + + static public final int t__Complex = 134; + + static public final int t__Imaginary = 135; + + static public final int t_restrict = 136; + + static public final int tLAST = t_restrict; +} \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ScannerException.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ScannerException.java similarity index 94% rename from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ScannerException.java rename to core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ScannerException.java index 8f299523ef7..101c989c0b3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ScannerException.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ScannerException.java @@ -8,7 +8,7 @@ * Contributors: * Rational Software - initial implementation ******************************************************************************/ -package org.eclipse.cdt.internal.core.parser; +package org.eclipse.cdt.core.parser; public class ScannerException extends Exception { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTClassSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTClassSpecifier.java index 4f5b3b2a32c..c73597c29ae 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTClassSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTClassSpecifier.java @@ -16,12 +16,14 @@ import java.util.Iterator; * @author jcamelon * */ -public interface IASTClassSpecifier extends IASTScope, IASTOffsetableNamedElement, IASTTemplatedDeclaration { +public interface IASTClassSpecifier extends IASTTypeSpecifier, IASTScope, IASTOffsetableNamedElement, IASTTemplatedDeclaration { public ClassNameType getClassNameType(); public ClassKind getClassKind(); public Iterator getBaseClauses(); + + public AccessVisibility getCurrentVisiblity(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTElaboratedTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTElaboratedTypeSpecifier.java new file mode 100644 index 00000000000..8a97632c4af --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTElaboratedTypeSpecifier.java @@ -0,0 +1,19 @@ +/********************************************************************** + * Copyright (c) 2002,2003 Rational Software Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation +***********************************************************************/ +package org.eclipse.cdt.core.parser.ast; + +/** + * @author jcamelon + * + */ +public interface IASTElaboratedTypeSpecifier extends IASTTypeSpecifier { + +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTEnumerationSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTEnumerationSpecifier.java new file mode 100644 index 00000000000..edea7070801 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTEnumerationSpecifier.java @@ -0,0 +1,19 @@ +/********************************************************************** + * Copyright (c) 2002,2003 Rational Software Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation +***********************************************************************/ +package org.eclipse.cdt.core.parser.ast; + +/** + * @author jcamelon + * + */ +public interface IASTEnumerationSpecifier extends IASTTypeSpecifier { + +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java index 0411c20ed63..94adb3c6da5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java @@ -48,4 +48,18 @@ public interface IASTFactory { public IASTLinkageSpecification createLinkageSpecification(IASTScope scope, String spec); + public IASTClassSpecifier createClassSpecifier( IASTScope scope, + String name, + ClassKind kind, + ClassNameType type, + AccessVisibility access, + IASTTemplateDeclaration ownerTemplateDeclaration, int startingOffset, int nameOffset ); + /** + * @param astClassSpec + * @param isVirtual + * @param visibility + * @param string + */ + public void addBaseSpecifier(IASTClassSpecifier astClassSpec, boolean isVirtual, AccessVisibility visibility, String string); + } \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTEnumSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTTypeSpecifier.java similarity index 94% rename from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTEnumSpecifier.java rename to core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTTypeSpecifier.java index 63c73d5126d..68f421b5f13 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTEnumSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTTypeSpecifier.java @@ -14,6 +14,6 @@ package org.eclipse.cdt.core.parser.ast; * @author jcamelon * */ -public interface IASTEnumSpecifier { +public interface IASTTypeSpecifier { } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/BranchTracker.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/BranchTracker.java index 4aab6428b9b..96906dc0250 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/BranchTracker.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/BranchTracker.java @@ -3,6 +3,8 @@ package org.eclipse.cdt.internal.core.parser; import java.util.EmptyStackException; import java.util.Stack; +import org.eclipse.cdt.core.parser.ScannerException; + /** * @author jcamelon * diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ContextStack.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ContextStack.java index 7e48264ce32..a87061d3f59 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ContextStack.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ContextStack.java @@ -19,7 +19,9 @@ import java.util.LinkedList; import java.util.Set; import java.util.Stack; +import org.eclipse.cdt.core.parser.IScannerContext; import org.eclipse.cdt.core.parser.ISourceElementRequestor; +import org.eclipse.cdt.core.parser.ScannerException; import org.eclipse.cdt.core.parser.ast.IASTInclusion; /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java index eb22ec564a1..6d3a1c1195b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java @@ -14,6 +14,8 @@ import java.util.EmptyStackException; import java.util.Stack; import org.eclipse.cdt.core.parser.IParser; +import org.eclipse.cdt.core.parser.IParserCallback; +import org.eclipse.cdt.core.parser.IToken; public class ExpressionEvaluator implements IParserCallback { @@ -34,61 +36,61 @@ public class ExpressionEvaluator implements IParserCallback { /** * @see org.eclipse.cdt.core.newparser.IParserCallback#expressionOperator(Token) */ - public void expressionOperator(Object expression, Token operator) { + public void expressionOperator(Object expression, IToken operator) { int second = popInt(); int first; switch (operator.getType()) { - case Token.tPLUS: + case IToken.tPLUS: first = popInt(); stack.push(new Integer(first + second)); break; - case Token.tMINUS: + case IToken.tMINUS: first = popInt(); stack.push(new Integer(first - second)); break; - case Token.tSTAR: + case IToken.tSTAR: first = popInt(); stack.push(new Integer(first * second)); break; - case Token.tDIV: + case IToken.tDIV: first = popInt(); stack.push(new Integer(first / second)); break; - case Token.tLT: + case IToken.tLT: first = popInt(); stack.push(new Integer(first < second ? 1 : 0)); break; - case Token.tLTEQUAL: + case IToken.tLTEQUAL: first = popInt(); stack.push(new Integer(first <= second ? 1 : 0)); break; - case Token.tGT: + case IToken.tGT: first = popInt(); stack.push(new Integer(first > second ? 1 : 0)); break; - case Token.tGTEQUAL: + case IToken.tGTEQUAL: first = popInt(); stack.push(new Integer(first >= second ? 1 : 0)); break; - case Token.tEQUAL: + case IToken.tEQUAL: first = popInt(); stack.push(new Integer(first == second ? 1 : 0)); break; - case Token.tNOTEQUAL: + case IToken.tNOTEQUAL: first = popInt(); stack.push(new Integer(first != second ? 1 : 0)); break; - case Token.tAND: + case IToken.tAND: first = popInt(); stack.push( new Integer( ( ( first != 0 ) && ( second != 0 ) ) ? 1 : 0 ) ); break; - case Token.tOR: + case IToken.tOR: first = popInt(); stack.push( new Integer( ( ( first != 0 ) || ( second != 0 ) ) ? 1 : 0 ) ); break; - case Token.tNOT: + case IToken.tNOT: stack.push( new Integer( ( second == 0 ) ? 1 : 0 ) ); break; default: @@ -99,9 +101,9 @@ public class ExpressionEvaluator implements IParserCallback { /** * @see org.eclipse.cdt.core.newparser.IParserCallback#expressionTerminal(Token) */ - public void expressionTerminal(Object expression, Token terminal) { + public void expressionTerminal(Object expression, IToken terminal) { switch (terminal.getType()) { - case Token.tINTEGER: + case IToken.tINTEGER: stack.push(new Integer(terminal.getImage())); break; default: @@ -143,13 +145,13 @@ public class ExpressionEvaluator implements IParserCallback { /** * @see org.eclipse.cdt.internal.core.parser.IParserCallback#simpleDeclarationBegin(java.lang.Object) */ - public Object simpleDeclarationBegin(Object Container, Token firstToken) { + public Object simpleDeclarationBegin(Object Container, IToken firstToken) { return null; } /** * @see org.eclipse.cdt.internal.core.parser.IParserCallback#simpleDeclarationEnd(java.lang.Object) */ - public void simpleDeclarationEnd(Object declaration, Token lastToken) { + public void simpleDeclarationEnd(Object declaration, IToken lastToken) { } /** * @see org.eclipse.cdt.internal.core.parser.IParserCallback#parameterDeclarationBegin(java.lang.Object) @@ -165,7 +167,7 @@ public class ExpressionEvaluator implements IParserCallback { /** * @see org.eclipse.cdt.internal.core.parser.IParserCallback#simpleDeclSpecifier(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) */ - public void simpleDeclSpecifier(Object Container, Token specifier) { + public void simpleDeclSpecifier(Object Container, IToken specifier) { } /** * @see org.eclipse.cdt.internal.core.parser.IParserCallback#declaratorBegin(java.lang.Object) @@ -213,7 +215,7 @@ public class ExpressionEvaluator implements IParserCallback { /** * @see org.eclipse.cdt.internal.core.parser.IParserCallback#classSpecifierBegin(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) */ - public Object classSpecifierBegin(Object container, Token classKey) { + public Object classSpecifierBegin(Object container, IToken classKey) { return null; } /** @@ -224,7 +226,7 @@ public class ExpressionEvaluator implements IParserCallback { /** * @see org.eclipse.cdt.internal.core.parser.IParserCallback#classSpecifierEnd(java.lang.Object) */ - public void classSpecifierEnd(Object classSpecifier, Token closingBrace) { + public void classSpecifierEnd(Object classSpecifier, IToken closingBrace) { } /** * @see org.eclipse.cdt.internal.core.parser.IParserCallback#baseSpecifierBegin(java.lang.Object) @@ -242,7 +244,7 @@ public class ExpressionEvaluator implements IParserCallback { */ public void baseSpecifierVisibility( Object baseSpecifier, - Token visibility) { + IToken visibility) { } /** * @see org.eclipse.cdt.internal.core.parser.IParserCallback#baseSpecifierVirtual(java.lang.Object, boolean) @@ -275,7 +277,7 @@ public class ExpressionEvaluator implements IParserCallback { /** * @see org.eclipse.cdt.internal.core.parser.IParserCallback#elaboratedTypeSpecifierBegin(java.lang.Object) */ - public Object elaboratedTypeSpecifierBegin(Object container, Token classKey) { + public Object elaboratedTypeSpecifierBegin(Object container, IToken classKey) { return null; } @@ -308,7 +310,7 @@ public class ExpressionEvaluator implements IParserCallback { /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#classMemberVisibility(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) */ - public void classMemberVisibility(Object classSpecifier, Token visibility) { + public void classMemberVisibility(Object classSpecifier, IToken visibility) { } /* (non-Javadoc) @@ -336,20 +338,20 @@ public class ExpressionEvaluator implements IParserCallback { /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#pointerOperatorType(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) */ - public void pointerOperatorType(Object ptrOperator, Token type) { + public void pointerOperatorType(Object ptrOperator, IToken type) { } /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#pointerOperatorCVModifier(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) */ - public void pointerOperatorCVModifier(Object ptrOperator, Token modifier) { + public void pointerOperatorCVModifier(Object ptrOperator, IToken modifier) { } /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#declaratorCVModifier(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) */ - public void declaratorCVModifier(Object declarator, Token modifier) { + public void declaratorCVModifier(Object declarator, IToken modifier) { } /* (non-Javadoc) @@ -382,7 +384,7 @@ public class ExpressionEvaluator implements IParserCallback { /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationBegin(java.lang.Object) */ - public Object namespaceDefinitionBegin(Object container, Token namespace) { + public Object namespaceDefinitionBegin(Object container, IToken namespace) { return null; } @@ -404,7 +406,7 @@ public class ExpressionEvaluator implements IParserCallback { /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationEnd(java.lang.Object) */ - public void namespaceDefinitionEnd(Object namespace, Token closingBrace) { + public void namespaceDefinitionEnd(Object namespace, IToken closingBrace) { } @@ -484,7 +486,7 @@ public class ExpressionEvaluator implements IParserCallback { /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierBegin(java.lang.Object) */ - public Object enumSpecifierBegin(Object container, Token enumKey) { + public Object enumSpecifierBegin(Object container, IToken enumKey) { return null; } @@ -505,7 +507,7 @@ public class ExpressionEvaluator implements IParserCallback { /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierEnd(java.lang.Object) */ - public void enumSpecifierEnd(Object enumSpec, Token closingBrace) { + public void enumSpecifierEnd(Object enumSpec, IToken closingBrace) { } @@ -527,7 +529,7 @@ public class ExpressionEvaluator implements IParserCallback { /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionEnd(java.lang.Object) */ - public void enumeratorEnd(Object enumDefn, Token lastToken) { + public void enumeratorEnd(Object enumDefn, IToken lastToken) { } @@ -624,7 +626,7 @@ public class ExpressionEvaluator implements IParserCallback { /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateDeclarationBegin(java.lang.Object, boolean) */ - public Object templateDeclarationBegin(Object container, Token exported) { + public Object templateDeclarationBegin(Object container, IToken exported) { return null; } @@ -637,13 +639,13 @@ public class ExpressionEvaluator implements IParserCallback { /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateDeclarationEnd(java.lang.Object) */ - public void templateDeclarationEnd(Object templateDecl, Token lastToken) { + public void templateDeclarationEnd(Object templateDecl, IToken lastToken) { } /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateTypeParameterBegin(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) */ - public Object templateTypeParameterBegin(Object templDecl, Token kind) { + public Object templateTypeParameterBegin(Object templDecl, IToken kind) { return null; } @@ -706,14 +708,14 @@ public class ExpressionEvaluator implements IParserCallback { /** * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#nameBegin(org.eclipse.cdt.internal.core.newparser.Token) */ - public void nameBegin(Token firstToken) { + public void nameBegin(IToken firstToken) { currName = new Name(firstToken); } /** * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#nameEnd(org.eclipse.cdt.internal.core.newparser.Token) */ - public void nameEnd(Token lastToken) { + public void nameEnd(IToken lastToken) { currName.setEnd(lastToken); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/MacroDescriptor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/MacroDescriptor.java index 13874ca22ea..ae22f367ad6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/MacroDescriptor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/MacroDescriptor.java @@ -13,6 +13,9 @@ package org.eclipse.cdt.internal.core.parser; import java.util.Iterator; import java.util.List; +import org.eclipse.cdt.core.parser.IMacroDescriptor; +import org.eclipse.cdt.core.parser.IToken; + public class MacroDescriptor implements IMacroDescriptor { public MacroDescriptor() @@ -89,7 +92,7 @@ public class MacroDescriptor implements IMacroDescriptor { current = 0; while( iter.hasNext() ) { - buffer.append( "Token #" + current++ + " is " + ((Token)iter.next()).toString() + "\n" ); + buffer.append( "Token #" + current++ + " is " + ((IToken)iter.next()).toString() + "\n" ); } return buffer.toString(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Name.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Name.java index 24f774c41ae..462213fa4f5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Name.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Name.java @@ -1,5 +1,7 @@ package org.eclipse.cdt.internal.core.parser; +import org.eclipse.cdt.core.parser.IToken; + /** @@ -12,44 +14,44 @@ package org.eclipse.cdt.internal.core.parser; */ public class Name { - private Token nameStart, nameEnd; + private IToken nameStart, nameEnd; - public Name(Token nameStart) { + public Name(IToken nameStart) { this.nameStart = nameStart; } - public Name(Token nameStart, Token nameEnd) { + public Name(IToken nameStart, IToken nameEnd) { this( nameStart ); setEnd( nameEnd ); } - public void setEnd(Token nameEnd) { + public void setEnd(IToken nameEnd) { this.nameEnd = nameEnd; } public int getStartOffset() { - return nameStart.offset; + return nameStart.getOffset(); } public int getEndOffset() { - return nameEnd.offset; + return nameEnd.getOffset(); } public String toString() { - Token t = nameStart; + IToken t = nameStart; StringBuffer buffer = new StringBuffer(); buffer.append( t.getImage() ); - if( t.getType() == Token.t_operator ) + if( t.getType() == IToken.t_operator ) buffer.append( " " ); while (t != nameEnd) { t = t.getNext(); buffer.append( t.getImage() ); - if (t.getType() == Token.t_operator) buffer.append( " " ); + if (t.getType() == IToken.t_operator) buffer.append( " " ); } return buffer.toString(); @@ -62,7 +64,7 @@ public class Name { /** * @return */ - public Token getNameStart() { + public IToken getNameStart() { return nameStart; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/NullSourceElementRequestor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/NullSourceElementRequestor.java index d57294842ca..47edcd58168 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/NullSourceElementRequestor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/NullSourceElementRequestor.java @@ -1,14 +1,15 @@ package org.eclipse.cdt.internal.core.parser; -import org.eclipse.cdt.core.parser.ISourceElementRequestor; import org.eclipse.cdt.core.parser.IParser; +import org.eclipse.cdt.core.parser.IParserCallback; import org.eclipse.cdt.core.parser.IProblem; +import org.eclipse.cdt.core.parser.ISourceElementRequestor; +import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.core.parser.ast.IASTASMDefinition; import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier; import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit; import org.eclipse.cdt.core.parser.ast.IASTConstructor; -import org.eclipse.cdt.core.parser.ast.IASTEnumSpecifier; -import org.eclipse.cdt.core.parser.ast.IASTEnumerator; +import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier; import org.eclipse.cdt.core.parser.ast.IASTField; import org.eclipse.cdt.core.parser.ast.IASTFunction; import org.eclipse.cdt.core.parser.ast.IASTInclusion; @@ -23,8 +24,6 @@ import org.eclipse.cdt.core.parser.ast.IASTTypedef; import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration; import org.eclipse.cdt.core.parser.ast.IASTUsingDirective; import org.eclipse.cdt.core.parser.ast.IASTVariable; -import org.eclipse.cdt.internal.core.parser.IParserCallback; -import org.eclipse.cdt.internal.core.parser.Token; public class NullSourceElementRequestor implements ISourceElementRequestor, IParserCallback { @@ -79,24 +78,6 @@ public class NullSourceElementRequestor implements ISourceElementRequestor, IPar public void acceptTypedef(IASTTypedef typedef) { } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterEnumSpecifier(org.eclipse.cdt.core.parser.ast.IASTEnumSpecifier) - */ - public void enterEnumSpecifier(IASTEnumSpecifier enumSpec) { - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptEnumerator(org.eclipse.cdt.core.parser.ast.IASTEnumerator) - */ - public void acceptEnumerator(IASTEnumerator enumerator) { - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitEnumSpecifier(org.eclipse.cdt.core.parser.ast.IASTEnumSpecifier) - */ - public void exitEnumSpecifier(IASTEnumSpecifier enumSpec) { - } - /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterFunctionBody(org.eclipse.cdt.core.parser.ast.IASTFunction) */ @@ -274,14 +255,14 @@ public class NullSourceElementRequestor implements ISourceElementRequestor, IPar /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#simpleDeclarationBegin(java.lang.Object) */ - public Object simpleDeclarationBegin(Object Container, Token firstToken) { + public Object simpleDeclarationBegin(Object Container, IToken firstToken) { return null; } /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#simpleDeclSpecifier(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) */ - public void simpleDeclSpecifier(Object Container, Token specifier) { + public void simpleDeclSpecifier(Object Container, IToken specifier) { } /* (non-Javadoc) @@ -294,7 +275,7 @@ public class NullSourceElementRequestor implements ISourceElementRequestor, IPar /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#simpleDeclarationEnd(java.lang.Object) */ - public void simpleDeclarationEnd(Object declaration, Token lastToken) { + public void simpleDeclarationEnd(Object declaration, IToken lastToken) { } /* (non-Javadoc) @@ -313,13 +294,13 @@ public class NullSourceElementRequestor implements ISourceElementRequestor, IPar /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#nameBegin(org.eclipse.cdt.internal.core.parser.Token) */ - public void nameBegin(Token firstToken) { + public void nameBegin(IToken firstToken) { } /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#nameEnd(org.eclipse.cdt.internal.core.parser.Token) */ - public void nameEnd(Token lastToken) { + public void nameEnd(IToken lastToken) { } /* (non-Javadoc) @@ -345,7 +326,7 @@ public class NullSourceElementRequestor implements ISourceElementRequestor, IPar /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#declaratorCVModifier(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) */ - public void declaratorCVModifier(Object declarator, Token modifier) { + public void declaratorCVModifier(Object declarator, IToken modifier) { } /* (non-Javadoc) @@ -383,7 +364,7 @@ public class NullSourceElementRequestor implements ISourceElementRequestor, IPar /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#pointerOperatorType(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) */ - public void pointerOperatorType(Object ptrOperator, Token type) { + public void pointerOperatorType(Object ptrOperator, IToken type) { } /* (non-Javadoc) @@ -395,7 +376,7 @@ public class NullSourceElementRequestor implements ISourceElementRequestor, IPar /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#pointerOperatorCVModifier(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) */ - public void pointerOperatorCVModifier(Object ptrOperator, Token modifier) { + public void pointerOperatorCVModifier(Object ptrOperator, IToken modifier) { } /* (non-Javadoc) @@ -433,7 +414,7 @@ public class NullSourceElementRequestor implements ISourceElementRequestor, IPar /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#classSpecifierBegin(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) */ - public Object classSpecifierBegin(Object container, Token classKey) { + public Object classSpecifierBegin(Object container, IToken classKey) { return null; } @@ -452,13 +433,13 @@ public class NullSourceElementRequestor implements ISourceElementRequestor, IPar /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#classMemberVisibility(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) */ - public void classMemberVisibility(Object classSpecifier, Token visibility) { + public void classMemberVisibility(Object classSpecifier, IToken visibility) { } /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#classSpecifierEnd(java.lang.Object) */ - public void classSpecifierEnd(Object classSpecifier, Token closingBrace) { + public void classSpecifierEnd(Object classSpecifier, IToken closingBrace) { } /* (non-Javadoc) @@ -477,7 +458,7 @@ public class NullSourceElementRequestor implements ISourceElementRequestor, IPar /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#baseSpecifierVisibility(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) */ - public void baseSpecifierVisibility(Object baseSpecifier, Token visibility) { + public void baseSpecifierVisibility(Object baseSpecifier, IToken visibility) { } /* (non-Javadoc) @@ -502,13 +483,13 @@ public class NullSourceElementRequestor implements ISourceElementRequestor, IPar /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#expressionOperator(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) */ - public void expressionOperator(Object expression, Token operator) { + public void expressionOperator(Object expression, IToken operator) { } /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#expressionTerminal(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) */ - public void expressionTerminal(Object expression, Token terminal) { + public void expressionTerminal(Object expression, IToken terminal) { } /* (non-Javadoc) @@ -526,7 +507,7 @@ public class NullSourceElementRequestor implements ISourceElementRequestor, IPar /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#elaboratedTypeSpecifierBegin(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) */ - public Object elaboratedTypeSpecifierBegin(Object container, Token classKey) { + public Object elaboratedTypeSpecifierBegin(Object container, IToken classKey) { return null; } @@ -551,7 +532,7 @@ public class NullSourceElementRequestor implements ISourceElementRequestor, IPar /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationBegin(java.lang.Object) */ - public Object namespaceDefinitionBegin(Object container, Token namespace) { + public Object namespaceDefinitionBegin(Object container, IToken namespace) { return null; } @@ -570,7 +551,7 @@ public class NullSourceElementRequestor implements ISourceElementRequestor, IPar /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationEnd(java.lang.Object) */ - public void namespaceDefinitionEnd(Object namespace, Token closingBrace) { + public void namespaceDefinitionEnd(Object namespace, IToken closingBrace) { } /* (non-Javadoc) @@ -647,7 +628,7 @@ public class NullSourceElementRequestor implements ISourceElementRequestor, IPar /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierBegin(java.lang.Object) */ - public Object enumSpecifierBegin(Object container, Token enumKey) { + public Object enumSpecifierBegin(Object container, IToken enumKey) { return null; } @@ -666,7 +647,7 @@ public class NullSourceElementRequestor implements ISourceElementRequestor, IPar /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierEnd(java.lang.Object) */ - public void enumSpecifierEnd(Object enumSpec, Token closingBrace) { + public void enumSpecifierEnd(Object enumSpec, IToken closingBrace) { } /* (non-Javadoc) @@ -685,7 +666,7 @@ public class NullSourceElementRequestor implements ISourceElementRequestor, IPar /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionEnd(java.lang.Object) */ - public void enumeratorEnd(Object enumDefn, Token lastToken) { + public void enumeratorEnd(Object enumDefn, IToken lastToken) { } /* (non-Javadoc) @@ -780,7 +761,7 @@ public class NullSourceElementRequestor implements ISourceElementRequestor, IPar /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateDeclarationBegin(java.lang.Object, boolean) */ - public Object templateDeclarationBegin(Object container, Token exported) { + public Object templateDeclarationBegin(Object container, IToken exported) { return null; } @@ -793,13 +774,13 @@ public class NullSourceElementRequestor implements ISourceElementRequestor, IPar /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateDeclarationEnd(java.lang.Object) */ - public void templateDeclarationEnd(Object templateDecl, Token lastToken) { + public void templateDeclarationEnd(Object templateDecl, IToken lastToken) { } /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateTypeParameterBegin(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token) */ - public Object templateTypeParameterBegin(Object templDecl, Token kind) { + public Object templateTypeParameterBegin(Object templDecl, IToken kind) { return null; } @@ -876,4 +857,20 @@ public class NullSourceElementRequestor implements ISourceElementRequestor, IPar */ public void simpleDeclSpecifierType(Object declaration, Object type) { } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptEnumerationSpecifier(org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier) + */ + public void acceptEnumerationSpecifier(IASTEnumerationSpecifier enumeration) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptClassReference(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier, int) + */ + public void acceptClassReference(IASTClassSpecifier classSpecifier, int referenceOffset) { + // TODO Auto-generated method stub + + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java index d365837815e..e770a88bbfc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java @@ -16,9 +16,16 @@ import java.io.InputStreamReader; import java.io.StringReader; import org.eclipse.cdt.core.parser.IParser; +import org.eclipse.cdt.core.parser.IParserCallback; import org.eclipse.cdt.core.parser.IScanner; import org.eclipse.cdt.core.parser.ISourceElementRequestor; +import org.eclipse.cdt.core.parser.IToken; +import org.eclipse.cdt.core.parser.ScannerException; +import org.eclipse.cdt.core.parser.ast.AccessVisibility; +import org.eclipse.cdt.core.parser.ast.ClassKind; +import org.eclipse.cdt.core.parser.ast.ClassNameType; import org.eclipse.cdt.core.parser.ast.IASTASMDefinition; +import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier; import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit; import org.eclipse.cdt.core.parser.ast.IASTFactory; import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification; @@ -38,6 +45,7 @@ import org.eclipse.cdt.internal.core.model.Util; */ public class Parser implements IParser { + private ClassNameType access; private static int DEFAULT_OFFSET = -1; // sentinel initial value for offsets private int firstErrorOffset = DEFAULT_OFFSET; // offset where the first parse error occurred private IParserCallback callback; // the parser callback that was registered with us @@ -56,7 +64,7 @@ public class Parser implements IParser { protected void failParse() throws EndOfFile { if( firstErrorOffset == DEFAULT_OFFSET ) - firstErrorOffset = LA(1).offset; + firstErrorOffset = LA(1).getOffset(); parsePassed = false; } @@ -181,8 +189,8 @@ c, quickParse); IASTCompilationUnit compilationUnit = astFactory.createCompilationUnit(); requestor.enterCompilationUnit( compilationUnit ); - Token lastBacktrack = null; - Token checkToken; + IToken lastBacktrack = null; + IToken checkToken; while (true) { try { checkToken = LA(1); @@ -232,13 +240,13 @@ c, quickParse); failParse(); consume(); int depth = 0; - while ( ! ( (LT(1) == Token.tSEMI && depth == 0 ) || ( LT(1) == Token.tRBRACE && depth == 1 ) ) ){ + while ( ! ( (LT(1) == IToken.tSEMI && depth == 0 ) || ( LT(1) == IToken.tRBRACE && depth == 1 ) ) ){ switch( LT(1)) { - case Token.tLBRACE: + case IToken.tLBRACE: ++depth; break; - case Token.tRBRACE: + case IToken.tRBRACE: --depth; break; } @@ -263,18 +271,18 @@ c, quickParse); */ protected void usingClause( Object container, IASTScope scope ) throws Backtrack { - Token firstToken = consume( Token.t_using ); + IToken firstToken = consume( IToken.t_using ); - if( LT(1) == Token.t_namespace ) + if( LT(1) == IToken.t_namespace ) { Object directive = null; try{ directive = callback.usingDirectiveBegin( container);} catch( Exception e ) {} // using-directive - consume( Token.t_namespace ); + consume( IToken.t_namespace ); // optional :: and nested classes handled in name TokenDuple duple = null ; - if( LT(1) == Token.tIDENTIFIER || LT(1) == Token.tCOLONCOLON ) + if( LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON ) { duple = name(); try{ callback.usingDirectiveNamespaceId( directive );} catch( Exception e ) {} @@ -285,9 +293,9 @@ c, quickParse); throw backtrack; } - if( LT(1) == Token.tSEMI ) + if( LT(1) == IToken.tSEMI ) { - consume( Token.tSEMI ); + consume( IToken.tSEMI ); try{ callback.usingDirectiveEnd( directive );} catch( Exception e ) {} IASTUsingDirective astUD = astFactory.createUsingDirective(scope, duple); @@ -306,14 +314,14 @@ c, quickParse); try{ usingDeclaration = callback.usingDeclarationBegin( container );} catch( Exception e ) {} boolean typeName = false; - if( LT(1) == Token.t_typename ) + if( LT(1) == IToken.t_typename ) { typeName = true; - consume( Token.t_typename ); + consume( IToken.t_typename ); } TokenDuple name = null; - if( LT(1) == Token.tIDENTIFIER || LT(1) == Token.tCOLONCOLON ) + if( LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON ) { // optional :: and nested classes handled in name name = name(); @@ -325,9 +333,9 @@ c, quickParse); throw backtrack; } - if( LT(1) == Token.tSEMI ) + if( LT(1) == IToken.tSEMI ) { - consume( Token.tSEMI ); + consume( IToken.tSEMI ); try{ callback.usingDeclarationEnd( usingDeclaration );} catch( Exception e ) {} @@ -355,29 +363,29 @@ c, quickParse); */ protected void linkageSpecification( Object container, IASTScope scope ) throws Backtrack { - consume( Token.t_extern ); + consume( IToken.t_extern ); - if( LT(1) != Token.tSTRING ) + if( LT(1) != IToken.tSTRING ) throw backtrack; Object linkageSpec = null; - Token spec = consume( Token.tSTRING ); + IToken spec = consume( IToken.tSTRING ); try{ linkageSpec = callback.linkageSpecificationBegin( container, spec.getImage() );} catch( Exception e ) {} - if( LT(1) == Token.tLBRACE ) + if( LT(1) == IToken.tLBRACE ) { - consume(Token.tLBRACE); + consume(IToken.tLBRACE); IASTLinkageSpecification linkage = astFactory.createLinkageSpecification(scope, spec.getImage()); requestor.enterLinkageSpecification( linkage ); linkageDeclarationLoop: - while (LT(1) != Token.tRBRACE) { - Token checkToken = LA(1); + while (LT(1) != IToken.tRBRACE) { + IToken checkToken = LA(1); switch (LT(1)) { - case Token.tRBRACE: - consume(Token.tRBRACE); + case IToken.tRBRACE: + consume(IToken.tRBRACE); break linkageDeclarationLoop; default: try @@ -427,17 +435,17 @@ c, quickParse); */ protected void templateDeclaration( Object container ) throws Backtrack { - Token firstToken = null; - if( LT(1) == Token.t_export ) + IToken firstToken = null; + if( LT(1) == IToken.t_export ) { - firstToken = consume( Token.t_export ); - consume( Token.t_template ); + firstToken = consume( IToken.t_export ); + consume( IToken.t_template ); } else - firstToken = consume( Token.t_template ); + firstToken = consume( IToken.t_template ); - if( LT(1) != Token.tLT ) + if( LT(1) != IToken.tLT ) { // explicit-instantiation Object instantiation = null; @@ -448,10 +456,10 @@ c, quickParse); } else { - consume( Token.tLT ); - if( LT(1) == Token.tGT ) + consume( IToken.tLT ); + if( LT(1) == IToken.tGT ) { - consume( Token.tGT ); + consume( IToken.tGT ); // explicit-specialization Object specialization = null; try{ specialization = callback.explicitSpecializationBegin( container ); } catch( Exception e ) { } @@ -466,9 +474,9 @@ c, quickParse); { try{ templateDeclaration = callback.templateDeclarationBegin( container, firstToken ); } catch ( Exception e ) {} templateParameterList( templateDeclaration ); - consume( Token.tGT ); + consume( IToken.tGT ); declaration( templateDeclaration ); - try{ callback.templateDeclarationEnd( templateDeclaration, lastToken ); } catch( Exception e ) {} + try{ callback.templateDeclarationEnd( templateDeclaration, (Token)lastToken ); } catch( Exception e ) {} } catch( Backtrack bt ) { @@ -511,8 +519,8 @@ c, quickParse); for ( ; ; ) { - if( LT(1) == Token.tGT ) return; - if( LT(1) == Token.t_class || LT(1) == Token.t_typename ) + if( LT(1) == IToken.tGT ) return; + if( LT(1) == IToken.t_class || LT(1) == IToken.t_typename ) { Object currentTemplateParm = null; try @@ -521,13 +529,13 @@ c, quickParse); currentTemplateParm = callback.templateTypeParameterBegin( templateParameterList, consume() ); } catch( Exception e ) {} - if( LT(1) == Token.tIDENTIFIER ) // optional identifier + if( LT(1) == IToken.tIDENTIFIER ) // optional identifier { identifier(); try { callback.templateTypeParameterName( currentTemplateParm );} catch( Exception e ) {} - if( LT(1) == Token.tASSIGN ) // optional = type-id + if( LT(1) == IToken.tASSIGN ) // optional = type-id { - consume( Token.tASSIGN ); + consume( IToken.tASSIGN ); typeId(); // type-id try{ callback.templateTypeParameterInitialTypeId( currentTemplateParm ); }catch( Exception e ) {} } @@ -540,31 +548,31 @@ c, quickParse); throw bt; } } - else if( LT(1) == Token.t_template ) + else if( LT(1) == IToken.t_template ) { - Token kind = consume( Token.t_template ); - consume( Token.tLT ); + IToken kind = consume( IToken.t_template ); + consume( IToken.tLT ); Object newTemplateParm = null; try{ newTemplateParm = callback.templateTypeParameterBegin(templateParameterList,kind ); } catch( Exception e ) {} templateParameterList( newTemplateParm ); - consume( Token.tGT ); - consume( Token.t_class ); - if( LT(1) == Token.tIDENTIFIER ) // optional identifier + consume( IToken.tGT ); + consume( IToken.t_class ); + if( LT(1) == IToken.tIDENTIFIER ) // optional identifier { identifier(); try{ callback.templateTypeParameterName( newTemplateParm );} catch( Exception e ) {} - if( LT(1) == Token.tASSIGN ) // optional = type-id + if( LT(1) == IToken.tASSIGN ) // optional = type-id { - consume( Token.tASSIGN ); + consume( IToken.tASSIGN ); typeId(); try{ callback.templateTypeParameterInitialTypeId( newTemplateParm );} catch( Exception e ) {} } } try{ callback.templateTypeParameterEnd( newTemplateParm );} catch( Exception e ) {} } - else if( LT(1) == Token.tCOMMA ) + else if( LT(1) == IToken.tCOMMA ) { - consume( Token.tCOMMA ); + consume( IToken.tCOMMA ); continue; } else @@ -604,12 +612,12 @@ c, quickParse); */ protected void declaration( Object container, IASTScope scope ) throws Backtrack { switch (LT(1)) { - case Token.t_asm: - Token first = consume( Token.t_asm ); - consume( Token.tLPAREN ); - String assembly = consume( Token.tSTRING ).getImage(); - consume( Token.tRPAREN ); - Token last = consume( Token.tSEMI ); + case IToken.t_asm: + IToken first = consume( IToken.t_asm ); + consume( IToken.tLPAREN ); + String assembly = consume( IToken.tSTRING ).getImage(); + consume( IToken.tRPAREN ); + IToken last = consume( IToken.tSEMI ); IASTASMDefinition asmDefinition = astFactory.createASMDefinition(scope, assembly, first.getOffset(), last.getEndOffset()); @@ -620,33 +628,33 @@ c, quickParse); requestor.acceptASMDefinition( asmDefinition ); return; - case Token.t_namespace: + case IToken.t_namespace: namespaceDefinition( container, scope); return; - case Token.t_using: + case IToken.t_using: usingClause( container, scope ); return; - case Token.t_export: - case Token.t_template: + case IToken.t_export: + case IToken.t_template: templateDeclaration( container ); return; - case Token.t_extern: - if( LT(2) == Token.tSTRING ) + case IToken.t_extern: + if( LT(2) == IToken.tSTRING ) { linkageSpecification( container, scope ); return; } default: - Token mark = mark(); + IToken mark = mark(); try { - simpleDeclaration( container, true ); // try it first with the original strategy + simpleDeclaration( container, true, scope ); // try it first with the original strategy } catch( Backtrack bt) { // did not work backup( mark ); - simpleDeclaration( container, false ); // try it again with the second strategy + simpleDeclaration( container, false, scope ); // try it again with the second strategy } } } @@ -665,18 +673,18 @@ c, quickParse); protected void namespaceDefinition( Object container, IASTScope scope ) throws Backtrack { Object namespace = null; - Token first = consume( Token.t_namespace ); + IToken first = consume( IToken.t_namespace ); try{ namespace = callback.namespaceDefinitionBegin( container, first );} catch( Exception e ) {} - Token identifier = null; + IToken identifier = null; // optional name - if( LT(1) == Token.tIDENTIFIER ) + if( LT(1) == IToken.tIDENTIFIER ) { identifier = identifier(); try{ callback.namespaceDefinitionId( namespace );} catch( Exception e ) {} } - if( LT(1) == Token.tLBRACE ) + if( LT(1) == IToken.tLBRACE ) { consume(); @@ -689,10 +697,10 @@ c, quickParse); requestor.enterNamespaceDefinition( namespaceDefinition ); namepsaceDeclarationLoop: - while (LT(1) != Token.tRBRACE) { - Token checkToken = LA(1); + while (LT(1) != IToken.tRBRACE) { + IToken checkToken = LA(1); switch (LT(1)) { - case Token.tRBRACE: + case IToken.tRBRACE: //consume(Token.tRBRACE); break namepsaceDeclarationLoop; default: @@ -712,8 +720,8 @@ c, quickParse); } // consume the } - Token last = consume( Token.tRBRACE ); - try{ callback.namespaceDefinitionEnd( namespace, last);} catch( Exception e ) {} + IToken last = consume( IToken.tRBRACE ); + try{ callback.namespaceDefinitionEnd( namespace, (Token)last);} catch( Exception e ) {} namespaceDefinition.setEndingOffset( last.getOffset() + last.getLength()); requestor.exitNamespaceDefinition( namespaceDefinition ); @@ -744,17 +752,17 @@ c, quickParse); * @param tryConstructor true == take strategy1 (constructor ) : false == take strategy 2 ( pointer to function) * @throws Backtrack request a backtrack */ - protected void simpleDeclaration( Object container, boolean tryConstructor ) throws Backtrack { + protected void simpleDeclaration( Object container, boolean tryConstructor, IASTScope scope ) throws Backtrack { Object simpleDecl = null; try{ simpleDecl = callback.simpleDeclarationBegin( container, LA(1));} catch( Exception e ) {} - declSpecifierSeq(simpleDecl, false, tryConstructor); + declSpecifierSeq(simpleDecl, false, tryConstructor, scope); Object declarator = null; - if (LT(1) != Token.tSEMI) + if (LT(1) != IToken.tSEMI) try { declarator = initDeclarator(simpleDecl); - while (LT(1) == Token.tCOMMA) { + while (LT(1) == IToken.tCOMMA) { consume(); try { @@ -768,26 +776,26 @@ c, quickParse); } switch (LT(1)) { - case Token.tSEMI: - consume(Token.tSEMI); + case IToken.tSEMI: + consume(IToken.tSEMI); break; - case Token.tCOLON: + case IToken.tCOLON: ctorInitializer(declarator); // Falling through on purpose - case Token.tLBRACE: + case IToken.tLBRACE: Object function = null; try{ function = callback.functionBodyBegin(simpleDecl ); } catch( Exception e ) {} if (quickParse) { // speed up the parser by skiping the body // simply look for matching brace and return - consume(Token.tLBRACE); + consume(IToken.tLBRACE); int depth = 1; while (depth > 0) { switch (consume().getType()) { - case Token.tRBRACE: + case IToken.tRBRACE: --depth; break; - case Token.tLBRACE: + case IToken.tLBRACE: ++depth; break; } @@ -801,7 +809,7 @@ c, quickParse); throw backtrack; } - try{ callback.simpleDeclarationEnd(simpleDecl, lastToken);} catch( Exception e ) {} + try{ callback.simpleDeclarationEnd(simpleDecl, (Token)lastToken);} catch( Exception e ) {} } /** @@ -816,23 +824,23 @@ c, quickParse); * @throws Backtrack request a backtrack */ protected void ctorInitializer(Object declarator) throws Backtrack { - consume( Token.tCOLON ); + consume( IToken.tCOLON ); Object constructorChain = null; try { constructorChain = callback.constructorChainBegin(declarator);} catch( Exception e ) {} try { for( ; ; ) { - if( LT(1) == Token.tLBRACE ) break; + if( LT(1) == IToken.tLBRACE ) break; Object constructorChainElement = null; try{ constructorChainElement = callback.constructorChainElementBegin( constructorChain );} catch( Exception e ) {} name(); try{ callback.constructorChainElementId(constructorChainElement);} catch( Exception e) {} - consume( Token.tLPAREN ); + consume( IToken.tLPAREN ); - while( LT(1) != Token.tRPAREN ) + while( LT(1) != IToken.tRPAREN ) { //handle expression list here Object item = null; @@ -842,15 +850,15 @@ c, quickParse); assignmentExpression( expression ); try{ callback.expressionEnd( item );} catch( Exception e) {} try{ callback.constructorChainElementExpressionListElementEnd( item );} catch( Exception e) {} - if( LT(1) == Token.tRPAREN ) break; - consume( Token.tCOMMA ); + if( LT(1) == IToken.tRPAREN ) break; + consume( IToken.tCOMMA ); } - consume( Token.tRPAREN ); + consume( IToken.tRPAREN ); try{ callback.constructorChainElementEnd(constructorChainElement );} catch( Exception e) {} - if( LT(1) == Token.tLBRACE ) break; - if( LT(1) == Token.tCOMMA ) consume( Token.tCOMMA ); + if( LT(1) == IToken.tLBRACE ) break; + if( LT(1) == IToken.tCOMMA ) consume( IToken.tCOMMA ); } } catch( Backtrack bt ) @@ -872,12 +880,12 @@ c, quickParse); */ protected void parameterDeclaration( Object containerObject ) throws Backtrack { - Token current = LA(1); + IToken current = LA(1); Object parameterDecl = null; try{ parameterDecl = callback.parameterDeclarationBegin( containerObject );} catch( Exception e ) {} - declSpecifierSeq( parameterDecl, true, false ); + declSpecifierSeq( parameterDecl, true, false, null ); - if (LT(1) != Token.tSEMI) + if (LT(1) != IToken.tSEMI) try { Object declarator = initDeclarator(parameterDecl); @@ -963,11 +971,11 @@ c, quickParse); private boolean lookAheadForConstructorOrConversion( Flags flags ) throws EndOfFile { if (flags.isForParameterDeclaration()) return false; - if (LT(2) == Token.tLPAREN && flags.isForConstructor()) return true; + if (LT(2) == IToken.tLPAREN && flags.isForConstructor()) return true; int posTokenAfterTemplateParameters = 2; - if (LT(posTokenAfterTemplateParameters) == Token.tLT) { + if (LT(posTokenAfterTemplateParameters) == IToken.tLT) { // a case for template constructor, like CFoobar::CFoobar posTokenAfterTemplateParameters++; @@ -977,10 +985,10 @@ c, quickParse); while (depth > 0) { switch (LT(posTokenAfterTemplateParameters++)) { - case Token.tGT : + case IToken.tGT : --depth; break; - case Token.tLT : + case IToken.tLT : ++depth; break; } @@ -991,20 +999,20 @@ c, quickParse); return ( ( - (LT(posTokenAfterTemplateParameters) == Token.tCOLONCOLON) + (LT(posTokenAfterTemplateParameters) == IToken.tCOLONCOLON) && ( LA(posTokenAfterTemplateParameters+1).getImage().equals( LA(1).getImage() ) || - LT(posTokenAfterTemplateParameters+1) == Token.tCOMPL + LT(posTokenAfterTemplateParameters+1) == IToken.tCOMPL ) ) || ( // for conversion operators - (LT(posTokenAfterTemplateParameters) == Token.tCOLONCOLON) + (LT(posTokenAfterTemplateParameters) == IToken.tCOLONCOLON) && ( - LT(posTokenAfterTemplateParameters+1) == Token.t_operator + LT(posTokenAfterTemplateParameters+1) == IToken.t_operator ) ) ); @@ -1021,10 +1029,10 @@ c, quickParse); flags.haveEncounteredTypename() && ( ( - LT(2) != Token.tIDENTIFIER || + LT(2) != IToken.tIDENTIFIER || ( - LT(3) != Token.tLPAREN && - LT(3) != Token.tASSIGN + LT(3) != IToken.tLPAREN && + LT(3) != IToken.tASSIGN ) ) && !LA(2).isPointer() @@ -1058,47 +1066,47 @@ c, quickParse); * @param tryConstructor true for constructor, false for pointer to function strategy * @throws Backtrack request a backtrack */ - protected void declSpecifierSeq( Object decl, boolean parm, boolean tryConstructor ) throws Backtrack { + protected void declSpecifierSeq( Object decl, boolean parm, boolean tryConstructor, IASTScope scope ) throws Backtrack { Flags flags = new Flags( parm, tryConstructor ); declSpecifiers: for (;;) { switch (LT(1)) { - case Token.t_inline: - case Token.t_auto: - case Token.t_register: - case Token.t_static: - case Token.t_extern: - case Token.t_mutable: - case Token.t_virtual: - case Token.t_explicit: - case Token.t_typedef: - case Token.t_friend: - case Token.t_const: - case Token.t_volatile: + case IToken.t_inline: + case IToken.t_auto: + case IToken.t_register: + case IToken.t_static: + case IToken.t_extern: + case IToken.t_mutable: + case IToken.t_virtual: + case IToken.t_explicit: + case IToken.t_typedef: + case IToken.t_friend: + case IToken.t_const: + case IToken.t_volatile: try{ callback.simpleDeclSpecifier(decl, consume());} catch( Exception e ) {} break; - case Token.t_signed: - case Token.t_unsigned: - case Token.t_short: - case Token.t_char: - case Token.t_wchar_t: - case Token.t_bool: - case Token.t_int: - case Token.t_long: - case Token.t_float: - case Token.t_double: - case Token.t_void: + case IToken.t_signed: + case IToken.t_unsigned: + case IToken.t_short: + case IToken.t_char: + case IToken.t_wchar_t: + case IToken.t_bool: + case IToken.t_int: + case IToken.t_long: + case IToken.t_float: + case IToken.t_double: + case IToken.t_void: flags.setEncounteredRawType(true); try{ callback.simpleDeclSpecifier(decl, consume());} catch( Exception e ) {} break; - case Token.t_typename: - try{ callback.simpleDeclSpecifier(decl, consume( Token.t_typename ));} catch( Exception e ) {} - Token first = LA(1); - Token last = null; + case IToken.t_typename: + try{ callback.simpleDeclSpecifier(decl, consume( IToken.t_typename ));} catch( Exception e ) {} + IToken first = LA(1); + IToken last = null; name(); - if( LT(1) == Token.t_template ) + if( LT(1) == IToken.t_template ) { - consume( Token.t_template ); + consume( IToken.t_template ); last = templateId(); try { @@ -1112,10 +1120,10 @@ c, quickParse); try{ callback.simpleDeclSpecifierName( decl );} catch( Exception e ) {} return; - case Token.tCOLONCOLON: - consume( Token.tCOLONCOLON ); + case IToken.tCOLONCOLON: + consume( IToken.tCOLONCOLON ); // handle nested later: - case Token.tIDENTIFIER: + case IToken.tIDENTIFIER: // TODO - Kludgy way to handle constructors/destructors // handle nested later: if ( flags.haveEncounteredRawType() ) @@ -1133,14 +1141,14 @@ c, quickParse); break; - case Token.t_class: - case Token.t_struct: - case Token.t_union: + case IToken.t_class: + case IToken.t_struct: + case IToken.t_union: if( !parm ) { try { - classSpecifier(decl); + classSpecifier(decl, scope); return; } catch( Backtrack bt ) @@ -1156,7 +1164,7 @@ c, quickParse); flags.setEncounteredTypename(true); break; } - case Token.t_enum: + case IToken.t_enum: if( !parm ) { try @@ -1209,11 +1217,11 @@ c, quickParse); * @return Last consumed token, or previousLast if nothing was consumed * @throws Backtrack request a backtrack */ - private Token consumeTemplateParameters(Token previousLast) throws Backtrack { - Token last = previousLast; + private IToken consumeTemplateParameters(IToken previousLast) throws Backtrack { + IToken last = previousLast; - if (LT(1) == Token.tLT) { - last = consume(Token.tLT); + if (LT(1) == IToken.tLT) { + last = consume(IToken.tLT); // until we get all the names sorted out int depth = 1; @@ -1221,10 +1229,10 @@ c, quickParse); while (depth > 0) { last = consume(); switch (last.getType()) { - case Token.tGT : + case IToken.tGT : --depth; break; - case Token.tLT : + case IToken.tLT : ++depth; break; } @@ -1239,8 +1247,8 @@ c, quickParse); * * @throws Backtrack request a backtrack */ - protected Token identifier() throws Backtrack { - Token first = consume(Token.tIDENTIFIER); // throws backtrack if its not that + protected IToken identifier() throws Backtrack { + IToken first = consume(IToken.tIDENTIFIER); // throws backtrack if its not that try { callback.nameBegin(first); @@ -1256,18 +1264,18 @@ c, quickParse); * * @throws Backtrack */ - protected void className() throws Backtrack + protected TokenDuple className() throws Backtrack { - if( LT(1) == Token.tIDENTIFIER) + if( LT(1) == IToken.tIDENTIFIER) { - if( LT(2) == Token.tLT ) + if( LT(2) == IToken.tLT ) { - templateId(); + return new TokenDuple( LA(1), templateId() ); } else { - identifier(); - return; + IToken t = identifier(); + return new TokenDuple(t, t); } } else @@ -1284,9 +1292,9 @@ c, quickParse); * * @throws Backtrack request a backtrack */ - protected Token templateId() throws Backtrack { - Token first = consume( Token.tIDENTIFIER ); - Token last = consumeTemplateParameters(first); + protected IToken templateId() throws Backtrack { + IToken first = consume( IToken.tIDENTIFIER ); + IToken last = consumeTemplateParameters(first); callback.nameBegin( first ); callback.nameEnd( last ); @@ -1305,21 +1313,21 @@ c, quickParse); * @throws Backtrack request a backtrack */ protected TokenDuple name() throws Backtrack { - Token first = LA(1); - Token last = null; + IToken first = LA(1); + IToken last = null; - Token mark = mark(); + IToken mark = mark(); try{ callback.nameBegin(first); } catch( Exception e ) {} - if (LT(1) == Token.tCOLONCOLON) + if (LT(1) == IToken.tCOLONCOLON) last = consume(); // TODO - whacky way to deal with destructors, please revisit - if (LT(1) == Token.tCOMPL) + if (LT(1) == IToken.tCOMPL) consume(); switch (LT(1)) { - case Token.tIDENTIFIER: + case IToken.tIDENTIFIER: last = consume(); last = consumeTemplateParameters(last); break; @@ -1328,20 +1336,20 @@ c, quickParse); throw backtrack; } - while (LT(1) == Token.tCOLONCOLON) { + while (LT(1) == IToken.tCOLONCOLON) { last = consume(); - if (LT(1) == Token.t_template ) + if (LT(1) == IToken.t_template ) consume(); - if (LT(1) == Token.tCOMPL) + if (LT(1) == IToken.tCOMPL) consume(); switch (LT(1)) { - case Token.t_operator: + case IToken.t_operator: backup( mark ); throw backtrack; - case Token.tIDENTIFIER: + case IToken.tIDENTIFIER: last = consume(); last = consumeTemplateParameters(last); } @@ -1366,8 +1374,8 @@ c, quickParse); */ protected Object cvQualifier( Object ptrOp ) throws Backtrack { switch (LT(1)) { - case Token.t_const: - case Token.t_volatile: + case IToken.t_const: + case IToken.t_volatile: try{ callback.pointerOperatorCVModifier( ptrOp, consume() ); } catch( Exception e ) {} return ptrOp; default: @@ -1389,7 +1397,7 @@ c, quickParse); // handle = initializerClause - if (LT(1) == Token.tASSIGN) { + if (LT(1) == IToken.tASSIGN) { consume(); // assignmentExpression || { initializerList , } || { } @@ -1406,25 +1414,25 @@ c, quickParse); try{ callback.expressionAbort( expression );} catch( Exception e ) {} } - if (LT(1) == Token.tLBRACE) { + if (LT(1) == IToken.tLBRACE) { // for now, just consume to matching brace consume(); int depth = 1; while (depth > 0) { switch (consume().getType()) { - case Token.tRBRACE: + case IToken.tRBRACE: --depth; break; - case Token.tLBRACE: + case IToken.tLBRACE: ++depth; break; } } } } - else if( LT(1) == Token.tLPAREN ) + else if( LT(1) == IToken.tLPAREN ) { - consume(Token.tLPAREN); // EAT IT! + consume(IToken.tLPAREN); // EAT IT! Object expression = null; try @@ -1439,7 +1447,7 @@ c, quickParse); try{ callback.expressionAbort( expression );} catch( Exception e ) {} } - if( LT(1) == Token.tRPAREN ) + if( LT(1) == IToken.tRPAREN ) consume(); } @@ -1484,37 +1492,37 @@ c, quickParse); } } - if (LT(1) == Token.tLPAREN) { + if (LT(1) == IToken.tLPAREN) { consume(); Object subDeclarator = declarator(declarator); - consume(Token.tRPAREN); + consume(IToken.tRPAREN); try{ callback.declaratorEnd( subDeclarator );} catch( Exception e ) {} } - else if( LT(1) == Token.t_operator ) + else if( LT(1) == IToken.t_operator ) { // we know this is an operator - Token operatorToken = consume( Token.t_operator ); - Token toSend = null; - if( LA(1).isOperator() || LT(1) == Token.tLPAREN || LT(1) == Token.tLBRACKET ) + IToken operatorToken = consume( IToken.t_operator ); + IToken toSend = null; + if( LA(1).isOperator() || LT(1) == IToken.tLPAREN || LT(1) == IToken.tLBRACKET ) { - if( (LT(1) == Token.t_new || LT(1) == Token.t_delete ) && - LT(2) == Token.tLBRACKET && LT(3) == Token.tRBRACKET ) + if( (LT(1) == IToken.t_new || LT(1) == IToken.t_delete ) && + LT(2) == IToken.tLBRACKET && LT(3) == IToken.tRBRACKET ) { consume(); - consume( Token.tLBRACKET ); - toSend = consume( Token.tRBRACKET ); + consume( IToken.tLBRACKET ); + toSend = consume( IToken.tRBRACKET ); // vector new and delete operators } - else if ( LT(1) == Token.tLPAREN && LT(2) == Token.tRPAREN ) + else if ( LT(1) == IToken.tLPAREN && LT(2) == IToken.tRPAREN ) { // operator () - consume( Token.tLPAREN ); - toSend = consume( Token.tRPAREN ); + consume( IToken.tLPAREN ); + toSend = consume( IToken.tRPAREN ); } - else if ( LT(1) == Token.tLBRACKET && LT(2) == Token.tRBRACKET ) + else if ( LT(1) == IToken.tLBRACKET && LT(2) == IToken.tRBRACKET ) { - consume( Token.tLBRACKET ); - toSend = consume( Token.tRBRACKET ); + consume( IToken.tLBRACKET ); + toSend = consume( IToken.tRBRACKET ); } else if( LA(1).isOperator() ) toSend = consume(); @@ -1554,40 +1562,40 @@ c, quickParse); } catch( Backtrack bt ) { - if( LT(1) == Token.tCOLONCOLON || LT(1) == Token.tIDENTIFIER ) + if( LT(1) == IToken.tCOLONCOLON || LT(1) == IToken.tIDENTIFIER ) { - Token start = consume(); - Token end = null; - if (start.type == Token.tIDENTIFIER) end = consumeTemplateParameters(end); - while( LT(1) == Token.tCOLONCOLON || LT(1) == Token.tIDENTIFIER ) + IToken start = consume(); + IToken end = null; + if (start.getType() == IToken.tIDENTIFIER) end = consumeTemplateParameters(end); + while( LT(1) == IToken.tCOLONCOLON || LT(1) == IToken.tIDENTIFIER ) { end = consume(); - if (end.type == Token.tIDENTIFIER) end = consumeTemplateParameters(end); + if (end.getType() == IToken.tIDENTIFIER) end = consumeTemplateParameters(end); } - if( LT(1) == Token.t_operator ) + if( LT(1) == IToken.t_operator ) { consume(); - if( LA(1).isOperator() || LT(1) == Token.tLPAREN || LT(1) == Token.tLBRACKET ) + if( LA(1).isOperator() || LT(1) == IToken.tLPAREN || LT(1) == IToken.tLBRACKET ) { - if( (LT(1) == Token.t_new || LT(1) == Token.t_delete ) && - LT(2) == Token.tLBRACKET && LT(3) == Token.tRBRACKET ) + if( (LT(1) == IToken.t_new || LT(1) == IToken.t_delete ) && + LT(2) == IToken.tLBRACKET && LT(3) == IToken.tRBRACKET ) { consume(); - consume( Token.tLBRACKET ); - end = consume( Token.tRBRACKET ); + consume( IToken.tLBRACKET ); + end = consume( IToken.tRBRACKET ); // vector new and delete operators } - else if ( LT(1) == Token.tLPAREN && LT(2) == Token.tRPAREN ) + else if ( LT(1) == IToken.tLPAREN && LT(2) == IToken.tRPAREN ) { // operator () - consume( Token.tLPAREN ); - end = consume( Token.tRPAREN ); + consume( IToken.tLPAREN ); + end = consume( IToken.tRPAREN ); } - else if ( LT(1) == Token.tLBRACKET && LT(2) == Token.tRBRACKET ) + else if ( LT(1) == IToken.tLBRACKET && LT(2) == IToken.tRBRACKET ) { - consume( Token.tLBRACKET ); - end = consume( Token.tRBRACKET ); + consume( IToken.tLBRACKET ); + end = consume( IToken.tRBRACKET ); } else if( LA(1).isOperator() ) end = consume(); @@ -1630,7 +1638,7 @@ c, quickParse); for (;;) { switch (LT(1)) { - case Token.tLPAREN: + case IToken.tLPAREN: // temporary fix for initializer/function declaration ambiguity if( ! LA(2).looksLikeExpression() ) { @@ -1642,13 +1650,13 @@ c, quickParse); parameterDeclarationLoop: for (;;) { switch (LT(1)) { - case Token.tRPAREN: + case IToken.tRPAREN: consume(); break parameterDeclarationLoop; - case Token.tELIPSE: + case IToken.tELIPSE: consume(); break; - case Token.tCOMMA: + case IToken.tCOMMA: consume(); seenParameter = false; break; @@ -1661,39 +1669,39 @@ c, quickParse); } try{ callback.argumentsEnd(clause);} catch( Exception e ) {} - if( LT(1) == Token.tCOLON ) + if( LT(1) == IToken.tCOLON ) { // this is most likely the definition of the constructor return declarator; } // const-volatile marker on the method - if( LT(1) == Token.t_const || LT(1) == Token.t_volatile ) + if( LT(1) == IToken.t_const || LT(1) == IToken.t_volatile ) { try{ callback.declaratorCVModifier( declarator, consume() );} catch( Exception e ) {} } //check for throws clause here - if( LT(1) == Token.t_throw ) + if( LT(1) == IToken.t_throw ) { try{ callback.declaratorThrowsException( declarator );} catch( Exception e ) {} consume(); // throw - consume( Token.tLPAREN );// ( + consume( IToken.tLPAREN );// ( boolean done = false; while( ! done ) { switch( LT(1) ) { - case Token.tRPAREN: + case IToken.tRPAREN: consume(); done = true; break; - case Token.tIDENTIFIER: + case IToken.tIDENTIFIER: //TODO this is not exactly right - should be type-id rather than just a name name(); try{ callback.declaratorThrowExceptionName( declarator );} catch( Exception e ) {} break; - case Token.tCOMMA: + case IToken.tCOMMA: consume(); break; default: @@ -1705,34 +1713,34 @@ c, quickParse); } // check for optional pure virtual - if( LT(1) == Token.tASSIGN && LT(2) == Token.tINTEGER && LA(2).getImage().equals( "0") ) + if( LT(1) == IToken.tASSIGN && LT(2) == IToken.tINTEGER && LA(2).getImage().equals( "0") ) { - consume( Token.tASSIGN); - consume( Token.tINTEGER); + consume( IToken.tASSIGN); + consume( IToken.tINTEGER); try{ callback.declaratorPureVirtual( declarator ); } catch( Exception e ) { } } } break; - case Token.tLBRACKET: - while( LT(1) == Token.tLBRACKET ) + case IToken.tLBRACKET: + while( LT(1) == IToken.tLBRACKET ) { consume(); // eat the '[' Object array = null; try{ array = callback.arrayDeclaratorBegin( declarator ); } catch( Exception e ) {} - if( LT(1) != Token.tRBRACKET ) + if( LT(1) != IToken.tRBRACKET ) { Object expression = null; try{ expression = callback.expressionBegin( array );} catch( Exception e ) {} constantExpression(expression); try{ callback.expressionEnd( expression ); } catch( Exception e ) {} } - consume(Token.tRBRACKET); + consume(IToken.tRBRACKET); try{ callback.arrayDeclaratorEnd( array );} catch( Exception e ) {} } continue; - case Token.tCOLON: - consume( Token.tCOLON ); + case IToken.tCOLON: + consume( IToken.tCOLON ); Object bitfield = null; try{ bitfield = callback.startBitfield( declarator );} catch( Exception e ) {} Object expression = null; @@ -1747,7 +1755,7 @@ c, quickParse); break; } - if( LA(1).getType() == Token.tIDENTIFIER ) + if( LA(1).getType() == IToken.tIDENTIFIER ) { try{ callback.declaratorAbort( declarator ); } catch( Exception e ) {} declarator = null; @@ -1774,22 +1782,22 @@ c, quickParse); Object ptrOp = null; try{ ptrOp = callback.pointerOperatorBegin( owner );} catch( Exception e ) {} - if (t == Token.tAMPER) { - try{ callback.pointerOperatorType( ptrOp, consume(Token.tAMPER) ); } catch( Exception e ) {} + if (t == IToken.tAMPER) { + try{ callback.pointerOperatorType( ptrOp, consume(IToken.tAMPER) ); } catch( Exception e ) {} try{ callback.pointerOperatorEnd( ptrOp );} catch( Exception e ) {} return; } - Token mark = mark(); + IToken mark = mark(); boolean hasName = false; - if (t == Token.tIDENTIFIER || t == Token.tCOLONCOLON) + if (t == IToken.tIDENTIFIER || t == IToken.tCOLONCOLON) { name(); hasName = true; } - if (t == Token.tSTAR) { + if (t == IToken.tSTAR) { if( hasName ) try{ callback.pointerOperatorName( ptrOp );} catch( Exception e ) {} @@ -1833,23 +1841,23 @@ c, quickParse); protected void enumSpecifier( Object owner ) throws Backtrack { Object enumSpecifier = null; - Token mark = mark(); - try{ enumSpecifier = callback.enumSpecifierBegin( owner, consume( Token.t_enum ) );} catch( Exception e ) {} + IToken mark = mark(); + try{ enumSpecifier = callback.enumSpecifierBegin( owner, consume( IToken.t_enum ) );} catch( Exception e ) {} - if( LT(1) == Token.tIDENTIFIER ) + if( LT(1) == IToken.tIDENTIFIER ) { identifier(); try{ callback.enumSpecifierId( enumSpecifier );} catch( Exception e ) {} } - if( LT(1) == Token.tLBRACE ) + if( LT(1) == IToken.tLBRACE ) { - consume( Token.tLBRACE ); + consume( IToken.tLBRACE ); - while( LT(1) != Token.tRBRACE ) + while( LT(1) != IToken.tRBRACE ) { Object defn; - if( LT(1) == Token.tIDENTIFIER ) + if( LT(1) == IToken.tIDENTIFIER ) { defn = null; try{ defn = callback.enumeratorBegin( enumSpecifier );} catch( Exception e ) {} @@ -1862,9 +1870,9 @@ c, quickParse); throw backtrack; } - if( LT(1) == Token.tASSIGN ) + if( LT(1) == IToken.tASSIGN ) { - consume( Token.tASSIGN ); + consume( IToken.tASSIGN ); Object expression = null; try{ expression = callback.expressionBegin( defn );} catch( Exception e ) {} constantExpression( expression ); @@ -1873,18 +1881,18 @@ c, quickParse); try{ callback.enumeratorEnd( defn, lastToken );} catch( Exception e ) {} - if( LT(1) == Token.tRBRACE ) + if( LT(1) == IToken.tRBRACE ) break; - if( LT(1) != Token.tCOMMA ) + if( LT(1) != IToken.tCOMMA ) { try{ callback.enumSpecifierAbort( enumSpecifier );} catch( Exception e ) {} throw backtrack; } - consume(Token.tCOMMA); + consume(IToken.tCOMMA); } - try{ callback.enumSpecifierEnd( enumSpecifier, consume( Token.tRBRACE ) );} catch( Exception e ) {} + try{ callback.enumSpecifierEnd( enumSpecifier, consume( IToken.tRBRACE ) );} catch( Exception e ) {} } else { @@ -1904,16 +1912,28 @@ c, quickParse); * @param owner IParserCallback object that represents the declaration that owns this classSpecifier * @throws Backtrack request a backtrack */ - protected void classSpecifier( Object owner ) throws Backtrack { - Token classKey = null; + protected void classSpecifier( Object owner, IASTScope scope ) throws Backtrack { + ClassNameType nameType = ClassNameType.t_identifier; + ClassKind classKind = null; + AccessVisibility access = AccessVisibility.v_public; - Token mark = mark(); + IToken classKey = null; + + IToken mark = mark(); // class key switch (LT(1)) { - case Token.t_class: - case Token.t_struct: - case Token.t_union: + case IToken.t_class: classKey = consume(); + classKind = ClassKind.k_class; + access = AccessVisibility.v_private; + break; + case IToken.t_struct: + classKey = consume(); + classKind = ClassKind.k_struct; + break; + case IToken.t_union: + classKey = consume(); + classKind = ClassKind.k_union; break; default: throw backtrack; @@ -1922,13 +1942,17 @@ c, quickParse); Object classSpec = null; try{ classSpec = callback.classSpecifierBegin( owner, classKey);} catch( Exception e ){} + TokenDuple duple = null; // class name - if (LT(1) == Token.tIDENTIFIER) { - className(); + if (LT(1) == IToken.tIDENTIFIER) { + duple = className(); try{ callback.classSpecifierName(classSpec);} catch( Exception e ){} } - if( LT(1) != Token.tCOLON && LT(1) != Token.tLBRACE ) + if( duple != null && !duple.isIdentifier() ) + nameType = ClassNameType.t_template; + + if( LT(1) != IToken.tCOLON && LT(1) != IToken.tLBRACE ) { // this is not a classSpecification try{ callback.classSpecifierAbort( classSpec );} catch( Exception e ){} @@ -1937,27 +1961,39 @@ c, quickParse); throw backtrack; } + IASTClassSpecifier astClassSpecifier = astFactory.createClassSpecifier( + scope, + duple == null ? "" : duple.toString(), + classKind, + nameType, + access, + null, //TODO add TemplateDeclaration here + classKey.getOffset(), + duple == null ? 0 : duple.getFirstToken().getOffset() ); + // base clause - if (LT(1) == Token.tCOLON) { - baseSpecifier( classSpec ); + if (LT(1) == IToken.tCOLON) { + baseSpecifier( classSpec, astClassSpecifier ); } - if (LT(1) == Token.tLBRACE) { - consume(Token.tLBRACE); + if (LT(1) == IToken.tLBRACE) { + consume(IToken.tLBRACE); + + requestor.enterClassSpecifier( astClassSpecifier ); memberDeclarationLoop: - while (LT(1) != Token.tRBRACE) { - Token checkToken = LA(1); + while (LT(1) != IToken.tRBRACE) { + IToken checkToken = LA(1); switch (LT(1)) { - case Token.t_public: - case Token.t_protected: - case Token.t_private: + case IToken.t_public: + case IToken.t_protected: + case IToken.t_private: try{ callback.classMemberVisibility( classSpec, consume() );} catch( Exception e ){} - consume(Token.tCOLON); + consume(IToken.tCOLON); break; - case Token.tRBRACE: - consume(Token.tRBRACE); + case IToken.tRBRACE: + consume(IToken.tRBRACE); break memberDeclarationLoop; default: try @@ -1974,8 +2010,13 @@ c, quickParse); if (checkToken == LA(1)) errorHandling(); } + + // consume the } - try{ callback.classSpecifierEnd(classSpec, consume( Token.tRBRACE )); } catch( Exception e ) {} + IToken lastToken = consume( IToken.tRBRACE ); + try{ callback.classSpecifierEnd(classSpec, lastToken); } catch( Exception e ) {} + astClassSpecifier.setEndingOffset( lastToken.getEndOffset() ); + requestor.exitClassSpecifier(astClassSpecifier); } @@ -1994,31 +2035,46 @@ c, quickParse); * @param classSpecOwner * @throws Backtrack */ - protected void baseSpecifier( Object classSpecOwner ) throws Backtrack { - consume( Token.tCOLON ); + protected void baseSpecifier( Object classSpecOwner, IASTClassSpecifier astClassSpec ) throws Backtrack { + consume( IToken.tCOLON ); Object baseSpecifier = null; try { baseSpecifier = callback.baseSpecifierBegin( classSpecOwner ); } catch( Exception e ) {} + boolean isVirtual = false; + AccessVisibility visibility = AccessVisibility.v_public; + TokenDuple nameDuple = null; baseSpecifierLoop: for (;;) { switch (LT(1)) { - case Token.t_virtual: - consume(Token.t_virtual); + case IToken.t_virtual: + consume(IToken.t_virtual); + isVirtual = true; try{ callback.baseSpecifierVirtual( baseSpecifier, true ); } catch( Exception e ){} break; - case Token.t_public: - case Token.t_protected: - case Token.t_private: + case IToken.t_public: try { callback.baseSpecifierVisibility( baseSpecifier, consume() );} catch( Exception e ){} break; - case Token.tCOLONCOLON: - case Token.tIDENTIFIER: - name(); + case IToken.t_protected: + try { callback.baseSpecifierVisibility( baseSpecifier, consume() );} catch( Exception e ){} + visibility = AccessVisibility.v_protected; + break; + case IToken.t_private: + visibility = AccessVisibility.v_private; + try { callback.baseSpecifierVisibility( baseSpecifier, consume() );} catch( Exception e ){} + break; + case IToken.tCOLONCOLON: + case IToken.tIDENTIFIER: + nameDuple = name(); try { callback.baseSpecifierName( baseSpecifier ); } catch( Exception e ){} break; - case Token.tCOMMA: + case IToken.tCOMMA: try { + astFactory.addBaseSpecifier( astClassSpec, isVirtual, visibility, nameDuple.toString() ); + isVirtual = false; + visibility = AccessVisibility.v_public; + nameDuple = null; + callback.baseSpecifierEnd( baseSpecifier ); baseSpecifier = callback.baseSpecifierBegin( classSpecOwner ); } catch( Exception e ){} @@ -2029,6 +2085,7 @@ c, quickParse); } } try { callback.baseSpecifierEnd( baseSpecifier ); } catch( Exception e ){} + astFactory.addBaseSpecifier( astClassSpec, isVirtual, visibility, nameDuple.toString() ); } /** @@ -2049,115 +2106,115 @@ c, quickParse); protected void statement() throws Backtrack { Object expression = null; switch (LT(1)) { - case Token.t_case: + case IToken.t_case: consume(); // TODO regarding this null try{ expression = callback.expressionBegin( null ); } catch( Exception e ) {} constantExpression(expression); try{ callback.expressionEnd( expression ); } catch( Exception e ) {} - consume(Token.tCOLON); + consume(IToken.tCOLON); statement(); return; - case Token.t_default: + case IToken.t_default: consume(); - consume(Token.tCOLON); + consume(IToken.tCOLON); statement(); return; - case Token.tLBRACE: + case IToken.tLBRACE: compoundStatement(); return; - case Token.t_if: + case IToken.t_if: consume(); - consume(Token.tLPAREN); + consume(IToken.tLPAREN); condition(); - consume(Token.tRPAREN); + consume(IToken.tRPAREN); statement(); - if (LT(1) == Token.t_else) { + if (LT(1) == IToken.t_else) { consume(); statement(); } return; - case Token.t_switch: + case IToken.t_switch: consume(); - consume(Token.tLPAREN); + consume(IToken.tLPAREN); condition(); - consume(Token.tRPAREN); + consume(IToken.tRPAREN); statement(); return; - case Token.t_while: + case IToken.t_while: consume(); - consume(Token.tLPAREN); + consume(IToken.tLPAREN); condition(); - consume(Token.tRPAREN); + consume(IToken.tRPAREN); statement(); return; - case Token.t_do: + case IToken.t_do: consume(); statement(); - consume(Token.t_while); - consume(Token.tLPAREN); + consume(IToken.t_while); + consume(IToken.tLPAREN); condition(); - consume(Token.tRPAREN); + consume(IToken.tRPAREN); return; - case Token.t_for: + case IToken.t_for: consume(); - consume(Token.tLPAREN); + consume(IToken.tLPAREN); forInitStatement(); - if (LT(1) != Token.tSEMI) + if (LT(1) != IToken.tSEMI) condition(); - consume(Token.tSEMI); - if (LT(1) != Token.tRPAREN) + consume(IToken.tSEMI); + if (LT(1) != IToken.tRPAREN) { try{ expression = callback.expressionBegin( null ); } catch( Exception e ) {} //TODO get rid of NULL expression(expression); try{ callback.expressionEnd( expression );} catch( Exception e ) {} } - consume(Token.tRPAREN); + consume(IToken.tRPAREN); statement(); return; - case Token.t_break: + case IToken.t_break: consume(); - consume(Token.tSEMI); + consume(IToken.tSEMI); return; - case Token.t_continue: + case IToken.t_continue: consume(); - consume(Token.tSEMI); + consume(IToken.tSEMI); return; - case Token.t_return: + case IToken.t_return: consume(); - if (LT(1) != Token.tSEMI) + if (LT(1) != IToken.tSEMI) { try{ expression = callback.expressionBegin( null );} catch( Exception e ) {} //TODO get rid of NULL expression(expression); try{ callback.expressionEnd( expression );} catch( Exception e ) {} } - consume(Token.tSEMI); + consume(IToken.tSEMI); return; - case Token.t_goto: + case IToken.t_goto: consume(); - consume(Token.tIDENTIFIER); - consume(Token.tSEMI); + consume(IToken.tIDENTIFIER); + consume(IToken.tSEMI); return; - case Token.t_try: + case IToken.t_try: consume(); compoundStatement(); - while (LT(1) == Token.t_catch) { + while (LT(1) == IToken.t_catch) { consume(); - consume(Token.tLPAREN); + consume(IToken.tLPAREN); declaration(null); // was exceptionDeclaration - consume(Token.tRPAREN); + consume(IToken.tRPAREN); compoundStatement(); } return; - case Token.tSEMI: + case IToken.tSEMI: consume(); return; default: // can be many things: // label - if (LT(1) == Token.tIDENTIFIER && LT(2) == Token.tCOLON) { + if (LT(1) == IToken.tIDENTIFIER && LT(2) == IToken.tCOLON) { consume(); consume(); statement(); @@ -2172,7 +2229,7 @@ c, quickParse); //TODO get rid of NULL expression(expression); try{ callback.expressionEnd( expression );} catch( Exception e ) {} - consume(Token.tSEMI); + consume(IToken.tSEMI); return; } catch (Backtrack b) { } @@ -2200,8 +2257,8 @@ c, quickParse); * @throws Backtrack */ protected void compoundStatement() throws Backtrack { - consume(Token.tLBRACE); - while (LT(1) != Token.tRBRACE) + consume(IToken.tLBRACE); + while (LT(1) != IToken.tRBRACE) statement(); consume(); } @@ -2220,8 +2277,8 @@ c, quickParse); public void expression( Object expression ) throws Backtrack { assignmentExpression( expression ); - while (LT(1) == Token.tCOMMA) { - Token t = consume(); + while (LT(1) == IToken.tCOMMA) { + IToken t = consume(); assignmentExpression( expression ); try{ callback.expressionOperator(expression, t);} catch( Exception e ) {} } @@ -2232,7 +2289,7 @@ c, quickParse); * @throws Backtrack */ protected void assignmentExpression( Object expression ) throws Backtrack { - if (LT(1) == Token.t_throw) { + if (LT(1) == IToken.t_throw) { throwExpression(expression); return; } @@ -2240,18 +2297,18 @@ c, quickParse); // if the condition not taken, try assignment operators if (!conditionalExpression(expression)) { switch (LT(1)) { - case Token.tASSIGN: - case Token.tSTARASSIGN: - case Token.tDIVASSIGN: - case Token.tMODASSIGN: - case Token.tPLUSASSIGN: - case Token.tMINUSASSIGN: - case Token.tSHIFTRASSIGN: - case Token.tSHIFTLASSIGN: - case Token.tAMPERASSIGN: - case Token.tXORASSIGN: - case Token.tBITORASSIGN: - Token t = consume(); + case IToken.tASSIGN: + case IToken.tSTARASSIGN: + case IToken.tDIVASSIGN: + case IToken.tMODASSIGN: + case IToken.tPLUSASSIGN: + case IToken.tMINUSASSIGN: + case IToken.tSHIFTRASSIGN: + case IToken.tSHIFTLASSIGN: + case IToken.tAMPERASSIGN: + case IToken.tXORASSIGN: + case IToken.tBITORASSIGN: + IToken t = consume(); conditionalExpression(expression); try { callback.expressionOperator(expression, t); } catch( Exception e ) {} break; @@ -2264,7 +2321,7 @@ c, quickParse); * @throws Backtrack */ protected void throwExpression( Object expression ) throws Backtrack { - consume(Token.t_throw); + consume(IToken.t_throw); try { expression(expression); @@ -2280,10 +2337,10 @@ c, quickParse); protected boolean conditionalExpression( Object expression ) throws Backtrack { logicalOrExpression( expression ); - if (LT(1) == Token.tQUESTION) { + if (LT(1) == IToken.tQUESTION) { consume(); expression(expression); - consume(Token.tCOLON); + consume(IToken.tCOLON); assignmentExpression(expression); return true; } else @@ -2297,8 +2354,8 @@ c, quickParse); protected void logicalOrExpression( Object expression ) throws Backtrack { logicalAndExpression( expression ); - while (LT(1) == Token.tOR) { - Token t = consume(); + while (LT(1) == IToken.tOR) { + IToken t = consume(); logicalAndExpression( expression ); try{ callback.expressionOperator(expression, t);} catch( Exception e ) {} } @@ -2311,8 +2368,8 @@ c, quickParse); protected void logicalAndExpression( Object expression ) throws Backtrack { inclusiveOrExpression( expression ); - while (LT(1) == Token.tAND) { - Token t = consume(); + while (LT(1) == IToken.tAND) { + IToken t = consume(); inclusiveOrExpression(expression ); try{ callback.expressionOperator(expression, t);} catch( Exception e ) {} } @@ -2325,8 +2382,8 @@ c, quickParse); protected void inclusiveOrExpression( Object expression ) throws Backtrack { exclusiveOrExpression(expression); - while (LT(1) == Token.tBITOR) { - Token t = consume(); + while (LT(1) == IToken.tBITOR) { + IToken t = consume(); exclusiveOrExpression(expression); try{ callback.expressionOperator(expression, t);} catch( Exception e ) {} } @@ -2339,8 +2396,8 @@ c, quickParse); protected void exclusiveOrExpression( Object expression ) throws Backtrack { andExpression( expression ); - while (LT(1) == Token.tXOR) { - Token t = consume(); + while (LT(1) == IToken.tXOR) { + IToken t = consume(); andExpression(expression); try { callback.expressionOperator(expression, t);} catch( Exception e ) {} @@ -2354,8 +2411,8 @@ c, quickParse); protected void andExpression( Object expression ) throws Backtrack { equalityExpression(expression); - while (LT(1) == Token.tAMPER) { - Token t = consume(); + while (LT(1) == IToken.tAMPER) { + IToken t = consume(); equalityExpression(expression); try{ callback.expressionOperator(expression, t); } catch( Exception e ) {} @@ -2372,9 +2429,9 @@ c, quickParse); for (;;) { switch (LT(1)) { - case Token.tEQUAL: - case Token.tNOTEQUAL: - Token t = consume(); + case IToken.tEQUAL: + case IToken.tNOTEQUAL: + IToken t = consume(); relationalExpression(expression); try{ callback.expressionOperator(expression, t);} catch( Exception e ) {} break; @@ -2393,16 +2450,16 @@ c, quickParse); for (;;) { switch (LT(1)) { - case Token.tGT: + case IToken.tGT: // For template args, the GT means end of args //if (templateArgs) // return; - case Token.tLT: - case Token.tLTEQUAL: - case Token.tGTEQUAL: - Token mark = mark(); - Token t = consume(); - Token next = LA(1); + case IToken.tLT: + case IToken.tLTEQUAL: + case IToken.tGTEQUAL: + IToken mark = mark(); + IToken t = consume(); + IToken next = LA(1); shiftExpression(expression); if( next == LA(1) ) { @@ -2432,9 +2489,9 @@ c, quickParse); for (;;) { switch (LT(1)) { - case Token.tSHIFTL: - case Token.tSHIFTR: - Token t = consume(); + case IToken.tSHIFTL: + case IToken.tSHIFTR: + IToken t = consume(); additiveExpression(expression); try{ callback.expressionOperator(expression, t);} catch( Exception e ) {} break; @@ -2453,9 +2510,9 @@ c, quickParse); for (;;) { switch (LT(1)) { - case Token.tPLUS: - case Token.tMINUS: - Token t = consume(); + case IToken.tPLUS: + case IToken.tMINUS: + IToken t = consume(); multiplicativeExpression(expression); try { callback.expressionOperator(expression, t); } catch( Exception e ) {} break; @@ -2474,10 +2531,10 @@ c, quickParse); for (;;) { switch (LT(1)) { - case Token.tSTAR: - case Token.tDIV: - case Token.tMOD: - Token t = consume(); + case IToken.tSTAR: + case IToken.tDIV: + case IToken.tMOD: + IToken t = consume(); pmExpression(expression ); try{ callback.expressionOperator(expression , t);} catch( Exception e ) {} break; @@ -2496,9 +2553,9 @@ c, quickParse); for (;;) { switch (LT(1)) { - case Token.tDOTSTAR: - case Token.tARROWSTAR: - Token t = consume(); + case IToken.tDOTSTAR: + case IToken.tARROWSTAR: + IToken t = consume(); castExpression( expression ); try{ callback.expressionOperator(expression, t);} catch( Exception e ) {} break; @@ -2515,20 +2572,20 @@ c, quickParse); */ protected void castExpression( Object expression ) throws Backtrack { // TO DO: we need proper symbol checkint to ensure type name - if (LT(1) == Token.tLPAREN) { - Token mark = mark(); + if (LT(1) == IToken.tLPAREN) { + IToken mark = mark(); consume(); // If this isn't a type name, then we shouldn't be here try { - if( LT(1) == Token.t_const ) consume(); + if( LT(1) == IToken.t_const ) consume(); typeId(); - while( LT(1) == Token.tSTAR ) + while( LT(1) == IToken.tSTAR ) { - consume( Token.tSTAR ); - if( LT(1) == Token.t_const || LT(1) == Token.t_volatile ) consume(); + consume( IToken.tSTAR ); + if( LT(1) == IToken.t_const || LT(1) == IToken.t_volatile ) consume(); } - consume(Token.tRPAREN); + consume(IToken.tRPAREN); castExpression( expression ); return; } catch (Backtrack b) { @@ -2547,33 +2604,33 @@ c, quickParse); name(); return; } catch (Backtrack b) { - Token begin = LA(1); - Token end = null; + IToken begin = LA(1); + IToken end = null; simpleMods: for( ; ; ) { switch( LT(1) ) { - case Token.t_short: - case Token.t_unsigned: - case Token.t_long: - case Token.t_const: + case IToken.t_short: + case IToken.t_unsigned: + case IToken.t_long: + case IToken.t_const: end = consume(); break; - case Token.tAMPER: - case Token.tSTAR: - case Token.tIDENTIFIER: + case IToken.tAMPER: + case IToken.tSTAR: + case IToken.tIDENTIFIER: if( end == null ) throw backtrack; end = consume(); break; - case Token.t_int: - case Token.t_char: - case Token.t_bool: - case Token.t_double: - case Token.t_float: - case Token.t_wchar_t: - case Token.t_void: + case IToken.t_int: + case IToken.t_char: + case IToken.t_bool: + case IToken.t_double: + case IToken.t_float: + case IToken.t_wchar_t: + case IToken.t_void: end = consume(); default: break simpleMods; @@ -2587,9 +2644,9 @@ c, quickParse); callback.nameEnd( end ); } catch( Exception e ) {} } - else if( LT(1) == Token.t_typename ) + else if( LT(1) == IToken.t_typename ) { - consume( Token.t_typename ); + consume( IToken.t_typename ); name(); } else @@ -2602,17 +2659,17 @@ c, quickParse); * @throws Backtrack */ protected void deleteExpression( Object expression ) throws Backtrack { - if (LT(1) == Token.tCOLONCOLON) { + if (LT(1) == IToken.tCOLONCOLON) { // global scope consume(); } - consume(Token.t_delete); + consume(IToken.t_delete); - if (LT(1) == Token.tLBRACKET) { + if (LT(1) == IToken.tLBRACKET) { // array delete consume(); - consume(Token.tRBRACKET); + consume(IToken.tRBRACKET); } castExpression( expression ); @@ -2635,34 +2692,34 @@ c, quickParse); * newinitializer: ( expressionlist? ) */ protected void newExpression( Object expression ) throws Backtrack { - if (LT(1) == Token.tCOLONCOLON) { + if (LT(1) == IToken.tCOLONCOLON) { // global scope consume(); } - consume (Token.t_new); + consume (IToken.t_new); boolean typeIdInParen = false; boolean placementParseFailure = true; - Token beforeSecondParen = null; - Token backtrackMarker = null; + IToken beforeSecondParen = null; + IToken backtrackMarker = null; - if( LT(1) == Token.tLPAREN ) + if( LT(1) == IToken.tLPAREN ) { - consume( Token.tLPAREN ); + consume( IToken.tLPAREN ); try { // Try to consume placement list // Note: since expressionList and expression are the same... backtrackMarker = mark(); expression(expression); - consume( Token.tRPAREN ); + consume( IToken.tRPAREN ); placementParseFailure = false; - if( LT(1) == Token.tLPAREN ) { + if( LT(1) == IToken.tLPAREN ) { beforeSecondParen = mark(); - consume( Token.tLPAREN ); + consume( IToken.tLPAREN ); typeIdInParen = true; } } catch (Backtrack e) { @@ -2674,10 +2731,10 @@ c, quickParse); // the first expression in () is not a placement // - then it has to be typeId typeId(); - consume(Token.tRPAREN); + consume(IToken.tRPAREN); } else { if (!typeIdInParen) { - if (LT(1) == Token.tLBRACKET) { + if (LT(1) == IToken.tLBRACKET) { // CASE: new (typeid-looking-as-placement) [expr]... // the first expression in () has been parsed as a placement; // however, we assume that it was in fact typeId, and this @@ -2701,9 +2758,9 @@ c, quickParse); // The problem is, the first expression might as well be a typeid try { typeId(); - consume(Token.tRPAREN); + consume(IToken.tRPAREN); - if (LT(1) == Token.tLPAREN || LT(1) == Token.tLBRACKET) { + if (LT(1) == IToken.tLPAREN || LT(1) == IToken.tLBRACKET) { // CASE: new (placement)(typeid)(initializer) // CASE: new (placement)(typeid)[] ... // Great, so far all our assumptions have been correct @@ -2730,20 +2787,20 @@ c, quickParse); typeId(); } - while (LT(1) == Token.tLBRACKET) { + while (LT(1) == IToken.tLBRACKET) { // array new consume(); assignmentExpression(expression); - consume(Token.tRBRACKET); + consume(IToken.tRBRACKET); } // newinitializer - if( LT(1) == Token.tLPAREN ) + if( LT(1) == IToken.tLPAREN ) { - consume( Token.tLPAREN ); - if( LT(1) != Token.tRPAREN ) + consume( IToken.tLPAREN ); + if( LT(1) != IToken.tRPAREN ) expression( expression ); - consume( Token.tRPAREN ); + consume( IToken.tRPAREN ); } } @@ -2754,27 +2811,27 @@ c, quickParse); */ protected void unaryExpression( Object expression ) throws Backtrack { switch (LT(1)) { - case Token.tSTAR: - case Token.tAMPER: - case Token.tPLUS: - case Token.tMINUS: - case Token.tNOT: - case Token.tCOMPL: - case Token.tINCR: - case Token.tDECR: - Token t = consume(); + case IToken.tSTAR: + case IToken.tAMPER: + case IToken.tPLUS: + case IToken.tMINUS: + case IToken.tNOT: + case IToken.tCOMPL: + case IToken.tINCR: + case IToken.tDECR: + IToken t = consume(); castExpression(expression); try{ callback.expressionOperator(expression, t);} catch( Exception e ) {} return; - case Token.t_sizeof: - consume(Token.t_sizeof); - Token mark = LA(1); - if (LT(1) == Token.tLPAREN) { + case IToken.t_sizeof: + consume(IToken.t_sizeof); + IToken mark = LA(1); + if (LT(1) == IToken.tLPAREN) { try { - consume( Token.tLPAREN ); + consume( IToken.tLPAREN ); typeId(); - consume(Token.tRPAREN); + consume(IToken.tRPAREN); } catch( Backtrack bt ) { @@ -2785,18 +2842,18 @@ c, quickParse); unaryExpression( expression ); } return; - case Token.t_new: + case IToken.t_new: newExpression( expression ); return; - case Token.t_delete: + case IToken.t_delete: deleteExpression( expression ); return; - case Token.tCOLONCOLON: + case IToken.tCOLONCOLON: switch (LT(2)) { - case Token.t_new: + case IToken.t_new: newExpression(expression); return; - case Token.t_delete: + case IToken.t_delete: deleteExpression(expression); return; default: @@ -2815,54 +2872,54 @@ c, quickParse); */ protected void postfixExpression( Object expression) throws Backtrack { switch (LT(1)) { - case Token.t_typename: + case IToken.t_typename: consume(); // TO DO: this break; // simple-type-specifier ( assignment-expression , .. ) - case Token.t_char: - case Token.t_wchar_t: - case Token.t_bool: - case Token.t_short: - case Token.t_int: - case Token.t_long: - case Token.t_signed: - case Token.t_unsigned: - case Token.t_float: - case Token.t_double: + case IToken.t_char: + case IToken.t_wchar_t: + case IToken.t_bool: + case IToken.t_short: + case IToken.t_int: + case IToken.t_long: + case IToken.t_signed: + case IToken.t_unsigned: + case IToken.t_float: + case IToken.t_double: consume(); - consume( Token.tLPAREN ); + consume( IToken.tLPAREN ); while( true ) { assignmentExpression( expression ); - if( LT(1) == Token.tRPAREN ) break; - consume( Token.tCOMMA ); + if( LT(1) == IToken.tRPAREN ) break; + consume( IToken.tCOMMA ); } - consume( Token.tRPAREN ); + consume( IToken.tRPAREN ); break; - case Token.t_dynamic_cast: - case Token.t_static_cast: - case Token.t_reinterpret_cast: - case Token.t_const_cast: + case IToken.t_dynamic_cast: + case IToken.t_static_cast: + case IToken.t_reinterpret_cast: + case IToken.t_const_cast: consume(); - consume(Token.tLT); + consume(IToken.tLT); typeId(); - consume(Token.tGT); - consume(Token.tLPAREN); + consume(IToken.tGT); + consume(IToken.tLPAREN); expression(expression); - consume(Token.tRPAREN); + consume(IToken.tRPAREN); break; - case Token.t_typeid: + case IToken.t_typeid: consume(); - consume(Token.tLPAREN); + consume(IToken.tLPAREN); try { typeId(); } catch (Backtrack b) { expression(expression); } - consume(Token.tRPAREN); + consume(IToken.tRPAREN); break; default: // TO DO: try simpleTypeSpecifier "(" expressionList ")" @@ -2871,26 +2928,26 @@ c, quickParse); for (;;) { switch (LT(1)) { - case Token.tLBRACKET: + case IToken.tLBRACKET: // array access consume(); expression(expression); - consume(Token.tRBRACKET); + consume(IToken.tRBRACKET); break; - case Token.tLPAREN: + case IToken.tLPAREN: // function call consume(); // Note: since expressionList and expression are the same... expression(expression); - consume(Token.tRPAREN); + consume(IToken.tRPAREN); break; - case Token.tINCR: - case Token.tDECR: + case IToken.tINCR: + case IToken.tDECR: // post incr/decr consume(); break; - case Token.tDOT: - case Token.tARROW: + case IToken.tDOT: + case IToken.tARROW: // member access consume(); primaryExpression(expression); @@ -2909,27 +2966,27 @@ c, quickParse); int type = LT(1); switch (type) { // TO DO: we need more literals... - case Token.tINTEGER: - case Token.tFLOATINGPT: - case Token.tSTRING: - case Token.tLSTRING: - case Token.t_false: - case Token.t_true: - case Token.tCHAR: + case IToken.tINTEGER: + case IToken.tFLOATINGPT: + case IToken.tSTRING: + case IToken.tLSTRING: + case IToken.t_false: + case IToken.t_true: + case IToken.tCHAR: try{ callback.expressionTerminal(expression, consume());} catch( Exception e ) {} return; - case Token.tIDENTIFIER: + case IToken.tIDENTIFIER: name(); try{ callback.expressionName(expression);} catch( Exception e ) {} return; - case Token.t_this: + case IToken.t_this: consume(); return; - case Token.tLPAREN: + case IToken.tLPAREN: consume(); expression(expression); - consume(Token.tRPAREN); + consume(IToken.tRPAREN); return; default: // TO DO: idExpression which yeilds a variable @@ -2942,22 +2999,22 @@ c, quickParse); * @throws Exception */ protected void varName() throws Exception { - if (LT(1) == Token.tCOLONCOLON) + if (LT(1) == IToken.tCOLONCOLON) consume(); for (;;) { switch (LT(1)) { - case Token.tIDENTIFIER: + case IToken.tIDENTIFIER: consume(); //if (isTemplateArgs()) { // rTemplateArgs(); //} - if (LT(1) == Token.tCOLONCOLON) { + if (LT(1) == IToken.tCOLONCOLON) { switch (LT(2)) { - case Token.tIDENTIFIER: - case Token.tCOMPL: - case Token.t_operator: + case IToken.tIDENTIFIER: + case IToken.tCOMPL: + case IToken.t_operator: consume(); break; default: @@ -2966,11 +3023,11 @@ c, quickParse); } else return; break; - case Token.tCOMPL: + case IToken.tCOMPL: consume(); - consume(Token.tIDENTIFIER); + consume(IToken.tIDENTIFIER); return; - case Token.t_operator: + case IToken.t_operator: consume(); //rOperatorName(); return; @@ -3002,7 +3059,7 @@ c, quickParse); // Token management private IScanner scanner; - private Token currToken, // current token we plan to consume next + private IToken currToken, // current token we plan to consume next lastToken; // last token we consumed /** @@ -3011,7 +3068,7 @@ c, quickParse); * @return the next token from the scanner * @throws EndOfFile thrown when the scanner.nextToken() yields no tokens */ - private Token fetchToken() throws EndOfFile { + private IToken fetchToken() throws EndOfFile { try { return scanner.nextToken(); } catch (EndOfFile e) { @@ -3029,7 +3086,7 @@ c, quickParse); * @return the token you wish to observe * @throws EndOfFile if looking ahead encounters EOF, throw EndOfFile */ - protected Token LA(int i) throws EndOfFile { + protected IToken LA(int i) throws EndOfFile { if (i < 1) // can't go backwards return null; @@ -3037,7 +3094,7 @@ c, quickParse); if (currToken == null) currToken = fetchToken(); - Token retToken = currToken; + IToken retToken = currToken; for (; i > 1; --i) { retToken = retToken.getNext(); @@ -3056,7 +3113,7 @@ c, quickParse); * @throws EndOfFile if looking ahead encounters EOF, throw EndOfFile */ protected int LT(int i) throws EndOfFile { - return LA(i).type; + return LA(i).getType(); } /** @@ -3065,7 +3122,7 @@ c, quickParse); * @return The token that was consumed and removed from our buffer. * @throws EndOfFile If there is no token to consume. */ - protected Token consume() throws EndOfFile { + protected IToken consume() throws EndOfFile { if (currToken == null) currToken = fetchToken(); @@ -3083,7 +3140,7 @@ c, quickParse); * @return the token that was consumed and removed from our buffer. * @throws Backtrack If LT(1) != type */ - protected Token consume(int type) throws Backtrack { + protected IToken consume(int type) throws Backtrack { if (LT(1) == type) return consume(); else @@ -3096,7 +3153,7 @@ c, quickParse); * @return The current token. * @throws EndOfFile If there are no more tokens. */ - protected Token mark() throws EndOfFile { + protected IToken mark() throws EndOfFile { if (currToken == null) currToken = fetchToken(); return currToken; @@ -3108,8 +3165,8 @@ c, quickParse); * @param mark The point that we wish to restore to. * */ - protected void backup(Token mark) { - currToken = mark; + protected void backup(IToken mark) { + currToken = (Token)mark; lastToken = null; // this is not entirely right ... } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ParserException.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ParserException.java index 90246f0a00d..95836fe8736 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ParserException.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ParserException.java @@ -10,9 +10,11 @@ ******************************************************************************/ package org.eclipse.cdt.internal.core.parser; +import org.eclipse.cdt.core.parser.IToken; + public class ParserException extends Exception { - public ParserException(Token t) { + public ParserException(IToken t) { } public ParserException( String msg ) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java index d4daad8e5b8..b666d8f6fca 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java @@ -24,13 +24,19 @@ import java.util.List; import java.util.StringTokenizer; import java.util.Vector; +import org.eclipse.cdt.core.parser.IMacroDescriptor; import org.eclipse.cdt.core.parser.IParser; +import org.eclipse.cdt.core.parser.IParserCallback; import org.eclipse.cdt.core.parser.IScanner; +import org.eclipse.cdt.core.parser.IScannerContext; import org.eclipse.cdt.core.parser.ISourceElementRequestor; +import org.eclipse.cdt.core.parser.IToken; +import org.eclipse.cdt.core.parser.ScannerException; import org.eclipse.cdt.core.parser.ast.IASTFactory; import org.eclipse.cdt.core.parser.ast.IASTInclusion; import org.eclipse.cdt.core.parser.ast.IASTMacro; + /** * @author jcamelon * @@ -474,7 +480,7 @@ public class Scanner implements IScanner { - public Token nextToken() throws ScannerException, Parser.EndOfFile { + public IToken nextToken() throws ScannerException, Parser.EndOfFile { return nextToken( true ); } @@ -559,7 +565,7 @@ public class Scanner implements IScanner { if (c != NOCHAR ) { - int type = wideString ? Token.tLSTRING : Token.tSTRING; + int type = wideString ? IToken.tLSTRING : IToken.tSTRING; //If the next token is going to be a string as well, we need to concatenate //it with this token. @@ -618,7 +624,7 @@ public class Scanner implements IScanner { String ident = buff.toString(); if (ident.equals(DEFINED)) - return newToken(Token.tINTEGER, handleDefinedMacro()); + return newToken(IToken.tINTEGER, handleDefinedMacro()); Object mapping = definitions.get(ident); @@ -637,7 +643,7 @@ public class Scanner implements IScanner { else tokenTypeObject = cKeywords.get(ident); - int tokenType = Token.tIDENTIFIER; + int tokenType = IToken.tIDENTIFIER; if (tokenTypeObject != null) tokenType = ((Integer) tokenTypeObject).intValue(); @@ -693,15 +699,15 @@ public class Scanner implements IScanner { //if pasting, there could actually be a float here instead of just a . if( buff.toString().equals( "." ) ){ if( c == '*' ){ - return newToken( Token.tDOTSTAR, ".*", contextStack.getCurrentContext() ); + return newToken( IToken.tDOTSTAR, ".*", contextStack.getCurrentContext() ); } else if( c == '.' ){ if( getChar() == '.' ) - return newToken( Token.tELIPSE, "..." ); + return newToken( IToken.tELIPSE, "..." ); else throw new ScannerException( "Invalid floating point @ offset " + contextStack.getCurrentContext().getOffset() ); } else { ungetChar( c ); - return newToken( Token.tDOT, ".", contextStack.getCurrentContext() ); + return newToken( IToken.tDOT, ".", contextStack.getCurrentContext() ); } } } else if (c == 'x') { @@ -806,9 +812,9 @@ public class Scanner implements IScanner { String result = buff.toString(); if( floatingPoint && result.equals(".") ) - tokenType = Token.tDOT; + tokenType = IToken.tDOT; else - tokenType = floatingPoint ? Token.tFLOATINGPT : Token.tINTEGER; + tokenType = floatingPoint ? IToken.tFLOATINGPT : IToken.tINTEGER; return newToken( tokenType, @@ -1022,11 +1028,11 @@ public class Scanner implements IScanner { c = next; next = getChar( true ); if( next == '\'' ) - return newToken( Token.tCHAR, '\\' + new Character( (char)c ).toString(), contextStack.getCurrentContext() ); + return newToken( IToken.tCHAR, '\\' + new Character( (char)c ).toString(), contextStack.getCurrentContext() ); else if( throwExceptionOnBadCharacterRead ) throw new ScannerException( "Invalid character '" + (char)c + "' read @ offset " + contextStack.getCurrentContext().getOffset() + " of file " + contextStack.getCurrentContext().getFilename() ); } else if( next == '\'' ) - return newToken( Token.tCHAR, new Character( (char)c ).toString(), contextStack.getCurrentContext() ); + return newToken( IToken.tCHAR, new Character( (char)c ).toString(), contextStack.getCurrentContext() ); else if( throwExceptionOnBadCharacterRead ) throw new ScannerException( "Invalid character '" + (char)c + "' read @ offset " + contextStack.getCurrentContext().getOffset() + " of file " + contextStack.getCurrentContext().getFilename() ); @@ -1035,51 +1041,51 @@ public class Scanner implements IScanner { switch (c) { case ':' : return newToken( - Token.tCOLONCOLON, + IToken.tCOLONCOLON, "::", contextStack.getCurrentContext()); default : ungetChar(c); return newToken( - Token.tCOLON, + IToken.tCOLON, ":", contextStack.getCurrentContext()); } case ';' : - return newToken(Token.tSEMI, ";", contextStack.getCurrentContext()); + return newToken(IToken.tSEMI, ";", contextStack.getCurrentContext()); case ',' : - return newToken(Token.tCOMMA, ",", contextStack.getCurrentContext()); + return newToken(IToken.tCOMMA, ",", contextStack.getCurrentContext()); case '?' : - return newToken(Token.tQUESTION, "?", contextStack.getCurrentContext()); + return newToken(IToken.tQUESTION, "?", contextStack.getCurrentContext()); case '(' : - return newToken(Token.tLPAREN, "(", contextStack.getCurrentContext()); + return newToken(IToken.tLPAREN, "(", contextStack.getCurrentContext()); case ')' : - return newToken(Token.tRPAREN, ")", contextStack.getCurrentContext()); + return newToken(IToken.tRPAREN, ")", contextStack.getCurrentContext()); case '[' : - return newToken(Token.tLBRACKET, "[", contextStack.getCurrentContext()); + return newToken(IToken.tLBRACKET, "[", contextStack.getCurrentContext()); case ']' : - return newToken(Token.tRBRACKET, "]", contextStack.getCurrentContext()); + return newToken(IToken.tRBRACKET, "]", contextStack.getCurrentContext()); case '{' : - return newToken(Token.tLBRACE, "{", contextStack.getCurrentContext()); + return newToken(IToken.tLBRACE, "{", contextStack.getCurrentContext()); case '}' : - return newToken(Token.tRBRACE, "}", contextStack.getCurrentContext()); + return newToken(IToken.tRBRACE, "}", contextStack.getCurrentContext()); case '+' : c = getChar(); switch (c) { case '=' : return newToken( - Token.tPLUSASSIGN, + IToken.tPLUSASSIGN, "+=", contextStack.getCurrentContext()); case '+' : return newToken( - Token.tINCR, + IToken.tINCR, "++", contextStack.getCurrentContext()); default : ungetChar(c); return newToken( - Token.tPLUS, + IToken.tPLUS, "+", contextStack.getCurrentContext()); } @@ -1088,12 +1094,12 @@ public class Scanner implements IScanner { switch (c) { case '=' : return newToken( - Token.tMINUSASSIGN, + IToken.tMINUSASSIGN, "-=", contextStack.getCurrentContext()); case '-' : return newToken( - Token.tDECR, + IToken.tDECR, "--", contextStack.getCurrentContext()); case '>' : @@ -1101,20 +1107,20 @@ public class Scanner implements IScanner { switch (c) { case '*' : return newToken( - Token.tARROWSTAR, + IToken.tARROWSTAR, "->*", contextStack.getCurrentContext()); default : ungetChar(c); return newToken( - Token.tARROW, + IToken.tARROW, "->", contextStack.getCurrentContext()); } default : ungetChar(c); return newToken( - Token.tMINUS, + IToken.tMINUS, "-", contextStack.getCurrentContext()); } @@ -1123,13 +1129,13 @@ public class Scanner implements IScanner { switch (c) { case '=' : return newToken( - Token.tSTARASSIGN, + IToken.tSTARASSIGN, "*=", contextStack.getCurrentContext()); default : ungetChar(c); return newToken( - Token.tSTAR, + IToken.tSTAR, "*", contextStack.getCurrentContext()); } @@ -1138,13 +1144,13 @@ public class Scanner implements IScanner { switch (c) { case '=' : return newToken( - Token.tMODASSIGN, + IToken.tMODASSIGN, "%=", contextStack.getCurrentContext()); default : ungetChar(c); return newToken( - Token.tMOD, + IToken.tMOD, "%", contextStack.getCurrentContext()); } @@ -1153,13 +1159,13 @@ public class Scanner implements IScanner { switch (c) { case '=' : return newToken( - Token.tXORASSIGN, + IToken.tXORASSIGN, "^=", contextStack.getCurrentContext()); default : ungetChar(c); return newToken( - Token.tXOR, + IToken.tXOR, "^", contextStack.getCurrentContext()); } @@ -1168,18 +1174,18 @@ public class Scanner implements IScanner { switch (c) { case '=' : return newToken( - Token.tAMPERASSIGN, + IToken.tAMPERASSIGN, "&=", contextStack.getCurrentContext()); case '&' : return newToken( - Token.tAND, + IToken.tAND, "&&", contextStack.getCurrentContext()); default : ungetChar(c); return newToken( - Token.tAMPER, + IToken.tAMPER, "&", contextStack.getCurrentContext()); } @@ -1188,35 +1194,35 @@ public class Scanner implements IScanner { switch (c) { case '=' : return newToken( - Token.tBITORASSIGN, + IToken.tBITORASSIGN, "|=", contextStack.getCurrentContext()); case '|' : return newToken( - Token.tOR, + IToken.tOR, "||", contextStack.getCurrentContext()); default : ungetChar(c); return newToken( - Token.tBITOR, + IToken.tBITOR, "|", contextStack.getCurrentContext()); } case '~' : - return newToken(Token.tCOMPL, "~", contextStack.getCurrentContext()); + return newToken(IToken.tCOMPL, "~", contextStack.getCurrentContext()); case '!' : c = getChar(); switch (c) { case '=' : return newToken( - Token.tNOTEQUAL, + IToken.tNOTEQUAL, "!=", contextStack.getCurrentContext()); default : ungetChar(c); return newToken( - Token.tNOT, + IToken.tNOT, "!", contextStack.getCurrentContext()); } @@ -1225,13 +1231,13 @@ public class Scanner implements IScanner { switch (c) { case '=' : return newToken( - Token.tEQUAL, + IToken.tEQUAL, "==", contextStack.getCurrentContext()); default : ungetChar(c); return newToken( - Token.tASSIGN, + IToken.tASSIGN, "=", contextStack.getCurrentContext()); } @@ -1243,24 +1249,24 @@ public class Scanner implements IScanner { switch (c) { case '=' : return newToken( - Token.tSHIFTLASSIGN, + IToken.tSHIFTLASSIGN, "<<=", contextStack.getCurrentContext()); default : ungetChar(c); return newToken( - Token.tSHIFTL, + IToken.tSHIFTL, "<<", contextStack.getCurrentContext()); } case '=' : return newToken( - Token.tLTEQUAL, + IToken.tLTEQUAL, "<=", contextStack.getCurrentContext()); default : ungetChar(c); - return newToken(Token.tLT, "<", contextStack.getCurrentContext()); + return newToken(IToken.tLT, "<", contextStack.getCurrentContext()); } case '>' : c = getChar(); @@ -1270,24 +1276,24 @@ public class Scanner implements IScanner { switch (c) { case '=' : return newToken( - Token.tSHIFTRASSIGN, + IToken.tSHIFTRASSIGN, ">>=", contextStack.getCurrentContext()); default : ungetChar(c); return newToken( - Token.tSHIFTR, + IToken.tSHIFTR, ">>", contextStack.getCurrentContext()); } case '=' : return newToken( - Token.tGTEQUAL, + IToken.tGTEQUAL, ">=", contextStack.getCurrentContext()); default : ungetChar(c); - return newToken(Token.tGT, ">", contextStack.getCurrentContext()); + return newToken(IToken.tGT, ">", contextStack.getCurrentContext()); } case '.' : c = getChar(); @@ -1297,7 +1303,7 @@ public class Scanner implements IScanner { switch (c) { case '.' : return newToken( - Token.tELIPSE, + IToken.tELIPSE, "...", contextStack.getCurrentContext()); default : @@ -1306,13 +1312,13 @@ public class Scanner implements IScanner { break; case '*' : return newToken( - Token.tDOTSTAR, + IToken.tDOTSTAR, ".*", contextStack.getCurrentContext()); default : ungetChar(c); return newToken( - Token.tDOT, + IToken.tDOT, ".", contextStack.getCurrentContext()); } @@ -1331,13 +1337,13 @@ public class Scanner implements IScanner { continue; case '=' : return newToken( - Token.tDIVASSIGN, + IToken.tDIVASSIGN, "/=", contextStack.getCurrentContext()); default : ungetChar(c); return newToken( - Token.tDIV, + IToken.tDIV, "/", contextStack.getCurrentContext()); } @@ -1371,7 +1377,7 @@ public class Scanner implements IScanner { // the static instance we always use protected static endOfMacroTokenException endOfMacroToken = new endOfMacroTokenException(); - protected Token nextTokenForStringizing() throws ScannerException, Parser.EndOfFile + protected IToken nextTokenForStringizing() throws ScannerException, Parser.EndOfFile { int c = getChar(); StringBuffer tokenImage = new StringBuffer(); @@ -1407,7 +1413,7 @@ public class Scanner implements IScanner { if (c != NOCHAR ) { - return newToken( Token.tSTRING, buff.toString(), contextStack.getCurrentContext()); + return newToken( IToken.tSTRING, buff.toString(), contextStack.getCurrentContext()); } else { if (throwExceptionOnUnboundedString) @@ -1425,23 +1431,23 @@ public class Scanner implements IScanner { c = next; next = getChar( true ); if( next == '\'' ) - return newToken( Token.tCHAR, '\\' + new Character( (char)c ).toString(), contextStack.getCurrentContext() ); + return newToken( IToken.tCHAR, '\\' + new Character( (char)c ).toString(), contextStack.getCurrentContext() ); else if( throwExceptionOnBadCharacterRead ) throw new ScannerException( "Invalid character '" + (char)c + "' read @ offset " + contextStack.getCurrentContext().getOffset() + " of file " + contextStack.getCurrentContext().getFilename() ); } else if( next == '\'' ) - return newToken( Token.tCHAR, new Character( (char)c ).toString(), contextStack.getCurrentContext() ); + return newToken( IToken.tCHAR, new Character( (char)c ).toString(), contextStack.getCurrentContext() ); else if( throwExceptionOnBadCharacterRead ) throw new ScannerException( "Invalid character '" + (char)c + "' read @ offset " + contextStack.getCurrentContext().getOffset() + " of file " + contextStack.getCurrentContext().getFilename() ); case ',' : if (tokenImage.length() > 0) throw endOfMacroToken; - return newToken(Token.tCOMMA, ",", contextStack.getCurrentContext()); + return newToken(IToken.tCOMMA, ",", contextStack.getCurrentContext()); case '(' : if (tokenImage.length() > 0) throw endOfMacroToken; - return newToken(Token.tLPAREN, "(", contextStack.getCurrentContext()); + return newToken(IToken.tLPAREN, "(", contextStack.getCurrentContext()); case ')' : if (tokenImage.length() > 0) throw endOfMacroToken; - return newToken(Token.tRPAREN, ")", contextStack.getCurrentContext()); + return newToken(IToken.tRPAREN, ")", contextStack.getCurrentContext()); case '/' : if (tokenImage.length() > 0) throw endOfMacroToken; c = getChar(); @@ -1472,7 +1478,7 @@ public class Scanner implements IScanner { // return completed token if (tokenImage.length() > 0) { - return newToken(Token.tIDENTIFIER, tokenImage.toString(), contextStack.getCurrentContext()); + return newToken(IToken.tIDENTIFIER, tokenImage.toString(), contextStack.getCurrentContext()); } // we're done @@ -1481,80 +1487,80 @@ public class Scanner implements IScanner { static { - cppKeywords.put("and", new Integer(Token.t_and)); - cppKeywords.put("and_eq", new Integer(Token.t_and_eq)); - cppKeywords.put("asm", new Integer(Token.t_asm)); - cppKeywords.put("auto", new Integer(Token.t_auto)); - cppKeywords.put("bitand", new Integer(Token.t_bitand)); - cppKeywords.put("bitor", new Integer(Token.t_bitor)); - cppKeywords.put("bool", new Integer(Token.t_bool)); - cppKeywords.put("break", new Integer(Token.t_break)); - cppKeywords.put("case", new Integer(Token.t_case)); - cppKeywords.put("catch", new Integer(Token.t_catch)); - cppKeywords.put("char", new Integer(Token.t_char)); - cppKeywords.put("class", new Integer(Token.t_class)); - cppKeywords.put("compl", new Integer(Token.t_compl)); - cppKeywords.put("const", new Integer(Token.t_const)); - cppKeywords.put("const_cast", new Integer(Token.t_const_cast)); - cppKeywords.put("continue", new Integer(Token.t_continue)); - cppKeywords.put("default", new Integer(Token.t_default)); - cppKeywords.put("delete", new Integer(Token.t_delete)); - cppKeywords.put("do", new Integer(Token.t_do)); - cppKeywords.put("double", new Integer(Token.t_double)); - cppKeywords.put("dynamic_cast", new Integer(Token.t_dynamic_cast)); - cppKeywords.put("else", new Integer(Token.t_else)); - cppKeywords.put("enum", new Integer(Token.t_enum)); - cppKeywords.put("explicit", new Integer(Token.t_explicit)); - cppKeywords.put("export", new Integer(Token.t_export)); - cppKeywords.put("extern", new Integer(Token.t_extern)); - cppKeywords.put("false", new Integer(Token.t_false)); - cppKeywords.put("float", new Integer(Token.t_float)); - cppKeywords.put("for", new Integer(Token.t_for)); - cppKeywords.put("friend", new Integer(Token.t_friend)); - cppKeywords.put("goto", new Integer(Token.t_goto)); - cppKeywords.put("if", new Integer(Token.t_if)); - cppKeywords.put("inline", new Integer(Token.t_inline)); - cppKeywords.put("int", new Integer(Token.t_int)); - cppKeywords.put("long", new Integer(Token.t_long)); - cppKeywords.put("mutable", new Integer(Token.t_mutable)); - cppKeywords.put("namespace", new Integer(Token.t_namespace)); - cppKeywords.put("new", new Integer(Token.t_new)); - cppKeywords.put("not", new Integer(Token.t_not)); - cppKeywords.put("not_eq", new Integer(Token.t_not_eq)); - cppKeywords.put("operator", new Integer(Token.t_operator)); - cppKeywords.put("or", new Integer(Token.t_or)); - cppKeywords.put("or_eq", new Integer(Token.t_or_eq)); - cppKeywords.put("private", new Integer(Token.t_private)); - cppKeywords.put("protected", new Integer(Token.t_protected)); - cppKeywords.put("public", new Integer(Token.t_public)); - cppKeywords.put("register", new Integer(Token.t_register)); - cppKeywords.put("reinterpret_cast", new Integer(Token.t_reinterpret_cast)); - cppKeywords.put("return", new Integer(Token.t_return)); - cppKeywords.put("short", new Integer(Token.t_short)); - cppKeywords.put("signed", new Integer(Token.t_signed)); - cppKeywords.put("sizeof", new Integer(Token.t_sizeof)); - cppKeywords.put("static", new Integer(Token.t_static)); - cppKeywords.put("static_cast", new Integer(Token.t_static_cast)); - cppKeywords.put("struct", new Integer(Token.t_struct)); - cppKeywords.put("switch", new Integer(Token.t_switch)); - cppKeywords.put("template", new Integer(Token.t_template)); - cppKeywords.put("this", new Integer(Token.t_this)); - cppKeywords.put("throw", new Integer(Token.t_throw)); - cppKeywords.put("true", new Integer(Token.t_true)); - cppKeywords.put("try", new Integer(Token.t_try)); - cppKeywords.put("typedef", new Integer(Token.t_typedef)); - cppKeywords.put("typeid", new Integer(Token.t_typeid)); - cppKeywords.put("typename", new Integer(Token.t_typename)); - cppKeywords.put("union", new Integer(Token.t_union)); - cppKeywords.put("unsigned", new Integer(Token.t_unsigned)); - cppKeywords.put("using", new Integer(Token.t_using)); - cppKeywords.put("virtual", new Integer(Token.t_virtual)); - cppKeywords.put("void", new Integer(Token.t_void)); - cppKeywords.put("volatile", new Integer(Token.t_volatile)); - cppKeywords.put("wchar_t", new Integer(Token.t_wchar_t)); - cppKeywords.put("while", new Integer(Token.t_while)); - cppKeywords.put("xor", new Integer(Token.t_xor)); - cppKeywords.put("xor_eq", new Integer(Token.t_xor_eq)); + cppKeywords.put("and", new Integer(IToken.t_and)); + cppKeywords.put("and_eq", new Integer(IToken.t_and_eq)); + cppKeywords.put("asm", new Integer(IToken.t_asm)); + cppKeywords.put("auto", new Integer(IToken.t_auto)); + cppKeywords.put("bitand", new Integer(IToken.t_bitand)); + cppKeywords.put("bitor", new Integer(IToken.t_bitor)); + cppKeywords.put("bool", new Integer(IToken.t_bool)); + cppKeywords.put("break", new Integer(IToken.t_break)); + cppKeywords.put("case", new Integer(IToken.t_case)); + cppKeywords.put("catch", new Integer(IToken.t_catch)); + cppKeywords.put("char", new Integer(IToken.t_char)); + cppKeywords.put("class", new Integer(IToken.t_class)); + cppKeywords.put("compl", new Integer(IToken.t_compl)); + cppKeywords.put("const", new Integer(IToken.t_const)); + cppKeywords.put("const_cast", new Integer(IToken.t_const_cast)); + cppKeywords.put("continue", new Integer(IToken.t_continue)); + cppKeywords.put("default", new Integer(IToken.t_default)); + cppKeywords.put("delete", new Integer(IToken.t_delete)); + cppKeywords.put("do", new Integer(IToken.t_do)); + cppKeywords.put("double", new Integer(IToken.t_double)); + cppKeywords.put("dynamic_cast", new Integer(IToken.t_dynamic_cast)); + cppKeywords.put("else", new Integer(IToken.t_else)); + cppKeywords.put("enum", new Integer(IToken.t_enum)); + cppKeywords.put("explicit", new Integer(IToken.t_explicit)); + cppKeywords.put("export", new Integer(IToken.t_export)); + cppKeywords.put("extern", new Integer(IToken.t_extern)); + cppKeywords.put("false", new Integer(IToken.t_false)); + cppKeywords.put("float", new Integer(IToken.t_float)); + cppKeywords.put("for", new Integer(IToken.t_for)); + cppKeywords.put("friend", new Integer(IToken.t_friend)); + cppKeywords.put("goto", new Integer(IToken.t_goto)); + cppKeywords.put("if", new Integer(IToken.t_if)); + cppKeywords.put("inline", new Integer(IToken.t_inline)); + cppKeywords.put("int", new Integer(IToken.t_int)); + cppKeywords.put("long", new Integer(IToken.t_long)); + cppKeywords.put("mutable", new Integer(IToken.t_mutable)); + cppKeywords.put("namespace", new Integer(IToken.t_namespace)); + cppKeywords.put("new", new Integer(IToken.t_new)); + cppKeywords.put("not", new Integer(IToken.t_not)); + cppKeywords.put("not_eq", new Integer(IToken.t_not_eq)); + cppKeywords.put("operator", new Integer(IToken.t_operator)); + cppKeywords.put("or", new Integer(IToken.t_or)); + cppKeywords.put("or_eq", new Integer(IToken.t_or_eq)); + cppKeywords.put("private", new Integer(IToken.t_private)); + cppKeywords.put("protected", new Integer(IToken.t_protected)); + cppKeywords.put("public", new Integer(IToken.t_public)); + cppKeywords.put("register", new Integer(IToken.t_register)); + cppKeywords.put("reinterpret_cast", new Integer(IToken.t_reinterpret_cast)); + cppKeywords.put("return", new Integer(IToken.t_return)); + cppKeywords.put("short", new Integer(IToken.t_short)); + cppKeywords.put("signed", new Integer(IToken.t_signed)); + cppKeywords.put("sizeof", new Integer(IToken.t_sizeof)); + cppKeywords.put("static", new Integer(IToken.t_static)); + cppKeywords.put("static_cast", new Integer(IToken.t_static_cast)); + cppKeywords.put("struct", new Integer(IToken.t_struct)); + cppKeywords.put("switch", new Integer(IToken.t_switch)); + cppKeywords.put("template", new Integer(IToken.t_template)); + cppKeywords.put("this", new Integer(IToken.t_this)); + cppKeywords.put("throw", new Integer(IToken.t_throw)); + cppKeywords.put("true", new Integer(IToken.t_true)); + cppKeywords.put("try", new Integer(IToken.t_try)); + cppKeywords.put("typedef", new Integer(IToken.t_typedef)); + cppKeywords.put("typeid", new Integer(IToken.t_typeid)); + cppKeywords.put("typename", new Integer(IToken.t_typename)); + cppKeywords.put("union", new Integer(IToken.t_union)); + cppKeywords.put("unsigned", new Integer(IToken.t_unsigned)); + cppKeywords.put("using", new Integer(IToken.t_using)); + cppKeywords.put("virtual", new Integer(IToken.t_virtual)); + cppKeywords.put("void", new Integer(IToken.t_void)); + cppKeywords.put("volatile", new Integer(IToken.t_volatile)); + cppKeywords.put("wchar_t", new Integer(IToken.t_wchar_t)); + cppKeywords.put("while", new Integer(IToken.t_while)); + cppKeywords.put("xor", new Integer(IToken.t_xor)); + cppKeywords.put("xor_eq", new Integer(IToken.t_xor_eq)); ppDirectives.put("#define", new Integer(PreprocessorDirectives.DEFINE)); ppDirectives.put("#undef",new Integer(PreprocessorDirectives.UNDEFINE)); @@ -1572,44 +1578,44 @@ public class Scanner implements IScanner { ppDirectives.put("#elif", new Integer(PreprocessorDirectives.ELIF)); ppDirectives.put("#", new Integer(PreprocessorDirectives.BLANK)); - cKeywords.put("auto", new Integer(Token.t_auto)); - cKeywords.put("break", new Integer(Token.t_break)); - cKeywords.put("case", new Integer(Token.t_case)); - cKeywords.put("char", new Integer(Token.t_char)); - cKeywords.put("const", new Integer(Token.t_const)); - cKeywords.put("continue", new Integer(Token.t_continue)); - cKeywords.put("default", new Integer(Token.t_default)); - cKeywords.put("delete", new Integer(Token.t_delete)); - cKeywords.put("do", new Integer(Token.t_do)); - cKeywords.put("double", new Integer(Token.t_double)); - cKeywords.put("else", new Integer(Token.t_else)); - cKeywords.put("enum", new Integer(Token.t_enum)); - cKeywords.put("extern", new Integer(Token.t_extern)); - cKeywords.put("float", new Integer(Token.t_float)); - cKeywords.put("for", new Integer(Token.t_for)); - cKeywords.put("goto", new Integer(Token.t_goto)); - cKeywords.put("if", new Integer(Token.t_if)); - cKeywords.put("inline", new Integer(Token.t_inline)); - cKeywords.put("int", new Integer(Token.t_int)); - cKeywords.put("long", new Integer(Token.t_long)); - cKeywords.put("register", new Integer(Token.t_register)); - cKeywords.put("restrict", new Integer(Token.t_restrict)); - cKeywords.put("return", new Integer(Token.t_return)); - cKeywords.put("short", new Integer(Token.t_short)); - cKeywords.put("signed", new Integer(Token.t_signed)); - cKeywords.put("sizeof", new Integer(Token.t_sizeof)); - cKeywords.put("static", new Integer(Token.t_static)); - cKeywords.put("struct", new Integer(Token.t_struct)); - cKeywords.put("switch", new Integer(Token.t_switch)); - cKeywords.put("typedef", new Integer(Token.t_typedef)); - cKeywords.put("union", new Integer(Token.t_union)); - cKeywords.put("unsigned", new Integer(Token.t_unsigned)); - cKeywords.put("void", new Integer(Token.t_void)); - cKeywords.put("volatile", new Integer(Token.t_volatile)); - cKeywords.put("while", new Integer(Token.t_while)); - cKeywords.put("_Bool", new Integer(Token.t__Bool)); - cKeywords.put("_Complex", new Integer(Token.t__Complex)); - cKeywords.put("_Imaginary", new Integer(Token.t__Imaginary)); + cKeywords.put("auto", new Integer(IToken.t_auto)); + cKeywords.put("break", new Integer(IToken.t_break)); + cKeywords.put("case", new Integer(IToken.t_case)); + cKeywords.put("char", new Integer(IToken.t_char)); + cKeywords.put("const", new Integer(IToken.t_const)); + cKeywords.put("continue", new Integer(IToken.t_continue)); + cKeywords.put("default", new Integer(IToken.t_default)); + cKeywords.put("delete", new Integer(IToken.t_delete)); + cKeywords.put("do", new Integer(IToken.t_do)); + cKeywords.put("double", new Integer(IToken.t_double)); + cKeywords.put("else", new Integer(IToken.t_else)); + cKeywords.put("enum", new Integer(IToken.t_enum)); + cKeywords.put("extern", new Integer(IToken.t_extern)); + cKeywords.put("float", new Integer(IToken.t_float)); + cKeywords.put("for", new Integer(IToken.t_for)); + cKeywords.put("goto", new Integer(IToken.t_goto)); + cKeywords.put("if", new Integer(IToken.t_if)); + cKeywords.put("inline", new Integer(IToken.t_inline)); + cKeywords.put("int", new Integer(IToken.t_int)); + cKeywords.put("long", new Integer(IToken.t_long)); + cKeywords.put("register", new Integer(IToken.t_register)); + cKeywords.put("restrict", new Integer(IToken.t_restrict)); + cKeywords.put("return", new Integer(IToken.t_return)); + cKeywords.put("short", new Integer(IToken.t_short)); + cKeywords.put("signed", new Integer(IToken.t_signed)); + cKeywords.put("sizeof", new Integer(IToken.t_sizeof)); + cKeywords.put("static", new Integer(IToken.t_static)); + cKeywords.put("struct", new Integer(IToken.t_struct)); + cKeywords.put("switch", new Integer(IToken.t_switch)); + cKeywords.put("typedef", new Integer(IToken.t_typedef)); + cKeywords.put("union", new Integer(IToken.t_union)); + cKeywords.put("unsigned", new Integer(IToken.t_unsigned)); + cKeywords.put("void", new Integer(IToken.t_void)); + cKeywords.put("volatile", new Integer(IToken.t_volatile)); + cKeywords.put("while", new Integer(IToken.t_while)); + cKeywords.put("_Bool", new Integer(IToken.t__Bool)); + cKeywords.put("_Complex", new Integer(IToken.t__Complex)); + cKeywords.put("_Imaginary", new Integer(IToken.t__Imaginary)); } @@ -1986,12 +1992,12 @@ public class Scanner implements IScanner { try { while (true) { - t = forStringizing ? tokenizer.nextTokenForStringizing() : tokenizer.nextToken(false); - if (t.type == Token.tLPAREN) { + t = (Token)(forStringizing ? tokenizer.nextTokenForStringizing() : tokenizer.nextToken(false)); + if (t.type == IToken.tLPAREN) { nParen++; - } else if (t.type == Token.tRPAREN) { + } else if (t.type == IToken.tRPAREN) { nParen--; - } else if (t.type == Token.tCOMMA && nParen == 0) { + } else if (t.type == IToken.tCOMMA && nParen == 0) { parameterValues.add(str); str = ""; space = false; @@ -2002,9 +2008,9 @@ public class Scanner implements IScanner { str += ' '; switch (t.type) { - case Token.tSTRING : str += '\"' + t.image + '\"'; break; - case Token.tLSTRING : str += "L\"" + t.image + '\"'; break; - case Token.tCHAR : str += '\'' + t.image + '\''; break; + case IToken.tSTRING : str += '\"' + t.image + '\"'; break; + case IToken.tLSTRING : str += "L\"" + t.image + '\"'; break; + case IToken.tCHAR : str += '\'' + t.image + '\''; break; default : str += t.image; break; } space = true; @@ -2065,7 +2071,7 @@ public class Scanner implements IScanner { for (int i = 0; i < numberOfTokens; ++i) { t = (Token) tokens.get(i); - if (t.type == Token.tIDENTIFIER) { + if (t.type == IToken.tIDENTIFIER) { String identifierName = t.image; // is this identifier in the parameterNames @@ -2115,9 +2121,9 @@ public class Scanner implements IScanner { } else { switch( t.type ) { - case Token.tSTRING: buffer.append('\"' + t.image + '\"'); break; - case Token.tLSTRING: buffer.append("L\"" + t.image + '\"'); break; - case Token.tCHAR: buffer.append('\'' + t.image + '\''); break; + case IToken.tSTRING: buffer.append('\"' + t.image + '\"'); break; + case IToken.tLSTRING: buffer.append("L\"" + t.image + '\"'); break; + case IToken.tCHAR: buffer.append('\'' + t.image + '\''); break; default: buffer.append(t.image); break; } } @@ -2126,7 +2132,7 @@ public class Scanner implements IScanner { if( i != numberOfTokens - 1) { - Token t2 = (Token) tokens.get(i+1); + IToken t2 = (IToken) tokens.get(i+1); if( t2.getType() == tPOUNDPOUND ) pastingNext = true; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ScannerContext.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ScannerContext.java index 0be28b83223..1a56bd848ba 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ScannerContext.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ScannerContext.java @@ -14,6 +14,7 @@ import java.io.IOException; import java.io.Reader; import java.util.Stack; +import org.eclipse.cdt.core.parser.IScannerContext; import org.eclipse.cdt.core.parser.ast.IASTInclusion; public class ScannerContext implements IScannerContext diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Token.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Token.java index 38d93c32eb6..d34eec20235 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Token.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Token.java @@ -10,7 +10,10 @@ ******************************************************************************/ package org.eclipse.cdt.internal.core.parser; -public class Token { +import org.eclipse.cdt.core.parser.IScannerContext; +import org.eclipse.cdt.core.parser.IToken; + +public class Token implements IToken { public Token(int t, String i, IScannerContext context ) { type = t; @@ -46,7 +49,7 @@ public class Token { public int getEndOffset() { return getOffset() + getLength(); } - public int getDelta( Token other ) + public int getDelta( IToken other ) { return other.getOffset() + other.getLength() - getOffset(); } @@ -87,184 +90,48 @@ public class Token { { switch( getType() ) { - case Token.t_new: - case Token.t_delete: - case Token.tPLUS: - case Token.tMINUS: - case Token.tSTAR: - case Token.tDIV: - case Token.tXOR: - case Token.tMOD: - case Token.tAMPER: - case Token.tBITOR: - case Token.tCOMPL: - case Token.tNOT: - case Token.tASSIGN: - case Token.tLT: - case Token.tGT: - case Token.tPLUSASSIGN: - case Token.tMINUSASSIGN: - case Token.tSTARASSIGN: - case Token.tDIVASSIGN: - case Token.tMODASSIGN: - case Token.tBITORASSIGN: - case Token.tAMPERASSIGN: - case Token.tXORASSIGN: - case Token.tSHIFTL: - case Token.tSHIFTR: - case Token.tSHIFTLASSIGN: - case Token.tSHIFTRASSIGN: - case Token.tEQUAL: - case Token.tNOTEQUAL: - case Token.tLTEQUAL: - case Token.tGTEQUAL: - case Token.tAND: - case Token.tOR: - case Token.tINCR: - case Token.tDECR: - case Token.tCOMMA: - case Token.tARROW: - case Token.tARROWSTAR: + case IToken.t_new: + case IToken.t_delete: + case IToken.tPLUS: + case IToken.tMINUS: + case IToken.tSTAR: + case IToken.tDIV: + case IToken.tXOR: + case IToken.tMOD: + case IToken.tAMPER: + case IToken.tBITOR: + case IToken.tCOMPL: + case IToken.tNOT: + case IToken.tASSIGN: + case IToken.tLT: + case IToken.tGT: + case IToken.tPLUSASSIGN: + case IToken.tMINUSASSIGN: + case IToken.tSTARASSIGN: + case IToken.tDIVASSIGN: + case IToken.tMODASSIGN: + case IToken.tBITORASSIGN: + case IToken.tAMPERASSIGN: + case IToken.tXORASSIGN: + case IToken.tSHIFTL: + case IToken.tSHIFTR: + case IToken.tSHIFTLASSIGN: + case IToken.tSHIFTRASSIGN: + case IToken.tEQUAL: + case IToken.tNOTEQUAL: + case IToken.tLTEQUAL: + case IToken.tGTEQUAL: + case IToken.tAND: + case IToken.tOR: + case IToken.tINCR: + case IToken.tDECR: + case IToken.tCOMMA: + case IToken.tARROW: + case IToken.tARROWSTAR: return true; default: return false; } } - // Token types - static public final int tIDENTIFIER = 1; - static public final int tINTEGER = 2; - static public final int tCOLONCOLON = 3; - static public final int tCOLON = 4; - static public final int tSEMI = 5; - static public final int tCOMMA = 6; - static public final int tQUESTION = 7; - static public final int tLPAREN = 8; - static public final int tRPAREN = 9; - static public final int tLBRACKET = 10; - static public final int tRBRACKET = 11; - static public final int tLBRACE = 12; - static public final int tRBRACE = 13; - static public final int tPLUSASSIGN = 14; - static public final int tINCR = 15; - static public final int tPLUS = 16; - static public final int tMINUSASSIGN = 17; - static public final int tDECR = 18; - static public final int tARROWSTAR = 19; - static public final int tARROW = 20; - static public final int tMINUS = 21; - static public final int tSTARASSIGN = 22; - static public final int tSTAR = 23; - static public final int tMODASSIGN = 24; - static public final int tMOD = 25; - static public final int tXORASSIGN = 26; - static public final int tXOR = 27; - static public final int tAMPERASSIGN = 28; - static public final int tAND = 29; - static public final int tAMPER = 30; - static public final int tBITORASSIGN = 31; - static public final int tOR = 32; - static public final int tBITOR = 33; - static public final int tCOMPL = 34; - static public final int tNOTEQUAL = 35; - static public final int tNOT = 36; - static public final int tEQUAL = 37; - static public final int tASSIGN = 38; - static public final int tSHIFTL = 40; - static public final int tLTEQUAL = 41; - static public final int tLT = 42; - static public final int tSHIFTRASSIGN = 43; - static public final int tSHIFTR = 44; - static public final int tGTEQUAL = 45; - static public final int tGT = 46; - static public final int tSHIFTLASSIGN = 47; - static public final int tELIPSE = 48; - static public final int tDOTSTAR = 49; - static public final int tDOT = 50; - static public final int tDIVASSIGN = 51; - static public final int tDIV = 52; - static public final int tCLASSNAME = 53; - static public final int t_and = 54; - static public final int t_and_eq = 55; - static public final int t_asm = 56; - static public final int t_auto = 57; - static public final int t_bitand = 58; - static public final int t_bitor = 59; - static public final int t_bool = 60; - static public final int t_break = 61; - static public final int t_case = 62; - static public final int t_catch = 63; - static public final int t_char = 64; - static public final int t_class = 65; - static public final int t_compl = 66; - static public final int t_const = 67; - static public final int t_const_cast = 69; - static public final int t_continue = 70; - static public final int t_default = 71; - static public final int t_delete = 72; - static public final int t_do = 73; - static public final int t_double = 74; - static public final int t_dynamic_cast = 75; - static public final int t_else = 76; - static public final int t_enum = 77; - static public final int t_explicit = 78; - static public final int t_export = 79; - static public final int t_extern = 80; - static public final int t_false = 81; - static public final int t_float = 82; - static public final int t_for = 83; - static public final int t_friend = 84; - static public final int t_goto = 85; - static public final int t_if = 86; - static public final int t_inline = 87; - static public final int t_int = 88; - static public final int t_long = 89; - static public final int t_mutable = 90; - static public final int t_namespace = 91; - static public final int t_new = 92; - static public final int t_not = 93; - static public final int t_not_eq = 94; - static public final int t_operator = 95; - static public final int t_or = 96; - static public final int t_or_eq = 97; - static public final int t_private = 98; - static public final int t_protected = 99; - static public final int t_public = 100; - static public final int t_register = 101; - static public final int t_reinterpret_cast = 102; - static public final int t_return = 103; - static public final int t_short = 104; - static public final int t_sizeof = 105; - static public final int t_static = 106; - static public final int t_static_cast = 107; - static public final int t_signed = 108; - static public final int t_struct = 109; - static public final int t_switch = 110; - static public final int t_template = 111; - static public final int t_this = 112; - static public final int t_throw = 113; - static public final int t_true = 114; - static public final int t_try = 115; - static public final int t_typedef = 116; - static public final int t_typeid = 117; - static public final int t_typename = 118; - static public final int t_union = 119; - static public final int t_unsigned = 120; - static public final int t_using = 121; - static public final int t_virtual = 122; - static public final int t_void = 123; - static public final int t_volatile = 124; - static public final int t_wchar_t = 125; - static public final int t_while = 126; - static public final int t_xor = 127; - static public final int t_xor_eq = 128; - static public final int tSTRING = 129; - static public final int tFLOATINGPT = 130; - static public final int tLSTRING = 131; - static public final int tCHAR = 132; - static public final int t__Bool = 133; - static public final int t__Complex = 134; - static public final int t__Imaginary = 135; - static public final int t_restrict = 136; - static public final int tLAST = t_restrict; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/TokenDuple.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/TokenDuple.java index 02a5d00ed15..a07d6e917b8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/TokenDuple.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/TokenDuple.java @@ -12,29 +12,31 @@ package org.eclipse.cdt.internal.core.parser; import java.util.Iterator; +import org.eclipse.cdt.core.parser.IToken; + /** * @author jcamelon * */ public class TokenDuple { - public TokenDuple( Token first, Token last ) + public TokenDuple( IToken first, IToken last ) { firstToken = first; lastToken = last; } - private final Token firstToken, lastToken; + private final IToken firstToken, lastToken; /** * @return */ - public Token getFirstToken() { + public IToken getFirstToken() { return firstToken; } /** * @return */ - public Token getLastToken() { + public IToken getLastToken() { return lastToken; } @@ -45,7 +47,7 @@ public class TokenDuple { private class TokenIterator implements Iterator { - private Token iter = TokenDuple.this.firstToken; + private IToken iter = TokenDuple.this.firstToken; /* (non-Javadoc) * @see java.util.Iterator#hasNext() @@ -58,7 +60,7 @@ public class TokenDuple { * @see java.util.Iterator#next() */ public Object next() { - Token temp = iter; + IToken temp = iter; iter = iter.getNext(); return temp; } @@ -75,7 +77,7 @@ public class TokenDuple { public String toString() { StringBuffer buff = new StringBuffer(); - Token iter = firstToken; + IToken iter = firstToken; for( ; ; ) { buff.append( iter.getImage() ); @@ -84,4 +86,10 @@ public class TokenDuple { } return buff.toString(); } + + public boolean isIdentifier() + { + return ( firstToken == lastToken ); + } + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTClassSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTClassSpecifier.java index 1125ace1a1f..1fda98aabbc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTClassSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTClassSpecifier.java @@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.parser.ast.full; import java.util.Iterator; +import org.eclipse.cdt.core.parser.ast.AccessVisibility; import org.eclipse.cdt.core.parser.ast.ClassKind; import org.eclipse.cdt.core.parser.ast.ClassNameType; import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration; @@ -134,4 +135,12 @@ public class ASTClassSpecifier implements IASTFClassSpecifier, IPSTSymbolExtensi return symbol; } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTClassSpecifier#getCurrentVisiblity() + */ + public AccessVisibility getCurrentVisiblity() { + // TODO Auto-generated method stub + return null; + } + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java index 041e6536463..f7d3e50fdc6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java @@ -12,15 +12,20 @@ package org.eclipse.cdt.internal.core.parser.ast.full; import java.util.Iterator; +import org.eclipse.cdt.core.parser.IToken; +import org.eclipse.cdt.core.parser.ast.AccessVisibility; +import org.eclipse.cdt.core.parser.ast.ClassKind; +import org.eclipse.cdt.core.parser.ast.ClassNameType; import org.eclipse.cdt.core.parser.ast.IASTASMDefinition; +import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier; import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit; import org.eclipse.cdt.core.parser.ast.IASTFactory; import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification; import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition; import org.eclipse.cdt.core.parser.ast.IASTScope; +import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration; import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration; import org.eclipse.cdt.core.parser.ast.IASTUsingDirective; -import org.eclipse.cdt.internal.core.parser.Token; import org.eclipse.cdt.internal.core.parser.TokenDuple; import org.eclipse.cdt.internal.core.parser.Parser.Backtrack; import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory; @@ -42,10 +47,10 @@ public class FullParseASTFactory extends BaseASTFactory implements IASTFactory { TokenDuple duple) throws Backtrack { Iterator iter = duple.iterator(); - Token t1 = (Token)iter.next(); + IToken t1 = (IToken)iter.next(); IContainerSymbol symbol = null; - if( t1.getType() == Token.tCOLONCOLON ) + if( t1.getType() == IToken.tCOLONCOLON ) symbol = pst.getCompilationUnit(); else { @@ -61,8 +66,8 @@ public class FullParseASTFactory extends BaseASTFactory implements IASTFactory { while( iter.hasNext() ) { - Token t = (Token)iter.next(); - if( t.getType() == Token.tCOLONCOLON ) continue; + IToken t = (IToken)iter.next(); + if( t.getType() == IToken.tCOLONCOLON ) continue; try { symbol = symbol.LookupNestedNameSpecifier( t.getImage() ); @@ -145,4 +150,20 @@ public class FullParseASTFactory extends BaseASTFactory implements IASTFactory { return null; } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createClassSpecifier(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, org.eclipse.cdt.core.parser.ast.ClassKind, org.eclipse.cdt.core.parser.ast.ClassNameType, org.eclipse.cdt.core.parser.ast.AccessVisibility, org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration) + */ + public IASTClassSpecifier createClassSpecifier(IASTScope scope, String name, ClassKind kind, ClassNameType type, AccessVisibility access, IASTTemplateDeclaration ownerTemplateDeclaration, int startingOffset, int nameOffset) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTFactory#addBaseSpecifier(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier, boolean, org.eclipse.cdt.core.parser.ast.AccessVisibility, java.lang.String) + */ + public void addBaseSpecifier(IASTClassSpecifier astClassSpec, boolean isVirtual, AccessVisibility visibility, String string) { + // TODO Auto-generated method stub + + } + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTBaseSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTBaseSpecifier.java new file mode 100644 index 00000000000..bad47bdab96 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTBaseSpecifier.java @@ -0,0 +1,57 @@ +/********************************************************************** + * Copyright (c) 2002,2003 Rational Software Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation +***********************************************************************/ +package org.eclipse.cdt.internal.core.parser.ast.quick; + +import org.eclipse.cdt.core.parser.ast.AccessVisibility; +import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier; +import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier; + +/** + * @author jcamelon + * + */ +public class ASTBaseSpecifier implements IASTBaseSpecifier { + + private final AccessVisibility visibility; + private final boolean isVirtual; + private final IASTClassSpecifier parentClass; + + public ASTBaseSpecifier( IASTClassSpecifier classSpec, boolean v, AccessVisibility a ) + { + parentClass = classSpec; + isVirtual = v; + visibility = a; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier#getAccess() + */ + public AccessVisibility getAccess() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier#isVirtual() + */ + public boolean isVirtual() { + // TODO Auto-generated method stub + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier#getParent() + */ + public IASTClassSpecifier getParent() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTClassSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTClassSpecifier.java new file mode 100644 index 00000000000..86e220d85ef --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTClassSpecifier.java @@ -0,0 +1,160 @@ +/********************************************************************** + * Copyright (c) 2002,2003 Rational Software Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation +***********************************************************************/ +package org.eclipse.cdt.internal.core.parser.ast.quick; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.cdt.core.parser.ast.AccessVisibility; +import org.eclipse.cdt.core.parser.ast.ClassKind; +import org.eclipse.cdt.core.parser.ast.ClassNameType; +import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier; +import org.eclipse.cdt.core.parser.ast.IASTDeclaration; +import org.eclipse.cdt.core.parser.ast.IASTScope; +import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration; +import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets; + +/** + * @author jcamelon + * + */ +public class ASTClassSpecifier extends ASTDeclaration implements IASTQClassSpecifier, IASTQScope { + + public ASTClassSpecifier(IASTScope scope, + String name, + ClassKind kind, + ClassNameType type, + AccessVisibility access, + IASTTemplateDeclaration ownerTemplateDeclaration ) + { + super(scope); + classNameType = type; + classKind = kind; + this.access = access; + this.name = name; + templateOwner = ownerTemplateDeclaration; + } + + private IASTTemplateDeclaration templateOwner = null; + private final String name; + private List declarations = new ArrayList(); + private List baseClauses = new ArrayList(); + private AccessVisibility access; + private NamedOffsets offsets = new NamedOffsets(); + private final ClassNameType classNameType; + private final ClassKind classKind; + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTClassSpecifier#getClassNameType() + */ + public ClassNameType getClassNameType() { + return classNameType; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTClassSpecifier#getClassKind() + */ + public ClassKind getClassKind() { + return classKind; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTClassSpecifier#getBaseClauses() + */ + public Iterator getBaseClauses() { + return baseClauses.iterator(); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTClassSpecifier#getCurrentVisiblity() + */ + public AccessVisibility getCurrentVisiblity() { + return access; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTScope#getDeclarations() + */ + public Iterator getDeclarations() { + return declarations.iterator(); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getName() + */ + public String getName() { + return name; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getElementNameOffset() + */ + public int getElementNameOffset() { + return offsets.getElementNameOffset(); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int) + */ + public void setNameOffset(int o) { + offsets.setNameOffset(o); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTTemplatedDeclaration#getOwnerTemplateDeclaration() + */ + public IASTTemplateDeclaration getOwnerTemplateDeclaration() { + return templateOwner; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffset(int) + */ + public void setStartingOffset(int o) { + offsets.setStartingOffset(o); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setEndingOffset(int) + */ + public void setEndingOffset(int o) { + offsets.setEndingOffset(o); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset() + */ + public int getElementStartingOffset() { + return offsets.getElementStartingOffset(); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset() + */ + public int getElementEndingOffset() { + return offsets.getElementEndingOffset(); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.internal.core.parser.ast.quick.IASTQScope#addDeclaration(org.eclipse.cdt.core.parser.ast.IASTDeclaration) + */ + public void addDeclaration(IASTDeclaration declaration) { + declarations.add( declaration ); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.internal.core.parser.ast.quick.IASTQClassSpecifier#addBaseClass(org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier) + */ + public void addBaseClass(IASTBaseSpecifier baseSpecifier) { + baseClauses.add( baseSpecifier ); + } + +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/IASTQClassSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/IASTQClassSpecifier.java new file mode 100644 index 00000000000..0d28deb31e8 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/IASTQClassSpecifier.java @@ -0,0 +1,23 @@ +/********************************************************************** + * Copyright (c) 2002,2003 Rational Software Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation +***********************************************************************/ +package org.eclipse.cdt.internal.core.parser.ast.quick; + +import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier; +import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier; + +/** + * @author jcamelon + * + */ +public interface IASTQClassSpecifier extends IASTClassSpecifier { + + public void addBaseClass( IASTBaseSpecifier baseSpecifier ); +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java index da2813bbc7c..0eedf65e60f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java @@ -10,12 +10,18 @@ ***********************************************************************/ package org.eclipse.cdt.internal.core.parser.ast.quick; +import org.eclipse.cdt.core.parser.ast.AccessVisibility; +import org.eclipse.cdt.core.parser.ast.ClassKind; +import org.eclipse.cdt.core.parser.ast.ClassNameType; import org.eclipse.cdt.core.parser.ast.IASTASMDefinition; +import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier; +import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier; import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit; import org.eclipse.cdt.core.parser.ast.IASTFactory; import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification; import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition; import org.eclipse.cdt.core.parser.ast.IASTScope; +import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration; import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration; import org.eclipse.cdt.core.parser.ast.IASTUsingDirective; import org.eclipse.cdt.internal.core.parser.TokenDuple; @@ -76,4 +82,22 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory return new ASTUsingDeclaration( scope, isTypeName, name.toString() ); } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createClassSpecifier(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, org.eclipse.cdt.core.parser.ast.ClassKind, org.eclipse.cdt.core.parser.ast.ClassNameType, org.eclipse.cdt.core.parser.ast.AccessVisibility, org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration) + */ + public IASTClassSpecifier createClassSpecifier(IASTScope scope, String name, ClassKind kind, ClassNameType type, AccessVisibility access, IASTTemplateDeclaration ownerTemplateDeclaration, int startingOffset, int nameOffset) { + IASTClassSpecifier spec = new ASTClassSpecifier( scope, name, kind, type, access, ownerTemplateDeclaration ); + spec.setStartingOffset( startingOffset ); + spec.setNameOffset( nameOffset ); + return spec; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTFactory#addBaseSpecifier(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier, boolean, org.eclipse.cdt.core.parser.ast.AccessVisibility, java.lang.String) + */ + public void addBaseSpecifier(IASTClassSpecifier astClassSpec, boolean isVirtual, AccessVisibility visibility, String string) { + IASTBaseSpecifier baseSpecifier = new ASTBaseSpecifier( astClassSpec, isVirtual, visibility ); + ((IASTQClassSpecifier)astClassSpec).addBaseClass(baseSpecifier); + } + }