1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

2003-06-13 John Camelon

Added Class/Base infrastructure to public interfaces & requestor callback. 
	Moved many internal interfaces to external packages. 
	Organized imports.
This commit is contained in:
John Camelon 2003-06-13 20:03:15 +00:00
parent d664093420
commit 22eb93f0e4
40 changed files with 1744 additions and 1322 deletions

View file

@ -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;
}

View file

@ -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
}
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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 );
}

View file

@ -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);
}
}

View file

@ -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;
}

View file

@ -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() );
}

View file

@ -12,7 +12,6 @@
***********************************************************************/
package org.eclipse.cdt.internal.core.dom;
import org.eclipse.cdt.internal.core.parser.Name;
/**

View file

@ -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.

View file

@ -1,4 +1,4 @@
package org.eclipse.cdt.internal.core.parser;
package org.eclipse.cdt.core.parser;
import java.util.List;
/**
* @author jcamelon

View file

@ -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 );

View file

@ -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 );

View file

@ -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;

View file

@ -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 );

View file

@ -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;
}

View file

@ -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 {

View file

@ -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();
}

View file

@ -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 {
}

View file

@ -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 {
}

View file

@ -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);
}

View file

@ -14,6 +14,6 @@ package org.eclipse.cdt.core.parser.ast;
* @author jcamelon
*
*/
public interface IASTEnumSpecifier {
public interface IASTTypeSpecifier {
}

View file

@ -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
*

View file

@ -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;
/**

View file

@ -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);
}

View file

@ -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();

View file

@ -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;
}

View file

@ -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
}
}

View file

@ -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 )

View file

@ -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;
}

View file

@ -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

View file

@ -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;
}

View file

@ -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 );
}
}

View file

@ -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;
}
}

View file

@ -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
}
}

View file

@ -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;
}
}

View file

@ -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 );
}
}

View file

@ -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 );
}

View file

@ -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);
}
}