mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 03:53:21 +02:00
Patch for John Camelon:
- Added AccessSpecifier and ClassKind to parser.util package and refactored callbacks. - Better encapsulated ExceptionSpecification in the DOM. - Updated DOM structures to return unmodifiable collections. - Added callback support for asmdefinitions. - Added callback support for constructor initializer chains. - Fixed bug 35781 and updated parser to catch all exceptions from callbacks to ensure best-effort parsing. - Removed Main.java from Parser package. - Updated tests.
This commit is contained in:
parent
b6bc4d280b
commit
53b11edee4
33 changed files with 1055 additions and 383 deletions
|
@ -0,0 +1,34 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Created on Mar 26, 2003
|
||||||
|
*
|
||||||
|
* 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:
|
||||||
|
* Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ASMDefinition extends Declaration {
|
||||||
|
|
||||||
|
final private String assemblyCode;
|
||||||
|
|
||||||
|
public ASMDefinition( String code )
|
||||||
|
{
|
||||||
|
assemblyCode = code;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
public String getAssemblyCode() {
|
||||||
|
return assemblyCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
package org.eclipse.cdt.internal.core.dom;
|
package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.core.parser.util.AccessSpecifier;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.util.ClassKey;
|
||||||
import org.eclipse.cdt.internal.core.parser.util.Name;
|
import org.eclipse.cdt.internal.core.parser.util.Name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,11 +19,12 @@ public class BaseSpecifier {
|
||||||
classSpecifier.addBaseSpecifier(this);
|
classSpecifier.addBaseSpecifier(this);
|
||||||
|
|
||||||
switch (classSpecifier.getClassKey()) {
|
switch (classSpecifier.getClassKey()) {
|
||||||
case ClassSpecifier.t_class:
|
case ClassKey.t_class:
|
||||||
access = t_private;
|
access.setAccess(AccessSpecifier.v_private);
|
||||||
break;
|
break;
|
||||||
case ClassSpecifier.t_struct:
|
case ClassKey.t_struct:
|
||||||
access = t_public;
|
default:
|
||||||
|
access.setAccess(AccessSpecifier.v_public);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,12 +36,10 @@ public class BaseSpecifier {
|
||||||
public void setVirtual(boolean isVirtual) { this.isVirtual = isVirtual; }
|
public void setVirtual(boolean isVirtual) { this.isVirtual = isVirtual; }
|
||||||
public boolean isVirtual() { return isVirtual; }
|
public boolean isVirtual() { return isVirtual; }
|
||||||
|
|
||||||
public static final int t_private = 0;
|
|
||||||
public static final int t_protected = 1;
|
private AccessSpecifier access = new AccessSpecifier();
|
||||||
public static final int t_public = 2;
|
public void setAccess(int access) { this.access.setAccess(access); }
|
||||||
private int access;
|
public int getAccess() { return access.getAccess(); }
|
||||||
public void setAccess(int access) { this.access = access; }
|
|
||||||
public int getAccess() { return access; }
|
|
||||||
|
|
||||||
private Name name;
|
private Name name;
|
||||||
public void setName(Name name) { this.name = name; }
|
public void setName(Name name) { this.name = name; }
|
||||||
|
|
|
@ -1,28 +1,23 @@
|
||||||
package org.eclipse.cdt.internal.core.dom;
|
package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.core.parser.util.AccessSpecifier;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.util.ClassKey;
|
||||||
import org.eclipse.cdt.internal.core.parser.util.Name;
|
import org.eclipse.cdt.internal.core.parser.util.Name;
|
||||||
|
|
||||||
public class ClassSpecifier extends TypeSpecifier implements IScope {
|
public class ClassSpecifier extends TypeSpecifier implements IScope {
|
||||||
|
|
||||||
public static final int t_class = 0;
|
AccessSpecifier access = new AccessSpecifier();
|
||||||
public static final int t_struct = 1;
|
ClassKey key = new ClassKey();
|
||||||
public static final int t_union = 2;
|
|
||||||
|
|
||||||
public static final int v_public = 0;
|
public int getClassKey() { return key.getClassKey(); }
|
||||||
public static final int v_protected = 1;
|
|
||||||
public static final int v_private = 3;
|
|
||||||
|
|
||||||
private int currentVisibility;
|
|
||||||
|
|
||||||
private final int classKey;
|
|
||||||
public int getClassKey() { return classKey; }
|
|
||||||
|
|
||||||
public ClassSpecifier(int classKey, SimpleDeclaration declaration) {
|
public ClassSpecifier(int classKey, SimpleDeclaration declaration) {
|
||||||
super(declaration);
|
super(declaration);
|
||||||
this.classKey = classKey;
|
this.key.setClassKey(classKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Name name;
|
private Name name;
|
||||||
|
@ -33,7 +28,7 @@ public class ClassSpecifier extends TypeSpecifier implements IScope {
|
||||||
public void addBaseSpecifier(BaseSpecifier baseSpecifier) {
|
public void addBaseSpecifier(BaseSpecifier baseSpecifier) {
|
||||||
baseSpecifiers.add(baseSpecifier);
|
baseSpecifiers.add(baseSpecifier);
|
||||||
}
|
}
|
||||||
public List getBaseSpecifiers() { return baseSpecifiers; }
|
public List getBaseSpecifiers() { return Collections.unmodifiableList(baseSpecifiers); }
|
||||||
|
|
||||||
private List declarations = new LinkedList();
|
private List declarations = new LinkedList();
|
||||||
|
|
||||||
|
@ -42,13 +37,13 @@ public class ClassSpecifier extends TypeSpecifier implements IScope {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getDeclarations() {
|
public List getDeclarations() {
|
||||||
return declarations;
|
return Collections.unmodifiableList( declarations );
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public int getCurrentVisibility() {
|
public int getCurrentVisibility() {
|
||||||
return currentVisibility;
|
return access.getAccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,7 +51,7 @@ public class ClassSpecifier extends TypeSpecifier implements IScope {
|
||||||
* @param currentVisiblity The currentVisiblity to set
|
* @param currentVisiblity The currentVisiblity to set
|
||||||
*/
|
*/
|
||||||
public void setCurrentVisibility(int currentVisiblity) {
|
public void setCurrentVisibility(int currentVisiblity) {
|
||||||
this.currentVisibility = currentVisiblity;
|
access.setAccess(currentVisiblity);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Created on Mar 28, 2003
|
||||||
|
*
|
||||||
|
* 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:
|
||||||
|
* Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ConstructorChain {
|
||||||
|
|
||||||
|
private List chainElements = new ArrayList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return List
|
||||||
|
*/
|
||||||
|
public List getChainElements() {
|
||||||
|
return Collections.unmodifiableList( chainElements );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addChainElement( ConstructorChainElement chainElement )
|
||||||
|
{
|
||||||
|
chainElements.add( chainElement );
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConstructorChain( Declarator declarator )
|
||||||
|
{
|
||||||
|
this.ownerDeclarator = declarator;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Declarator ownerDeclarator;
|
||||||
|
/**
|
||||||
|
* @return Declarator
|
||||||
|
*/
|
||||||
|
public Declarator getOwnerDeclarator() {
|
||||||
|
return ownerDeclarator;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Created on Mar 28, 2003
|
||||||
|
*
|
||||||
|
* 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:
|
||||||
|
* Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.core.parser.util.Name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ConstructorChainElement {
|
||||||
|
|
||||||
|
private Name name;
|
||||||
|
private List expressionList = new ArrayList();
|
||||||
|
private final ConstructorChain ownerChain;
|
||||||
|
|
||||||
|
ConstructorChainElement( ConstructorChain chain )
|
||||||
|
{
|
||||||
|
ownerChain = chain;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Name
|
||||||
|
*/
|
||||||
|
public Name getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the name.
|
||||||
|
* @param name The name to set
|
||||||
|
*/
|
||||||
|
public void setName(Name name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return List
|
||||||
|
*/
|
||||||
|
public List getExpressionList() {
|
||||||
|
return Collections.unmodifiableList( expressionList );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addExpression( ConstructorChainElementExpression expression )
|
||||||
|
{
|
||||||
|
expressionList.add( expression );
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return ConstructorChain
|
||||||
|
*/
|
||||||
|
public ConstructorChain getOwnerChain() {
|
||||||
|
return ownerChain;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Created on Mar 28, 2003
|
||||||
|
*
|
||||||
|
* 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:
|
||||||
|
* Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ConstructorChainElementExpression implements IExpressionOwner {
|
||||||
|
|
||||||
|
Expression exp;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.IExpressionOwner#getExpression()
|
||||||
|
*/
|
||||||
|
public Expression getExpression() {
|
||||||
|
return exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.IExpressionOwner#setExpression(org.eclipse.cdt.internal.core.dom.Expression)
|
||||||
|
*/
|
||||||
|
public void setExpression(Expression exp) {
|
||||||
|
this.exp = exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConstructorChainElementExpression( ConstructorChainElement element )
|
||||||
|
{
|
||||||
|
this.ownerElement = element;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final ConstructorChainElement ownerElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return ConstructorChainElement
|
||||||
|
*/
|
||||||
|
public ConstructorChainElement getOwnerElement() {
|
||||||
|
return ownerElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,6 +3,8 @@ package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.parser.IParserCallback;
|
import org.eclipse.cdt.internal.core.parser.IParserCallback;
|
||||||
import org.eclipse.cdt.internal.core.parser.Token;
|
import org.eclipse.cdt.internal.core.parser.Token;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.util.AccessSpecifier;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.util.ClassKey;
|
||||||
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
|
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
|
||||||
import org.eclipse.cdt.internal.core.parser.util.Name;
|
import org.eclipse.cdt.internal.core.parser.util.Name;
|
||||||
|
|
||||||
|
@ -38,19 +40,19 @@ public class DOMBuilder implements IParserCallback
|
||||||
public Object classSpecifierBegin(Object container, Token classKey) {
|
public Object classSpecifierBegin(Object container, Token classKey) {
|
||||||
SimpleDeclaration decl = (SimpleDeclaration)container;
|
SimpleDeclaration decl = (SimpleDeclaration)container;
|
||||||
|
|
||||||
int kind = ClassSpecifier.t_struct;
|
int kind = ClassKey.t_struct;
|
||||||
int visibility = ClassSpecifier.v_public;
|
int visibility = AccessSpecifier.v_public;
|
||||||
|
|
||||||
switch (classKey.getType()) {
|
switch (classKey.getType()) {
|
||||||
case Token.t_class:
|
case Token.t_class:
|
||||||
kind = ClassSpecifier.t_class;
|
kind = ClassKey.t_class;
|
||||||
visibility = ClassSpecifier.v_private;
|
visibility = AccessSpecifier.v_private;
|
||||||
break;
|
break;
|
||||||
case Token.t_struct:
|
case Token.t_struct:
|
||||||
kind = ClassSpecifier.t_struct;
|
kind = ClassKey.t_struct;
|
||||||
break;
|
break;
|
||||||
case Token.t_union:
|
case Token.t_union:
|
||||||
kind = ClassSpecifier.t_union;
|
kind = ClassKey.t_union;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,17 +227,17 @@ public class DOMBuilder implements IParserCallback
|
||||||
|
|
||||||
public void baseSpecifierVisibility( Object baseSpecifier, Token visibility )
|
public void baseSpecifierVisibility( Object baseSpecifier, Token visibility )
|
||||||
{
|
{
|
||||||
int access = BaseSpecifier.t_public;
|
int access = AccessSpecifier.v_public;
|
||||||
switch( visibility.type )
|
switch( visibility.type )
|
||||||
{
|
{
|
||||||
case Token.t_public:
|
case Token.t_public:
|
||||||
access = BaseSpecifier.t_public;
|
access = AccessSpecifier.v_public;
|
||||||
break;
|
break;
|
||||||
case Token.t_protected:
|
case Token.t_protected:
|
||||||
access = BaseSpecifier.t_protected;
|
access = AccessSpecifier.v_protected;
|
||||||
break;
|
break;
|
||||||
case Token.t_private:
|
case Token.t_private:
|
||||||
access = BaseSpecifier.t_private;
|
access = AccessSpecifier.v_private;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -305,17 +307,17 @@ public class DOMBuilder implements IParserCallback
|
||||||
*/
|
*/
|
||||||
public Object elaboratedTypeSpecifierBegin(Object container, Token classKey) {
|
public Object elaboratedTypeSpecifierBegin(Object container, Token classKey) {
|
||||||
SimpleDeclaration declaration = (SimpleDeclaration)container;
|
SimpleDeclaration declaration = (SimpleDeclaration)container;
|
||||||
int kind = ClassSpecifier.t_struct;
|
int kind = ClassKey.t_struct;
|
||||||
|
|
||||||
switch (classKey.getType()) {
|
switch (classKey.getType()) {
|
||||||
case Token.t_class:
|
case Token.t_class:
|
||||||
kind = ClassSpecifier.t_class;
|
kind = ClassKey.t_class;
|
||||||
break;
|
break;
|
||||||
case Token.t_struct:
|
case Token.t_struct:
|
||||||
kind = ClassSpecifier.t_struct;
|
kind = ClassKey.t_struct;
|
||||||
break;
|
break;
|
||||||
case Token.t_union:
|
case Token.t_union:
|
||||||
kind = ClassSpecifier.t_union;
|
kind = ClassKey.t_union;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,13 +359,13 @@ public class DOMBuilder implements IParserCallback
|
||||||
switch( visibility.getType() )
|
switch( visibility.getType() )
|
||||||
{
|
{
|
||||||
case Token.t_public:
|
case Token.t_public:
|
||||||
spec.setCurrentVisibility( ClassSpecifier.v_public );
|
spec.setCurrentVisibility( AccessSpecifier.v_public );
|
||||||
break;
|
break;
|
||||||
case Token.t_protected:
|
case Token.t_protected:
|
||||||
spec.setCurrentVisibility( ClassSpecifier.v_protected );
|
spec.setCurrentVisibility( AccessSpecifier.v_protected );
|
||||||
break;
|
break;
|
||||||
case Token.t_private:
|
case Token.t_private:
|
||||||
spec.setCurrentVisibility( ClassSpecifier.v_private );
|
spec.setCurrentVisibility( AccessSpecifier.v_private );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -472,7 +474,7 @@ public class DOMBuilder implements IParserCallback
|
||||||
*/
|
*/
|
||||||
public void declaratorThrowExceptionName(Object declarator ) {
|
public void declaratorThrowExceptionName(Object declarator ) {
|
||||||
Declarator decl = (Declarator)declarator;
|
Declarator decl = (Declarator)declarator;
|
||||||
decl.addExceptionSpecifierTypeName( currName );
|
decl.getExceptionSpecifier().addTypeName( currName );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -480,7 +482,7 @@ public class DOMBuilder implements IParserCallback
|
||||||
*/
|
*/
|
||||||
public void declaratorThrowsException(Object declarator) {
|
public void declaratorThrowsException(Object declarator) {
|
||||||
Declarator decl = (Declarator)declarator;
|
Declarator decl = (Declarator)declarator;
|
||||||
decl.throwsExceptions();
|
decl.getExceptionSpecifier().setThrowsException(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -650,4 +652,75 @@ public class DOMBuilder implements IParserCallback
|
||||||
*/
|
*/
|
||||||
public void enumDefinitionEnd(Object enumDefn) {
|
public void enumDefinitionEnd(Object enumDefn) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#asmDefinition(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void asmDefinition(Object container, String assemblyCode) {
|
||||||
|
IScope scope = (IScope)container;
|
||||||
|
ASMDefinition definition = new ASMDefinition( assemblyCode );
|
||||||
|
scope.addDeclaration( definition );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainBegin(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object constructorChainBegin(Object declarator) {
|
||||||
|
Declarator d = (Declarator)declarator;
|
||||||
|
ConstructorChain chain = new ConstructorChain(d);
|
||||||
|
return chain;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainAbort(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void constructorChainAbort(Object ctor) {
|
||||||
|
ctor = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainEnd(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void constructorChainEnd(Object ctor) {
|
||||||
|
ConstructorChain chain = (ConstructorChain)ctor;
|
||||||
|
chain.getOwnerDeclarator().setCtorChain(chain);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainElementBegin(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object constructorChainElementBegin(Object ctor) {
|
||||||
|
return new ConstructorChainElement( (ConstructorChain)ctor );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainElementEnd(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void constructorChainElementEnd(Object element) {
|
||||||
|
ConstructorChainElement ele = (ConstructorChainElement)element;
|
||||||
|
ele.getOwnerChain().addChainElement( ele );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainId(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void constructorChainElementId(Object element) {
|
||||||
|
ConstructorChainElement ele = (ConstructorChainElement)element;
|
||||||
|
ele.setName(currName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainElementExpressionListElementBegin(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object constructorChainElementExpressionListElementBegin(Object element) {
|
||||||
|
return new ConstructorChainElementExpression( (ConstructorChainElement)element );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainElementExpressionListElementEnd(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void constructorChainElementExpressionListElementEnd(Object expression) {
|
||||||
|
ConstructorChainElementExpression exp = (ConstructorChainElementExpression)expression;
|
||||||
|
exp.getOwnerElement().addExpression( exp );
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package org.eclipse.cdt.internal.core.dom;
|
package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
|
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
|
||||||
|
@ -80,45 +81,28 @@ public class Declarator implements IExpressionOwner {
|
||||||
initialExpression = exp;
|
initialExpression = exp;
|
||||||
}
|
}
|
||||||
|
|
||||||
List pointerOperators = null;
|
List pointerOperators = new ArrayList();
|
||||||
List arrayQualifiers = null;
|
List arrayQualifiers = new ArrayList();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return List
|
* @return List
|
||||||
*/
|
*/
|
||||||
public List getPointerOperators() {
|
public List getPointerOperators() {
|
||||||
return pointerOperators;
|
return Collections.unmodifiableList(pointerOperators);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPointerOperator( PointerOperator po )
|
public void addPointerOperator( PointerOperator po )
|
||||||
{
|
{
|
||||||
if( pointerOperators == null )
|
|
||||||
{
|
|
||||||
pointerOperators = new ArrayList();
|
|
||||||
}
|
|
||||||
pointerOperators.add(po);
|
pointerOperators.add(po);
|
||||||
}
|
}
|
||||||
|
|
||||||
List exceptionSpecifier = null;
|
ExceptionSpecifier exceptionSpecifier = new ExceptionSpecifier();
|
||||||
|
|
||||||
public List getExceptionSpecifier()
|
public ExceptionSpecifier getExceptionSpecifier()
|
||||||
{
|
{
|
||||||
return exceptionSpecifier;
|
return exceptionSpecifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void throwsExceptions()
|
|
||||||
{
|
|
||||||
if( exceptionSpecifier == null )
|
|
||||||
exceptionSpecifier = new ArrayList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addExceptionSpecifierTypeName( Name name )
|
|
||||||
{
|
|
||||||
exceptionSpecifier.add( name );
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isConst = false;
|
boolean isConst = false;
|
||||||
boolean isVolatile = false;
|
boolean isVolatile = false;
|
||||||
/**
|
/**
|
||||||
|
@ -155,16 +139,29 @@ public class Declarator implements IExpressionOwner {
|
||||||
* @return List
|
* @return List
|
||||||
*/
|
*/
|
||||||
public List getArrayQualifiers() {
|
public List getArrayQualifiers() {
|
||||||
return arrayQualifiers;
|
return Collections.unmodifiableList( arrayQualifiers );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addArrayQualifier( ArrayQualifier q )
|
public void addArrayQualifier( ArrayQualifier q )
|
||||||
{
|
{
|
||||||
if( arrayQualifiers == null )
|
|
||||||
{
|
|
||||||
arrayQualifiers = new ArrayList();
|
|
||||||
}
|
|
||||||
arrayQualifiers.add(q);
|
arrayQualifiers.add(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ConstructorChain ctorChain = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return ConstructorChain
|
||||||
|
*/
|
||||||
|
public ConstructorChain getCtorChain() {
|
||||||
|
return ctorChain;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the ctorChain.
|
||||||
|
* @param ctorChain The ctorChain to set
|
||||||
|
*/
|
||||||
|
public void setCtorChain(ConstructorChain ctorChain) {
|
||||||
|
this.ctorChain = ctorChain;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.eclipse.cdt.internal.core.dom;
|
package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.core.parser.util.ClassKey;
|
||||||
import org.eclipse.cdt.internal.core.parser.util.Name;
|
import org.eclipse.cdt.internal.core.parser.util.Name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,14 +14,13 @@ import org.eclipse.cdt.internal.core.parser.util.Name;
|
||||||
*/
|
*/
|
||||||
public class ElaboratedTypeSpecifier extends TypeSpecifier {
|
public class ElaboratedTypeSpecifier extends TypeSpecifier {
|
||||||
|
|
||||||
public static final int t_class = 0;
|
ClassKey classKey = new ClassKey();
|
||||||
public static final int t_struct = 1;
|
public int getClassKey() { return classKey.getClassKey(); }
|
||||||
public static final int t_union = 2;
|
|
||||||
public static final int t_enum = 3;
|
|
||||||
|
|
||||||
private final int classKey;
|
|
||||||
public int getClassKey() { return classKey; }
|
|
||||||
|
|
||||||
|
public void setClassKey( int classKey )
|
||||||
|
{
|
||||||
|
this.classKey.setClassKey( classKey );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.dom.TypeSpecifier#getDeclaration()
|
* @see org.eclipse.cdt.internal.core.dom.TypeSpecifier#getDeclaration()
|
||||||
|
@ -38,7 +38,7 @@ public class ElaboratedTypeSpecifier extends TypeSpecifier {
|
||||||
|
|
||||||
public ElaboratedTypeSpecifier(int classKey, SimpleDeclaration declaration) {
|
public ElaboratedTypeSpecifier(int classKey, SimpleDeclaration declaration) {
|
||||||
super(declaration);
|
super(declaration);
|
||||||
this.classKey = classKey;
|
this.classKey.setClassKey( classKey );
|
||||||
}
|
}
|
||||||
|
|
||||||
private Name name;
|
private Name name;
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom;
|
package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ public class EnumerationSpecifier extends TypeSpecifier {
|
||||||
* @return List
|
* @return List
|
||||||
*/
|
*/
|
||||||
public List getEnumeratorDefinitions() {
|
public List getEnumeratorDefinitions() {
|
||||||
return enumeratorDefinitions;
|
return Collections.unmodifiableList( enumeratorDefinitions );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Created on Mar 26, 2003
|
||||||
|
*
|
||||||
|
* 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:
|
||||||
|
* Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.core.parser.util.Name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ExceptionSpecifier {
|
||||||
|
|
||||||
|
private List typeNames = new LinkedList();
|
||||||
|
private boolean throwsException = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return List
|
||||||
|
*/
|
||||||
|
public List getTypeNames() {
|
||||||
|
return Collections.unmodifiableList( typeNames );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addTypeName( Name name )
|
||||||
|
{
|
||||||
|
typeNames.add( name );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the throwsException.
|
||||||
|
* @param throwsException The throwsException to set
|
||||||
|
*/
|
||||||
|
public void setThrowsException(boolean throwsException) {
|
||||||
|
this.throwsException = throwsException;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public boolean throwsException() {
|
||||||
|
return throwsException;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -12,6 +12,7 @@
|
||||||
package org.eclipse.cdt.internal.core.dom;
|
package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.parser.Token;
|
import org.eclipse.cdt.internal.core.parser.Token;
|
||||||
|
@ -31,7 +32,7 @@ public class Expression {
|
||||||
|
|
||||||
public List tokens()
|
public List tokens()
|
||||||
{
|
{
|
||||||
return tokens;
|
return Collections.unmodifiableList( tokens );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom;
|
package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -42,7 +43,7 @@ public class LinkageSpecification extends Declaration implements IScope {
|
||||||
* @see org.eclipse.cdt.internal.core.dom.IScope#getDeclarations()
|
* @see org.eclipse.cdt.internal.core.dom.IScope#getDeclarations()
|
||||||
*/
|
*/
|
||||||
public List getDeclarations() {
|
public List getDeclarations() {
|
||||||
return declarations;
|
return Collections.unmodifiableList( declarations );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.eclipse.cdt.internal.core.dom;
|
package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.core.parser.util.AccessSpecifier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author dschaefe
|
* @author dschaefe
|
||||||
*
|
*
|
||||||
|
@ -9,17 +11,14 @@ package org.eclipse.cdt.internal.core.dom;
|
||||||
* Window>Preferences>Java>Code Generation.
|
* Window>Preferences>Java>Code Generation.
|
||||||
*/
|
*/
|
||||||
public class MemberDeclaration {
|
public class MemberDeclaration {
|
||||||
public static final int t_private = 0;
|
|
||||||
public static final int t_protected = 1;
|
|
||||||
public static final int t_public = 2;
|
|
||||||
|
|
||||||
public MemberDeclaration(int access, Declaration declaration) {
|
public MemberDeclaration(int access, Declaration declaration) {
|
||||||
this.access = access;
|
this.access.setAccess( access );
|
||||||
this.declaration = declaration;
|
this.declaration = declaration;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int access;
|
private AccessSpecifier access = new AccessSpecifier();
|
||||||
public int getAccess() { return access; }
|
public int getAccess() { return access.getAccess(); }
|
||||||
|
|
||||||
private Declaration declaration;
|
private Declaration declaration;
|
||||||
public Declaration getDeclaration() { return declaration; }
|
public Declaration getDeclaration() { return declaration; }
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom;
|
package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -44,7 +45,7 @@ public class NamespaceDefinition extends Declaration implements IScope {
|
||||||
* @see org.eclipse.cdt.internal.core.dom.IScope#getDeclarations()
|
* @see org.eclipse.cdt.internal.core.dom.IScope#getDeclarations()
|
||||||
*/
|
*/
|
||||||
public List getDeclarations() {
|
public List getDeclarations() {
|
||||||
return declarations;
|
return Collections.unmodifiableList( declarations );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.eclipse.cdt.internal.core.dom;
|
package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ public class ParameterDeclaration extends Declaration implements DeclSpecifier.C
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getDeclarators() {
|
public List getDeclarators() {
|
||||||
return declarators;
|
return Collections.unmodifiableList( declarators );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.eclipse.cdt.internal.core.dom;
|
package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -25,7 +26,7 @@ public class ParameterDeclarationClause implements IScope {
|
||||||
* @see org.eclipse.cdt.core.dom.IScope#getDeclarations()
|
* @see org.eclipse.cdt.core.dom.IScope#getDeclarations()
|
||||||
*/
|
*/
|
||||||
public List getDeclarations() {
|
public List getDeclarations() {
|
||||||
return declarations;
|
return Collections.unmodifiableList( declarations );
|
||||||
}
|
}
|
||||||
|
|
||||||
private List declarations = new LinkedList();
|
private List declarations = new LinkedList();
|
||||||
|
|
|
@ -21,7 +21,6 @@ public class PointerOperator {
|
||||||
public final static int t_undefined = 0;
|
public final static int t_undefined = 0;
|
||||||
public final static int t_pointer = 1;
|
public final static int t_pointer = 1;
|
||||||
public final static int t_reference = 2;
|
public final static int t_reference = 2;
|
||||||
|
|
||||||
private int type = t_undefined;
|
private int type = t_undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.eclipse.cdt.internal.core.dom;
|
package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -51,7 +52,7 @@ public class SimpleDeclaration extends Declaration implements DeclSpecifier.Cont
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getDeclarators() {
|
public List getDeclarators() {
|
||||||
return declarators;
|
return Collections.unmodifiableList( declarators );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.eclipse.cdt.internal.core.dom;
|
package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -15,6 +16,6 @@ public class TranslationUnit implements IScope {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getDeclarations() {
|
public List getDeclarations() {
|
||||||
return declarations;
|
return Collections.unmodifiableList( declarations );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
2003-03-28 John Camelon
|
||||||
|
Added AccessSpecifier and ClassKind to parser.util package and refactored callbacks.
|
||||||
|
Better encapsulated ExceptionSpecification in the DOM.
|
||||||
|
Updated DOM structures to return unmodifiable collections.
|
||||||
|
Added callback support for asmdefinitions.
|
||||||
|
Added callback support for constructor initializer chains.
|
||||||
|
Fixed bug 35781 and updated parser to catch all exceptions from callbacks to ensure best-effort parsing.
|
||||||
|
Removed Main.java from Parser package.
|
||||||
|
|
||||||
2003-03-26 Andrew Niefer
|
2003-03-26 Andrew Niefer
|
||||||
Moved type information and ParameterInfo from Declaration into util.TypeInfo
|
Moved type information and ParameterInfo from Declaration into util.TypeInfo
|
||||||
Initial implementation of standard conversion sequences for function resolution
|
Initial implementation of standard conversion sequences for function resolution
|
||||||
|
|
|
@ -16,6 +16,7 @@ import java.util.List;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.internal.core.parser.IParserCallback;
|
import org.eclipse.cdt.internal.core.parser.IParserCallback;
|
||||||
import org.eclipse.cdt.internal.core.parser.Token;
|
import org.eclipse.cdt.internal.core.parser.Token;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.util.AccessSpecifier;
|
||||||
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
|
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
|
||||||
import org.eclipse.cdt.internal.core.parser.util.Name;
|
import org.eclipse.cdt.internal.core.parser.util.Name;
|
||||||
|
|
||||||
|
@ -39,7 +40,8 @@ public class NewModelBuilder implements IParserCallback {
|
||||||
* @see org.eclipse.cdt.core.newparser.IParserCallback#beginClass(String, String)
|
* @see org.eclipse.cdt.core.newparser.IParserCallback#beginClass(String, String)
|
||||||
*/
|
*/
|
||||||
public Object classSpecifierBegin(Object container, Token classKey) {
|
public Object classSpecifierBegin(Object container, Token classKey) {
|
||||||
|
if( container instanceof SimpleDeclarationWrapper )
|
||||||
|
{
|
||||||
SimpleDeclarationWrapper c = (SimpleDeclarationWrapper)container;
|
SimpleDeclarationWrapper c = (SimpleDeclarationWrapper)container;
|
||||||
|
|
||||||
int kind;
|
int kind;
|
||||||
|
@ -60,15 +62,21 @@ public class NewModelBuilder implements IParserCallback {
|
||||||
|
|
||||||
return wrapper;
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#classSpecifierName()
|
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#classSpecifierName()
|
||||||
*/
|
*/
|
||||||
public void classSpecifierName(Object classSpecifier)
|
public void classSpecifierName(Object classSpecifier)
|
||||||
|
{
|
||||||
|
if( classSpecifier instanceof SimpleDeclarationWrapper )
|
||||||
{
|
{
|
||||||
SimpleDeclarationWrapper wrapper = (SimpleDeclarationWrapper)classSpecifier;
|
SimpleDeclarationWrapper wrapper = (SimpleDeclarationWrapper)classSpecifier;
|
||||||
wrapper.setName( currName );
|
wrapper.setName( currName );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.core.newparser.IParserCallback#endClass()
|
* @see org.eclipse.cdt.core.newparser.IParserCallback#endClass()
|
||||||
|
@ -376,13 +384,13 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
|
||||||
switch( visibility.getType() )
|
switch( visibility.getType() )
|
||||||
{
|
{
|
||||||
case Token.t_public:
|
case Token.t_public:
|
||||||
spec.setCurrentVisibility( SimpleDeclarationWrapper.v_public );
|
spec.setCurrentVisibility( AccessSpecifier.v_public );
|
||||||
break;
|
break;
|
||||||
case Token.t_protected:
|
case Token.t_protected:
|
||||||
spec.setCurrentVisibility( SimpleDeclarationWrapper.v_protected );
|
spec.setCurrentVisibility( AccessSpecifier.v_protected );
|
||||||
break;
|
break;
|
||||||
case Token.t_private:
|
case Token.t_private:
|
||||||
spec.setCurrentVisibility( SimpleDeclarationWrapper.v_private );
|
spec.setCurrentVisibility( AccessSpecifier.v_private );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -471,48 +479,42 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationBegin(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationBegin(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public Object namespaceDefinitionBegin(Object container) {
|
public Object namespaceDefinitionBegin(Object container) {
|
||||||
// TODO Auto-generated method stub
|
// until Namespaces are made part of the code model, just return the container object
|
||||||
return null;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationId(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationId(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void namespaceDefinitionId(Object namespace) {
|
public void namespaceDefinitionId(Object namespace) {
|
||||||
// TODO Auto-generated method stub
|
// until namespaceDefinitionBegin is updated to do more than return its container, do nothing
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationAbort(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationAbort(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void namespaceDefinitionAbort(Object namespace) {
|
public void namespaceDefinitionAbort(Object namespace) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationEnd(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationEnd(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void namespaceDefinitionEnd(Object namespace) {
|
public void namespaceDefinitionEnd(Object namespace) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#linkageSpecificationBegin(java.lang.Object, java.lang.String)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#linkageSpecificationBegin(java.lang.Object, java.lang.String)
|
||||||
*/
|
*/
|
||||||
public Object linkageSpecificationBegin(Object container, String literal) {
|
public Object linkageSpecificationBegin(Object container, String literal) {
|
||||||
// TODO Auto-generated method stub
|
// until linkageSpecs are part of the code model (do they need to be?) just return the container object
|
||||||
return null;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#linkageSpecificationEnd(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#linkageSpecificationEnd(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void linkageSpecificationEnd(Object linkageSpec) {
|
public void linkageSpecificationEnd(Object linkageSpec) {
|
||||||
// TODO Auto-generated method stub
|
// do not implement anything unless linkageSpecificationBegin does more than just return its container
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -635,4 +637,76 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#asmDefinition(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void asmDefinition(Object container, String assemblyCode) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainBegin(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object constructorChainBegin(Object declarator) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainAbort(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void constructorChainAbort(Object ctor) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainEnd(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void constructorChainEnd(Object ctor) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainElementBegin(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object constructorChainElementBegin(Object ctor) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainElementEnd(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void constructorChainElementEnd(Object element) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainId(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void constructorChainElementId(Object ctor) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainElementExpressionListElementBegin(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object constructorChainElementExpressionListElementBegin(Object element) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainElementExpressionListElementEnd(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void constructorChainElementExpressionListElementEnd(Object expression) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.IStructure;
|
import org.eclipse.cdt.core.model.IStructure;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.util.AccessSpecifier;
|
||||||
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
|
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
|
||||||
import org.eclipse.cdt.internal.core.parser.util.Name;
|
import org.eclipse.cdt.internal.core.parser.util.Name;
|
||||||
|
|
||||||
|
@ -228,16 +229,12 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
|
||||||
this.functionDefinition = functionDefinition;
|
this.functionDefinition = functionDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final int v_public = 0;
|
private AccessSpecifier currentVisibility = new AccessSpecifier();
|
||||||
public static final int v_protected = 1;
|
|
||||||
public static final int v_private = 2;
|
|
||||||
|
|
||||||
private int currentVisibility;
|
|
||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public int getCurrentVisibility() {
|
public int getCurrentVisibility() {
|
||||||
return currentVisibility;
|
return currentVisibility.getAccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -245,7 +242,7 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
|
||||||
* @param currentVisibility The currentVisibility to set
|
* @param currentVisibility The currentVisibility to set
|
||||||
*/
|
*/
|
||||||
public void setCurrentVisibility(int currentVisibility) {
|
public void setCurrentVisibility(int currentVisibility) {
|
||||||
this.currentVisibility = currentVisibility;
|
this.currentVisibility.setAccess( currentVisibility );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -565,4 +565,61 @@ public class ExpressionEvaluator implements IParserCallback {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#asmDefinition(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void asmDefinition(Object container, String assemblyCode) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainBegin(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object constructorChainBegin(Object declarator) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainAbort(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void constructorChainAbort(Object ctor) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainEnd(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void constructorChainEnd(Object ctor) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainElementBegin(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object constructorChainElementBegin(Object ctor) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainElementEnd(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void constructorChainElementEnd(Object element) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainId(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void constructorChainElementId(Object ctor) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainElementExpressionListElementBegin(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object constructorChainElementExpressionListElementBegin(Object element) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainElementExpressionListElementEnd(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void constructorChainElementExpressionListElementEnd(Object expression) {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,4 +103,17 @@ public interface IParserCallback {
|
||||||
public void enumDefinitionId( Object enumDefn );
|
public void enumDefinitionId( Object enumDefn );
|
||||||
public void enumDefinitionEnd( Object enumDefn );
|
public void enumDefinitionEnd( Object enumDefn );
|
||||||
|
|
||||||
|
public void asmDefinition( Object container, String assemblyCode );
|
||||||
|
|
||||||
|
public Object constructorChainBegin( Object declarator );
|
||||||
|
public void constructorChainAbort( Object ctor );
|
||||||
|
public void constructorChainEnd( Object ctor );
|
||||||
|
|
||||||
|
public Object constructorChainElementBegin( Object ctor );
|
||||||
|
public void constructorChainElementId( Object element );
|
||||||
|
public void constructorChainElementEnd( Object element );
|
||||||
|
|
||||||
|
public Object constructorChainElementExpressionListElementBegin( Object element );
|
||||||
|
public void constructorChainElementExpressionListElementEnd( Object expression );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,82 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2001 Rational Software Corp. 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:
|
|
||||||
* Rational Software - initial implementation
|
|
||||||
******************************************************************************/
|
|
||||||
package org.eclipse.cdt.internal.core.parser;
|
|
||||||
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.Reader;
|
|
||||||
|
|
||||||
public class Main {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
|
|
||||||
String fileName = null;
|
|
||||||
|
|
||||||
// Find the file
|
|
||||||
for (int i = 0; i < args.length; ++i) {
|
|
||||||
if (!args[i].startsWith("-"))
|
|
||||||
fileName = args[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fileName == null) {
|
|
||||||
System.out.println("Error: no files.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Reader reader;
|
|
||||||
try {
|
|
||||||
reader = new FileReader(fileName);
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.err.println(e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Scanner scanner = new Scanner();
|
|
||||||
scanner.initialize( reader, fileName );
|
|
||||||
|
|
||||||
// Now pass on the preprocessing options
|
|
||||||
for (int i = 0; i < args.length; ++i) {
|
|
||||||
if (args[i].startsWith("-I")) {
|
|
||||||
String dir = args[i].substring(2);
|
|
||||||
scanner.addIncludePath(dir);
|
|
||||||
} else if (args[i].startsWith("-D")) {
|
|
||||||
int pos = args[i].indexOf('=');
|
|
||||||
String name;
|
|
||||||
String value = "";
|
|
||||||
if (pos < 0) {
|
|
||||||
name = args[i].substring(2);
|
|
||||||
} else {
|
|
||||||
name = args[i].substring(2, pos);
|
|
||||||
value = args[i].substring(pos + 1);
|
|
||||||
}
|
|
||||||
scanner.addDefinition(name, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Parser parser = null;
|
|
||||||
try {
|
|
||||||
parser = new Parser(scanner);
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.out.println(e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
long startTime = System.currentTimeMillis();
|
|
||||||
try {
|
|
||||||
parser.parse();
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.err.println(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
long time = System.currentTimeMillis() - startTime;
|
|
||||||
|
|
||||||
System.out.println("done " + scanner.getCount() + " tokens in " + time + "ms.");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -466,4 +466,61 @@ public class NullParserCallback implements IParserCallback {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#asmDefinition(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void asmDefinition(Object container, String assemblyCode) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainBegin(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object constructorChainBegin(Object declarator) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainAbort(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void constructorChainAbort(Object ctor) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainEnd(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void constructorChainEnd(Object ctor) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainElementBegin(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object constructorChainElementBegin(Object ctor) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainElementEnd(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void constructorChainElementEnd(Object element) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainId(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void constructorChainElementId(Object ctor) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainElementExpressionListElementBegin(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object constructorChainElementExpressionListElementBegin(Object element) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainElementExpressionListElementEnd(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void constructorChainElementExpressionListElementEnd(Object expression) {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,8 @@ c, quick);
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected void translationUnit() throws Backtrack {
|
protected void translationUnit() throws Backtrack {
|
||||||
Object translationUnit = callback.translationUnitBegin();
|
Object translationUnit = null;
|
||||||
|
try{ translationUnit = callback.translationUnitBegin();} catch( Exception e ) {}
|
||||||
Token lastBacktrack = null;
|
Token lastBacktrack = null;
|
||||||
Token lastToken;
|
Token lastToken;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -101,7 +102,7 @@ c, quick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
callback.translationUnitEnd(translationUnit);
|
try{ callback.translationUnitEnd(translationUnit);} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void consumeToNextSemicolon() throws EndOfFile {
|
protected void consumeToNextSemicolon() throws EndOfFile {
|
||||||
|
@ -132,7 +133,8 @@ c, quick);
|
||||||
|
|
||||||
if( LT(1) == Token.t_namespace )
|
if( LT(1) == Token.t_namespace )
|
||||||
{
|
{
|
||||||
Object directive = callback.usingDirectiveBegin( container );
|
Object directive = null;
|
||||||
|
try{ directive = callback.usingDirectiveBegin( container );} catch( Exception e ) {}
|
||||||
// using-directive
|
// using-directive
|
||||||
consume( Token.t_namespace );
|
consume( Token.t_namespace );
|
||||||
|
|
||||||
|
@ -140,29 +142,30 @@ c, quick);
|
||||||
if( LT(1) == Token.tIDENTIFIER || LT(1) == Token.tCOLONCOLON )
|
if( LT(1) == Token.tIDENTIFIER || LT(1) == Token.tCOLONCOLON )
|
||||||
{
|
{
|
||||||
name();
|
name();
|
||||||
callback.usingDirectiveNamespaceId( directive );
|
try{ callback.usingDirectiveNamespaceId( directive );} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
callback.usingDirectiveAbort(directive);
|
try{ callback.usingDirectiveAbort(directive);} catch( Exception e ) {}
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( LT(1) == Token.tSEMI )
|
if( LT(1) == Token.tSEMI )
|
||||||
{
|
{
|
||||||
consume( Token.tSEMI );
|
consume( Token.tSEMI );
|
||||||
callback.usingDirectiveEnd( directive );
|
try{ callback.usingDirectiveEnd( directive );} catch( Exception e ) {}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
callback.usingDirectiveAbort(directive);
|
try{ callback.usingDirectiveAbort(directive);} catch( Exception e ) {}
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Object usingDeclaration = callback.usingDeclarationBegin( container );
|
Object usingDeclaration = null;
|
||||||
|
try{ usingDeclaration = callback.usingDeclarationBegin( container );} catch( Exception e ) {}
|
||||||
|
|
||||||
boolean typeName = false;
|
boolean typeName = false;
|
||||||
if( LT(1) == Token.t_typename )
|
if( LT(1) == Token.t_typename )
|
||||||
|
@ -175,22 +178,22 @@ c, quick);
|
||||||
{
|
{
|
||||||
// optional :: and nested classes handled in name
|
// optional :: and nested classes handled in name
|
||||||
name();
|
name();
|
||||||
callback.usingDeclarationMapping( usingDeclaration, typeName );
|
try{ callback.usingDeclarationMapping( usingDeclaration, typeName ); } catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
callback.usingDeclarationAbort( usingDeclaration );
|
try{ callback.usingDeclarationAbort( usingDeclaration );} catch( Exception e ) {}
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( LT(1) == Token.tSEMI )
|
if( LT(1) == Token.tSEMI )
|
||||||
{
|
{
|
||||||
consume( Token.tSEMI );
|
consume( Token.tSEMI );
|
||||||
callback.usingDeclarationEnd( usingDeclaration );
|
try{ callback.usingDeclarationEnd( usingDeclaration );} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
callback.usingDeclarationAbort( usingDeclaration );
|
try{ callback.usingDeclarationAbort( usingDeclaration );} catch( Exception e ) {}
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +218,8 @@ c, quick);
|
||||||
if( LT(1) != Token.tSTRING )
|
if( LT(1) != Token.tSTRING )
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
|
|
||||||
Object linkageSpec = callback.linkageSpecificationBegin( container, consume( Token.tSTRING ).getImage() );
|
Object linkageSpec = null;
|
||||||
|
try{ linkageSpec = callback.linkageSpecificationBegin( container, consume( Token.tSTRING ).getImage() );} catch( Exception e ) {}
|
||||||
|
|
||||||
if( LT(1) == Token.tLBRACE )
|
if( LT(1) == Token.tLBRACE )
|
||||||
{
|
{
|
||||||
|
@ -235,12 +239,12 @@ c, quick);
|
||||||
}
|
}
|
||||||
// consume the }
|
// consume the }
|
||||||
consume();
|
consume();
|
||||||
callback.linkageSpecificationEnd( linkageSpec );
|
try{ callback.linkageSpecificationEnd( linkageSpec );} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
else // single declaration
|
else // single declaration
|
||||||
{
|
{
|
||||||
declaration( linkageSpec );
|
declaration( linkageSpec );
|
||||||
callback.linkageSpecificationEnd( linkageSpec );
|
try{ callback.linkageSpecificationEnd( linkageSpec );} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,8 +269,14 @@ c, quick);
|
||||||
protected void declaration( Object container ) throws Backtrack {
|
protected void declaration( Object container ) throws Backtrack {
|
||||||
switch (LT(1)) {
|
switch (LT(1)) {
|
||||||
case Token.t_asm:
|
case Token.t_asm:
|
||||||
// asmDefinition( );
|
consume( Token.t_asm );
|
||||||
consume();
|
consume( Token.tLPAREN );
|
||||||
|
String assembly = consume( Token.tSTRING ).getImage();
|
||||||
|
consume( Token.tRPAREN );
|
||||||
|
consume( Token.tSEMI );
|
||||||
|
// if we made it this far, then we have all we need
|
||||||
|
// do the callback
|
||||||
|
try{ callback.asmDefinition( container, assembly );} catch( Exception e ) {}
|
||||||
return;
|
return;
|
||||||
case Token.t_namespace:
|
case Token.t_namespace:
|
||||||
namespaceDefinition( container );
|
namespaceDefinition( container );
|
||||||
|
@ -280,8 +290,11 @@ c, quick);
|
||||||
consume();
|
consume();
|
||||||
return;
|
return;
|
||||||
case Token.t_extern:
|
case Token.t_extern:
|
||||||
|
if( LT(2) == Token.tSTRING )
|
||||||
|
{
|
||||||
linkageSpecification( container );
|
linkageSpecification( container );
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
simpleDeclaration( container );
|
simpleDeclaration( container );
|
||||||
}
|
}
|
||||||
|
@ -300,13 +313,14 @@ c, quick);
|
||||||
protected void namespaceDefinition( Object container ) throws Backtrack
|
protected void namespaceDefinition( Object container ) throws Backtrack
|
||||||
{
|
{
|
||||||
consume( Token.t_namespace);
|
consume( Token.t_namespace);
|
||||||
Object namespace = callback.namespaceDefinitionBegin( container );
|
Object namespace = null;
|
||||||
|
try{ namespace = callback.namespaceDefinitionBegin( container );} catch( Exception e ) {}
|
||||||
|
|
||||||
// optional name
|
// optional name
|
||||||
if( LT(1) == Token.tIDENTIFIER )
|
if( LT(1) == Token.tIDENTIFIER )
|
||||||
{
|
{
|
||||||
name();
|
name();
|
||||||
callback.namespaceDefinitionId( namespace );
|
try{ callback.namespaceDefinitionId( namespace );} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( LT(1) == Token.tLBRACE )
|
if( LT(1) == Token.tLBRACE )
|
||||||
|
@ -327,11 +341,11 @@ c, quick);
|
||||||
}
|
}
|
||||||
// consume the }
|
// consume the }
|
||||||
consume();
|
consume();
|
||||||
callback.namespaceDefinitionEnd( namespace );
|
try{ callback.namespaceDefinitionEnd( namespace );} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
callback.namespaceDefinitionAbort( namespace );
|
try{ callback.namespaceDefinitionAbort( namespace );} catch( Exception e ) {}
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -349,12 +363,14 @@ c, quick);
|
||||||
* - work in ctorInitializer and functionTryBlock
|
* - work in ctorInitializer and functionTryBlock
|
||||||
*/
|
*/
|
||||||
protected void simpleDeclaration( Object container ) throws Backtrack {
|
protected void simpleDeclaration( Object container ) throws Backtrack {
|
||||||
Object simpleDecl = callback.simpleDeclarationBegin( container);
|
Object simpleDecl = null;
|
||||||
|
try{ simpleDecl = callback.simpleDeclarationBegin( container);} catch( Exception e ) {}
|
||||||
declSpecifierSeq(simpleDecl, false);
|
declSpecifierSeq(simpleDecl, false);
|
||||||
|
Object declarator = null;
|
||||||
|
|
||||||
if (LT(1) != Token.tSEMI)
|
if (LT(1) != Token.tSEMI)
|
||||||
try {
|
try {
|
||||||
initDeclarator(simpleDecl);
|
declarator = initDeclarator(simpleDecl);
|
||||||
|
|
||||||
while (LT(1) == Token.tCOMMA) {
|
while (LT(1) == Token.tCOMMA) {
|
||||||
consume();
|
consume();
|
||||||
|
@ -374,19 +390,15 @@ c, quick);
|
||||||
consume();
|
consume();
|
||||||
break;
|
break;
|
||||||
case Token.tCOLON:
|
case Token.tCOLON:
|
||||||
// TODO - Initializer for constructor, for now consume
|
ctorInitializer(declarator);
|
||||||
// and look for the left brace;
|
|
||||||
consume();
|
|
||||||
while (LT(1) != Token.tLBRACE) {
|
|
||||||
consume();
|
|
||||||
}
|
|
||||||
// Falling through on purpose
|
// Falling through on purpose
|
||||||
case Token.tLBRACE:
|
case Token.tLBRACE:
|
||||||
Object function = callback.functionBodyBegin(simpleDecl );
|
Object function = null;
|
||||||
|
try{ function = callback.functionBodyBegin(simpleDecl ); } catch( Exception e ) {}
|
||||||
if (quickParse) {
|
if (quickParse) {
|
||||||
// speed up the parser by skiping the body
|
// speed up the parser by skiping the body
|
||||||
// simply look for matching brace and return
|
// simply look for matching brace and return
|
||||||
consume();
|
consume(Token.tLBRACE);
|
||||||
int depth = 1;
|
int depth = 1;
|
||||||
while (depth > 0) {
|
while (depth > 0) {
|
||||||
switch (consume().getType()) {
|
switch (consume().getType()) {
|
||||||
|
@ -401,30 +413,79 @@ c, quick);
|
||||||
} else {
|
} else {
|
||||||
functionBody();
|
functionBody();
|
||||||
}
|
}
|
||||||
callback.functionBodyEnd(function);
|
try{ callback.functionBodyEnd(function);} catch( Exception e ) {}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback.simpleDeclarationEnd(simpleDecl);
|
try{ callback.simpleDeclarationEnd(simpleDecl);} catch( Exception e ) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void ctorInitializer(Object declarator) throws Backtrack {
|
||||||
|
consume( Token.tCOLON );
|
||||||
|
|
||||||
|
Object constructorChain = null;
|
||||||
|
try { constructorChain = callback.constructorChainBegin(declarator);} catch( Exception e ) {}
|
||||||
|
|
||||||
|
try {
|
||||||
|
for( ; ; ) {
|
||||||
|
if( LT(1) == Token.tLBRACE ) break;
|
||||||
|
|
||||||
|
Object constructorChainElement = null;
|
||||||
|
try{ constructorChainElement = callback.constructorChainElementBegin( constructorChain );} catch( Exception e ) {}
|
||||||
|
name();
|
||||||
|
try{ callback.constructorChainElementId(constructorChainElement);} catch( Exception e) {}
|
||||||
|
|
||||||
|
consume( Token.tLPAREN );
|
||||||
|
|
||||||
|
while( LT(1) != Token.tRPAREN )
|
||||||
|
{
|
||||||
|
//handle expression list here
|
||||||
|
Object item = null;
|
||||||
|
try{ item = callback.constructorChainElementExpressionListElementBegin(constructorChainElement );} catch( Exception e ) {}
|
||||||
|
Object expression = null;
|
||||||
|
try{ expression = callback.expressionBegin( item );} catch( Exception e) {}
|
||||||
|
assignmentExpression( expression );
|
||||||
|
try{ callback.expressionEnd( item );} catch( Exception e) {}
|
||||||
|
try{ callback.constructorChainElementExpressionListElementEnd( item );} catch( Exception e) {}
|
||||||
|
if( LT(1) == Token.tRPAREN ) break;
|
||||||
|
consume( Token.tCOMMA );
|
||||||
|
}
|
||||||
|
|
||||||
|
consume( Token.tRPAREN );
|
||||||
|
try{ callback.constructorChainElementEnd(constructorChainElement );} catch( Exception e) {}
|
||||||
|
|
||||||
|
if( LT(1) == Token.tLBRACE ) break;
|
||||||
|
if( LT(1) == Token.tCOMMA ) consume( Token.tCOMMA );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch( Backtrack bt )
|
||||||
|
{
|
||||||
|
try { callback.constructorChainAbort( constructorChain );} catch( Exception e ) {}
|
||||||
|
if( ! quickParse )
|
||||||
|
throw backtrack;
|
||||||
|
}
|
||||||
|
|
||||||
|
try { callback.constructorChainEnd( constructorChain ); } catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void parameterDeclaration( Object containerObject ) throws Backtrack
|
protected void parameterDeclaration( Object containerObject ) throws Backtrack
|
||||||
{
|
{
|
||||||
Object parameterDecl = callback.parameterDeclarationBegin( containerObject );
|
Object parameterDecl = null;
|
||||||
|
try{ parameterDecl = callback.parameterDeclarationBegin( containerObject );} catch( Exception e ) {}
|
||||||
declSpecifierSeq( parameterDecl, true );
|
declSpecifierSeq( parameterDecl, true );
|
||||||
|
|
||||||
if (LT(1) != Token.tSEMI)
|
if (LT(1) != Token.tSEMI)
|
||||||
try {
|
try {
|
||||||
initDeclarator(parameterDecl);
|
Object declarator = initDeclarator(parameterDecl);
|
||||||
|
|
||||||
} catch (Backtrack b) {
|
} catch (Backtrack b) {
|
||||||
// allowed to be empty
|
// allowed to be empty
|
||||||
}
|
}
|
||||||
|
|
||||||
callback.parameterDeclarationEnd( parameterDecl );
|
try{ callback.parameterDeclarationEnd( parameterDecl );} catch( Exception e ) {}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -466,7 +527,7 @@ c, quick);
|
||||||
case Token.t_signed:
|
case Token.t_signed:
|
||||||
case Token.t_unsigned:
|
case Token.t_unsigned:
|
||||||
case Token.t_short:
|
case Token.t_short:
|
||||||
callback.simpleDeclSpecifier(decl, consume());
|
try{ callback.simpleDeclSpecifier(decl, consume());} catch( Exception e ) {}
|
||||||
break;
|
break;
|
||||||
case Token.t_char:
|
case Token.t_char:
|
||||||
case Token.t_wchar_t:
|
case Token.t_wchar_t:
|
||||||
|
@ -477,14 +538,14 @@ c, quick);
|
||||||
case Token.t_double:
|
case Token.t_double:
|
||||||
case Token.t_void:
|
case Token.t_void:
|
||||||
encounteredRawType = true;
|
encounteredRawType = true;
|
||||||
callback.simpleDeclSpecifier(decl, consume());
|
try{ callback.simpleDeclSpecifier(decl, consume());} catch( Exception e ) {}
|
||||||
break;
|
break;
|
||||||
case Token.t_typename:
|
case Token.t_typename:
|
||||||
consume();
|
consume( Token.t_typename );
|
||||||
name();
|
name();
|
||||||
break;
|
break;
|
||||||
case Token.tCOLONCOLON:
|
case Token.tCOLONCOLON:
|
||||||
consume();
|
consume( Token.tCOLONCOLON );
|
||||||
// handle nested later:
|
// handle nested later:
|
||||||
case Token.tIDENTIFIER:
|
case Token.tIDENTIFIER:
|
||||||
// TODO - Kludgy way to handle constructors/destructors
|
// TODO - Kludgy way to handle constructors/destructors
|
||||||
|
@ -493,9 +554,9 @@ c, quick);
|
||||||
{
|
{
|
||||||
if( ! encounteredTypename )
|
if( ! encounteredTypename )
|
||||||
{
|
{
|
||||||
callback.simpleDeclSpecifier(decl,LA(1));
|
try{ callback.simpleDeclSpecifier(decl,LA(1));} catch( Exception e ) {}
|
||||||
name();
|
name();
|
||||||
callback.simpleDeclSpecifierName( decl );
|
try{ callback.simpleDeclSpecifierName( decl );} catch( Exception e ) {}
|
||||||
encounteredTypename = true;
|
encounteredTypename = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -512,10 +573,11 @@ c, quick);
|
||||||
catch( Backtrack bt )
|
catch( Backtrack bt )
|
||||||
{
|
{
|
||||||
// this is an elaborated class specifier
|
// this is an elaborated class specifier
|
||||||
Object elab = callback.elaboratedTypeSpecifierBegin( decl, consume() );
|
Object elab = null;
|
||||||
|
try{ elab = callback.elaboratedTypeSpecifierBegin( decl, consume() );} catch( Exception e ) {}
|
||||||
name();
|
name();
|
||||||
callback.elaboratedTypeSpecifierName( elab );
|
try{ callback.elaboratedTypeSpecifierName( elab ); } catch( Exception e ) {}
|
||||||
callback.elaboratedTypeSpecifierEnd( elab );
|
try{ callback.elaboratedTypeSpecifierEnd( elab );} catch( Exception e ) {}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Token.t_enum:
|
case Token.t_enum:
|
||||||
|
@ -527,10 +589,11 @@ c, quick);
|
||||||
catch( Backtrack bt )
|
catch( Backtrack bt )
|
||||||
{
|
{
|
||||||
// this is an elaborated class specifier
|
// this is an elaborated class specifier
|
||||||
Object elab = callback.elaboratedTypeSpecifierBegin( decl, consume() );
|
Object elab = null;
|
||||||
|
try{ elab = callback.elaboratedTypeSpecifierBegin( decl, consume() ); } catch( Exception e ) {}
|
||||||
name();
|
name();
|
||||||
callback.elaboratedTypeSpecifierName( elab );
|
try{ callback.elaboratedTypeSpecifierName( elab );} catch( Exception e ) {}
|
||||||
callback.elaboratedTypeSpecifierEnd( elab );
|
try{ callback.elaboratedTypeSpecifierEnd( elab );} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -542,8 +605,11 @@ c, quick);
|
||||||
|
|
||||||
protected void identifier() throws Backtrack {
|
protected void identifier() throws Backtrack {
|
||||||
Token first = consume(Token.tIDENTIFIER); // throws backtrack if its not that
|
Token first = consume(Token.tIDENTIFIER); // throws backtrack if its not that
|
||||||
|
try
|
||||||
|
{
|
||||||
callback.nameBegin(first);
|
callback.nameBegin(first);
|
||||||
callback.nameEnd(first);
|
callback.nameEnd(first);
|
||||||
|
} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -561,7 +627,7 @@ c, quick);
|
||||||
Token first = LA(1);
|
Token first = LA(1);
|
||||||
Token last = null;
|
Token last = null;
|
||||||
|
|
||||||
callback.nameBegin(first);
|
try{ callback.nameBegin(first); } catch( Exception e ) {}
|
||||||
|
|
||||||
if (LT(1) == Token.tCOLONCOLON)
|
if (LT(1) == Token.tCOLONCOLON)
|
||||||
last = consume();
|
last = consume();
|
||||||
|
@ -590,7 +656,7 @@ c, quick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
callback.nameEnd(last);
|
try{ callback.nameEnd(last);} catch( Exception e ) {}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,7 +668,7 @@ c, quick);
|
||||||
switch (LT(1)) {
|
switch (LT(1)) {
|
||||||
case Token.t_const:
|
case Token.t_const:
|
||||||
case Token.t_volatile:
|
case Token.t_volatile:
|
||||||
callback.pointerOperatorCVModifier( ptrOp, consume() );
|
try{ callback.pointerOperatorCVModifier( ptrOp, consume() ); } catch( Exception e ) {}
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
|
@ -616,7 +682,7 @@ c, quick);
|
||||||
* To Do:
|
* To Do:
|
||||||
* - handle initializers
|
* - handle initializers
|
||||||
*/
|
*/
|
||||||
protected void initDeclarator( Object owner ) throws Backtrack {
|
protected Object initDeclarator( Object owner ) throws Backtrack {
|
||||||
Object declarator = declarator( owner );
|
Object declarator = declarator( owner );
|
||||||
|
|
||||||
// handle = initializerClause
|
// handle = initializerClause
|
||||||
|
@ -627,14 +693,14 @@ c, quick);
|
||||||
Object expression = null;
|
Object expression = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
expression = callback.expressionBegin( declarator );
|
try{ expression = callback.expressionBegin( declarator ); } catch( Exception e ) {}
|
||||||
assignmentExpression( expression );
|
assignmentExpression( expression );
|
||||||
callback.expressionEnd( expression );
|
try{ callback.expressionEnd( expression );} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
catch( Backtrack b )
|
catch( Backtrack b )
|
||||||
{
|
{
|
||||||
if( expression != null )
|
if( expression != null )
|
||||||
callback.expressionAbort( expression );
|
try{ callback.expressionAbort( expression );} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LT(1) == Token.tLBRACE) {
|
if (LT(1) == Token.tLBRACE) {
|
||||||
|
@ -655,19 +721,19 @@ c, quick);
|
||||||
}
|
}
|
||||||
else if( LT(1) == Token.tLPAREN )
|
else if( LT(1) == Token.tLPAREN )
|
||||||
{
|
{
|
||||||
consume(); // EAT IT!
|
consume(Token.tLPAREN); // EAT IT!
|
||||||
|
|
||||||
Object expression = null;
|
Object expression = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
expression = callback.expressionBegin( declarator );
|
try{ expression = callback.expressionBegin( declarator ); } catch( Exception e ) {}
|
||||||
constantExpression( expression );
|
constantExpression( expression );
|
||||||
callback.expressionEnd( expression );
|
try{ callback.expressionEnd( expression ); } catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
catch( Backtrack b )
|
catch( Backtrack b )
|
||||||
{
|
{
|
||||||
if( expression != null )
|
if( expression != null )
|
||||||
callback.expressionAbort( expression );
|
try{ callback.expressionAbort( expression );} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( LT(1) == Token.tRPAREN )
|
if( LT(1) == Token.tRPAREN )
|
||||||
|
@ -675,7 +741,8 @@ c, quick);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
callback.declaratorEnd( declarator );
|
try{ callback.declaratorEnd( declarator );} catch( Exception e ) {}
|
||||||
|
return declarator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -696,7 +763,8 @@ c, quick);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Object declarator = callback.declaratorBegin( container );
|
Object declarator = null;
|
||||||
|
try{ declarator = callback.declaratorBegin( container );} catch( Exception e ) {}
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
try {
|
try {
|
||||||
|
@ -714,7 +782,7 @@ c, quick);
|
||||||
}
|
}
|
||||||
|
|
||||||
name();
|
name();
|
||||||
callback.declaratorId(declarator);
|
try{ callback.declaratorId(declarator);} catch( Exception e ) {}
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
switch (LT(1)) {
|
switch (LT(1)) {
|
||||||
|
@ -723,7 +791,8 @@ c, quick);
|
||||||
if( LT(2) != Token.tINTEGER )
|
if( LT(2) != Token.tINTEGER )
|
||||||
{
|
{
|
||||||
// parameterDeclarationClause
|
// parameterDeclarationClause
|
||||||
Object clause = callback.argumentsBegin(declarator);
|
Object clause = null;
|
||||||
|
try { clause = callback.argumentsBegin(declarator);} catch( Exception e ) {}
|
||||||
consume();
|
consume();
|
||||||
boolean seenParameter = false;
|
boolean seenParameter = false;
|
||||||
parameterDeclarationLoop:
|
parameterDeclarationLoop:
|
||||||
|
@ -746,18 +815,24 @@ c, quick);
|
||||||
seenParameter = true;
|
seenParameter = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
callback.argumentsEnd(clause);
|
try{ callback.argumentsEnd(clause);} catch( Exception e ) {}
|
||||||
|
|
||||||
|
if( LT(1) == Token.tCOLON )
|
||||||
|
{
|
||||||
|
// this is most likely the definition of the constructor
|
||||||
|
return declarator;
|
||||||
|
}
|
||||||
|
|
||||||
// const-volatile marker on the method
|
// const-volatile marker on the method
|
||||||
if( LT(1) == Token.t_const || LT(1) == Token.t_volatile )
|
if( LT(1) == Token.t_const || LT(1) == Token.t_volatile )
|
||||||
{
|
{
|
||||||
callback.declaratorCVModifier( declarator, consume() );
|
try{ callback.declaratorCVModifier( declarator, consume() );} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
//check for throws clause here
|
//check for throws clause here
|
||||||
if( LT(1) == Token.t_throw )
|
if( LT(1) == Token.t_throw )
|
||||||
{
|
{
|
||||||
callback.declaratorThrowsException( declarator );
|
try{ callback.declaratorThrowsException( declarator );} catch( Exception e ) {}
|
||||||
consume(); // throw
|
consume(); // throw
|
||||||
consume( Token.tLPAREN );// (
|
consume( Token.tLPAREN );// (
|
||||||
boolean done = false;
|
boolean done = false;
|
||||||
|
@ -772,7 +847,7 @@ c, quick);
|
||||||
case Token.tIDENTIFIER:
|
case Token.tIDENTIFIER:
|
||||||
//TODO this is not exactly right - should be type-id rather than just a name
|
//TODO this is not exactly right - should be type-id rather than just a name
|
||||||
name();
|
name();
|
||||||
callback.declaratorThrowExceptionName( declarator );
|
try{ callback.declaratorThrowExceptionName( declarator );} catch( Exception e ) {}
|
||||||
break;
|
break;
|
||||||
case Token.tCOMMA:
|
case Token.tCOMMA:
|
||||||
consume();
|
consume();
|
||||||
|
@ -790,15 +865,17 @@ c, quick);
|
||||||
while( LT(1) == Token.tLBRACKET )
|
while( LT(1) == Token.tLBRACKET )
|
||||||
{
|
{
|
||||||
consume(); // eat the '['
|
consume(); // eat the '['
|
||||||
Object array = callback.arrayDeclaratorBegin( declarator );
|
Object array = null;
|
||||||
|
try{ array = callback.arrayDeclaratorBegin( declarator ); } catch( Exception e ) {}
|
||||||
if( LT(1) != Token.tRBRACKET )
|
if( LT(1) != Token.tRBRACKET )
|
||||||
{
|
{
|
||||||
Object expression = callback.expressionBegin( array );
|
Object expression = null;
|
||||||
|
try{ expression = callback.expressionBegin( array );} catch( Exception e ) {}
|
||||||
constantExpression(expression);
|
constantExpression(expression);
|
||||||
callback.expressionEnd( expression );
|
try{ callback.expressionEnd( expression ); } catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
consume(Token.tRBRACKET);
|
consume(Token.tRBRACKET);
|
||||||
callback.arrayDeclaratorEnd( array );
|
try{ callback.arrayDeclaratorEnd( array );} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -807,11 +884,12 @@ c, quick);
|
||||||
|
|
||||||
if( LA(1).getType() == Token.tIDENTIFIER )
|
if( LA(1).getType() == Token.tIDENTIFIER )
|
||||||
{
|
{
|
||||||
callback.declaratorAbort( container, declarator );
|
try{ callback.declaratorAbort( container, declarator ); } catch( Exception e ) {}
|
||||||
declarator = null;
|
declarator = null;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return declarator;
|
return declarator;
|
||||||
|
|
||||||
} while( true );
|
} while( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -823,23 +901,29 @@ c, quick);
|
||||||
*/
|
*/
|
||||||
protected void ptrOperator(Object owner) throws Backtrack {
|
protected void ptrOperator(Object owner) throws Backtrack {
|
||||||
int t = LT(1);
|
int t = LT(1);
|
||||||
Object ptrOp = callback.pointerOperatorBegin( owner );
|
Object ptrOp = null;
|
||||||
|
try{ ptrOp = callback.pointerOperatorBegin( owner );} catch( Exception e ) {}
|
||||||
|
|
||||||
if (t == Token.tAMPER) {
|
if (t == Token.tAMPER) {
|
||||||
callback.pointerOperatorType( ptrOp, consume() );
|
try{ callback.pointerOperatorType( ptrOp, consume() ); } catch( Exception e ) {}
|
||||||
callback.pointerOperatorEnd( ptrOp );
|
try{ callback.pointerOperatorEnd( ptrOp );} catch( Exception e ) {}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Token mark = mark();
|
Token mark = mark();
|
||||||
|
|
||||||
|
boolean hasName = false;
|
||||||
if (t == Token.tIDENTIFIER || t == Token.tCOLONCOLON)
|
if (t == Token.tIDENTIFIER || t == Token.tCOLONCOLON)
|
||||||
{
|
{
|
||||||
name();
|
name();
|
||||||
callback.pointerOperatorName( ptrOp );
|
hasName = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t == Token.tSTAR) {
|
if (t == Token.tSTAR) {
|
||||||
callback.pointerOperatorType( ptrOp, consume());
|
if( hasName )
|
||||||
|
try{ callback.pointerOperatorName( ptrOp );} catch( Exception e ) {}
|
||||||
|
|
||||||
|
try{ callback.pointerOperatorType( ptrOp, consume());} catch( Exception e ) {}
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
try {
|
try {
|
||||||
|
@ -850,7 +934,7 @@ c, quick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
callback.pointerOperatorEnd( ptrOp );
|
try{ callback.pointerOperatorEnd( ptrOp );} catch( Exception e ) {}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -874,12 +958,13 @@ c, quick);
|
||||||
{
|
{
|
||||||
consume( Token.t_enum );
|
consume( Token.t_enum );
|
||||||
|
|
||||||
Object enumSpecifier = callback.enumSpecifierBegin( owner );
|
Object enumSpecifier = null;
|
||||||
|
try{ enumSpecifier = callback.enumSpecifierBegin( owner );} catch( Exception e ) {}
|
||||||
|
|
||||||
if( LT(1) == Token.tIDENTIFIER )
|
if( LT(1) == Token.tIDENTIFIER )
|
||||||
{
|
{
|
||||||
identifier();
|
identifier();
|
||||||
callback.enumSpecifierId( enumSpecifier );
|
try{ callback.enumSpecifierId( enumSpecifier );} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( LT(1) == Token.tLBRACE )
|
if( LT(1) == Token.tLBRACE )
|
||||||
|
@ -891,39 +976,41 @@ c, quick);
|
||||||
Object defn;
|
Object defn;
|
||||||
if( LT(1) == Token.tIDENTIFIER )
|
if( LT(1) == Token.tIDENTIFIER )
|
||||||
{
|
{
|
||||||
defn = callback.enumDefinitionBegin( enumSpecifier );
|
defn = null;
|
||||||
|
try{ defn = callback.enumDefinitionBegin( enumSpecifier );} catch( Exception e ) {}
|
||||||
identifier();
|
identifier();
|
||||||
callback.enumDefinitionId( defn );
|
try{ callback.enumDefinitionId( defn ); } catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
callback.enumSpecifierAbort( enumSpecifier );
|
try{ callback.enumSpecifierAbort( enumSpecifier );} catch( Exception e ) {}
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( LT(1) == Token.tASSIGN )
|
if( LT(1) == Token.tASSIGN )
|
||||||
{
|
{
|
||||||
consume( Token.tASSIGN );
|
consume( Token.tASSIGN );
|
||||||
Object expression = callback.expressionBegin( defn );
|
Object expression = null;
|
||||||
|
try{ expression = callback.expressionBegin( defn );} catch( Exception e ) {}
|
||||||
constantExpression( expression );
|
constantExpression( expression );
|
||||||
callback.expressionEnd( expression );
|
try{ callback.expressionEnd( expression );} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
callback.enumDefinitionEnd( defn );
|
try{ callback.enumDefinitionEnd( defn );} catch( Exception e ) {}
|
||||||
|
|
||||||
if( LT(1) == Token.tRBRACE )
|
if( LT(1) == Token.tRBRACE )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if( LT(1) != Token.tCOMMA )
|
if( LT(1) != Token.tCOMMA )
|
||||||
{
|
{
|
||||||
callback.enumSpecifierAbort( enumSpecifier );
|
try{ callback.enumSpecifierAbort( enumSpecifier );} catch( Exception e ) {}
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
}
|
}
|
||||||
consume(Token.tCOMMA); // if we made it this far
|
consume(Token.tCOMMA); // if we made it this far
|
||||||
}
|
}
|
||||||
consume( Token.tRBRACE );
|
consume( Token.tRBRACE );
|
||||||
|
|
||||||
callback.enumSpecifierEnd( enumSpecifier );
|
try{ callback.enumSpecifierEnd( enumSpecifier );} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -952,24 +1039,25 @@ c, quick);
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object classSpec = callback.classSpecifierBegin( owner, classKey);
|
Object classSpec = null;
|
||||||
|
try{ classSpec = callback.classSpecifierBegin( owner, classKey);} catch( Exception e ){}
|
||||||
|
|
||||||
// class name
|
// class name
|
||||||
if (LT(1) == Token.tIDENTIFIER) {
|
if (LT(1) == Token.tIDENTIFIER) {
|
||||||
name();
|
name();
|
||||||
callback.classSpecifierName(classSpec);
|
try{ callback.classSpecifierName(classSpec);} catch( Exception e ){}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( LT(1) != Token.tCOLON && LT(1) != Token.tLBRACE )
|
if( LT(1) != Token.tCOLON && LT(1) != Token.tLBRACE )
|
||||||
{
|
{
|
||||||
// this is not a classSpecification
|
// this is not a classSpecification
|
||||||
callback.classSpecifierAbort( classSpec );
|
try{ callback.classSpecifierAbort( classSpec );} catch( Exception e ){}
|
||||||
classSpec = null;
|
classSpec = null;
|
||||||
backup( mark );
|
backup( mark );
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
callback.classSpecifierSafe( classSpec );
|
try{ callback.classSpecifierSafe( classSpec ); } catch( Exception e ){}
|
||||||
|
|
||||||
// base clause
|
// base clause
|
||||||
if (LT(1) == Token.tCOLON) {
|
if (LT(1) == Token.tCOLON) {
|
||||||
|
@ -989,7 +1077,7 @@ c, quick);
|
||||||
case Token.t_public:
|
case Token.t_public:
|
||||||
case Token.t_protected:
|
case Token.t_protected:
|
||||||
case Token.t_private:
|
case Token.t_private:
|
||||||
callback.classMemberVisibility( classSpec, consume() );
|
try{ callback.classMemberVisibility( classSpec, consume() );} catch( Exception e ){}
|
||||||
consume(Token.tCOLON);
|
consume(Token.tCOLON);
|
||||||
break;
|
break;
|
||||||
case Token.tRBRACE:
|
case Token.tRBRACE:
|
||||||
|
@ -1005,40 +1093,44 @@ c, quick);
|
||||||
consume();
|
consume();
|
||||||
}
|
}
|
||||||
|
|
||||||
callback.classSpecifierEnd(classSpec);
|
try{ callback.classSpecifierEnd(classSpec); } catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void baseSpecifier( Object classSpecOwner ) throws Backtrack {
|
protected void baseSpecifier( Object classSpecOwner ) throws Backtrack {
|
||||||
|
|
||||||
Object baseSpecifier = callback.baseSpecifierBegin( classSpecOwner );
|
Object baseSpecifier = null;
|
||||||
|
|
||||||
|
try { baseSpecifier = callback.baseSpecifierBegin( classSpecOwner ); } catch( Exception e ) {}
|
||||||
|
|
||||||
baseSpecifierLoop:
|
baseSpecifierLoop:
|
||||||
for (;;) {
|
for (;;) {
|
||||||
switch (LT(1)) {
|
switch (LT(1)) {
|
||||||
case Token.t_virtual:
|
case Token.t_virtual:
|
||||||
callback.baseSpecifierVirtual( baseSpecifier, true );
|
consume(Token.t_virtual);
|
||||||
consume();
|
try{ callback.baseSpecifierVirtual( baseSpecifier, true ); } catch( Exception e ){}
|
||||||
break;
|
break;
|
||||||
case Token.t_public:
|
case Token.t_public:
|
||||||
case Token.t_protected:
|
case Token.t_protected:
|
||||||
case Token.t_private:
|
case Token.t_private:
|
||||||
callback.baseSpecifierVisibility( baseSpecifier, consume() );
|
try { callback.baseSpecifierVisibility( baseSpecifier, consume() );} catch( Exception e ){}
|
||||||
break;
|
break;
|
||||||
case Token.tCOLONCOLON:
|
case Token.tCOLONCOLON:
|
||||||
case Token.tIDENTIFIER:
|
case Token.tIDENTIFIER:
|
||||||
name();
|
name();
|
||||||
callback.baseSpecifierName( baseSpecifier );
|
try { callback.baseSpecifierName( baseSpecifier ); } catch( Exception e ){}
|
||||||
break;
|
break;
|
||||||
case Token.tCOMMA:
|
case Token.tCOMMA:
|
||||||
|
try {
|
||||||
callback.baseSpecifierEnd( baseSpecifier );
|
callback.baseSpecifierEnd( baseSpecifier );
|
||||||
baseSpecifier = callback.baseSpecifierBegin( classSpecOwner );
|
baseSpecifier = callback.baseSpecifierBegin( classSpecOwner );
|
||||||
|
} catch( Exception e ){}
|
||||||
consume();
|
consume();
|
||||||
continue baseSpecifierLoop;
|
continue baseSpecifierLoop;
|
||||||
default:
|
default:
|
||||||
break baseSpecifierLoop;
|
break baseSpecifierLoop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
callback.baseSpecifierEnd( baseSpecifier );
|
try { callback.baseSpecifierEnd( baseSpecifier ); } catch( Exception e ){}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void functionBody() throws Backtrack {
|
protected void functionBody() throws Backtrack {
|
||||||
|
@ -1051,9 +1143,10 @@ c, quick);
|
||||||
switch (LT(1)) {
|
switch (LT(1)) {
|
||||||
case Token.t_case:
|
case Token.t_case:
|
||||||
consume();
|
consume();
|
||||||
expression = callback.expressionBegin( null ); //TODO regarding this null
|
// TODO regarding this null
|
||||||
|
try{ expression = callback.expressionBegin( null ); } catch( Exception e ) {}
|
||||||
constantExpression(expression);
|
constantExpression(expression);
|
||||||
callback.expressionEnd( expression );
|
try{ callback.expressionEnd( expression ); } catch( Exception e ) {}
|
||||||
consume(Token.tCOLON);
|
consume(Token.tCOLON);
|
||||||
statement();
|
statement();
|
||||||
return;
|
return;
|
||||||
|
@ -1107,9 +1200,10 @@ c, quick);
|
||||||
consume(Token.tSEMI);
|
consume(Token.tSEMI);
|
||||||
if (LT(1) != Token.tRPAREN)
|
if (LT(1) != Token.tRPAREN)
|
||||||
{
|
{
|
||||||
expression = callback.expressionBegin( null ); //TODO get rid of NULL
|
try{ expression = callback.expressionBegin( null ); } catch( Exception e ) {}
|
||||||
|
//TODO get rid of NULL
|
||||||
expression(expression);
|
expression(expression);
|
||||||
callback.expressionEnd( expression );
|
try{ callback.expressionEnd( expression );} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
consume(Token.tRPAREN);
|
consume(Token.tRPAREN);
|
||||||
statement();
|
statement();
|
||||||
|
@ -1126,9 +1220,10 @@ c, quick);
|
||||||
consume();
|
consume();
|
||||||
if (LT(1) != Token.tSEMI)
|
if (LT(1) != Token.tSEMI)
|
||||||
{
|
{
|
||||||
expression = callback.expressionBegin( null ); //TODO get rid of NULL
|
try{ expression = callback.expressionBegin( null );} catch( Exception e ) {}
|
||||||
|
//TODO get rid of NULL
|
||||||
expression(expression);
|
expression(expression);
|
||||||
callback.expressionEnd( expression );
|
try{ callback.expressionEnd( expression );} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
consume(Token.tSEMI);
|
consume(Token.tSEMI);
|
||||||
return;
|
return;
|
||||||
|
@ -1165,9 +1260,10 @@ c, quick);
|
||||||
// Note: the function style cast ambiguity is handled in expression
|
// Note: the function style cast ambiguity is handled in expression
|
||||||
// Since it only happens when we are in a statement
|
// Since it only happens when we are in a statement
|
||||||
try {
|
try {
|
||||||
expression = callback.expressionBegin( null ); //TODO get rid of NULL
|
try{ expression = callback.expressionBegin( null ); } catch( Exception e ) {}
|
||||||
|
//TODO get rid of NULL
|
||||||
expression(expression);
|
expression(expression);
|
||||||
callback.expressionEnd( expression );
|
try{ callback.expressionEnd( expression );} catch( Exception e ) {}
|
||||||
consume(Token.tSEMI);
|
consume(Token.tSEMI);
|
||||||
return;
|
return;
|
||||||
} catch (Backtrack b) {
|
} catch (Backtrack b) {
|
||||||
|
@ -1204,7 +1300,7 @@ c, quick);
|
||||||
while (LT(1) == Token.tCOMMA) {
|
while (LT(1) == Token.tCOMMA) {
|
||||||
Token t = consume();
|
Token t = consume();
|
||||||
assignmentExpression( expression );
|
assignmentExpression( expression );
|
||||||
callback.expressionOperator(expression, t);
|
try{ callback.expressionOperator(expression, t);} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1230,7 +1326,7 @@ c, quick);
|
||||||
case Token.tBITORASSIGN:
|
case Token.tBITORASSIGN:
|
||||||
Token t = consume();
|
Token t = consume();
|
||||||
conditionalExpression(expression);
|
conditionalExpression(expression);
|
||||||
callback.expressionOperator(expression, t);
|
try { callback.expressionOperator(expression, t); } catch( Exception e ) {}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1264,7 +1360,7 @@ c, quick);
|
||||||
while (LT(1) == Token.tOR) {
|
while (LT(1) == Token.tOR) {
|
||||||
Token t = consume();
|
Token t = consume();
|
||||||
logicalAndExpression( expression );
|
logicalAndExpression( expression );
|
||||||
callback.expressionOperator(expression, t);
|
try{ callback.expressionOperator(expression, t);} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1274,7 +1370,7 @@ c, quick);
|
||||||
while (LT(1) == Token.tAND) {
|
while (LT(1) == Token.tAND) {
|
||||||
Token t = consume();
|
Token t = consume();
|
||||||
inclusiveOrExpression(expression );
|
inclusiveOrExpression(expression );
|
||||||
callback.expressionOperator(expression, t);
|
try{ callback.expressionOperator(expression, t);} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1284,7 +1380,7 @@ c, quick);
|
||||||
while (LT(1) == Token.tBITOR) {
|
while (LT(1) == Token.tBITOR) {
|
||||||
Token t = consume();
|
Token t = consume();
|
||||||
exclusiveOrExpression(expression);
|
exclusiveOrExpression(expression);
|
||||||
callback.expressionOperator(expression, t);
|
try{ callback.expressionOperator(expression, t);} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1294,7 +1390,8 @@ c, quick);
|
||||||
while (LT(1) == Token.tXOR) {
|
while (LT(1) == Token.tXOR) {
|
||||||
Token t = consume();
|
Token t = consume();
|
||||||
andExpression(expression);
|
andExpression(expression);
|
||||||
callback.expressionOperator(expression, t);
|
try { callback.expressionOperator(expression, t);} catch( Exception e ) {}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1304,7 +1401,9 @@ c, quick);
|
||||||
while (LT(1) == Token.tAMPER) {
|
while (LT(1) == Token.tAMPER) {
|
||||||
Token t = consume();
|
Token t = consume();
|
||||||
equalityExpression(expression);
|
equalityExpression(expression);
|
||||||
callback.expressionOperator(expression, t);
|
|
||||||
|
try{ callback.expressionOperator(expression, t); } catch( Exception e ) {}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1317,7 +1416,7 @@ c, quick);
|
||||||
case Token.tNOTEQUAL:
|
case Token.tNOTEQUAL:
|
||||||
Token t = consume();
|
Token t = consume();
|
||||||
relationalExpression(expression);
|
relationalExpression(expression);
|
||||||
callback.expressionOperator(expression, t);
|
try{ callback.expressionOperator(expression, t);} catch( Exception e ) {}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
|
@ -1339,7 +1438,7 @@ c, quick);
|
||||||
case Token.tGTEQUAL:
|
case Token.tGTEQUAL:
|
||||||
Token t = consume();
|
Token t = consume();
|
||||||
shiftExpression(expression);
|
shiftExpression(expression);
|
||||||
callback.expressionOperator(expression, t);
|
try{ callback.expressionOperator(expression, t);} catch( Exception e ) {}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
|
@ -1356,7 +1455,7 @@ c, quick);
|
||||||
case Token.tSHIFTR:
|
case Token.tSHIFTR:
|
||||||
Token t = consume();
|
Token t = consume();
|
||||||
additiveExpression(expression);
|
additiveExpression(expression);
|
||||||
callback.expressionOperator(expression, t);
|
try{ callback.expressionOperator(expression, t);} catch( Exception e ) {}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
|
@ -1373,7 +1472,7 @@ c, quick);
|
||||||
case Token.tMINUS:
|
case Token.tMINUS:
|
||||||
Token t = consume();
|
Token t = consume();
|
||||||
multiplicativeExpression(expression);
|
multiplicativeExpression(expression);
|
||||||
callback.expressionOperator(expression, t);
|
try { callback.expressionOperator(expression, t); } catch( Exception e ) {}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
|
@ -1391,7 +1490,7 @@ c, quick);
|
||||||
case Token.tMOD:
|
case Token.tMOD:
|
||||||
Token t = consume();
|
Token t = consume();
|
||||||
pmExpression(expression );
|
pmExpression(expression );
|
||||||
callback.expressionOperator(expression , t);
|
try{ callback.expressionOperator(expression , t);} catch( Exception e ) {}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
|
@ -1408,7 +1507,7 @@ c, quick);
|
||||||
case Token.tARROWSTAR:
|
case Token.tARROWSTAR:
|
||||||
Token t = consume();
|
Token t = consume();
|
||||||
castExpression( expression );
|
castExpression( expression );
|
||||||
callback.expressionOperator(expression, t);
|
try{ callback.expressionOperator(expression, t);} catch( Exception e ) {}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
|
@ -1489,7 +1588,7 @@ c, quick);
|
||||||
case Token.tDECR:
|
case Token.tDECR:
|
||||||
Token t = consume();
|
Token t = consume();
|
||||||
castExpression(expression);
|
castExpression(expression);
|
||||||
callback.expressionOperator(expression, t);
|
try{ callback.expressionOperator(expression, t);} catch( Exception e ) {}
|
||||||
return;
|
return;
|
||||||
case Token.t_sizeof:
|
case Token.t_sizeof:
|
||||||
if (LT(1) == Token.tLPAREN) {
|
if (LT(1) == Token.tLPAREN) {
|
||||||
|
@ -1595,13 +1694,13 @@ c, quick);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
// TO DO: we need more literals...
|
// TO DO: we need more literals...
|
||||||
case Token.tINTEGER:
|
case Token.tINTEGER:
|
||||||
callback.expressionTerminal(expression, consume());
|
try{ callback.expressionTerminal(expression, consume());} catch( Exception e ) {}
|
||||||
return;
|
return;
|
||||||
case Token.tSTRING:
|
case Token.tSTRING:
|
||||||
callback.expressionTerminal(expression, consume());
|
try{ callback.expressionTerminal(expression, consume());} catch( Exception e ) {}
|
||||||
return;
|
return;
|
||||||
case Token.tIDENTIFIER:
|
case Token.tIDENTIFIER:
|
||||||
callback.expressionTerminal(expression, consume());
|
try{ callback.expressionTerminal(expression, consume());} catch( Exception e ) {}
|
||||||
return;
|
return;
|
||||||
case Token.t_this:
|
case Token.t_this:
|
||||||
consume();
|
consume();
|
||||||
|
@ -1732,24 +1831,4 @@ c, quick);
|
||||||
currToken = mark;
|
currToken = mark;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Utility routines that require a knowledge of the grammar
|
|
||||||
protected static String generateName(Token startToken) throws ParserException {
|
|
||||||
Token currToken = startToken.getNext();
|
|
||||||
|
|
||||||
if (currToken == null || currToken.getType() != Token.tCOLONCOLON)
|
|
||||||
return startToken.getImage();
|
|
||||||
|
|
||||||
StringBuffer buff = new StringBuffer(startToken.getImage());
|
|
||||||
while (currToken != null && currToken.getType() == Token.tCOLONCOLON) {
|
|
||||||
currToken = currToken.getNext();
|
|
||||||
if (currToken == null || currToken.getType() != Token.tIDENTIFIER)
|
|
||||||
// Not good
|
|
||||||
throw new ParserException(startToken);
|
|
||||||
buff.append("::");
|
|
||||||
buff.append(currToken.getImage());
|
|
||||||
currToken = currToken.getNext();
|
|
||||||
}
|
|
||||||
|
|
||||||
return buff.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -762,7 +762,7 @@ public class ParserSymbolTable {
|
||||||
|
|
||||||
//HashSet.add returns false if wrapper.parent is already in the set
|
//HashSet.add returns false if wrapper.parent is already in the set
|
||||||
//this means we have circular inheritance
|
//this means we have circular inheritance
|
||||||
if( data.inheritanceChain.add( wrapper.parent ) ){
|
if( ! data.inheritanceChain.contains( wrapper.parent ) ){
|
||||||
|
|
||||||
//is this name define in this scope?
|
//is this name define in this scope?
|
||||||
temp = LookupInContained( data, wrapper.parent );
|
temp = LookupInContained( data, wrapper.parent );
|
||||||
|
@ -771,7 +771,7 @@ public class ParserSymbolTable {
|
||||||
temp = LookupInParents( data, wrapper.parent );
|
temp = LookupInParents( data, wrapper.parent );
|
||||||
}
|
}
|
||||||
|
|
||||||
data.inheritanceChain.remove( wrapper.parent );
|
//data.inheritanceChain.remove( wrapper.parent );
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_CircularInheritance );
|
throw new ParserSymbolTableException( ParserSymbolTableException.r_CircularInheritance );
|
||||||
|
@ -799,7 +799,7 @@ public class ParserSymbolTable {
|
||||||
temp = null; //reset temp for next iteration
|
temp = null; //reset temp for next iteration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
data.inheritanceChain.remove( lookIn);
|
||||||
return decl;
|
return decl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Created on Mar 26, 2003
|
||||||
|
*
|
||||||
|
* 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:
|
||||||
|
* Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.parser.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class AccessSpecifier {
|
||||||
|
|
||||||
|
public static final int v_private = 0;
|
||||||
|
public static final int v_protected = 1;
|
||||||
|
public static final int v_public = 2;
|
||||||
|
|
||||||
|
private int access;
|
||||||
|
public void setAccess(int access) { this.access = access; }
|
||||||
|
public int getAccess() { return access; }
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Created on Mar 26, 2003
|
||||||
|
*
|
||||||
|
* 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:
|
||||||
|
* Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.parser.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ClassKey {
|
||||||
|
|
||||||
|
public static final int t_class = 0;
|
||||||
|
public static final int t_struct = 1;
|
||||||
|
public static final int t_union = 2;
|
||||||
|
public static final int t_enum = 3;
|
||||||
|
|
||||||
|
private int classKey = t_class;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public int getClassKey() {
|
||||||
|
return classKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the classKey.
|
||||||
|
* @param classKey The classKey to set
|
||||||
|
*/
|
||||||
|
public void setClassKey(int classKey) {
|
||||||
|
this.classKey = classKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,3 +1,6 @@
|
||||||
|
2003-03-28 John Camelon
|
||||||
|
Added testConstructorChain() and testASMDefinition() to DOMTests.
|
||||||
|
|
||||||
2003-03-27 Alain Magloire
|
2003-03-27 Alain Magloire
|
||||||
|
|
||||||
Changes were done in the Core Model API, the hierarchy is now
|
Changes were done in the Core Model API, the hierarchy is now
|
||||||
|
|
|
@ -7,13 +7,18 @@ import java.util.List;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.core.dom.ASMDefinition;
|
||||||
import org.eclipse.cdt.internal.core.dom.ArrayQualifier;
|
import org.eclipse.cdt.internal.core.dom.ArrayQualifier;
|
||||||
import org.eclipse.cdt.internal.core.dom.BaseSpecifier;
|
import org.eclipse.cdt.internal.core.dom.BaseSpecifier;
|
||||||
import org.eclipse.cdt.internal.core.dom.ClassSpecifier;
|
import org.eclipse.cdt.internal.core.dom.ClassSpecifier;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.ConstructorChain;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.ConstructorChainElement;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.ConstructorChainElementExpression;
|
||||||
import org.eclipse.cdt.internal.core.dom.DOMBuilder;
|
import org.eclipse.cdt.internal.core.dom.DOMBuilder;
|
||||||
import org.eclipse.cdt.internal.core.dom.Declarator;
|
import org.eclipse.cdt.internal.core.dom.Declarator;
|
||||||
import org.eclipse.cdt.internal.core.dom.EnumerationSpecifier;
|
import org.eclipse.cdt.internal.core.dom.EnumerationSpecifier;
|
||||||
import org.eclipse.cdt.internal.core.dom.EnumeratorDefinition;
|
import org.eclipse.cdt.internal.core.dom.EnumeratorDefinition;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.ExceptionSpecifier;
|
||||||
import org.eclipse.cdt.internal.core.dom.Expression;
|
import org.eclipse.cdt.internal.core.dom.Expression;
|
||||||
import org.eclipse.cdt.internal.core.dom.LinkageSpecification;
|
import org.eclipse.cdt.internal.core.dom.LinkageSpecification;
|
||||||
import org.eclipse.cdt.internal.core.dom.NamespaceDefinition;
|
import org.eclipse.cdt.internal.core.dom.NamespaceDefinition;
|
||||||
|
@ -27,6 +32,7 @@ import org.eclipse.cdt.internal.core.dom.UsingDirective;
|
||||||
import org.eclipse.cdt.internal.core.parser.Parser;
|
import org.eclipse.cdt.internal.core.parser.Parser;
|
||||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
import org.eclipse.cdt.internal.core.parser.Token;
|
import org.eclipse.cdt.internal.core.parser.Token;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.util.AccessSpecifier;
|
||||||
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
|
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
|
||||||
import org.eclipse.cdt.internal.core.parser.util.Name;
|
import org.eclipse.cdt.internal.core.parser.util.Name;
|
||||||
|
|
||||||
|
@ -402,17 +408,17 @@ public class DOMTests extends TestCase {
|
||||||
List baseClasses = classSpecifier.getBaseSpecifiers();
|
List baseClasses = classSpecifier.getBaseSpecifiers();
|
||||||
assertEquals( 3, baseClasses.size() );
|
assertEquals( 3, baseClasses.size() );
|
||||||
BaseSpecifier bs = (BaseSpecifier)baseClasses.get( 0 );
|
BaseSpecifier bs = (BaseSpecifier)baseClasses.get( 0 );
|
||||||
assertEquals( bs.getAccess(), BaseSpecifier.t_public );
|
assertEquals( bs.getAccess(), AccessSpecifier.v_public );
|
||||||
assertEquals( bs.isVirtual(), false );
|
assertEquals( bs.isVirtual(), false );
|
||||||
assertEquals( bs.getName().toString(), "B" );
|
assertEquals( bs.getName().toString(), "B" );
|
||||||
|
|
||||||
bs = (BaseSpecifier)baseClasses.get( 1 );
|
bs = (BaseSpecifier)baseClasses.get( 1 );
|
||||||
assertEquals( bs.getAccess(), BaseSpecifier.t_private );
|
assertEquals( bs.getAccess(), AccessSpecifier.v_private );
|
||||||
assertEquals( bs.isVirtual(), false );
|
assertEquals( bs.isVirtual(), false );
|
||||||
assertEquals( bs.getName().toString(), "C" );
|
assertEquals( bs.getName().toString(), "C" );
|
||||||
|
|
||||||
bs = (BaseSpecifier)baseClasses.get( 2 );
|
bs = (BaseSpecifier)baseClasses.get( 2 );
|
||||||
assertEquals( bs.getAccess(), BaseSpecifier.t_protected );
|
assertEquals( bs.getAccess(), AccessSpecifier.v_protected );
|
||||||
assertEquals( bs.isVirtual(), true );
|
assertEquals( bs.isVirtual(), true );
|
||||||
assertEquals( bs.getName().toString(), "D" );
|
assertEquals( bs.getName().toString(), "D" );
|
||||||
|
|
||||||
|
@ -585,13 +591,14 @@ public class DOMTests extends TestCase {
|
||||||
assertEquals( declarator.getName().toString(), "foo");
|
assertEquals( declarator.getName().toString(), "foo");
|
||||||
assertTrue( declarator.isConst() );
|
assertTrue( declarator.isConst() );
|
||||||
assertFalse( declarator.isVolatile() );
|
assertFalse( declarator.isVolatile() );
|
||||||
List exceptions = declarator.getExceptionSpecifier();
|
ExceptionSpecifier exceptions = declarator.getExceptionSpecifier();
|
||||||
assertEquals( exceptions.size(), 3 );
|
List typenames = exceptions.getTypeNames();
|
||||||
Name n = (Name)exceptions.get(0);
|
assertEquals( typenames.size(), 3 );
|
||||||
|
Name n = (Name)typenames.get(0);
|
||||||
assertEquals( n.toString(), "yay");
|
assertEquals( n.toString(), "yay");
|
||||||
n = (Name)exceptions.get(1);
|
n = (Name)typenames.get(1);
|
||||||
assertEquals( n.toString(), "nay");
|
assertEquals( n.toString(), "nay");
|
||||||
n = (Name)exceptions.get(2);
|
n = (Name)typenames.get(2);
|
||||||
assertEquals( n.toString(), "we::dont::care");
|
assertEquals( n.toString(), "we::dont::care");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -687,6 +694,56 @@ public class DOMTests extends TestCase {
|
||||||
assertEquals( po5.getType(), PointerOperator.t_pointer );
|
assertEquals( po5.getType(), PointerOperator.t_pointer );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testASMDefinition() throws Exception
|
||||||
|
{
|
||||||
|
TranslationUnit tu = parse( "asm( \"mov ep1 ds2\");" );
|
||||||
|
assertEquals( tu.getDeclarations().size(), 1 );
|
||||||
|
ASMDefinition asm = (ASMDefinition)tu.getDeclarations().get(0);
|
||||||
|
assertEquals( asm.getAssemblyCode(), "mov ep1 ds2" );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testConstructorChain() throws Exception
|
||||||
|
{
|
||||||
|
TranslationUnit tu = parse( "TrafficLight_Actor::TrafficLight_Actor( RTController * rtg_rts, RTActorRef * rtg_ref ) : RTActor( rtg_rts, rtg_ref ), myId( 0 ) {}" );
|
||||||
|
List tuDeclarations = tu.getDeclarations();
|
||||||
|
assertEquals( tuDeclarations.size(), 1 );
|
||||||
|
SimpleDeclaration decl1 = (SimpleDeclaration)tuDeclarations.get(0);
|
||||||
|
List declarators1 = decl1.getDeclarators();
|
||||||
|
assertEquals( declarators1.size(), 1 );
|
||||||
|
Declarator declarator1 = (Declarator)declarators1.get(0);
|
||||||
|
assertEquals( declarator1.getName().toString(), "TrafficLight_Actor::TrafficLight_Actor");
|
||||||
|
ConstructorChain chain1 = declarator1.getCtorChain();
|
||||||
|
List chainElements1 = chain1.getChainElements();
|
||||||
|
assertEquals( chainElements1.size(), 2 );
|
||||||
|
ConstructorChainElement element1_1 = (ConstructorChainElement) chainElements1.get(0);
|
||||||
|
assertEquals( element1_1.getName().toString(), "RTActor");
|
||||||
|
List expressions1_1 = element1_1.getExpressionList();
|
||||||
|
assertEquals( expressions1_1.size(), 2 );
|
||||||
|
ConstructorChainElementExpression expression1_1_1 = (ConstructorChainElementExpression)expressions1_1.get(0);
|
||||||
|
assertEquals( expression1_1_1.getExpression().tokens().size(), 1 );
|
||||||
|
Token t1_1_1 = (Token)expression1_1_1.getExpression().tokens().get(0);
|
||||||
|
ConstructorChainElementExpression expression1_1_2 = (ConstructorChainElementExpression)expressions1_1.get(1);
|
||||||
|
assertEquals( expression1_1_2.getExpression().tokens().size(), 1 );
|
||||||
|
Token t1_1_2 = (Token)expression1_1_2.getExpression().tokens().get(0);
|
||||||
|
|
||||||
|
assertEquals( t1_1_1.getType(), Token.tIDENTIFIER );
|
||||||
|
assertEquals( t1_1_1.getImage(), "rtg_rts");
|
||||||
|
assertEquals( t1_1_2.getType(), Token.tIDENTIFIER );
|
||||||
|
assertEquals( t1_1_2.getImage(), "rtg_ref");
|
||||||
|
|
||||||
|
ConstructorChainElement element1_2 = (ConstructorChainElement) chainElements1.get(1);
|
||||||
|
assertEquals( element1_2.getName().toString(), "myId" );
|
||||||
|
List expressions1_2 = element1_2.getExpressionList();
|
||||||
|
assertEquals( expressions1_2.size(), 1 );
|
||||||
|
ConstructorChainElementExpression expression = (ConstructorChainElementExpression) expressions1_2.get(0);
|
||||||
|
assertEquals( expression.getExpression().tokens().size(), 1 );
|
||||||
|
Token t = (Token)expression.getExpression().tokens().get(0);
|
||||||
|
assertEquals( t.getImage(), "0");
|
||||||
|
assertEquals( t.getType(), Token.tINTEGER );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// public void testErrors()
|
// public void testErrors()
|
||||||
// {
|
// {
|
||||||
|
|
Loading…
Add table
Reference in a new issue