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

Completed Quickparse expression representation.

Updated ExpressionEvaluation and associated tests.
This commit is contained in:
John Camelon 2003-06-28 22:39:35 +00:00
parent 6fa5a87930
commit bc44d5b65f
26 changed files with 1202 additions and 1213 deletions

View file

@ -1,3 +1,7 @@
2003-06-28 John Camelon
Completed Quickparse expression representation.
Updated ExpressionEvaluation and associated tests.
2003-06-26 John Camelon 2003-06-26 John Camelon
Update IASTExpression. Update IASTExpression.
Move Parser.Backtrack and Parser.EndOfFile to external interface. Move Parser.Backtrack and Parser.EndOfFile to external interface.

View file

@ -1130,7 +1130,6 @@ public class DOMTests extends BaseDOMTest {
writer.write( "A(const A&);\n" ); writer.write( "A(const A&);\n" );
writer.write( "};\n" ); writer.write( "};\n" );
writer.write( "A::A(const A&v) : x(v.x) { }\n" ); writer.write( "A::A(const A&v) : x(v.x) { }\n" );
TranslationUnit tu = parse( writer.toString() );
} }
public void testBug36288() throws Exception public void testBug36288() throws Exception
@ -1536,6 +1535,11 @@ public class DOMTests extends BaseDOMTest {
assertNotNull( enumerator.getExpression() ); assertNotNull( enumerator.getExpression() );
} }
public void testWeirdExpression() throws Exception
{
parse( "int x = rhs.spImpl_.get();");
}
public void testBug36690() throws Exception { public void testBug36690() throws Exception {
TranslationUnit tu = parse("Functor(const Functor& rhs) : spImpl_(Impl::Clone(rhs.spImpl_.get())){}"); TranslationUnit tu = parse("Functor(const Functor& rhs) : spImpl_(Impl::Clone(rhs.spImpl_.get())){}");
assertEquals( tu.getDeclarations().size(), 1 ); assertEquals( tu.getDeclarations().size(), 1 );

View file

@ -8,7 +8,9 @@ import junit.framework.TestSuite;
import org.eclipse.cdt.core.parser.IParser; import org.eclipse.cdt.core.parser.IParser;
import org.eclipse.cdt.core.parser.ParserFactory; import org.eclipse.cdt.core.parser.ParserFactory;
import org.eclipse.cdt.internal.core.parser.ExpressionEvaluator; import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.core.parser.ast.IASTExpression;
import org.eclipse.cdt.internal.core.parser.NullSourceElementRequestor;
public class ExprEvalTest extends TestCase { public class ExprEvalTest extends TestCase {
@ -21,14 +23,55 @@ public class ExprEvalTest extends TestCase {
} }
public void runTest(String code, int expectedValue) throws Exception { public void runTest(String code, int expectedValue) throws Exception {
ExpressionEvaluator evaluator = new ExpressionEvaluator();
IParser parser = ParserFactory.createParser(ParserFactory.createScanner( new StringReader( code ), null, null, null, null ), evaluator, null); IParser parser = ParserFactory.createParser(ParserFactory.createScanner( new StringReader( code ), null, null, null, null ), new NullSourceElementRequestor(), ParserMode.QUICK_PARSE);
parser.expression(null); IASTExpression expression = parser.expression(null);
assertEquals(expectedValue, ((Integer)evaluator.getResult()).intValue()); assertEquals(expectedValue, expression.evaluateExpression());
} }
public void testInteger() throws Exception { public void testInteger() throws Exception {
runTest("5;", 5); runTest("5;", 5);
runTest( "33;", 33 );
}
public void testNot() throws Exception
{
runTest( "!1;", 0 );
runTest( "!0;", 1 );
runTest( "!4;", 0 );
runTest( "!!4;", 1 );
}
public void testMultiplicational() throws Exception
{
runTest( "3 * 4;", 12 );
runTest( "55 * 2;", 110 );
runTest( "4 / 3;", 1 );
runTest( "100/4;", 25 );
runTest( "8 % 2;", 0 );
runTest( "8 % 3;", 2 );
}
public void testAdditive() throws Exception
{
runTest( "4 + 4;", 8 );
runTest( "4 - 4;", 0 );
}
public void testLogicalAnd() throws Exception
{
runTest( "4 && 5;", 1 );
runTest( "0 && 5;", 0 );
runTest( "5 && 0;", 0 );
runTest( "0 && 0;", 0 );
}
public void testLogicalOr() throws Exception
{
runTest( "4 || 5;", 1 );
runTest( "0 || 5;", 1 );
runTest( "5 || 0;", 1 );
runTest( "0 || 0;", 0 );
} }
public void testRelational() throws Exception { public void testRelational() throws Exception {

View file

@ -337,7 +337,7 @@ public class DeltaProcessor {
// get the workspace delta, and start processing there. // get the workspace delta, and start processing there.
IResourceDelta[] deltas = changes.getAffectedChildren(); IResourceDelta[] deltas = changes.getAffectedChildren();
ICElementDelta[] translatedDeltas = new CElementDelta[deltas.length]; ICElementDelta[] translatedDeltas = new CElementDelta[deltas.length];
System.out.println("delta.length: " + deltas.length); //System.out.println("delta.length: " + deltas.length);
for (int i = 0; i < deltas.length; i++) { for (int i = 0; i < deltas.length; i++) {
IResourceDelta delta = deltas[i]; IResourceDelta delta = deltas[i];
fCurrentDelta = new CElementDelta(root); fCurrentDelta = new CElementDelta(root);

View file

@ -1,3 +1,7 @@
2003-06-28 John Camelon
Completed Quickparse expression representation.
Updated ExpressionEvaluation and associated tests.
2003-06-26 John Camelon 2003-06-26 John Camelon
Update IASTExpression. Update IASTExpression.
Move Parser.Backtrack and Parser.EndOfFile to external interface. Move Parser.Backtrack and Parser.EndOfFile to external interface.

View file

@ -10,6 +10,8 @@
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.core.parser; package org.eclipse.cdt.core.parser;
import org.eclipse.cdt.core.parser.ast.IASTExpression;
/** /**
@ -38,7 +40,7 @@ public interface IParser {
* @throws Backtrack thrown if the Scanner/Stream provided does not yield a valid * @throws Backtrack thrown if the Scanner/Stream provided does not yield a valid
* expression * expression
*/ */
public void expression(Object expression) throws Backtrack; public IASTExpression expression(Object expression) throws Backtrack;
/** /**
* Is the parser configured for ANSI C or ANSI C++? * Is the parser configured for ANSI C or ANSI C++?

View file

@ -0,0 +1,31 @@
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.core.parser;
import java.util.Iterator;
/**
* @author jcamelon
*/
public interface ITokenDuple {
/**
* @return
*/
public abstract IToken getFirstToken();
/**
* @return
*/
public abstract IToken getLastToken();
public abstract Iterator iterator();
public abstract String toString();
public abstract boolean isIdentifier();
}

View file

@ -83,4 +83,5 @@ public class ParserFactory {
return new LineOffsetReconciler( input ); return new LineOffsetReconciler( input );
} }
} }

View file

@ -18,90 +18,122 @@ import org.eclipse.cdt.core.parser.Enum;
*/ */
public interface IASTExpression public interface IASTExpression
{ {
public class ExpressionKind extends Enum public class Kind extends Enum
{ {
public static final ExpressionKind PRIMARY_INTEGER_LITERAL = new ExpressionKind( 0 ); public static final Kind PRIMARY_EMPTY = new Kind( -1 );
public static final ExpressionKind PRIMARY_CHAR_LITERAL = new ExpressionKind( 1 ); public static final Kind PRIMARY_INTEGER_LITERAL = new Kind( 0 );
public static final ExpressionKind PRIMARY_FLOAT_LITERAL = new ExpressionKind( 2 ); public static final Kind PRIMARY_CHAR_LITERAL = new Kind( 1 );
public static final ExpressionKind PRIMARY_STRING_LITERAL = new ExpressionKind( 3 ); public static final Kind PRIMARY_FLOAT_LITERAL = new Kind( 2 );
public static final ExpressionKind PRIMARY_BOOLEAN_LITERAL = new ExpressionKind( 4 ); public static final Kind PRIMARY_STRING_LITERAL = new Kind( 3 );
public static final ExpressionKind PRIMARY_THIS = new ExpressionKind( 5 ); public static final Kind PRIMARY_BOOLEAN_LITERAL = new Kind( 4 );
public static final ExpressionKind PRIMARY_BRACKETED_EXPRESSION = new ExpressionKind( 6 ); public static final Kind PRIMARY_THIS = new Kind( 5 );
public static final ExpressionKind ID_EXPRESSION = new ExpressionKind( 7 ); public static final Kind PRIMARY_BRACKETED_EXPRESSION = new Kind( 6 );
public static final ExpressionKind POSTFIX_ARRAY = new ExpressionKind( 8 ); public static final Kind ID_EXPRESSION = new Kind( 7 );
public static final ExpressionKind POSTFIX_CONSTRUCT = new ExpressionKind( 9 ); public static final Kind POSTFIX_SUBSCRIPT = new Kind( 8 );
public static final ExpressionKind POSTFIX_SIMPLETYPE_CONSTRUCT = new ExpressionKind( 10 ); public static final Kind POSTFIX_FUNCTIONCALL = new Kind( 9 );
public static final ExpressionKind POSTFIX_TYPENAME_IDENTIFIER = new ExpressionKind( 11 ); public static final Kind POSTFIX_SIMPLETYPE_INT = new Kind( 10 );
public static final ExpressionKind POSTFIX_TYPENAME_TEMPLATEID = new ExpressionKind( 12 ); public static final Kind POSTFIX_SIMPLETYPE_SHORT = new Kind( 11 );
public static final ExpressionKind POSTFIX_DOT_IDEXPRESSION = new ExpressionKind( 13 ); public static final Kind POSTFIX_SIMPLETYPE_DOUBLE = new Kind( 12 );
public static final ExpressionKind POSTFIX_ARROW_IDEXPRESSION = new ExpressionKind( 14 ); public static final Kind POSTFIX_SIMPLETYPE_FLOAT = new Kind( 13 );
public static final ExpressionKind POSTFIX_DOT_DESTRUCTOR = new ExpressionKind( 15 ); public static final Kind POSTFIX_SIMPLETYPE_CHAR = new Kind( 14 );
public static final ExpressionKind POSTFIX_ARROW_DESTRUCTOR = new ExpressionKind( 16 ); public static final Kind POSTFIX_SIMPLETYPE_WCHART = new Kind( 15 );
public static final ExpressionKind POSTFIX_INCREMENT = new ExpressionKind( 17 ); public static final Kind POSTFIX_SIMPLETYPE_SIGNED = new Kind( 16 );
public static final ExpressionKind POSTFIX_DECREMENT = new ExpressionKind( 18 ); public static final Kind POSTFIX_SIMPLETYPE_UNSIGNED = new Kind( 17 );
public static final ExpressionKind POSTFIX_DYNAMIC_CAST = new ExpressionKind( 19 ); public static final Kind POSTFIX_SIMPLETYPE_BOOL = new Kind( 18 );
public static final ExpressionKind POSTFIX_REINTERPRET_CAST = new ExpressionKind( 20 ); public static final Kind POSTFIX_SIMPLETYPE_LONG = new Kind( 19 );
public static final ExpressionKind POSTFIX_STATIC_CAST = new ExpressionKind( 21 ); public static final Kind POSTFIX_TYPENAME_IDENTIFIER = new Kind( 20 );
public static final ExpressionKind POSTFIX_CONST_CAST = new ExpressionKind( 22 ); public static final Kind POSTFIX_TYPENAME_TEMPLATEID = new Kind( 21 );
public static final ExpressionKind POSTFIX_TYPEID_EXPRESSION = new ExpressionKind( 23 ); public static final Kind POSTFIX_DOT_IDEXPRESSION = new Kind( 22 );
public static final ExpressionKind POSTFIX_TYPEID_TYPEID = new ExpressionKind( 24 ); public static final Kind POSTFIX_ARROW_IDEXPRESSION = new Kind( 23 );
public static final ExpressionKind UNARY_INCREMENT = new ExpressionKind( 25 ); public static final Kind POSTFIX_DOT_TEMPL_IDEXPRESS = new Kind( 24 );
public static final ExpressionKind UNARY_DECREMENT = new ExpressionKind( 26 ); public static final Kind POSTFIX_ARROW_TEMPL_IDEXP = new Kind( 25 );
public static final ExpressionKind UNARY_STAR_CASTEXPRESSION = new ExpressionKind( 27 ); public static final Kind POSTFIX_DOT_DESTRUCTOR = new Kind( 26 );
public static final ExpressionKind UNARY_AMPSND_CASTEXPRESSION = new ExpressionKind( 28 ); public static final Kind POSTFIX_ARROW_DESTRUCTOR = new Kind( 27 );
public static final ExpressionKind UNARY_PLUS_CASTEXPRESSION = new ExpressionKind( 29 ); public static final Kind POSTFIX_INCREMENT = new Kind( 28 );
public static final ExpressionKind UNARY_MINUS_CASTEXPRESSION = new ExpressionKind( 30 ); public static final Kind POSTFIX_DECREMENT = new Kind( 29 );
public static final ExpressionKind UNARY_NOT_CASTEXPRESSION = new ExpressionKind( 31 ); public static final Kind POSTFIX_DYNAMIC_CAST = new Kind( 30 );
public static final ExpressionKind UNARY_TILDE_CASTEXPRESSION = new ExpressionKind( 32 ); public static final Kind POSTFIX_REINTERPRET_CAST = new Kind( 31 );
public static final ExpressionKind UNARY_SIZEOF_UNARYEXPRESSION = new ExpressionKind( 33 ); public static final Kind POSTFIX_STATIC_CAST = new Kind( 32 );
public static final ExpressionKind UNARY_SIZEOF_TYPEID = new ExpressionKind( 34 ); public static final Kind POSTFIX_CONST_CAST = new Kind( 33 );
public static final ExpressionKind NEW_NEWTYPEID = new ExpressionKind( 35 ); public static final Kind POSTFIX_TYPEID_EXPRESSION = new Kind( 34 );
public static final ExpressionKind NEW_TYPEID = new ExpressionKind( 36 ); public static final Kind POSTFIX_TYPEID_TYPEID = new Kind( 35 );
public static final ExpressionKind DELETE_CASTEXPRESSION = new ExpressionKind( 37 ); public static final Kind UNARY_INCREMENT = new Kind( 36 );
public static final ExpressionKind DELETE_VECTORCASTEXPRESSION = new ExpressionKind( 38 ); public static final Kind UNARY_DECREMENT = new Kind( 37 );
public static final ExpressionKind CASTEXPRESSION = new ExpressionKind( 39 ); public static final Kind UNARY_STAR_CASTEXPRESSION = new Kind( 38 );
public static final ExpressionKind PM_DOTSTAR = new ExpressionKind( 40 ); public static final Kind UNARY_AMPSND_CASTEXPRESSION = new Kind( 39 );
public static final ExpressionKind PM_ARROWSTAR = new ExpressionKind( 41 ); public static final Kind UNARY_PLUS_CASTEXPRESSION = new Kind( 40 );
public static final ExpressionKind MULTIPLICATIVE_MULTIPLY = new ExpressionKind( 42 ); public static final Kind UNARY_MINUS_CASTEXPRESSION = new Kind( 41 );
public static final ExpressionKind MULTIPLICATIVE_DIVIDE = new ExpressionKind( 43 ); public static final Kind UNARY_NOT_CASTEXPRESSION = new Kind( 42 );
public static final ExpressionKind MULTIPLICATIVE_MODULUS = new ExpressionKind( 44 ); public static final Kind UNARY_TILDE_CASTEXPRESSION = new Kind( 43 );
public static final ExpressionKind ADDITIVE_PLUS = new ExpressionKind( 45 ); public static final Kind UNARY_SIZEOF_UNARYEXPRESSION = new Kind( 44 );
public static final ExpressionKind ADDITIVE_MINUS = new ExpressionKind( 46 ); public static final Kind UNARY_SIZEOF_TYPEID = new Kind( 45 );
public static final ExpressionKind SHIFT_LEFT = new ExpressionKind( 47 ); public static final Kind NEW_NEWTYPEID = new Kind( 46 );
public static final ExpressionKind SHIFT_RIGHT = new ExpressionKind( 48 ); public static final Kind NEW_TYPEID = new Kind( 47 );
public static final ExpressionKind RELATIONAL_LESSTHAN = new ExpressionKind( 49 ); public static final Kind DELETE_CASTEXPRESSION = new Kind( 48 );
public static final ExpressionKind RELATIONAL_GREATERTHAN = new ExpressionKind( 50 ); public static final Kind DELETE_VECTORCASTEXPRESSION = new Kind( 49 );
public static final ExpressionKind RELATIONAL_LESSTHANEQUALTO = new ExpressionKind( 51 ); public static final Kind CASTEXPRESSION = new Kind( 50 );
public static final ExpressionKind RELATIONAL_GREATERTHANEQUALTO= new ExpressionKind( 52 ); public static final Kind PM_DOTSTAR = new Kind( 51 );
public static final ExpressionKind EQUALITY_EQUALS = new ExpressionKind( 53 ); public static final Kind PM_ARROWSTAR = new Kind( 52 );
public static final ExpressionKind EQUALITY_NOTEQUALS = new ExpressionKind( 54 ); public static final Kind MULTIPLICATIVE_MULTIPLY = new Kind( 53 );
public static final ExpressionKind ANDEXPRESSION = new ExpressionKind( 55 ); public static final Kind MULTIPLICATIVE_DIVIDE = new Kind( 54 );
public static final ExpressionKind EXCLUSIVEOREXPRESSION = new ExpressionKind( 56 ); public static final Kind MULTIPLICATIVE_MODULUS = new Kind( 55 );
public static final ExpressionKind INCLUSIVEOREXPRESSION = new ExpressionKind( 57 ); public static final Kind ADDITIVE_PLUS = new Kind( 56 );
public static final ExpressionKind LOGICALANDEXPRESSION = new ExpressionKind( 58 ); public static final Kind ADDITIVE_MINUS = new Kind( 57 );
public static final ExpressionKind LOGICALOREXPRESSION = new ExpressionKind( 59 ); public static final Kind SHIFT_LEFT = new Kind( 58 );
public static final ExpressionKind CONDITIONALEXPRESSION = new ExpressionKind( 60 ); public static final Kind SHIFT_RIGHT = new Kind( 59 );
public static final ExpressionKind THROWEXPRESSION = new ExpressionKind( 61 ); public static final Kind RELATIONAL_LESSTHAN = new Kind( 60 );
public static final ExpressionKind ASSIGNMENTEXPRESSION = new ExpressionKind( 62 ); public static final Kind RELATIONAL_GREATERTHAN = new Kind( 61 );
public static final ExpressionKind EXPRESSIONLIST = new ExpressionKind( 63 ); public static final Kind RELATIONAL_LESSTHANEQUALTO = new Kind( 62 );
public static final Kind RELATIONAL_GREATERTHANEQUALTO= new Kind( 63 );
public static final Kind EQUALITY_EQUALS = new Kind( 64 );
public static final Kind EQUALITY_NOTEQUALS = new Kind( 65 );
public static final Kind ANDEXPRESSION = new Kind( 66 );
public static final Kind EXCLUSIVEOREXPRESSION = new Kind( 67 );
public static final Kind INCLUSIVEOREXPRESSION = new Kind( 68 );
public static final Kind LOGICALANDEXPRESSION = new Kind( 69 );
public static final Kind LOGICALOREXPRESSION = new Kind( 70 );
public static final Kind CONDITIONALEXPRESSION_SIMPLE = new Kind( 71 );
public static final Kind CONDITIONALEXPRESSION_HARD = new Kind( 72 );
public static final Kind THROWEXPRESSION = new Kind( 72 );
public static final Kind ASSIGNMENTEXPRESSION_NORMAL = new Kind( 73 );
public static final Kind ASSIGNMENTEXPRESSION_PLUS = new Kind( 74 );
public static final Kind ASSIGNMENTEXPRESSION_MINUS = new Kind( 75 );
public static final Kind ASSIGNMENTEXPRESSION_MULT = new Kind( 76 );
public static final Kind ASSIGNMENTEXPRESSION_DIV = new Kind( 77 );
public static final Kind ASSIGNMENTEXPRESSION_MOD = new Kind( 78 );
public static final Kind ASSIGNMENTEXPRESSION_LSHIFT = new Kind( 79 );
public static final Kind ASSIGNMENTEXPRESSION_RSHIFT = new Kind( 80 );
public static final Kind ASSIGNMENTEXPRESSION_AND = new Kind( 81 );
public static final Kind ASSIGNMENTEXPRESSION_OR = new Kind( 82 );
public static final Kind ASSIGNMENTEXPRESSION_XOR = new Kind( 83 );
public static final Kind EXPRESSIONLIST = new Kind( 84 );
/** /**
* @param enumValue * @param enumValue
*/ */
private ExpressionKind(int enumValue) private Kind(int enumValue)
{ {
super(enumValue); super(enumValue);
} }
} }
public ExpressionKind getExpressionKind(); public interface IASTNewExpressionDescriptor
{
}
public Kind getExpressionKind();
public IASTExpression getLHSExpression(); public IASTExpression getLHSExpression();
public IASTExpression getRHSExpression(); public IASTExpression getRHSExpression();
public IASTExpression getThirdExpression();
public String getLiteralString(); public String getLiteralString();
public String getTypeId(); public String getTypeId();
public String getId(); public String getId();
public IASTNewExpressionDescriptor getNewExpressionDescriptor();
public int evaluateExpression() throws ExpressionEvaluationException; public int evaluateExpression() throws ExpressionEvaluationException;

View file

@ -10,9 +10,12 @@
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.core.parser.ast; package org.eclipse.cdt.core.parser.ast;
import java.util.List;
import org.eclipse.cdt.core.parser.Backtrack; import org.eclipse.cdt.core.parser.Backtrack;
import org.eclipse.cdt.core.parser.ITokenDuple;
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType; import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType;
import org.eclipse.cdt.internal.core.parser.TokenDuple; import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
/** /**
* @author jcamelon * @author jcamelon
@ -25,13 +28,13 @@ public interface IASTFactory {
public IASTUsingDirective createUsingDirective( public IASTUsingDirective createUsingDirective(
IASTScope scope, IASTScope scope,
TokenDuple duple) ITokenDuple duple)
throws Backtrack; throws Backtrack;
public IASTUsingDeclaration createUsingDeclaration( public IASTUsingDeclaration createUsingDeclaration(
IASTScope scope, IASTScope scope,
boolean isTypeName, boolean isTypeName,
TokenDuple name ); ITokenDuple name );
public IASTASMDefinition createASMDefinition( public IASTASMDefinition createASMDefinition(
@ -68,4 +71,10 @@ public interface IASTFactory {
public IASTEnumerationSpecifier createEnumerationSpecifier(String name, int startingOffset, int nameOffset ); public IASTEnumerationSpecifier createEnumerationSpecifier(String name, int startingOffset, int nameOffset );
public void addEnumerator(IASTEnumerationSpecifier enumeration, String string, int startingOffset, int endingOffset); public void addEnumerator(IASTEnumerationSpecifier enumeration, String string, int startingOffset, int endingOffset);
public IASTExpression createExpression( IASTExpression.Kind kind, IASTExpression lhs, IASTExpression rhs, IASTExpression thirdExpression, String id, String typeId, String literal, IASTNewExpressionDescriptor newDescriptor );
public IASTExpression.IASTNewExpressionDescriptor createNewDescriptor();
public IASTInitializerClause createIASTInitializerClause(IASTInitializerClause.Kind kind, IASTExpression assignmentExpression, List initializerClauses);
} }

View file

@ -0,0 +1,40 @@
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.core.parser.ast;
import java.util.List;
import org.eclipse.cdt.core.parser.Enum;
/**
* @author jcamelon
*/
public interface IASTInitializerClause {
public class Kind extends Enum
{
public static final Kind ASSIGNMENT_EXPRESSION = new Kind( 1 );
public static final Kind INITIALIZER_LIST = new Kind( 2 );
public static final Kind EMPTY = new Kind( 3 );
/**
* @param enumValue
*/
protected Kind(int enumValue) {
super(enumValue);
}
}
public Kind getKind();
public List getInitializerList();
public IASTExpression getAssigmentExpression();
}

View file

@ -19,7 +19,6 @@ import java.util.LinkedList;
import java.util.Set; import java.util.Set;
import java.util.Stack; import java.util.Stack;
import org.eclipse.cdt.core.parser.IScannerContext;
import org.eclipse.cdt.core.parser.ISourceElementRequestor; import org.eclipse.cdt.core.parser.ISourceElementRequestor;
import org.eclipse.cdt.core.parser.ScannerException; import org.eclipse.cdt.core.parser.ScannerException;
import org.eclipse.cdt.core.parser.ast.IASTInclusion; import org.eclipse.cdt.core.parser.ast.IASTInclusion;

View file

@ -14,7 +14,7 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.parser.ast.IASTExpression; import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
/** /**
* @author jcamelon * @author jcamelon
@ -25,7 +25,7 @@ public class Declarator implements IParameterCollection
private final DeclarationWrapper owner1; private final DeclarationWrapper owner1;
private final Declarator owner2; private final Declarator owner2;
private String name; private String name;
private IASTExpression initialValueExpression; private IASTInitializerClause initializerClause;
private List ptrOps = new ArrayList(); private List ptrOps = new ArrayList();
private List parameters = new ArrayList(); private List parameters = new ArrayList();
@ -133,17 +133,17 @@ public class Declarator implements IParameterCollection
/** /**
* @return * @return
*/ */
public IASTExpression getInitialValueExpression() public IASTInitializerClause getInitializerClause()
{ {
return initialValueExpression; return initializerClause;
} }
/** /**
* @param expression * @param expression
*/ */
public void setInitialValueExpression(IASTExpression expression) public void setInitializerClause(IASTInitializerClause expression)
{ {
initialValueExpression = expression; initializerClause = expression;
} }
} }

View file

@ -0,0 +1,40 @@
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.internal.core.parser;
/**
* @author jcamelon
*/
public class DeclaratorDuple {
public DeclaratorDuple( Object o, Declarator d )
{
object = o;
declarator = d;
}
private final Declarator declarator;
private final Object object;
/**
* @return
*/
public Declarator getDeclarator() {
return declarator;
}
/**
* @return
*/
public Object getObject() {
return object;
}
}

View file

@ -1,754 +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.util.EmptyStackException;
import java.util.Stack;
import org.eclipse.cdt.core.parser.IParser;
import org.eclipse.cdt.core.parser.IParserCallback;
import org.eclipse.cdt.core.parser.IToken;
public class ExpressionEvaluator implements IParserCallback {
public class ExpressionException extends Exception {
public ExpressionException(String msg) {
super(msg);
}
}
private Stack stack = new Stack();
private int popInt() {
return ((Integer)stack.pop()).intValue();
}
/**
* @see org.eclipse.cdt.core.newparser.IParserCallback#expressionOperator(Token)
*/
public void expressionOperator(Object expression, IToken operator) {
int second = popInt();
int first;
switch (operator.getType()) {
case IToken.tPLUS:
first = popInt();
stack.push(new Integer(first + second));
break;
case IToken.tMINUS:
first = popInt();
stack.push(new Integer(first - second));
break;
case IToken.tSTAR:
first = popInt();
stack.push(new Integer(first * second));
break;
case IToken.tDIV:
first = popInt();
stack.push(new Integer(first / second));
break;
case IToken.tLT:
first = popInt();
stack.push(new Integer(first < second ? 1 : 0));
break;
case IToken.tLTEQUAL:
first = popInt();
stack.push(new Integer(first <= second ? 1 : 0));
break;
case IToken.tGT:
first = popInt();
stack.push(new Integer(first > second ? 1 : 0));
break;
case IToken.tGTEQUAL:
first = popInt();
stack.push(new Integer(first >= second ? 1 : 0));
break;
case IToken.tEQUAL:
first = popInt();
stack.push(new Integer(first == second ? 1 : 0));
break;
case IToken.tNOTEQUAL:
first = popInt();
stack.push(new Integer(first != second ? 1 : 0));
break;
case IToken.tAND:
first = popInt();
stack.push( new Integer( ( ( first != 0 ) && ( second != 0 ) ) ? 1 : 0 ) );
break;
case IToken.tOR:
first = popInt();
stack.push( new Integer( ( ( first != 0 ) || ( second != 0 ) ) ? 1 : 0 ) );
break;
case IToken.tNOT:
stack.push( new Integer( ( second == 0 ) ? 1 : 0 ) );
break;
default:
// throw new ExpressionException("Unhandled operator: " + operator );
}
}
/**
* @see org.eclipse.cdt.core.newparser.IParserCallback#expressionTerminal(Token)
*/
public void expressionTerminal(Object expression, IToken terminal) {
switch (terminal.getType()) {
case IToken.tINTEGER:
stack.push(new Integer(terminal.getImage()));
break;
default:
// throw new ExpressionException("Unhandled terminal: " + terminal.getImage());
}
}
public Object getResult() throws EmptyStackException {
return stack.peek();
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#translationUnitBegin()
*/
public Object translationUnitBegin() {
return null;
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#translationUnitEnd(java.lang.Object)
*/
public void translationUnitEnd(Object unit) {
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#inclusionBegin(java.lang.String, int)
*/
public Object inclusionBegin(String includeFile, int offset, int inclusionBeginOffset, boolean local) {
return null;
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#inclusionEnd()
*/
public void inclusionEnd(Object inclusion) {
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#macro(java.lang.String, int)
*/
public Object macro(String macroName, int offset, int macroBeginOffset, int macroEndOffset) {
return null;
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#simpleDeclarationBegin(java.lang.Object)
*/
public Object simpleDeclarationBegin(Object Container, IToken firstToken) {
return null;
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#simpleDeclarationEnd(java.lang.Object)
*/
public void simpleDeclarationEnd(Object declaration, IToken lastToken) {
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#parameterDeclarationBegin(java.lang.Object)
*/
public Object parameterDeclarationBegin(Object Container) {
return null;
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#parameterDeclarationEnd(java.lang.Object)
*/
public void parameterDeclarationEnd(Object declaration) {
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#simpleDeclSpecifier(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token)
*/
public void simpleDeclSpecifier(Object Container, IToken specifier) {
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#declaratorBegin(java.lang.Object)
*/
public Object declaratorBegin(Object container) {
return null;
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#declaratorId(java.lang.Object)
*/
public void declaratorId(Object declarator) {
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#declaratorAbort(java.lang.Object, java.lang.Object)
*/
public void declaratorAbort(Object declarator) {
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#declaratorEnd(java.lang.Object)
*/
public void declaratorEnd(Object declarator) {
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#argumentsBegin(java.lang.Object)
*/
public Object argumentsBegin(Object declarator) {
return null;
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#argumentsEnd(java.lang.Object)
*/
public void argumentsEnd(Object parameterDeclarationClause) {
}
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#oldKRParametersBegin()
*/
public Object oldKRParametersBegin( Object parameterDeclarationClause ) {
return null;
}
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#oldKRParametersEnd()
*/
public void oldKRParametersEnd(Object oldKRParameterDeclarationClause) {
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#functionBodyBegin()
*/
public Object functionBodyBegin(Object declaration) {
return null;
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#functionBodyEnd()
*/
public void functionBodyEnd(Object functionBody ) {
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#classSpecifierBegin(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token)
*/
public Object classSpecifierBegin(Object container, IToken classKey) {
return null;
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#classSpecifierName(java.lang.Object)
*/
public void classSpecifierName(Object classSpecifier) {
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#classSpecifierEnd(java.lang.Object)
*/
public void classSpecifierEnd(Object classSpecifier, IToken closingBrace) {
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#baseSpecifierBegin(java.lang.Object)
*/
public Object baseSpecifierBegin(Object containingClassSpec) {
return null;
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#baseSpecifierName(java.lang.Object)
*/
public void baseSpecifierName(Object baseSpecifier) {
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#baseSpecifierVisibility(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token)
*/
public void baseSpecifierVisibility(
Object baseSpecifier,
IToken visibility) {
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#baseSpecifierVirtual(java.lang.Object, boolean)
*/
public void baseSpecifierVirtual(Object baseSpecifier, boolean virtual) {
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#baseSpecifierEnd(java.lang.Object)
*/
public void baseSpecifierEnd(Object baseSpecifier) {
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#expressionBegin(java.lang.Object)
*/
public Object expressionBegin(Object container) {
return null;
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#expressionEnd(java.lang.Object)
*/
public void expressionEnd(Object expression) {
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#classSpecifierAbort(java.lang.Object)
*/
public void classSpecifierAbort(Object classSpecifier) {
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#elaboratedTypeSpecifierBegin(java.lang.Object)
*/
public Object elaboratedTypeSpecifierBegin(Object container, IToken classKey) {
return null;
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#elaboratedTypeSpecifierEnd(java.lang.Object)
*/
public void elaboratedTypeSpecifierEnd(Object elab) {
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#elaboratedTypeSpecifierName(java.lang.Object)
*/
public void elaboratedTypeSpecifierName(Object container) {
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#simpleDeclSpecifierName(java.lang.Object)
*/
public void simpleDeclSpecifierName(Object declaration) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#expressionAbort(java.lang.Object)
*/
public void expressionAbort(Object expression) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#classMemberVisibility(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token)
*/
public void classMemberVisibility(Object classSpecifier, IToken visibility) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#pointerOperatorBegin(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token)
*/
public Object pointerOperatorBegin(Object container) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#pointerOperatorEnd(java.lang.Object)
*/
public void pointerOperatorEnd(Object ptrOperator) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#pointerOperatorName(java.lang.Object)
*/
public void pointerOperatorName(Object ptrOperator) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#pointerOperatorType(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token)
*/
public void pointerOperatorType(Object ptrOperator, IToken type) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#pointerOperatorCVModifier(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token)
*/
public void pointerOperatorCVModifier(Object ptrOperator, IToken modifier) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#declaratorCVModifier(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token)
*/
public void declaratorCVModifier(Object declarator, IToken modifier) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#arrayBegin(java.lang.Object)
*/
public Object arrayDeclaratorBegin(Object declarator) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#arrayEnd(java.lang.Object)
*/
public void arrayDeclaratorEnd(Object arrayQualifier ) {
;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#exceptionSpecificationTypename(java.lang.Object)
*/
public void declaratorThrowExceptionName(Object declarator) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#declaratorThrowsException(java.lang.Object)
*/
public void declaratorThrowsException(Object declarator) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationBegin(java.lang.Object)
*/
public Object namespaceDefinitionBegin(Object container, IToken namespace) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationId(java.lang.Object)
*/
public void namespaceDefinitionId(Object namespace) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationAbort(java.lang.Object)
*/
public void namespaceDefinitionAbort(Object namespace) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationEnd(java.lang.Object)
*/
public void namespaceDefinitionEnd(Object namespace, IToken closingBrace) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#linkageSpecificationBegin(java.lang.Object, java.lang.String)
*/
public Object linkageSpecificationBegin(Object container, String literal) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#linkageSpecificationEnd(java.lang.Object)
*/
public void linkageSpecificationEnd(Object linkageSpec) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#usingDirectiveBegin(java.lang.Object)
*/
public Object usingDirectiveBegin(Object container) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#usingDirectiveNamespaceId(java.lang.Object)
*/
public void usingDirectiveNamespaceId(Object container) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#usingDirectiveEnd(java.lang.Object)
*/
public void usingDirectiveEnd(Object directive) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#usingDeclarationBegin(java.lang.Object)
*/
public Object usingDeclarationBegin(Object container) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#usingDeclarationMapping(java.lang.Object)
*/
public void usingDeclarationMapping(Object container, boolean isTypename) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#usingDeclarationEnd(java.lang.Object)
*/
public void usingDeclarationEnd(Object directive) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#usingDirectiveAbort(java.lang.Object)
*/
public void usingDirectiveAbort(Object directive) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#usingDeclarationAbort(java.lang.Object)
*/
public void usingDeclarationAbort(Object declaration) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierBegin(java.lang.Object)
*/
public Object enumSpecifierBegin(Object container, IToken enumKey) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierId(java.lang.Object)
*/
public void enumSpecifierId(Object enumSpec) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierAbort(java.lang.Object)
*/
public void enumSpecifierAbort(Object enumSpec) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierEnd(java.lang.Object)
*/
public void enumSpecifierEnd(Object enumSpec, IToken closingBrace) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionBegin(java.lang.Object)
*/
public Object enumeratorBegin(Object enumSpec) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionId(java.lang.Object)
*/
public void enumeratorId(Object enumDefn) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionEnd(java.lang.Object)
*/
public void enumeratorEnd(Object enumDefn, IToken lastToken) {
}
/* (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) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#explicitInstantiationBegin(java.lang.Object)
*/
public Object explicitInstantiationBegin(Object container) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#explicitInstantiationEnd(java.lang.Object)
*/
public void explicitInstantiationEnd(Object instantiation) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#explicitSpecializationBegin(java.lang.Object)
*/
public Object explicitSpecializationBegin(Object container) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#explicitSpecializationEnd(java.lang.Object)
*/
public void explicitSpecializationEnd(Object instantiation) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#declaratorPureVirtual(java.lang.Object)
*/
public void declaratorPureVirtual(Object declarator) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateDeclarationBegin(java.lang.Object, boolean)
*/
public Object templateDeclarationBegin(Object container, IToken exported) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateDeclarationAbort(java.lang.Object)
*/
public void templateDeclarationAbort(Object templateDecl) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateDeclarationEnd(java.lang.Object)
*/
public void templateDeclarationEnd(Object templateDecl, IToken lastToken) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateTypeParameterBegin(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token)
*/
public Object templateTypeParameterBegin(Object templDecl, IToken kind) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateTypeParameterName(java.lang.Object)
*/
public void templateTypeParameterName(Object typeParm) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateTypeInitialTypeId(java.lang.Object)
*/
public void templateTypeParameterInitialTypeId(Object typeParm) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateTypeParameterEnd(java.lang.Object)
*/
public void templateTypeParameterEnd(Object typeParm) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateTypeParameterAbort(java.lang.Object)
*/
public void templateTypeParameterAbort(Object typeParm) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#pointerOperatorAbort(java.lang.Object)
*/
public void pointerOperatorAbort(Object ptrOperator) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateParameterListBegin(java.lang.Object)
*/
public Object templateParameterListBegin(Object declaration) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateParameterListEnd(java.lang.Object)
*/
public void templateParameterListEnd(Object parameterList) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#setParser(org.eclipse.cdt.internal.core.parser.IParser)
*/
public void setParser(IParser parser) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#expressionName(java.lang.Object)
*/
public void expressionName(Object expression) {
stack.push( currName );
}
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#nameBegin(org.eclipse.cdt.internal.core.newparser.Token)
*/
public void nameBegin(IToken firstToken) {
currName = new Name(firstToken);
}
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#nameEnd(org.eclipse.cdt.internal.core.newparser.Token)
*/
public void nameEnd(IToken lastToken) {
currName.setEnd(lastToken);
}
Name currName = null;
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#startBitfield(java.lang.Object)
*/
public Object startBitfield(Object declarator) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#endBitfield(java.lang.Object)
*/
public void endBitfield(Object bitfield) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#simpleDeclSpecifierType(java.lang.Object, java.lang.Object)
*/
public void simpleDeclSpecifierType(Object declaration, Object type) {
}
}

View file

@ -1,4 +1,4 @@
package org.eclipse.cdt.core.parser; package org.eclipse.cdt.internal.core.parser;
import java.io.IOException; import java.io.IOException;
import java.io.Reader; import java.io.Reader;
@ -6,11 +6,6 @@ import org.eclipse.cdt.core.parser.ast.IASTInclusion;
/** /**
* @author jcamelon * @author jcamelon
* *
* To change this generated comment edit the template variable
"typecomment":
* Window>Preferences>Java>Templates.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/ */
public interface IScannerContext { public interface IScannerContext {
@ -24,7 +19,6 @@ public interface IScannerContext {
* *
* @param macroOffset Offset of the expanding macro * @param macroOffset Offset of the expanding macro
* @param macroLength Length of the macro identifier * @param macroLength Length of the macro identifier
* @param line Initial line counter for the context
* @return * @return
*/ */
public IScannerContext initialize(Reader r, String f, int k, IASTInclusion i, int macroOffset, int macroLength, int line ); public IScannerContext initialize(Reader r, String f, int k, IASTInclusion i, int macroOffset, int macroLength, int line );
@ -57,12 +51,6 @@ public interface IScannerContext {
*/ */
public int getRelativeOffset(); public int getRelativeOffset();
/**
* Returns current line counter.
* @return int
*/
public int getLine();
public Reader getReader(); public Reader getReader();
public int undoStackSize(); public int undoStackSize();
@ -75,4 +63,9 @@ public interface IScannerContext {
public IASTInclusion getExtension(); public IASTInclusion getExtension();
public void setExtension( IASTInclusion ext ); public void setExtension( IASTInclusion ext );
/**
* @return
*/
public int getLine();
} }

View file

@ -25,20 +25,22 @@ import java.util.Map;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.Vector; import java.util.Vector;
import org.eclipse.cdt.core.parser.Backtrack;
import org.eclipse.cdt.core.parser.EndOfFile; import org.eclipse.cdt.core.parser.EndOfFile;
import org.eclipse.cdt.core.parser.IMacroDescriptor; import org.eclipse.cdt.core.parser.IMacroDescriptor;
import org.eclipse.cdt.core.parser.IParser; import org.eclipse.cdt.core.parser.IParser;
import org.eclipse.cdt.core.parser.IParserCallback; import org.eclipse.cdt.core.parser.IParserCallback;
import org.eclipse.cdt.core.parser.IProblemReporter; import org.eclipse.cdt.core.parser.IProblemReporter;
import org.eclipse.cdt.core.parser.IScanner; import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.core.parser.IScannerContext;
import org.eclipse.cdt.core.parser.ISourceElementRequestor; import org.eclipse.cdt.core.parser.ISourceElementRequestor;
import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.core.parser.IToken;
import org.eclipse.cdt.core.parser.ITranslationResult;
import org.eclipse.cdt.core.parser.ITranslationOptions; import org.eclipse.cdt.core.parser.ITranslationOptions;
import org.eclipse.cdt.core.parser.ITranslationResult;
import org.eclipse.cdt.core.parser.ParserFactory; import org.eclipse.cdt.core.parser.ParserFactory;
import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.core.parser.ScannerException; import org.eclipse.cdt.core.parser.ScannerException;
import org.eclipse.cdt.core.parser.ast.ExpressionEvaluationException;
import org.eclipse.cdt.core.parser.ast.IASTExpression;
import org.eclipse.cdt.core.parser.ast.IASTFactory; import org.eclipse.cdt.core.parser.ast.IASTFactory;
import org.eclipse.cdt.core.parser.ast.IASTInclusion; import org.eclipse.cdt.core.parser.ast.IASTInclusion;
import org.eclipse.cdt.core.parser.ast.IASTMacro; import org.eclipse.cdt.core.parser.ast.IASTMacro;
@ -1652,51 +1654,35 @@ public class Scanner implements IScanner {
} }
else else
{ {
Object expressionEvalResult = null;
try {
ExpressionEvaluator evaluator = new ExpressionEvaluator();
IScanner trial = IScanner trial =
ParserFactory.createScanner( ParserFactory.createScanner(
new StringReader(expression + ";"), new StringReader(expression + ";"),
EXPRESSION, EXPRESSION,
definitions, definitions,
null, ParserMode.COMPLETE_PARSE, null, ParserMode.QUICK_PARSE );
problemReporter, translationResult ); IParser parser = ParserFactory.createParser(trial, new NullSourceElementRequestor(), ParserMode.QUICK_PARSE );
IParser parser = ParserFactory.createParser(trial, evaluator, ParserMode.COMPLETE_PARSE, problemReporter, translationResult );
parser.expression(null);
expressionEvalResult = evaluator.getResult(); try {
IASTExpression exp = parser.expression(null);
} catch (Exception e ) { if( exp.evaluateExpression() == 0 )
throw new ScannerException(
"Expression "
+ expression
+ " evaluates to an undefined value");
} finally
{
if (expressionEvalResult == null)
throw new ScannerException(
"Expression "
+ expression
+ " evaluates to an undefined value");
}
if (expressionEvalResult instanceof Integer ) {
int i = ((Integer) expressionEvalResult).intValue();
if (i == 0) {
return false; return false;
} catch( Backtrack b )
{
throwExpressionEvaluationError(expression);
}
catch (ExpressionEvaluationException e) {
throwExpressionEvaluationError(expression);
} }
return true; return true;
} else if (
expressionEvalResult instanceof Boolean ) { }
return ((Boolean) expressionEvalResult).booleanValue(); }
} else {
protected void throwExpressionEvaluationError(String expression) throws ScannerException {
throw new ScannerException( throw new ScannerException(
"Unexpected expression type - we do not expect " "Expression "
+ expressionEvalResult.getClass().getName()); + expression
} + " evaluates to an undefined value");
}
} }
protected void skipOverSinglelineComment() throws ScannerException { protected void skipOverSinglelineComment() throws ScannerException {

View file

@ -14,7 +14,6 @@ import java.io.IOException;
import java.io.Reader; import java.io.Reader;
import java.util.Stack; import java.util.Stack;
import org.eclipse.cdt.core.parser.IScannerContext;
import org.eclipse.cdt.core.parser.ast.IASTInclusion; import org.eclipse.cdt.core.parser.ast.IASTInclusion;
public class ScannerContext implements IScannerContext public class ScannerContext implements IScannerContext

View file

@ -10,7 +10,6 @@
******************************************************************************/ ******************************************************************************/
package org.eclipse.cdt.internal.core.parser; package org.eclipse.cdt.internal.core.parser;
import org.eclipse.cdt.core.parser.IScannerContext;
import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.core.parser.IToken;
public class Token implements IToken { public class Token implements IToken {

View file

@ -12,13 +12,14 @@ package org.eclipse.cdt.internal.core.parser;
import java.util.Iterator; import java.util.Iterator;
import org.eclipse.cdt.core.parser.*;
import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.core.parser.IToken;
/** /**
* @author jcamelon * @author jcamelon
* *
*/ */
public class TokenDuple { public class TokenDuple implements ITokenDuple {
public TokenDuple( IToken first, IToken last ) public TokenDuple( IToken first, IToken last )
{ {

View file

@ -11,9 +11,11 @@
package org.eclipse.cdt.internal.core.parser.ast.full; package org.eclipse.cdt.internal.core.parser.ast.full;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import org.eclipse.cdt.core.parser.Backtrack; import org.eclipse.cdt.core.parser.Backtrack;
import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.core.parser.IToken;
import org.eclipse.cdt.core.parser.ITokenDuple;
import org.eclipse.cdt.core.parser.ast.AccessVisibility; import org.eclipse.cdt.core.parser.ast.AccessVisibility;
import org.eclipse.cdt.core.parser.ast.ClassKind; import org.eclipse.cdt.core.parser.ast.ClassKind;
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition; import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
@ -21,7 +23,9 @@ import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit; import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier; import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTExpression;
import org.eclipse.cdt.core.parser.ast.IASTFactory; import org.eclipse.cdt.core.parser.ast.IASTFactory;
import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification; import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition; import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
import org.eclipse.cdt.core.parser.ast.IASTScope; import org.eclipse.cdt.core.parser.ast.IASTScope;
@ -29,7 +33,8 @@ import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration; import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective; import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType; import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType;
import org.eclipse.cdt.internal.core.parser.TokenDuple; import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory; import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol; import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
import org.eclipse.cdt.internal.core.parser.pst.ISymbol; import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
@ -46,7 +51,7 @@ public class FullParseASTFactory extends BaseASTFactory implements IASTFactory {
public IASTUsingDirective createUsingDirective( public IASTUsingDirective createUsingDirective(
IASTScope scope, IASTScope scope,
TokenDuple duple) ITokenDuple duple)
throws Backtrack { throws Backtrack {
Iterator iter = duple.iterator(); Iterator iter = duple.iterator();
IToken t1 = (IToken)iter.next(); IToken t1 = (IToken)iter.next();
@ -147,7 +152,7 @@ public class FullParseASTFactory extends BaseASTFactory implements IASTFactory {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createUsingDeclaration(org.eclipse.cdt.core.parser.ast.IASTScope, boolean, org.eclipse.cdt.internal.core.parser.TokenDuple) * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createUsingDeclaration(org.eclipse.cdt.core.parser.ast.IASTScope, boolean, org.eclipse.cdt.internal.core.parser.TokenDuple)
*/ */
public IASTUsingDeclaration createUsingDeclaration(IASTScope scope, boolean isTypeName, TokenDuple name) { public IASTUsingDeclaration createUsingDeclaration(IASTScope scope, boolean isTypeName, ITokenDuple name) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
@ -195,4 +200,28 @@ public class FullParseASTFactory extends BaseASTFactory implements IASTFactory {
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createExpression(org.eclipse.cdt.core.parser.ast.IASTExpression.ExpressionKind, org.eclipse.cdt.core.parser.ast.IASTExpression, org.eclipse.cdt.core.parser.ast.IASTExpression, java.lang.String, java.lang.String, java.lang.String)
*/
public IASTExpression createExpression(Kind kind, IASTExpression lhs, IASTExpression rhs, IASTExpression thirdExpression, String id, String typeId, String literal, IASTNewExpressionDescriptor newDescriptor) {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createNewDescriptor()
*/
public IASTNewExpressionDescriptor createNewDescriptor() {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createIASTInitializerClause()
*/
public IASTInitializerClause createIASTInitializerClause(IASTInitializerClause.Kind kind, IASTExpression assignmentExpression, List initializerClauses) {
// TODO Auto-generated method stub
return null;
}
} }

View file

@ -0,0 +1,167 @@
/*
* Created on Jun 26, 2003
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package org.eclipse.cdt.internal.core.parser.ast.quick;
import org.eclipse.cdt.core.parser.ast.ExpressionEvaluationException;
import org.eclipse.cdt.core.parser.ast.IASTExpression;
/**
* @author jcamelon
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class ASTExpression implements IASTExpression {
private final Kind kind;
private final IASTExpression lhs, rhs, third;
private final String id, typeId, literal;
private final IASTNewExpressionDescriptor newDescriptor;
/**
* @param kind
* @param lhs
* @param rhs
* @param id
* @param typeId
* @param literal
*/
public ASTExpression(Kind kind, IASTExpression lhs, IASTExpression rhs, IASTExpression third, String id, String typeId, String literal, IASTNewExpressionDescriptor newDescriptor) {
this.kind = kind;
this.lhs =lhs;
this.rhs = rhs;
this.third = third;
this.typeId = typeId;
this.id = id;
this.literal = literal;
this.newDescriptor = newDescriptor;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTExpression#getExpressionKind()
*/
public Kind getExpressionKind() {
return kind;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTExpression#getLHSExpression()
*/
public IASTExpression getLHSExpression() {
return lhs;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTExpression#getRHSExpression()
*/
public IASTExpression getRHSExpression() {
return rhs;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTExpression#getLiteralString()
*/
public String getLiteralString() {
return literal;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTExpression#getTypeId()
*/
public String getTypeId() {
return typeId;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTExpression#getId()
*/
public String getId() {
return id;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTExpression#getNewExpressionDescriptor()
*/
public IASTNewExpressionDescriptor getNewExpressionDescriptor() {
return newDescriptor;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTExpression#getThirdExpression()
*/
public IASTExpression getThirdExpression() {
return third;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTExpression#evaluateExpression()
*/
public int evaluateExpression() throws ExpressionEvaluationException {
// primary expressions
if( getExpressionKind() == IASTExpression.Kind.PRIMARY_INTEGER_LITERAL )
return Integer.parseInt( getLiteralString() );
if( getExpressionKind() == IASTExpression.Kind.PRIMARY_BRACKETED_EXPRESSION )
return getLHSExpression().evaluateExpression();
// unary not
if( getExpressionKind() == IASTExpression.Kind.UNARY_NOT_CASTEXPRESSION )
return ( ( getLHSExpression().evaluateExpression() == 0 ) ? 1 : 0 );
// multiplicative expressions
if( getExpressionKind() == IASTExpression.Kind.MULTIPLICATIVE_MULTIPLY )
return ( getLHSExpression().evaluateExpression() * getRHSExpression().evaluateExpression()) ;
if( getExpressionKind() == IASTExpression.Kind.MULTIPLICATIVE_DIVIDE )
return ( getLHSExpression().evaluateExpression() / getRHSExpression().evaluateExpression()) ;
if( getExpressionKind() == IASTExpression.Kind.MULTIPLICATIVE_MODULUS )
return ( getLHSExpression().evaluateExpression() % getRHSExpression().evaluateExpression()) ;
// additives
if( getExpressionKind() == IASTExpression.Kind.ADDITIVE_PLUS )
return ( getLHSExpression().evaluateExpression() + getRHSExpression().evaluateExpression()) ;
if( getExpressionKind() == IASTExpression.Kind.ADDITIVE_MINUS )
return ( getLHSExpression().evaluateExpression() - getRHSExpression().evaluateExpression()) ;
// shift expression
if( getExpressionKind() == IASTExpression.Kind.SHIFT_LEFT )
return ( getLHSExpression().evaluateExpression() << getRHSExpression().evaluateExpression()) ;
if( getExpressionKind() == IASTExpression.Kind.SHIFT_RIGHT )
return ( getLHSExpression().evaluateExpression() >> getRHSExpression().evaluateExpression()) ;
// relational
if( getExpressionKind() == IASTExpression.Kind.RELATIONAL_LESSTHAN )
return ( getLHSExpression().evaluateExpression() < getRHSExpression().evaluateExpression() ? 1 : 0 ) ;
if( getExpressionKind() == IASTExpression.Kind.RELATIONAL_GREATERTHAN )
return ( getLHSExpression().evaluateExpression() > getRHSExpression().evaluateExpression() ? 1 : 0 ) ;
if( getExpressionKind() == IASTExpression.Kind.RELATIONAL_LESSTHANEQUALTO )
return ( getLHSExpression().evaluateExpression() <= getRHSExpression().evaluateExpression() ? 1 : 0 ) ;
if( getExpressionKind() == IASTExpression.Kind.RELATIONAL_GREATERTHANEQUALTO )
return ( getLHSExpression().evaluateExpression() >= getRHSExpression().evaluateExpression() ? 1 : 0 ) ;
// equality
if( getExpressionKind() == IASTExpression.Kind.EQUALITY_EQUALS )
return ( getLHSExpression().evaluateExpression() == getRHSExpression().evaluateExpression() ? 1 : 0 ) ;
if( getExpressionKind() == IASTExpression.Kind.EQUALITY_NOTEQUALS )
return ( getLHSExpression().evaluateExpression() != getRHSExpression().evaluateExpression() ? 1 : 0 ) ;
// and
if( getExpressionKind() == IASTExpression.Kind.ANDEXPRESSION )
return ( getLHSExpression().evaluateExpression() & getRHSExpression().evaluateExpression() ) ;
// xor
if( getExpressionKind() == IASTExpression.Kind.EXCLUSIVEOREXPRESSION )
return ( getLHSExpression().evaluateExpression() ^ getRHSExpression().evaluateExpression() ) ;
// or
if( getExpressionKind() == IASTExpression.Kind.INCLUSIVEOREXPRESSION )
return ( getLHSExpression().evaluateExpression() | getRHSExpression().evaluateExpression() ) ;
// logical and
if( getExpressionKind() == IASTExpression.Kind.LOGICALANDEXPRESSION )
return( ( getLHSExpression().evaluateExpression() != 0 ) && ( getRHSExpression().evaluateExpression() != 0 ) ) ? 1 : 0 ;
// logical or
if( getExpressionKind() == IASTExpression.Kind.LOGICALOREXPRESSION )
return( ( getLHSExpression().evaluateExpression() != 0 ) || ( getRHSExpression().evaluateExpression() != 0 ) ) ? 1 : 0 ;
throw new ExpressionEvaluationException();
}
}

View file

@ -0,0 +1,58 @@
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.internal.core.parser.ast.quick;
import java.util.List;
import org.eclipse.cdt.core.parser.ast.IASTExpression;
import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
/**
* @author jcamelon
*/
public class ASTInitializerClause implements IASTInitializerClause {
private final IASTInitializerClause.Kind kind;
private final IASTExpression assignmentExpression;
private final List initializerClauses;
/**
* @param kind
* @param assignmentExpression
* @param initializerClauses
*/
public ASTInitializerClause(Kind kind, IASTExpression assignmentExpression, List initializerClauses) {
this.kind = kind;
this.assignmentExpression = assignmentExpression;
this.initializerClauses = initializerClauses;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTInitializerClause#getKind()
*/
public Kind getKind() {
return kind;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTInitializerClause#getInitializerList()
*/
public List getInitializerList() {
return initializerClauses;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTInitializerClause#getAssigmentExpression()
*/
public IASTExpression getAssigmentExpression() {
return assignmentExpression;
}
}

View file

@ -0,0 +1,20 @@
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.internal.core.parser.ast.quick;
import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
/**
* @author jcamelon
*/
public class ASTNewDescriptor implements IASTNewExpressionDescriptor {
}

View file

@ -10,7 +10,10 @@
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.internal.core.parser.ast.quick; package org.eclipse.cdt.internal.core.parser.ast.quick;
import java.util.List;
import org.eclipse.cdt.core.parser.Backtrack; import org.eclipse.cdt.core.parser.Backtrack;
import org.eclipse.cdt.core.parser.ITokenDuple;
import org.eclipse.cdt.core.parser.ast.AccessVisibility; import org.eclipse.cdt.core.parser.ast.AccessVisibility;
import org.eclipse.cdt.core.parser.ast.ClassKind; import org.eclipse.cdt.core.parser.ast.ClassKind;
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition; import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
@ -20,7 +23,9 @@ import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier; import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTEnumerator; import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
import org.eclipse.cdt.core.parser.ast.IASTExpression;
import org.eclipse.cdt.core.parser.ast.IASTFactory; import org.eclipse.cdt.core.parser.ast.IASTFactory;
import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification; import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition; import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
import org.eclipse.cdt.core.parser.ast.IASTScope; import org.eclipse.cdt.core.parser.ast.IASTScope;
@ -28,7 +33,8 @@ import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration; import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective; import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType; import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType;
import org.eclipse.cdt.internal.core.parser.TokenDuple; import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory; import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
/** /**
@ -40,7 +46,7 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.ast.IASTFactory#createUsingDirective(org.eclipse.cdt.internal.core.parser.ast.IASTScope, org.eclipse.cdt.internal.core.parser.TokenDuple) * @see org.eclipse.cdt.internal.core.parser.ast.IASTFactory#createUsingDirective(org.eclipse.cdt.internal.core.parser.ast.IASTScope, org.eclipse.cdt.internal.core.parser.TokenDuple)
*/ */
public IASTUsingDirective createUsingDirective(IASTScope scope, TokenDuple duple) throws Backtrack { public IASTUsingDirective createUsingDirective(IASTScope scope, ITokenDuple duple) throws Backtrack {
return new ASTUsingDirective( scope, duple.toString() ); return new ASTUsingDirective( scope, duple.toString() );
} }
@ -81,7 +87,7 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createUsingDeclaration(org.eclipse.cdt.core.parser.ast.IASTScope, boolean, org.eclipse.cdt.internal.core.parser.TokenDuple) * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createUsingDeclaration(org.eclipse.cdt.core.parser.ast.IASTScope, boolean, org.eclipse.cdt.internal.core.parser.TokenDuple)
*/ */
public IASTUsingDeclaration createUsingDeclaration(IASTScope scope, boolean isTypeName, TokenDuple name) { public IASTUsingDeclaration createUsingDeclaration(IASTScope scope, boolean isTypeName, ITokenDuple name) {
return new ASTUsingDeclaration( scope, isTypeName, name.toString() ); return new ASTUsingDeclaration( scope, isTypeName, name.toString() );
} }
@ -127,4 +133,25 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
IASTEnumerator enumerator = new ASTEnumerator( enumeration, string, startingOffset, endingOffset ); IASTEnumerator enumerator = new ASTEnumerator( enumeration, string, startingOffset, endingOffset );
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createExpression(org.eclipse.cdt.core.parser.ast.IASTExpression.ExpressionKind, org.eclipse.cdt.core.parser.ast.IASTExpression, org.eclipse.cdt.core.parser.ast.IASTExpression, java.lang.String, java.lang.String, java.lang.String)
*/
public IASTExpression createExpression(Kind kind, IASTExpression lhs, IASTExpression rhs, IASTExpression thirdExpression, String id, String typeId, String literal, IASTNewExpressionDescriptor newDescriptor) {
return new ASTExpression( kind, lhs, rhs, thirdExpression, id, typeId, literal, newDescriptor );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createNewDescriptor()
*/
public IASTNewExpressionDescriptor createNewDescriptor() {
return new ASTNewDescriptor();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createIASTInitializerClause()
*/
public IASTInitializerClause createIASTInitializerClause(IASTInitializerClause.Kind kind, IASTExpression assignmentExpression, List initializerClauses) {
return new ASTInitializerClause( kind, assignmentExpression, initializerClauses );
}
} }