[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Applied [HEAD] Expressions now have almost complete AST Representation in Parser
|
Completed Quickparse _expression_ representation.
Updated ExpressionEvaluation and associated
tests.
JohnCIndex: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/ChangeLog,v
retrieving revision 1.9
diff -u -r1.9 ChangeLog
--- ChangeLog 27 Jun 2003 00:20:03 -0000 1.9
+++ ChangeLog 28 Jun 2003 22:38:52 -0000
@@ -1,3 +1,7 @@
+2003-06-28 John Camelon
+ Completed Quickparse expression representation.
+ Updated ExpressionEvaluation and associated tests.
+
2003-06-26 John Camelon
Update IASTExpression.
Move Parser.Backtrack and Parser.EndOfFile to external interface.
Index: parser/org/eclipse/cdt/core/parser/tests/DOMTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/DOMTests.java,v
retrieving revision 1.3
diff -u -r1.3 DOMTests.java
--- parser/org/eclipse/cdt/core/parser/tests/DOMTests.java 26 Jun 2003 00:11:32 -0000 1.3
+++ parser/org/eclipse/cdt/core/parser/tests/DOMTests.java 28 Jun 2003 22:38:53 -0000
@@ -1130,7 +1130,6 @@
writer.write( "A(const A&);\n" );
writer.write( "};\n" );
writer.write( "A::A(const A&v) : x(v.x) { }\n" );
- TranslationUnit tu = parse( writer.toString() );
}
public void testBug36288() throws Exception
@@ -1534,6 +1533,11 @@
EnumeratorDefinition enumerator = (EnumeratorDefinition )enumerators.get(0);
assertEquals( enumerator.getName().toString(), "isPointer");
assertNotNull( enumerator.getExpression() );
+ }
+
+ public void testWeirdExpression() throws Exception
+ {
+ parse( "int x = rhs.spImpl_.get();");
}
public void testBug36690() throws Exception {
Index: parser/org/eclipse/cdt/core/parser/tests/ExprEvalTest.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ExprEvalTest.java,v
retrieving revision 1.2
diff -u -r1.2 ExprEvalTest.java
--- parser/org/eclipse/cdt/core/parser/tests/ExprEvalTest.java 23 Jun 2003 18:05:26 -0000 1.2
+++ parser/org/eclipse/cdt/core/parser/tests/ExprEvalTest.java 28 Jun 2003 22:38:53 -0000
@@ -8,7 +8,9 @@
import org.eclipse.cdt.core.parser.IParser;
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 {
@@ -21,14 +23,55 @@
}
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);
- parser.expression(null);
- assertEquals(expectedValue, ((Integer)evaluator.getResult()).intValue());
+
+ IParser parser = ParserFactory.createParser(ParserFactory.createScanner( new StringReader( code ), null, null, null, null ), new NullSourceElementRequestor(), ParserMode.QUICK_PARSE);
+ IASTExpression expression = parser.expression(null);
+ assertEquals(expectedValue, expression.evaluateExpression());
}
public void testInteger() throws Exception {
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 {
Index: model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java,v
retrieving revision 1.10
diff -u -r1.10 DeltaProcessor.java
--- model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java 27 Jun 2003 14:31:27 -0000 1.10
+++ model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java 28 Jun 2003 22:38:35 -0000
@@ -337,7 +337,7 @@
// get the workspace delta, and start processing there.
IResourceDelta[] deltas = changes.getAffectedChildren();
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++) {
IResourceDelta delta = deltas[i];
fCurrentDelta = new CElementDelta(root);
Index: parser/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/ChangeLog,v
retrieving revision 1.68
diff -u -r1.68 ChangeLog
--- parser/ChangeLog 28 Jun 2003 19:48:12 -0000 1.68
+++ parser/ChangeLog 28 Jun 2003 22:38:36 -0000
@@ -1,3 +1,7 @@
+2003-06-28 John Camelon
+ Completed Quickparse expression representation.
+ Updated ExpressionEvaluation and associated tests.
+
2003-06-26 John Camelon
Update IASTExpression.
Move Parser.Backtrack and Parser.EndOfFile to external interface.
Index: parser/org/eclipse/cdt/core/parser/IParser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IParser.java,v
retrieving revision 1.4
diff -u -r1.4 IParser.java
--- parser/org/eclipse/cdt/core/parser/IParser.java 27 Jun 2003 00:20:07 -0000 1.4
+++ parser/org/eclipse/cdt/core/parser/IParser.java 28 Jun 2003 22:38:36 -0000
@@ -10,6 +10,8 @@
***********************************************************************/
package org.eclipse.cdt.core.parser;
+import org.eclipse.cdt.core.parser.ast.IASTExpression;
+
/**
@@ -38,7 +40,7 @@
* @throws Backtrack thrown if the Scanner/Stream provided does not yield a valid
* 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++?
Index: parser/org/eclipse/cdt/core/parser/IScannerContext.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/IScannerContext.java
diff -N parser/org/eclipse/cdt/core/parser/IScannerContext.java
--- parser/org/eclipse/cdt/core/parser/IScannerContext.java 28 Jun 2003 19:48:12 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,78 +0,0 @@
-package org.eclipse.cdt.core.parser;
-import java.io.IOException;
-import java.io.Reader;
-
-import org.eclipse.cdt.core.parser.ast.IASTInclusion;
-/**
- * @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 static int SENTINEL = 0;
- public static int TOP = 1;
- public static int INCLUSION = 2;
- public static int MACROEXPANSION = 3;
-
- /**
- * This initializer is used for scanner contexts which are macro expansions.
- *
- * @param macroOffset Offset of the expanding macro
- * @param macroLength Length of the macro identifier
- * @param line Initial line counter for the context
- * @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);
- public int read() throws IOException;
- public String getFilename();
-
- /**
- * Returns macro offset (the offset of the top expanded macro).
- * @return int
- */
- public int getMacroOffset();
-
- /**
- * Returns macro length (the length of the top expanded macro identifier).
- * @return int
- */
- public int getMacroLength();
-
- /**
- * Returns the offset.
- * @return int
- */
- public int getOffset();
-
- /**
- * Returns relative offset (relative to the beginning of the ScannerContext).
- * @return int
- */
- public int getRelativeOffset();
-
- /**
- * Returns current line counter.
- * @return int
- */
- public int getLine();
-
- public Reader getReader();
-
- public int undoStackSize();
- public int popUndo();
- public void pushUndo(int undo);
-
- public int getKind();
- public void setKind( int kind );
-
- public IASTInclusion getExtension();
- public void setExtension( IASTInclusion ext );
-
-}
\ No newline at end of file
Index: parser/org/eclipse/cdt/core/parser/ITokenDuple.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ITokenDuple.java
diff -N parser/org/eclipse/cdt/core/parser/ITokenDuple.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ITokenDuple.java 28 Jun 2003 22:38:36 -0000
@@ -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();
+}
\ No newline at end of file
Index: parser/org/eclipse/cdt/core/parser/ParserFactory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserFactory.java,v
retrieving revision 1.4
diff -u -r1.4 ParserFactory.java
--- parser/org/eclipse/cdt/core/parser/ParserFactory.java 28 Jun 2003 19:48:12 -0000 1.4
+++ parser/org/eclipse/cdt/core/parser/ParserFactory.java 28 Jun 2003 22:38:36 -0000
@@ -83,4 +83,5 @@
return new LineOffsetReconciler( input );
}
+
}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTExpression.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTExpression.java,v
retrieving revision 1.2
diff -u -r1.2 IASTExpression.java
--- parser/org/eclipse/cdt/core/parser/ast/IASTExpression.java 27 Jun 2003 00:20:07 -0000 1.2
+++ parser/org/eclipse/cdt/core/parser/ast/IASTExpression.java 28 Jun 2003 22:38:36 -0000
@@ -18,90 +18,122 @@
*/
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 ExpressionKind PRIMARY_CHAR_LITERAL = new ExpressionKind( 1 );
- public static final ExpressionKind PRIMARY_FLOAT_LITERAL = new ExpressionKind( 2 );
- public static final ExpressionKind PRIMARY_STRING_LITERAL = new ExpressionKind( 3 );
- public static final ExpressionKind PRIMARY_BOOLEAN_LITERAL = new ExpressionKind( 4 );
- public static final ExpressionKind PRIMARY_THIS = new ExpressionKind( 5 );
- public static final ExpressionKind PRIMARY_BRACKETED_EXPRESSION = new ExpressionKind( 6 );
- public static final ExpressionKind ID_EXPRESSION = new ExpressionKind( 7 );
- public static final ExpressionKind POSTFIX_ARRAY = new ExpressionKind( 8 );
- public static final ExpressionKind POSTFIX_CONSTRUCT = new ExpressionKind( 9 );
- public static final ExpressionKind POSTFIX_SIMPLETYPE_CONSTRUCT = new ExpressionKind( 10 );
- public static final ExpressionKind POSTFIX_TYPENAME_IDENTIFIER = new ExpressionKind( 11 );
- public static final ExpressionKind POSTFIX_TYPENAME_TEMPLATEID = new ExpressionKind( 12 );
- public static final ExpressionKind POSTFIX_DOT_IDEXPRESSION = new ExpressionKind( 13 );
- public static final ExpressionKind POSTFIX_ARROW_IDEXPRESSION = new ExpressionKind( 14 );
- public static final ExpressionKind POSTFIX_DOT_DESTRUCTOR = new ExpressionKind( 15 );
- public static final ExpressionKind POSTFIX_ARROW_DESTRUCTOR = new ExpressionKind( 16 );
- public static final ExpressionKind POSTFIX_INCREMENT = new ExpressionKind( 17 );
- public static final ExpressionKind POSTFIX_DECREMENT = new ExpressionKind( 18 );
- public static final ExpressionKind POSTFIX_DYNAMIC_CAST = new ExpressionKind( 19 );
- public static final ExpressionKind POSTFIX_REINTERPRET_CAST = new ExpressionKind( 20 );
- public static final ExpressionKind POSTFIX_STATIC_CAST = new ExpressionKind( 21 );
- public static final ExpressionKind POSTFIX_CONST_CAST = new ExpressionKind( 22 );
- public static final ExpressionKind POSTFIX_TYPEID_EXPRESSION = new ExpressionKind( 23 );
- public static final ExpressionKind POSTFIX_TYPEID_TYPEID = new ExpressionKind( 24 );
- public static final ExpressionKind UNARY_INCREMENT = new ExpressionKind( 25 );
- public static final ExpressionKind UNARY_DECREMENT = new ExpressionKind( 26 );
- public static final ExpressionKind UNARY_STAR_CASTEXPRESSION = new ExpressionKind( 27 );
- public static final ExpressionKind UNARY_AMPSND_CASTEXPRESSION = new ExpressionKind( 28 );
- public static final ExpressionKind UNARY_PLUS_CASTEXPRESSION = new ExpressionKind( 29 );
- public static final ExpressionKind UNARY_MINUS_CASTEXPRESSION = new ExpressionKind( 30 );
- public static final ExpressionKind UNARY_NOT_CASTEXPRESSION = new ExpressionKind( 31 );
- public static final ExpressionKind UNARY_TILDE_CASTEXPRESSION = new ExpressionKind( 32 );
- public static final ExpressionKind UNARY_SIZEOF_UNARYEXPRESSION = new ExpressionKind( 33 );
- public static final ExpressionKind UNARY_SIZEOF_TYPEID = new ExpressionKind( 34 );
- public static final ExpressionKind NEW_NEWTYPEID = new ExpressionKind( 35 );
- public static final ExpressionKind NEW_TYPEID = new ExpressionKind( 36 );
- public static final ExpressionKind DELETE_CASTEXPRESSION = new ExpressionKind( 37 );
- public static final ExpressionKind DELETE_VECTORCASTEXPRESSION = new ExpressionKind( 38 );
- public static final ExpressionKind CASTEXPRESSION = new ExpressionKind( 39 );
- public static final ExpressionKind PM_DOTSTAR = new ExpressionKind( 40 );
- public static final ExpressionKind PM_ARROWSTAR = new ExpressionKind( 41 );
- public static final ExpressionKind MULTIPLICATIVE_MULTIPLY = new ExpressionKind( 42 );
- public static final ExpressionKind MULTIPLICATIVE_DIVIDE = new ExpressionKind( 43 );
- public static final ExpressionKind MULTIPLICATIVE_MODULUS = new ExpressionKind( 44 );
- public static final ExpressionKind ADDITIVE_PLUS = new ExpressionKind( 45 );
- public static final ExpressionKind ADDITIVE_MINUS = new ExpressionKind( 46 );
- public static final ExpressionKind SHIFT_LEFT = new ExpressionKind( 47 );
- public static final ExpressionKind SHIFT_RIGHT = new ExpressionKind( 48 );
- public static final ExpressionKind RELATIONAL_LESSTHAN = new ExpressionKind( 49 );
- public static final ExpressionKind RELATIONAL_GREATERTHAN = new ExpressionKind( 50 );
- public static final ExpressionKind RELATIONAL_LESSTHANEQUALTO = new ExpressionKind( 51 );
- public static final ExpressionKind RELATIONAL_GREATERTHANEQUALTO= new ExpressionKind( 52 );
- public static final ExpressionKind EQUALITY_EQUALS = new ExpressionKind( 53 );
- public static final ExpressionKind EQUALITY_NOTEQUALS = new ExpressionKind( 54 );
- public static final ExpressionKind ANDEXPRESSION = new ExpressionKind( 55 );
- public static final ExpressionKind EXCLUSIVEOREXPRESSION = new ExpressionKind( 56 );
- public static final ExpressionKind INCLUSIVEOREXPRESSION = new ExpressionKind( 57 );
- public static final ExpressionKind LOGICALANDEXPRESSION = new ExpressionKind( 58 );
- public static final ExpressionKind LOGICALOREXPRESSION = new ExpressionKind( 59 );
- public static final ExpressionKind CONDITIONALEXPRESSION = new ExpressionKind( 60 );
- public static final ExpressionKind THROWEXPRESSION = new ExpressionKind( 61 );
- public static final ExpressionKind ASSIGNMENTEXPRESSION = new ExpressionKind( 62 );
- public static final ExpressionKind EXPRESSIONLIST = new ExpressionKind( 63 );
+ public static final Kind PRIMARY_EMPTY = new Kind( -1 );
+ public static final Kind PRIMARY_INTEGER_LITERAL = new Kind( 0 );
+ public static final Kind PRIMARY_CHAR_LITERAL = new Kind( 1 );
+ public static final Kind PRIMARY_FLOAT_LITERAL = new Kind( 2 );
+ public static final Kind PRIMARY_STRING_LITERAL = new Kind( 3 );
+ public static final Kind PRIMARY_BOOLEAN_LITERAL = new Kind( 4 );
+ public static final Kind PRIMARY_THIS = new Kind( 5 );
+ public static final Kind PRIMARY_BRACKETED_EXPRESSION = new Kind( 6 );
+ public static final Kind ID_EXPRESSION = new Kind( 7 );
+ public static final Kind POSTFIX_SUBSCRIPT = new Kind( 8 );
+ public static final Kind POSTFIX_FUNCTIONCALL = new Kind( 9 );
+ public static final Kind POSTFIX_SIMPLETYPE_INT = new Kind( 10 );
+ public static final Kind POSTFIX_SIMPLETYPE_SHORT = new Kind( 11 );
+ public static final Kind POSTFIX_SIMPLETYPE_DOUBLE = new Kind( 12 );
+ public static final Kind POSTFIX_SIMPLETYPE_FLOAT = new Kind( 13 );
+ public static final Kind POSTFIX_SIMPLETYPE_CHAR = new Kind( 14 );
+ public static final Kind POSTFIX_SIMPLETYPE_WCHART = new Kind( 15 );
+ public static final Kind POSTFIX_SIMPLETYPE_SIGNED = new Kind( 16 );
+ public static final Kind POSTFIX_SIMPLETYPE_UNSIGNED = new Kind( 17 );
+ public static final Kind POSTFIX_SIMPLETYPE_BOOL = new Kind( 18 );
+ public static final Kind POSTFIX_SIMPLETYPE_LONG = new Kind( 19 );
+ public static final Kind POSTFIX_TYPENAME_IDENTIFIER = new Kind( 20 );
+ public static final Kind POSTFIX_TYPENAME_TEMPLATEID = new Kind( 21 );
+ public static final Kind POSTFIX_DOT_IDEXPRESSION = new Kind( 22 );
+ public static final Kind POSTFIX_ARROW_IDEXPRESSION = new Kind( 23 );
+ public static final Kind POSTFIX_DOT_TEMPL_IDEXPRESS = new Kind( 24 );
+ public static final Kind POSTFIX_ARROW_TEMPL_IDEXP = new Kind( 25 );
+ public static final Kind POSTFIX_DOT_DESTRUCTOR = new Kind( 26 );
+ public static final Kind POSTFIX_ARROW_DESTRUCTOR = new Kind( 27 );
+ public static final Kind POSTFIX_INCREMENT = new Kind( 28 );
+ public static final Kind POSTFIX_DECREMENT = new Kind( 29 );
+ public static final Kind POSTFIX_DYNAMIC_CAST = new Kind( 30 );
+ public static final Kind POSTFIX_REINTERPRET_CAST = new Kind( 31 );
+ public static final Kind POSTFIX_STATIC_CAST = new Kind( 32 );
+ public static final Kind POSTFIX_CONST_CAST = new Kind( 33 );
+ public static final Kind POSTFIX_TYPEID_EXPRESSION = new Kind( 34 );
+ public static final Kind POSTFIX_TYPEID_TYPEID = new Kind( 35 );
+ public static final Kind UNARY_INCREMENT = new Kind( 36 );
+ public static final Kind UNARY_DECREMENT = new Kind( 37 );
+ public static final Kind UNARY_STAR_CASTEXPRESSION = new Kind( 38 );
+ public static final Kind UNARY_AMPSND_CASTEXPRESSION = new Kind( 39 );
+ public static final Kind UNARY_PLUS_CASTEXPRESSION = new Kind( 40 );
+ public static final Kind UNARY_MINUS_CASTEXPRESSION = new Kind( 41 );
+ public static final Kind UNARY_NOT_CASTEXPRESSION = new Kind( 42 );
+ public static final Kind UNARY_TILDE_CASTEXPRESSION = new Kind( 43 );
+ public static final Kind UNARY_SIZEOF_UNARYEXPRESSION = new Kind( 44 );
+ public static final Kind UNARY_SIZEOF_TYPEID = new Kind( 45 );
+ public static final Kind NEW_NEWTYPEID = new Kind( 46 );
+ public static final Kind NEW_TYPEID = new Kind( 47 );
+ public static final Kind DELETE_CASTEXPRESSION = new Kind( 48 );
+ public static final Kind DELETE_VECTORCASTEXPRESSION = new Kind( 49 );
+ public static final Kind CASTEXPRESSION = new Kind( 50 );
+ public static final Kind PM_DOTSTAR = new Kind( 51 );
+ public static final Kind PM_ARROWSTAR = new Kind( 52 );
+ public static final Kind MULTIPLICATIVE_MULTIPLY = new Kind( 53 );
+ public static final Kind MULTIPLICATIVE_DIVIDE = new Kind( 54 );
+ public static final Kind MULTIPLICATIVE_MODULUS = new Kind( 55 );
+ public static final Kind ADDITIVE_PLUS = new Kind( 56 );
+ public static final Kind ADDITIVE_MINUS = new Kind( 57 );
+ public static final Kind SHIFT_LEFT = new Kind( 58 );
+ public static final Kind SHIFT_RIGHT = new Kind( 59 );
+ public static final Kind RELATIONAL_LESSTHAN = new Kind( 60 );
+ public static final Kind RELATIONAL_GREATERTHAN = new Kind( 61 );
+ 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
*/
- private ExpressionKind(int enumValue)
+ private Kind(int enumValue)
{
super(enumValue);
}
}
- public ExpressionKind getExpressionKind();
+ public interface IASTNewExpressionDescriptor
+ {
+
+ }
+
+
+
+ public Kind getExpressionKind();
public IASTExpression getLHSExpression();
public IASTExpression getRHSExpression();
+ public IASTExpression getThirdExpression();
public String getLiteralString();
public String getTypeId();
- public String getId();
+ public String getId();
+ public IASTNewExpressionDescriptor getNewExpressionDescriptor();
public int evaluateExpression() throws ExpressionEvaluationException;
Index: parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java,v
retrieving revision 1.5
diff -u -r1.5 IASTFactory.java
--- parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java 27 Jun 2003 00:20:07 -0000 1.5
+++ parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java 28 Jun 2003 22:38:36 -0000
@@ -10,9 +10,12 @@
***********************************************************************/
package org.eclipse.cdt.core.parser.ast;
+import java.util.List;
+
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.internal.core.parser.TokenDuple;
+import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
/**
* @author jcamelon
@@ -25,13 +28,13 @@
public IASTUsingDirective createUsingDirective(
IASTScope scope,
- TokenDuple duple)
+ ITokenDuple duple)
throws Backtrack;
public IASTUsingDeclaration createUsingDeclaration(
IASTScope scope,
boolean isTypeName,
- TokenDuple name );
+ ITokenDuple name );
public IASTASMDefinition createASMDefinition(
@@ -67,5 +70,11 @@
public IASTElaboratedTypeSpecifier createElaboratedTypeSpecifier(ClassKind elaboratedClassKind, String typeName, int startingOffset, int endOffset );
public IASTEnumerationSpecifier createEnumerationSpecifier(String name, int startingOffset, int nameOffset );
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);
}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTInitializerClause.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTInitializerClause.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTInitializerClause.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTInitializerClause.java 28 Jun 2003 22:38:36 -0000
@@ -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();
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ContextStack.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ContextStack.java,v
retrieving revision 1.8
diff -u -r1.8 ContextStack.java
--- parser/org/eclipse/cdt/internal/core/parser/ContextStack.java 28 Jun 2003 19:48:12 -0000 1.8
+++ parser/org/eclipse/cdt/internal/core/parser/ContextStack.java 28 Jun 2003 22:38:36 -0000
@@ -19,7 +19,6 @@
import java.util.Set;
import java.util.Stack;
-import org.eclipse.cdt.core.parser.IScannerContext;
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
import org.eclipse.cdt.core.parser.ScannerException;
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
Index: parser/org/eclipse/cdt/internal/core/parser/Declarator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Declarator.java,v
retrieving revision 1.2
diff -u -r1.2 Declarator.java
--- parser/org/eclipse/cdt/internal/core/parser/Declarator.java 25 Jun 2003 22:47:52 -0000 1.2
+++ parser/org/eclipse/cdt/internal/core/parser/Declarator.java 28 Jun 2003 22:38:36 -0000
@@ -14,7 +14,7 @@
import java.util.Collections;
import java.util.List;
-import org.eclipse.cdt.core.parser.ast.IASTExpression;
+import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
/**
* @author jcamelon
@@ -25,7 +25,7 @@
private final DeclarationWrapper owner1;
private final Declarator owner2;
private String name;
- private IASTExpression initialValueExpression;
+ private IASTInitializerClause initializerClause;
private List ptrOps = new ArrayList();
private List parameters = new ArrayList();
@@ -133,17 +133,17 @@
/**
* @return
*/
- public IASTExpression getInitialValueExpression()
+ public IASTInitializerClause getInitializerClause()
{
- return initialValueExpression;
+ return initializerClause;
}
/**
* @param expression
*/
- public void setInitialValueExpression(IASTExpression expression)
+ public void setInitializerClause(IASTInitializerClause expression)
{
- initialValueExpression = expression;
+ initializerClause = expression;
}
}
Index: parser/org/eclipse/cdt/internal/core/parser/DeclaratorDuple.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/DeclaratorDuple.java
diff -N parser/org/eclipse/cdt/internal/core/parser/DeclaratorDuple.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/DeclaratorDuple.java 28 Jun 2003 22:38:36 -0000
@@ -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;
+ }
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java
--- parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java 18 Jun 2003 19:36:20 -0000 1.28
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -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) {
- }
-}
Index: parser/org/eclipse/cdt/internal/core/parser/IScannerContext.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/IScannerContext.java
diff -N parser/org/eclipse/cdt/internal/core/parser/IScannerContext.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/IScannerContext.java 28 Jun 2003 22:38:36 -0000
@@ -0,0 +1,71 @@
+package org.eclipse.cdt.internal.core.parser;
+import java.io.IOException;
+import java.io.Reader;
+
+import org.eclipse.cdt.core.parser.ast.IASTInclusion;
+/**
+ * @author jcamelon
+ *
+ */
+public interface IScannerContext {
+
+ public static int SENTINEL = 0;
+ public static int TOP = 1;
+ public static int INCLUSION = 2;
+ public static int MACROEXPANSION = 3;
+
+ /**
+ * This initializer is used for scanner contexts which are macro expansions.
+ *
+ * @param macroOffset Offset of the expanding macro
+ * @param macroLength Length of the macro identifier
+ * @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);
+ public int read() throws IOException;
+ public String getFilename();
+
+ /**
+ * Returns macro offset (the offset of the top expanded macro).
+ * @return int
+ */
+ public int getMacroOffset();
+
+ /**
+ * Returns macro length (the length of the top expanded macro identifier).
+ * @return int
+ */
+ public int getMacroLength();
+
+ /**
+ * Returns the offset.
+ * @return int
+ */
+ public int getOffset();
+
+ /**
+ * Returns relative offset (relative to the beginning of the ScannerContext).
+ * @return int
+ */
+ public int getRelativeOffset();
+
+ public Reader getReader();
+
+ public int undoStackSize();
+ public int popUndo();
+ public void pushUndo(int undo);
+
+ public int getKind();
+ public void setKind( int kind );
+
+ public IASTInclusion getExtension();
+ public void setExtension( IASTInclusion ext );
+
+ /**
+ * @return
+ */
+ public int getLine();
+
+}
\ No newline at end of file
Index: parser/org/eclipse/cdt/internal/core/parser/Parser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java,v
retrieving revision 1.61
diff -u -r1.61 Parser.java
--- parser/org/eclipse/cdt/internal/core/parser/Parser.java 28 Jun 2003 19:48:12 -0000 1.61
+++ parser/org/eclipse/cdt/internal/core/parser/Parser.java 28 Jun 2003 22:38:38 -0000
@@ -9,15 +9,19 @@
* Rational Software - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.internal.core.parser;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.cdt.core.parser.Backtrack;
import org.eclipse.cdt.core.parser.EndOfFile;
import org.eclipse.cdt.core.parser.IParser;
import org.eclipse.cdt.core.parser.IParserCallback;
import org.eclipse.cdt.core.parser.IProblemReporter;
import org.eclipse.cdt.core.parser.IScanner;
-import org.eclipse.cdt.core.parser.ITranslationResult;
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
import org.eclipse.cdt.core.parser.IToken;
+import org.eclipse.cdt.core.parser.ITokenDuple;
+import org.eclipse.cdt.core.parser.ITranslationResult;
import org.eclipse.cdt.core.parser.ParserFactory;
import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.core.parser.ScannerException;
@@ -28,13 +32,16 @@
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
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.IASTInitializerClause;
import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType;
+import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
import org.eclipse.cdt.internal.core.model.Util;
@@ -995,29 +1002,7 @@
catch (Exception e)
{
}
- if (mode == ParserMode.QUICK_PARSE)
- {
- // speed up the parser by skiping the body
- // simply look for matching brace and return
- consume(IToken.tLBRACE);
- int depth = 1;
- while (depth > 0)
- {
- switch (consume().getType())
- {
- case IToken.tRBRACE :
- --depth;
- break;
- case IToken.tLBRACE :
- ++depth;
- break;
- }
- }
- }
- else
- {
- functionBody();
- }
+ handleFunctionBody();
try
{
callback.functionBodyEnd(function);
@@ -1037,6 +1022,32 @@
{
}
}
+
+ protected void handleFunctionBody() throws Backtrack, EndOfFile {
+ if (mode == ParserMode.QUICK_PARSE)
+ {
+ // speed up the parser by skiping the body
+ // simply look for matching brace and return
+ consume(IToken.tLBRACE);
+ int depth = 1;
+ while (depth > 0)
+ {
+ switch (consume().getType())
+ {
+ case IToken.tRBRACE :
+ --depth;
+ break;
+ case IToken.tLBRACE :
+ ++depth;
+ break;
+ }
+ }
+ }
+ else
+ {
+ functionBody();
+ }
+ }
/**
* This method parses a constructor chain
* ctorinitializer: : meminitializerlist
@@ -1105,7 +1116,7 @@
catch (Exception e)
{
}
- assignmentExpression(expression);
+ IASTExpression assignmentExpression = assignmentExpression(expression);
try
{
callback.expressionEnd(item);
@@ -1557,7 +1568,7 @@
{
}
}
- TokenDuple duple = new TokenDuple(first, last);
+ ITokenDuple duple = new TokenDuple(first, last);
sdw.setTypeName(duple.toString());
try
{
@@ -1588,7 +1599,7 @@
catch (Exception e)
{
}
- TokenDuple d = name();
+ ITokenDuple d = name();
sdw.setTypeName(d.toString());
try
{
@@ -1687,7 +1698,7 @@
{
}
- TokenDuple d = name();
+ ITokenDuple d = name();
IASTElaboratedTypeSpecifier elaboratedTypeSpec = astFactory.createElaboratedTypeSpecifier( eck, d.toString(), t.getOffset(),
d.getLastToken().getEndOffset() );
@@ -1763,7 +1774,7 @@
*
* @throws Backtrack
*/
- protected TokenDuple className() throws Backtrack
+ protected ITokenDuple className() throws Backtrack
{
if (LT(1) == IToken.tIDENTIFIER)
{
@@ -1914,63 +1925,16 @@
protected Object initDeclarator(Object owner, DeclarationWrapper sdw)
throws Backtrack
{
- Object declarator = declarator(owner, sdw, null);
+ DeclaratorDuple duple = declarator(owner, sdw, null);
+ Object declarator = duple.getObject();
+ Declarator d = duple.getDeclarator();
+
// handle = initializerClause
- if (LT(1) == IToken.tASSIGN)
+ if(LT(1) == IToken.tASSIGN )
{
- consume();
- // assignmentExpression || { initializerList , } || { }
- Object expression = null;
- try
- {
- try
- {
- expression = callback.expressionBegin(declarator);
- }
- catch (Exception e)
- {
- }
- assignmentExpression(expression);
- try
- {
- callback.expressionEnd(expression);
- }
- catch (Exception e)
- {
- }
- //TODO add in expression information here
- }
- catch (Backtrack b)
- {
- if (expression != null)
- try
- {
- callback.expressionAbort(expression);
- }
- catch (Exception e)
- {
- }
- }
- if (LT(1) == IToken.tLBRACE)
- {
- //TODO do this for real
- // for now, just consume to matching brace
- consume();
- int depth = 1;
- while (depth > 0)
- {
- switch (consume().getType())
- {
- case IToken.tRBRACE :
- --depth;
- break;
- case IToken.tLBRACE :
- ++depth;
- break;
- }
- }
- }
- }
+ consume( IToken.tASSIGN );
+ d.setInitializerClause( initializerClause( declarator ) );
+ }
else if (LT(1) == IToken.tLPAREN)
{
consume(IToken.tLPAREN); // EAT IT!
@@ -2016,7 +1980,78 @@
}
return declarator;
}
+
/**
+ *
+ */
+ protected IASTInitializerClause initializerClause(Object declarator) throws Backtrack
+ {
+ if (LT(1) == IToken.tLBRACE)
+ {
+ //TODO - parse this for real
+ consume(IToken.tLBRACE);
+ if( LT(1) == (IToken.tRBRACE ) )
+ {
+ consume( IToken.tRBRACE );
+ return astFactory.createIASTInitializerClause( IASTInitializerClause.Kind.EMPTY, null, null );
+ }
+
+ // otherwise it is a list of initializers
+ List initializerClauses = new ArrayList();
+ for( ; ; )
+ {
+ IASTInitializerClause clause = initializerClause( declarator );
+ initializerClauses.add( clause );
+ if( LT(1) == IToken.tRBRACE ) break;
+ consume( IToken.tCOMMA );
+ }
+ consume( IToken.tRBRACE );
+ return astFactory.createIASTInitializerClause( IASTInitializerClause.Kind.INITIALIZER_LIST, null, initializerClauses );
+ }
+ // try this now instead
+ // assignmentExpression || { initializerList , } || { }
+ Object expression = null;
+ try
+ {
+ try
+ {
+ expression = callback.expressionBegin(declarator);
+ }
+ catch (Exception e)
+ {
+ }
+
+ IToken marked = mark();
+ IASTExpression assignmentExpression = assignmentExpression(expression);
+
+ try
+ {
+ callback.expressionEnd(expression);
+ }
+ catch (Exception e)
+ {
+ }
+
+ return astFactory.createIASTInitializerClause( IASTInitializerClause.Kind.ASSIGNMENT_EXPRESSION, assignmentExpression, null );
+ }
+ catch (Backtrack b)
+ {
+ if (expression != null)
+ try
+ {
+ callback.expressionAbort(expression);
+ }
+ catch (Exception e)
+ {
+ }
+ }
+
+
+
+ throw backtrack;
+ }
+
+ /**
* Parse a declarator, as according to the ANSI C++ specification.
*
* declarator
@@ -2037,7 +2072,7 @@
* @return declarator that this parsing produced.
* @throws Backtrack request a backtrack
*/
- protected Object declarator(Object container, DeclarationWrapper sdw, Declarator owningDeclarator) throws Backtrack
+ protected DeclaratorDuple declarator(Object container, DeclarationWrapper sdw, Declarator owningDeclarator) throws Backtrack
{
boolean anonymous = false;
do
@@ -2071,11 +2106,11 @@
if (LT(1) == IToken.tLPAREN)
{
consume();
- Object subDeclarator = declarator(declarator, null, d);
+ DeclaratorDuple subDeclarator = declarator(declarator, null, d);
consume(IToken.tRPAREN);
try
{
- callback.declaratorEnd(subDeclarator);
+ callback.declaratorEnd(subDeclarator.getObject());
}
catch (Exception e)
{
@@ -2174,7 +2209,7 @@
if (LT(1) == IToken.tCOLON)
{
// this is most likely the definition of the constructor
- return declarator;
+ return new DeclaratorDuple( declarator, d );
}
IToken beforeCVModifier = mark();
IToken cvModifier = null;
@@ -2408,7 +2443,7 @@
}
else
{
- return declarator;
+ return new DeclaratorDuple( declarator, d );
}
}
while (true);
@@ -2524,7 +2559,7 @@
IToken mark = mark();
IToken tokenType = LA(1);
boolean hasName = false;
- TokenDuple nameDuple = null;
+ ITokenDuple nameDuple = null;
if (t == IToken.tIDENTIFIER || t == IToken.tCOLONCOLON)
{
callback.nameBegin(tokenType);
@@ -2791,7 +2826,7 @@
catch (Exception e)
{
}
- TokenDuple duple = null;
+ ITokenDuple duple = null;
// class name
if (LT(1) == IToken.tIDENTIFIER)
{
@@ -2920,7 +2955,7 @@
}
boolean isVirtual = false;
AccessVisibility visibility = AccessVisibility.PUBLIC;
- TokenDuple nameDuple = null;
+ ITokenDuple nameDuple = null;
baseSpecifierLoop : for (;;)
{
switch (LT(1))
@@ -3254,16 +3289,18 @@
{
conditionalExpression(expression);
}
+
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParser#expression(java.lang.Object)
*/
- public void expression(Object expression) throws Backtrack
+ public IASTExpression expression(Object expression) throws Backtrack
{
- assignmentExpression(expression);
+ IASTExpression assignmentExpression = assignmentExpression(expression);
while (LT(1) == IToken.tCOMMA)
{
IToken t = consume();
- assignmentExpression(expression);
+ IASTExpression secondExpression = assignmentExpression(expression);
+
try
{
callback.expressionOperator(expression, t);
@@ -3271,93 +3308,115 @@
catch (Exception e)
{
}
+ assignmentExpression = astFactory.createExpression( IASTExpression.Kind.EXPRESSIONLIST, assignmentExpression, secondExpression, null, "", "", "", null );
}
+ return assignmentExpression;
}
/**
* @param expression
* @throws Backtrack
*/
- protected void assignmentExpression(Object expression) throws Backtrack
+ protected IASTExpression assignmentExpression(Object expression) throws Backtrack
{
if (LT(1) == IToken.t_throw)
{
- throwExpression(expression);
- return;
+ return throwExpression(expression);
}
+ IASTExpression conditionalExpression = conditionalExpression(expression);
// if the condition not taken, try assignment operators
- if (!conditionalExpression(expression))
+ if (conditionalExpression != null && conditionalExpression.getExpressionKind() == IASTExpression.Kind.CONDITIONALEXPRESSION_HARD )
+ return conditionalExpression;
+
+ switch (LT(1))
{
- switch (LT(1))
- {
- case IToken.tASSIGN :
- case IToken.tSTARASSIGN :
- case IToken.tDIVASSIGN :
- case IToken.tMODASSIGN :
- case IToken.tPLUSASSIGN :
- case IToken.tMINUSASSIGN :
- case IToken.tSHIFTRASSIGN :
- case IToken.tSHIFTLASSIGN :
- case IToken.tAMPERASSIGN :
- case IToken.tXORASSIGN :
- case IToken.tBITORASSIGN :
- IToken t = consume();
- conditionalExpression(expression);
- try
- {
- callback.expressionOperator(expression, t);
- }
- catch (Exception e)
- {
- }
- break;
- }
+ case IToken.tASSIGN :
+ return assignmentOperatorExpression(expression, IASTExpression.Kind.ASSIGNMENTEXPRESSION_NORMAL );
+ case IToken.tSTARASSIGN :
+ return assignmentOperatorExpression(expression, IASTExpression.Kind.ASSIGNMENTEXPRESSION_MULT );
+ case IToken.tDIVASSIGN :
+ return assignmentOperatorExpression(expression, IASTExpression.Kind.ASSIGNMENTEXPRESSION_DIV );
+ case IToken.tMODASSIGN :
+ return assignmentOperatorExpression(expression, IASTExpression.Kind.ASSIGNMENTEXPRESSION_MOD );
+ case IToken.tPLUSASSIGN :
+ return assignmentOperatorExpression(expression, IASTExpression.Kind.ASSIGNMENTEXPRESSION_PLUS );
+ case IToken.tMINUSASSIGN :
+ return assignmentOperatorExpression(expression, IASTExpression.Kind.ASSIGNMENTEXPRESSION_MINUS );
+ case IToken.tSHIFTRASSIGN :
+ return assignmentOperatorExpression(expression, IASTExpression.Kind.ASSIGNMENTEXPRESSION_RSHIFT );
+ case IToken.tSHIFTLASSIGN :
+ return assignmentOperatorExpression(expression, IASTExpression.Kind.ASSIGNMENTEXPRESSION_LSHIFT );
+ case IToken.tAMPERASSIGN :
+ return assignmentOperatorExpression(expression, IASTExpression.Kind.ASSIGNMENTEXPRESSION_AND );
+ case IToken.tXORASSIGN :
+ return assignmentOperatorExpression(expression, IASTExpression.Kind.ASSIGNMENTEXPRESSION_XOR );
+ case IToken.tBITORASSIGN :
+ return assignmentOperatorExpression(expression, IASTExpression.Kind.ASSIGNMENTEXPRESSION_OR );
}
+ return conditionalExpression;
+
}
+
+ protected IASTExpression assignmentOperatorExpression(Object expression, IASTExpression.Kind kind )
+ throws EndOfFile, Backtrack {
+ IToken t = consume();
+ IASTExpression assignmentExpression = assignmentExpression(expression);
+ try
+ {
+ callback.expressionOperator(expression, t);
+ }
+ catch (Exception e)
+ {
+ }
+ return astFactory.createExpression( kind, assignmentExpression, null, null, "", "", "", null );
+ }
/**
* @param expression
* @throws Backtrack
*/
- protected void throwExpression(Object expression) throws Backtrack
+ protected IASTExpression throwExpression(Object expression) throws Backtrack
{
consume(IToken.t_throw);
+ IASTExpression throwExpression = null;
try
{
- expression(expression);
+ throwExpression = expression(expression);
}
catch (Backtrack b)
{
}
+ return astFactory.createExpression( IASTExpression.Kind.THROWEXPRESSION, throwExpression, null, null, "", "", "", null );
}
/**
* @param expression
* @return
* @throws Backtrack
*/
- protected boolean conditionalExpression(Object expression) throws Backtrack
+ protected IASTExpression conditionalExpression(Object expression) throws Backtrack
{
- logicalOrExpression(expression);
+ IASTExpression firstExpression = logicalOrExpression(expression);
if (LT(1) == IToken.tQUESTION)
{
consume();
- expression(expression);
+ IASTExpression secondExpression = expression(expression);
consume(IToken.tCOLON);
- assignmentExpression(expression);
- return true;
+ IASTExpression thirdExpression = assignmentExpression(expression);
+ return astFactory.createExpression( IASTExpression.Kind.CONDITIONALEXPRESSION_HARD, firstExpression, secondExpression, thirdExpression, "","","",null);
}
else
- return false;
+ return firstExpression;
}
/**
* @param expression
* @throws Backtrack
*/
- protected void logicalOrExpression(Object expression) throws Backtrack
+ protected IASTExpression logicalOrExpression(Object expression) throws Backtrack
{
- logicalAndExpression(expression);
+ IASTExpression firstExpression = logicalAndExpression(expression);
+
while (LT(1) == IToken.tOR)
{
IToken t = consume();
- logicalAndExpression(expression);
+ IASTExpression secondExpression = logicalAndExpression(expression);
try
{
callback.expressionOperator(expression, t);
@@ -3365,19 +3424,21 @@
catch (Exception e)
{
}
+ firstExpression = astFactory.createExpression( IASTExpression.Kind.LOGICALOREXPRESSION, firstExpression, secondExpression, null, "", "", "", null );
}
+ return firstExpression;
}
/**
* @param expression
* @throws Backtrack
*/
- protected void logicalAndExpression(Object expression) throws Backtrack
+ protected IASTExpression logicalAndExpression(Object expression) throws Backtrack
{
- inclusiveOrExpression(expression);
+ IASTExpression firstExpression = inclusiveOrExpression(expression);
while (LT(1) == IToken.tAND)
{
IToken t = consume();
- inclusiveOrExpression(expression);
+ IASTExpression secondExpression = inclusiveOrExpression(expression);
try
{
callback.expressionOperator(expression, t);
@@ -3385,19 +3446,21 @@
catch (Exception e)
{
}
+ firstExpression = astFactory.createExpression( IASTExpression.Kind.LOGICALANDEXPRESSION, firstExpression, secondExpression, null, "", "", "", null );
}
+ return firstExpression;
}
/**
* @param expression
* @throws Backtrack
*/
- protected void inclusiveOrExpression(Object expression) throws Backtrack
+ protected IASTExpression inclusiveOrExpression(Object expression) throws Backtrack
{
- exclusiveOrExpression(expression);
+ IASTExpression firstExpression = exclusiveOrExpression(expression);
while (LT(1) == IToken.tBITOR)
{
IToken t = consume();
- exclusiveOrExpression(expression);
+ IASTExpression secondExpression = exclusiveOrExpression(expression);
try
{
callback.expressionOperator(expression, t);
@@ -3405,19 +3468,21 @@
catch (Exception e)
{
}
+ firstExpression = astFactory.createExpression( IASTExpression.Kind.INCLUSIVEOREXPRESSION, firstExpression, secondExpression, null, "", "", "", null );
}
+ return firstExpression;
}
/**
* @param expression
* @throws Backtrack
*/
- protected void exclusiveOrExpression(Object expression) throws Backtrack
+ protected IASTExpression exclusiveOrExpression(Object expression) throws Backtrack
{
- andExpression(expression);
+ IASTExpression firstExpression = andExpression(expression);
while (LT(1) == IToken.tXOR)
{
IToken t = consume();
- andExpression(expression);
+ IASTExpression secondExpression = andExpression(expression);
try
{
callback.expressionOperator(expression, t);
@@ -3425,19 +3490,21 @@
catch (Exception e)
{
}
+ firstExpression = astFactory.createExpression( IASTExpression.Kind.EXCLUSIVEOREXPRESSION, firstExpression, secondExpression, null, "", "", "", null );
}
+ return firstExpression;
}
/**
* @param expression
* @throws Backtrack
*/
- protected void andExpression(Object expression) throws Backtrack
+ protected IASTExpression andExpression(Object expression) throws Backtrack
{
- equalityExpression(expression);
+ IASTExpression firstExpression = equalityExpression(expression);
while (LT(1) == IToken.tAMPER)
{
IToken t = consume();
- equalityExpression(expression);
+ IASTExpression secondExpression = equalityExpression(expression);
try
{
callback.expressionOperator(expression, t);
@@ -3445,23 +3512,25 @@
catch (Exception e)
{
}
+ firstExpression = astFactory.createExpression( IASTExpression.Kind.ANDEXPRESSION, firstExpression, secondExpression, null, "", "", "", null );
}
+ return firstExpression;
}
/**
* @param expression
* @throws Backtrack
*/
- protected void equalityExpression(Object expression) throws Backtrack
+ protected IASTExpression equalityExpression(Object expression) throws Backtrack
{
- relationalExpression(expression);
+ IASTExpression firstExpression = relationalExpression(expression);
for (;;)
{
switch (LT(1))
{
case IToken.tEQUAL :
- case IToken.tNOTEQUAL :
+ case IToken.tNOTEQUAL :
IToken t = consume();
- relationalExpression(expression);
+ IASTExpression secondExpression = relationalExpression(expression);
try
{
callback.expressionOperator(expression, t);
@@ -3469,9 +3538,11 @@
catch (Exception e)
{
}
+ firstExpression = astFactory.createExpression( ( t.getType() == IToken.tEQUAL ) ? IASTExpression.Kind.EQUALITY_EQUALS : IASTExpression.Kind.EQUALITY_NOTEQUALS,
+ firstExpression, secondExpression, null, "", "", "", null );
break;
default :
- return;
+ return firstExpression;
}
}
}
@@ -3479,30 +3550,27 @@
* @param expression
* @throws Backtrack
*/
- protected void relationalExpression(Object expression) throws Backtrack
+ protected IASTExpression relationalExpression(Object expression) throws Backtrack
{
- shiftExpression(expression);
+ IASTExpression firstExpression = shiftExpression(expression);
for (;;)
{
switch (LT(1))
{
case IToken.tGT :
- // For template args, the GT means end of args
- //if (templateArgs)
- // return;
case IToken.tLT :
case IToken.tLTEQUAL :
case IToken.tGTEQUAL :
IToken mark = mark();
IToken t = consume();
IToken next = LA(1);
- shiftExpression(expression);
+ IASTExpression secondExpression = shiftExpression(expression);
if (next == LA(1))
{
// we did not consume anything
// this is most likely an error
backup(mark);
- return;
+ return firstExpression;
}
else
{
@@ -3513,10 +3581,33 @@
catch (Exception e)
{
}
+
+ IASTExpression.Kind kind = null;
+ switch( t.getType() )
+ {
+ case IToken.tGT :
+ kind = IASTExpression.Kind.RELATIONAL_GREATERTHAN;
+ break;
+
+ case IToken.tLT :
+ kind = IASTExpression.Kind.RELATIONAL_LESSTHAN;
+ break;
+
+ case IToken.tLTEQUAL :
+ kind = IASTExpression.Kind.RELATIONAL_LESSTHANEQUALTO;
+ break;
+
+ case IToken.tGTEQUAL :
+ kind = IASTExpression.Kind.RELATIONAL_GREATERTHANEQUALTO;
+ break;
+
+ }
+
+ firstExpression = astFactory.createExpression( kind, firstExpression, secondExpression, null, "", "", "", null );
}
break;
default :
- return;
+ return firstExpression;
}
}
}
@@ -3524,9 +3615,9 @@
* @param expression
* @throws Backtrack
*/
- protected void shiftExpression(Object expression) throws Backtrack
+ protected IASTExpression shiftExpression(Object expression) throws Backtrack
{
- additiveExpression(expression);
+ IASTExpression firstExpression = additiveExpression(expression);
for (;;)
{
switch (LT(1))
@@ -3534,7 +3625,7 @@
case IToken.tSHIFTL :
case IToken.tSHIFTR :
IToken t = consume();
- additiveExpression(expression);
+ IASTExpression secondExpression = additiveExpression(expression);
try
{
callback.expressionOperator(expression, t);
@@ -3542,9 +3633,11 @@
catch (Exception e)
{
}
+ firstExpression = astFactory.createExpression( ( ( t.getType() == IToken.tSHIFTL ) ? IASTExpression.Kind.SHIFT_LEFT : IASTExpression.Kind.SHIFT_RIGHT ),
+ firstExpression, secondExpression, null, "", "", "", null );
break;
default :
- return;
+ return firstExpression ;
}
}
}
@@ -3552,9 +3645,9 @@
* @param expression
* @throws Backtrack
*/
- protected void additiveExpression(Object expression) throws Backtrack
+ protected IASTExpression additiveExpression(Object expression) throws Backtrack
{
- multiplicativeExpression(expression);
+ IASTExpression firstExpression = multiplicativeExpression(expression);
for (;;)
{
switch (LT(1))
@@ -3562,7 +3655,7 @@
case IToken.tPLUS :
case IToken.tMINUS :
IToken t = consume();
- multiplicativeExpression(expression);
+ IASTExpression secondExpression = multiplicativeExpression(expression);
try
{
callback.expressionOperator(expression, t);
@@ -3570,9 +3663,12 @@
catch (Exception e)
{
}
+ firstExpression = astFactory.createExpression( ( ( t.getType() == IToken.tPLUS ) ? IASTExpression.Kind.ADDITIVE_PLUS : IASTExpression.Kind.ADDITIVE_MINUS),
+ firstExpression, secondExpression, null, "", "", "", null );
+
break;
default :
- return;
+ return firstExpression;
}
}
}
@@ -3580,9 +3676,9 @@
* @param expression
* @throws Backtrack
*/
- protected void multiplicativeExpression(Object expression) throws Backtrack
+ protected IASTExpression multiplicativeExpression(Object expression) throws Backtrack
{
- pmExpression(expression);
+ IASTExpression firstExpression = pmExpression(expression);
for (;;)
{
switch (LT(1))
@@ -3591,7 +3687,7 @@
case IToken.tDIV :
case IToken.tMOD :
IToken t = consume();
- pmExpression(expression);
+ IASTExpression secondExpression = pmExpression(expression);
try
{
callback.expressionOperator(expression, t);
@@ -3599,9 +3695,30 @@
catch (Exception e)
{
}
- break;
+
+
+ IASTExpression.Kind kind = null;
+ switch( t.getType() )
+ {
+ case IToken.tSTAR :
+ kind = IASTExpression.Kind.MULTIPLICATIVE_MULTIPLY;
+ break;
+
+ case IToken.tDIV :
+ kind = IASTExpression.Kind.MULTIPLICATIVE_DIVIDE;
+ break;
+
+ case IToken.tMOD :
+ kind = IASTExpression.Kind.MULTIPLICATIVE_MODULUS;
+ break;
+
+ }
+
+ firstExpression = astFactory.createExpression( kind, firstExpression, secondExpression, null, "", "", "", null );
+ break;
+
default :
- return;
+ return firstExpression;
}
}
}
@@ -3609,9 +3726,9 @@
* @param expression
* @throws Backtrack
*/
- protected void pmExpression(Object expression) throws Backtrack
+ protected IASTExpression pmExpression(Object expression) throws Backtrack
{
- castExpression(expression);
+ IASTExpression firstExpression = castExpression(expression);
for (;;)
{
switch (LT(1))
@@ -3619,7 +3736,7 @@
case IToken.tDOTSTAR :
case IToken.tARROWSTAR :
IToken t = consume();
- castExpression(expression);
+ IASTExpression secondExpression = castExpression(expression);
try
{
callback.expressionOperator(expression, t);
@@ -3627,9 +3744,12 @@
catch (Exception e)
{
}
+ firstExpression = astFactory.createExpression( ( ( t.getType() == IToken.tDOTSTAR ) ? IASTExpression.Kind.PM_DOTSTAR : IASTExpression.Kind.PM_ARROWSTAR),
+ firstExpression, secondExpression, null, "", "", "", null );
+
break;
default :
- return;
+ return firstExpression;
}
}
}
@@ -3638,19 +3758,20 @@
* : unaryExpression
* | "(" typeId ")" castExpression
*/
- protected void castExpression(Object expression) throws Backtrack
+ protected IASTExpression castExpression(Object expression) throws Backtrack
{
// TO DO: we need proper symbol checkint to ensure type name
if (LT(1) == IToken.tLPAREN)
{
IToken mark = mark();
consume();
+ ITokenDuple duple = null;
// If this isn't a type name, then we shouldn't be here
try
{
if (LT(1) == IToken.t_const)
consume();
- typeId();
+ duple = typeId();
while (LT(1) == IToken.tSTAR)
{
consume(IToken.tSTAR);
@@ -3658,30 +3779,31 @@
consume();
}
consume(IToken.tRPAREN);
- castExpression(expression);
- return;
+ IASTExpression castExpression = castExpression(expression);
+ return astFactory.createExpression( IASTExpression.Kind.CASTEXPRESSION, castExpression, null, null, null, duple.toString(), "", null );
}
catch (Backtrack b)
{
backup(mark);
}
}
- unaryExpression(expression);
+ return unaryExpression(expression);
}
/**
* @throws Backtrack
*/
- protected void typeId() throws Backtrack
+ protected ITokenDuple typeId() throws Backtrack
{
+ IToken begin = LA(1);
+ IToken end = null;
+
try
{
- name();
- return;
+ ITokenDuple d = name();
+ return d;
}
catch (Backtrack b)
{
- IToken begin = LA(1);
- IToken end = null;
simpleMods : for (;;)
{
switch (LT(1))
@@ -3721,16 +3843,13 @@
catch (Exception e)
{
}
+ return new TokenDuple( begin, end );
}
- else if (LT(1) == IToken.t_typename)
- {
- consume(IToken.t_typename);
- name();
- }
- else if( LT(1) == IToken.t_struct || LT(1) == IToken.t_class || LT(1) == IToken.t_enum || LT(1) == IToken.t_union )
+ else if (LT(1) == IToken.t_typename || LT(1) == IToken.t_struct || LT(1) == IToken.t_class || LT(1) == IToken.t_enum || LT(1) == IToken.t_union )
{
consume();
- name();
+ ITokenDuple d = name();
+ return new TokenDuple( begin, d.getLastToken() );
}
else
throw backtrack;
@@ -3740,7 +3859,7 @@
* @param expression
* @throws Backtrack
*/
- protected void deleteExpression(Object expression) throws Backtrack
+ protected IASTExpression deleteExpression(Object expression) throws Backtrack
{
if (LT(1) == IToken.tCOLONCOLON)
{
@@ -3748,13 +3867,17 @@
consume();
}
consume(IToken.t_delete);
+ boolean vectored = false;
if (LT(1) == IToken.tLBRACKET)
{
// array delete
consume();
consume(IToken.tRBRACKET);
+ vectored = true;
}
- castExpression(expression);
+ IASTExpression castExpression = castExpression(expression);
+ return astFactory.createExpression( ( vectored ? IASTExpression.Kind.DELETE_VECTORCASTEXPRESSION : IASTExpression.Kind.DELETE_CASTEXPRESSION ),
+ castExpression, null, null, "", "", "", null );
}
/**
* Pazse a new-expression.
@@ -3772,7 +3895,7 @@
* directnewdeclarator [ constantexpression ]
* newinitializer: ( expressionlist? )
*/
- protected void newExpression(Object expression) throws Backtrack
+ protected IASTExpression newExpression(Object expression) throws Backtrack
{
if (LT(1) == IToken.tCOLONCOLON)
{
@@ -3780,10 +3903,13 @@
consume();
}
consume(IToken.t_new);
+
boolean typeIdInParen = false;
boolean placementParseFailure = true;
+
IToken beforeSecondParen = null;
IToken backtrackMarker = null;
+
if (LT(1) == IToken.tLPAREN)
{
consume(IToken.tLPAREN);
@@ -3842,7 +3968,7 @@
// Hmmm, so it wasn't typeId after all... Then it is
// CASE: new (typeid-looking-as-placement)
backup(backtrackMarker);
- return;
+ return null; // TODO fix this
}
}
}
@@ -3870,7 +3996,7 @@
// Worst-case scenario - this cannot be resolved w/o more semantic information.
// Luckily, we don't need to know what was that - we only know that
// new-expression ends here.
- return;
+ return null; // TODO fix this
}
}
catch (Backtrack e)
@@ -3904,222 +4030,351 @@
expression(expression);
consume(IToken.tRPAREN);
}
+ return null; //TODO fix this
+ }
+
+
+ protected IASTExpression unaryOperatorCastExpression( Object expression, IASTExpression.Kind kind, IToken consumed ) throws Backtrack
+ {
+ IASTExpression castExpression = castExpression(expression);
+ try
+ {
+ callback.expressionOperator(expression, consumed);
+ }
+ catch (Exception e)
+ {
+ }
+ return astFactory.createExpression( kind, castExpression, null, null, "", "", "", null );
}
/**
* @param expression
* @throws Backtrack
*/
- protected void unaryExpression(Object expression) throws Backtrack
+ protected IASTExpression unaryExpression(Object expression) throws Backtrack
{
switch (LT(1))
{
case IToken.tSTAR :
+ return unaryOperatorCastExpression( expression, IASTExpression.Kind.UNARY_STAR_CASTEXPRESSION, consume() );
case IToken.tAMPER :
+ return unaryOperatorCastExpression( expression, IASTExpression.Kind.UNARY_AMPSND_CASTEXPRESSION, consume() );
case IToken.tPLUS :
+ return unaryOperatorCastExpression( expression, IASTExpression.Kind.UNARY_PLUS_CASTEXPRESSION, consume() );
case IToken.tMINUS :
+ return unaryOperatorCastExpression( expression, IASTExpression.Kind.UNARY_MINUS_CASTEXPRESSION, consume() );
case IToken.tNOT :
+ return unaryOperatorCastExpression( expression, IASTExpression.Kind.UNARY_NOT_CASTEXPRESSION, consume() );
case IToken.tCOMPL :
+ return unaryOperatorCastExpression( expression, IASTExpression.Kind.UNARY_TILDE_CASTEXPRESSION, consume() );
case IToken.tINCR :
- case IToken.tDECR :
- IToken t = consume();
- castExpression(expression);
- try
- {
- callback.expressionOperator(expression, t);
- }
- catch (Exception e)
- {
- }
- return;
+ return unaryOperatorCastExpression( expression, IASTExpression.Kind.UNARY_INCREMENT, consume() );
+ case IToken.tDECR :
+ return unaryOperatorCastExpression( expression, IASTExpression.Kind.UNARY_DECREMENT, consume() );
+
case IToken.t_sizeof :
consume(IToken.t_sizeof);
IToken mark = LA(1);
+ ITokenDuple d = null;
+ IASTExpression unaryExpression = null;
if (LT(1) == IToken.tLPAREN)
{
try
{
consume(IToken.tLPAREN);
- typeId();
+ d = typeId();
consume(IToken.tRPAREN);
}
catch (Backtrack bt)
{
backup(mark);
- unaryExpression(expression);
+ unaryExpression = unaryExpression(expression);
}
}
else
{
- unaryExpression(expression);
+ unaryExpression = unaryExpression(expression);
}
- return;
+
+ if( d != null & unaryExpression == null )
+ return astFactory.createExpression( IASTExpression.Kind.UNARY_SIZEOF_TYPEID, null, null, null, "", d.toString(), "", null );
+ else if( unaryExpression != null && d == null )
+ return astFactory.createExpression( IASTExpression.Kind.UNARY_SIZEOF_UNARYEXPRESSION, unaryExpression, null, null, "", "", "", null );
+ else
+ throw backtrack;
+
case IToken.t_new :
- newExpression(expression);
- return;
+ return newExpression(expression);
case IToken.t_delete :
- deleteExpression(expression);
- return;
+ return deleteExpression(expression);
case IToken.tCOLONCOLON :
switch (LT(2))
{
case IToken.t_new :
- newExpression(expression);
- return;
+ return newExpression(expression);
case IToken.t_delete :
- deleteExpression(expression);
- return;
+ return deleteExpression(expression);
default :
- postfixExpression(expression);
- return;
+ return postfixExpression(expression);
}
default :
- postfixExpression(expression);
- return;
+ return postfixExpression(expression);
}
}
/**
* @param expression
* @throws Backtrack
*/
- protected void postfixExpression(Object expression) throws Backtrack
+ protected IASTExpression postfixExpression(Object expression) throws Backtrack
{
+ IASTExpression firstExpression = null;
+ boolean isTemplate = false;
switch (LT(1))
{
case IToken.t_typename :
- consume();
- // TO DO: this
+ consume(); //TODO: the rest of this
break;
- // simple-type-specifier ( assignment-expression , .. )
+ // simple-type-specifier ( assignment-expression , .. )
case IToken.t_char :
+ firstExpression = simpleTypeConstructorExpression(expression, IASTExpression.Kind.POSTFIX_SIMPLETYPE_CHAR );
+ break;
case IToken.t_wchar_t :
+ firstExpression = simpleTypeConstructorExpression(expression, IASTExpression.Kind.POSTFIX_SIMPLETYPE_WCHART );
+ break;
case IToken.t_bool :
+ firstExpression = simpleTypeConstructorExpression(expression, IASTExpression.Kind.POSTFIX_SIMPLETYPE_BOOL);
+ break;
case IToken.t_short :
+ firstExpression = simpleTypeConstructorExpression(expression, IASTExpression.Kind.POSTFIX_SIMPLETYPE_SHORT);
+ break;
case IToken.t_int :
+ firstExpression = simpleTypeConstructorExpression(expression, IASTExpression.Kind.POSTFIX_SIMPLETYPE_INT);
+ break;
case IToken.t_long :
+ firstExpression = simpleTypeConstructorExpression(expression, IASTExpression.Kind.POSTFIX_SIMPLETYPE_LONG);
+ break;
case IToken.t_signed :
+ firstExpression = simpleTypeConstructorExpression(expression, IASTExpression.Kind.POSTFIX_SIMPLETYPE_SIGNED);
+ break;
case IToken.t_unsigned :
+ firstExpression = simpleTypeConstructorExpression(expression, IASTExpression.Kind.POSTFIX_SIMPLETYPE_UNSIGNED);
+ break;
case IToken.t_float :
+ firstExpression = simpleTypeConstructorExpression(expression, IASTExpression.Kind.POSTFIX_SIMPLETYPE_FLOAT);
+ break;
case IToken.t_double :
- consume();
- consume(IToken.tLPAREN);
- while (true)
- {
- assignmentExpression(expression);
- if (LT(1) == IToken.tRPAREN)
- break;
- consume(IToken.tCOMMA);
- }
- consume(IToken.tRPAREN);
+ firstExpression = simpleTypeConstructorExpression(expression, IASTExpression.Kind.POSTFIX_SIMPLETYPE_DOUBLE);
break;
case IToken.t_dynamic_cast :
+ firstExpression = specialCastExpression(expression, IASTExpression.Kind.POSTFIX_DYNAMIC_CAST );
+ break;
case IToken.t_static_cast :
+ firstExpression = specialCastExpression(expression, IASTExpression.Kind.POSTFIX_STATIC_CAST );
+ break;
case IToken.t_reinterpret_cast :
+ firstExpression = specialCastExpression(expression, IASTExpression.Kind.POSTFIX_REINTERPRET_CAST );
+ break;
case IToken.t_const_cast :
- consume();
- consume(IToken.tLT);
- typeId();
- consume(IToken.tGT);
- consume(IToken.tLPAREN);
- expression(expression);
- consume(IToken.tRPAREN);
+ firstExpression = specialCastExpression(expression, IASTExpression.Kind.POSTFIX_CONST_CAST );
break;
case IToken.t_typeid :
consume();
consume(IToken.tLPAREN);
+ boolean isTypeId = true;
+ IASTExpression lhs = null;
+ ITokenDuple typeId = null;
try
{
- typeId();
+ typeId = typeId();
}
catch (Backtrack b)
{
- expression(expression);
+ isTypeId = false;
+ lhs = expression(expression);
}
consume(IToken.tRPAREN);
+
+ firstExpression = astFactory.createExpression( ( isTypeId ? IASTExpression.Kind.POSTFIX_TYPEID_TYPEID : IASTExpression.Kind.POSTFIX_TYPEID_EXPRESSION ),
+ lhs, null, null, "", ( isTypeId ? typeId.toString() : "" ), "", null );
+
break;
default :
- // TO DO: try simpleTypeSpecifier "(" expressionList ")"
- primaryExpression(expression);
- }
- for (;;)
- {
- switch (LT(1))
- {
- case IToken.tLBRACKET :
- // array access
- consume();
- expression(expression);
- consume(IToken.tRBRACKET);
- break;
- case IToken.tLPAREN :
- // function call
- consume();
- // Note: since expressionList and expression are the same...
- expression(expression);
- consume(IToken.tRPAREN);
- break;
- case IToken.tINCR :
- case IToken.tDECR :
- // post incr/decr
- consume();
- break;
- case IToken.tDOT :
- case IToken.tARROW :
- // member access
- consume();
- primaryExpression(expression);
- break;
- default :
- return;
- }
+ firstExpression = primaryExpression(expression);
}
+
+ IASTExpression secondExpression = null;
+
+ for( ; ; )
+ {
+ switch (LT(1))
+ {
+ case IToken.tLBRACKET :
+ // array access
+ consume();
+ secondExpression = expression(expression);
+ consume(IToken.tRBRACKET);
+ firstExpression = astFactory.createExpression( IASTExpression.Kind.POSTFIX_SUBSCRIPT, firstExpression, secondExpression, null, "", "", "", null );
+ break;
+ case IToken.tLPAREN :
+ // function call
+ consume();
+ secondExpression = expression(expression);
+ consume(IToken.tRPAREN);
+ firstExpression = astFactory.createExpression( IASTExpression.Kind.POSTFIX_FUNCTIONCALL, firstExpression, secondExpression, null, "", "", "", null );
+ break;
+ case IToken.tINCR :
+ consume();
+ firstExpression = astFactory.createExpression( IASTExpression.Kind.POSTFIX_INCREMENT, firstExpression, null, null, "", "", "", null );
+ break;
+ case IToken.tDECR :
+ consume();
+ firstExpression = astFactory.createExpression( IASTExpression.Kind.POSTFIX_DECREMENT, firstExpression, null, null, "", "", "", null );
+ break;
+ case IToken.tDOT :
+ // member access
+ consume( IToken.tDOT );
+
+ if( LT(1) == IToken.t_template )
+ {
+ consume( IToken.t_template );
+ isTemplate = true;
+ }
+ secondExpression = primaryExpression(expression);
+ firstExpression = astFactory.createExpression( ( isTemplate ? IASTExpression.Kind.POSTFIX_DOT_TEMPL_IDEXPRESS : IASTExpression.Kind.POSTFIX_DOT_IDEXPRESSION),
+ firstExpression, secondExpression, null, "", "", "", null );
+ break;
+ case IToken.tARROW :
+ // member access
+ consume( IToken.tARROW );
+ if( LT(1) == IToken.t_template )
+ {
+ consume( IToken.t_template );
+ isTemplate = true;
+ }
+ secondExpression = primaryExpression(expression);
+ firstExpression = astFactory.createExpression( ( isTemplate ? IASTExpression.Kind.POSTFIX_ARROW_TEMPL_IDEXP : IASTExpression.Kind.POSTFIX_ARROW_IDEXPRESSION),
+ firstExpression, secondExpression, null, "", "", "", null );
+ break;
+ default :
+ return firstExpression;
+ }
+ }
+
+
}
+ protected IASTExpression specialCastExpression(Object expression, IASTExpression.Kind kind)
+ throws EndOfFile, Backtrack {
+ consume();
+ consume(IToken.tLT);
+ ITokenDuple duple = typeId();
+ consume(IToken.tGT);
+ consume(IToken.tLPAREN);
+ IASTExpression lhs = expression(expression);
+ consume(IToken.tRPAREN);
+ return astFactory.createExpression( kind, lhs, null, null, "", "", "", null );
+ }
+
+ protected IASTExpression simpleTypeConstructorExpression(Object expression, Kind type) throws EndOfFile, Backtrack {
+ consume();
+ consume(IToken.tLPAREN);
+ IASTExpression inside = expression( expression );
+ // while (true)
+ // {
+ // assignmentExpression(expression);
+ // if (LT(1) == IToken.tRPAREN)
+ // break;
+ // consume(IToken.tCOMMA);
+ // }
+ consume(IToken.tRPAREN);
+ return astFactory.createExpression( type, inside, null, null, "", "", "", null );
+ }
/**
* @param expression
* @throws Backtrack
*/
- protected void primaryExpression(Object expression) throws Backtrack
+ protected IASTExpression primaryExpression(Object expression) throws Backtrack
{
- int type = LT(1);
- switch (type)
+ IToken t = null;
+ switch (LT(1))
{
// TO DO: we need more literals...
case IToken.tINTEGER :
+ t = consume();
+ try
+ {
+ callback.expressionTerminal(expression, t );
+ }
+ catch (Exception e)
+ {
+ }
+ return astFactory.createExpression( IASTExpression.Kind.PRIMARY_INTEGER_LITERAL, null, null, null, "", "", t.getImage(), null );
+
case IToken.tFLOATINGPT :
+ t = consume();
+ try
+ {
+ callback.expressionTerminal(expression, t );
+ }
+ catch (Exception e)
+ {
+ }
+ return astFactory.createExpression( IASTExpression.Kind.PRIMARY_FLOAT_LITERAL, null, null, null, "", "", t.getImage(), null );
+
case IToken.tSTRING :
case IToken.tLSTRING :
+ t = consume();
+ try
+ {
+ callback.expressionTerminal(expression, t );
+ }
+ catch (Exception e)
+ {
+ }
+ return astFactory.createExpression( IASTExpression.Kind.PRIMARY_INTEGER_LITERAL, null, null, null, "", "", t.getImage(), null );
+
case IToken.t_false :
case IToken.t_true :
+ t = consume();
+ try
+ {
+ callback.expressionTerminal(expression, t );
+ }
+ catch (Exception e)
+ {
+ }
+ return astFactory.createExpression( IASTExpression.Kind.PRIMARY_BOOLEAN_LITERAL, null, null, null, "", "", t.getImage(), null );
+
case IToken.tCHAR :
+ t = consume();
try
{
- callback.expressionTerminal(expression, consume());
- }
- catch (Exception e)
- {
- }
- return;
- case IToken.tIDENTIFIER :
- name();
- try
- {
- callback.expressionName(expression);
+ callback.expressionTerminal(expression, t );
}
catch (Exception e)
{
}
- return;
+ return astFactory.createExpression( IASTExpression.Kind.PRIMARY_CHAR_LITERAL, null, null, null, "", "", t.getImage(), null );
case IToken.t_this :
- consume();
- return;
+ consume( IToken.t_this );
+ return astFactory.createExpression( IASTExpression.Kind.PRIMARY_THIS, null, null, null, "", "", "", null );
case IToken.tLPAREN :
consume();
- expression(expression);
+ IASTExpression lhs = expression(expression);
consume(IToken.tRPAREN);
- return;
- default :
- // TO DO: idExpression which yeilds a variable
- //idExpression();
- return;
+ return astFactory.createExpression( IASTExpression.Kind.PRIMARY_BRACKETED_EXPRESSION, lhs, null, null, "", "", "", null );
+
+ case IToken.tIDENTIFIER :
+
+ ITokenDuple duple = name(); //TODO should be an ID Expression really
+ try
+ {
+ callback.expressionName(expression);
+ }
+ catch (Exception e)
+ {
+ }
+ return astFactory.createExpression( IASTExpression.Kind.ID_EXPRESSION, null, null, null, "", "", duple.toString(), null );
+ default :
+ return astFactory.createExpression( IASTExpression.Kind.PRIMARY_EMPTY, null, null, null, "", "", "", null );
}
}
/**
Index: parser/org/eclipse/cdt/internal/core/parser/Scanner.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java,v
retrieving revision 1.36
diff -u -r1.36 Scanner.java
--- parser/org/eclipse/cdt/internal/core/parser/Scanner.java 28 Jun 2003 19:48:12 -0000 1.36
+++ parser/org/eclipse/cdt/internal/core/parser/Scanner.java 28 Jun 2003 22:38:38 -0000
@@ -25,20 +25,22 @@
import java.util.StringTokenizer;
import java.util.Vector;
+import org.eclipse.cdt.core.parser.Backtrack;
import org.eclipse.cdt.core.parser.EndOfFile;
import org.eclipse.cdt.core.parser.IMacroDescriptor;
import org.eclipse.cdt.core.parser.IParser;
import org.eclipse.cdt.core.parser.IParserCallback;
import org.eclipse.cdt.core.parser.IProblemReporter;
import org.eclipse.cdt.core.parser.IScanner;
-import org.eclipse.cdt.core.parser.IScannerContext;
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
import org.eclipse.cdt.core.parser.IToken;
-import org.eclipse.cdt.core.parser.ITranslationResult;
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.ParserMode;
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.IASTInclusion;
import org.eclipse.cdt.core.parser.ast.IASTMacro;
@@ -1652,51 +1654,35 @@
}
else
{
- Object expressionEvalResult = null;
- try {
- ExpressionEvaluator evaluator = new ExpressionEvaluator();
- IScanner trial =
- ParserFactory.createScanner(
- new StringReader(expression + ";"),
+ IScanner trial =
+ ParserFactory.createScanner(
+ new StringReader(expression + ";"),
EXPRESSION,
definitions,
- null, ParserMode.COMPLETE_PARSE,
- problemReporter, translationResult );
- IParser parser = ParserFactory.createParser(trial, evaluator, ParserMode.COMPLETE_PARSE, problemReporter, translationResult );
- parser.expression(null);
-
- expressionEvalResult = evaluator.getResult();
-
- } catch (Exception e ) {
- throw new ScannerException(
- "Expression "
- + expression
- + " evaluates to an undefined value");
- } finally
+ null, ParserMode.QUICK_PARSE );
+ IParser parser = ParserFactory.createParser(trial, new NullSourceElementRequestor(), ParserMode.QUICK_PARSE );
+
+ try {
+ IASTExpression exp = parser.expression(null);
+ if( exp.evaluateExpression() == 0 )
+ return false;
+ } catch( Backtrack b )
{
- if (expressionEvalResult == null)
- throw new ScannerException(
- "Expression "
- + expression
- + " evaluates to an undefined value");
+ throwExpressionEvaluationError(expression);
}
-
-
- if (expressionEvalResult instanceof Integer ) {
- int i = ((Integer) expressionEvalResult).intValue();
- if (i == 0) {
- return false;
- }
- return true;
- } else if (
- expressionEvalResult instanceof Boolean ) {
- return ((Boolean) expressionEvalResult).booleanValue();
- } else {
- throw new ScannerException(
- "Unexpected expression type - we do not expect "
- + expressionEvalResult.getClass().getName());
+ catch (ExpressionEvaluationException e) {
+ throwExpressionEvaluationError(expression);
}
+ return true;
+
}
+ }
+
+ protected void throwExpressionEvaluationError(String expression) throws ScannerException {
+ throw new ScannerException(
+ "Expression "
+ + expression
+ + " evaluates to an undefined value");
}
protected void skipOverSinglelineComment() throws ScannerException {
Index: parser/org/eclipse/cdt/internal/core/parser/ScannerContext.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ScannerContext.java,v
retrieving revision 1.8
diff -u -r1.8 ScannerContext.java
--- parser/org/eclipse/cdt/internal/core/parser/ScannerContext.java 28 Jun 2003 19:48:12 -0000 1.8
+++ parser/org/eclipse/cdt/internal/core/parser/ScannerContext.java 28 Jun 2003 22:38:38 -0000
@@ -14,7 +14,6 @@
import java.io.Reader;
import java.util.Stack;
-import org.eclipse.cdt.core.parser.IScannerContext;
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
public class ScannerContext implements IScannerContext
Index: parser/org/eclipse/cdt/internal/core/parser/Token.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Token.java,v
retrieving revision 1.16
diff -u -r1.16 Token.java
--- parser/org/eclipse/cdt/internal/core/parser/Token.java 23 Jun 2003 18:05:24 -0000 1.16
+++ parser/org/eclipse/cdt/internal/core/parser/Token.java 28 Jun 2003 22:38:38 -0000
@@ -10,7 +10,6 @@
******************************************************************************/
package org.eclipse.cdt.internal.core.parser;
-import org.eclipse.cdt.core.parser.IScannerContext;
import org.eclipse.cdt.core.parser.IToken;
public class Token implements IToken {
Index: parser/org/eclipse/cdt/internal/core/parser/TokenDuple.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/TokenDuple.java,v
retrieving revision 1.3
diff -u -r1.3 TokenDuple.java
--- parser/org/eclipse/cdt/internal/core/parser/TokenDuple.java 13 Jun 2003 20:03:14 -0000 1.3
+++ parser/org/eclipse/cdt/internal/core/parser/TokenDuple.java 28 Jun 2003 22:38:38 -0000
@@ -12,13 +12,14 @@
import java.util.Iterator;
+import org.eclipse.cdt.core.parser.*;
import org.eclipse.cdt.core.parser.IToken;
/**
* @author jcamelon
*
*/
-public class TokenDuple {
+public class TokenDuple implements ITokenDuple {
public TokenDuple( IToken first, IToken last )
{
Index: parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java,v
retrieving revision 1.5
diff -u -r1.5 FullParseASTFactory.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java 27 Jun 2003 00:20:07 -0000 1.5
+++ parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java 28 Jun 2003 22:38:39 -0000
@@ -11,9 +11,11 @@
package org.eclipse.cdt.internal.core.parser.ast.full;
import java.util.Iterator;
+import java.util.List;
import org.eclipse.cdt.core.parser.Backtrack;
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.ClassKind;
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
@@ -21,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.IASTEnumerationSpecifier;
+import org.eclipse.cdt.core.parser.ast.IASTExpression;
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.IASTNamespaceDefinition;
import org.eclipse.cdt.core.parser.ast.IASTScope;
@@ -29,7 +33,8 @@
import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
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.pst.IContainerSymbol;
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
@@ -46,7 +51,7 @@
public IASTUsingDirective createUsingDirective(
IASTScope scope,
- TokenDuple duple)
+ ITokenDuple duple)
throws Backtrack {
Iterator iter = duple.iterator();
IToken t1 = (IToken)iter.next();
@@ -147,7 +152,7 @@
/* (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)
*/
- public IASTUsingDeclaration createUsingDeclaration(IASTScope scope, boolean isTypeName, TokenDuple name) {
+ public IASTUsingDeclaration createUsingDeclaration(IASTScope scope, boolean isTypeName, ITokenDuple name) {
// TODO Auto-generated method stub
return null;
}
@@ -194,5 +199,29 @@
// TODO Auto-generated method stub
}
+
+ /* (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;
+ }
}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTExpression.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTExpression.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTExpression.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTExpression.java 28 Jun 2003 22:38:39 -0000
@@ -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();
+ }
+
+
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTInitializerClause.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTInitializerClause.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTInitializerClause.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTInitializerClause.java 28 Jun 2003 22:38:39 -0000
@@ -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;
+ }
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTNewDescriptor.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTNewDescriptor.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTNewDescriptor.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTNewDescriptor.java 28 Jun 2003 22:38:39 -0000
@@ -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 {
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java,v
retrieving revision 1.5
diff -u -r1.5 QuickParseASTFactory.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java 27 Jun 2003 00:20:07 -0000 1.5
+++ parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java 28 Jun 2003 22:38:39 -0000
@@ -10,7 +10,10 @@
***********************************************************************/
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.ITokenDuple;
import org.eclipse.cdt.core.parser.ast.AccessVisibility;
import org.eclipse.cdt.core.parser.ast.ClassKind;
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
@@ -20,7 +23,9 @@
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
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.IASTInitializerClause;
import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
import org.eclipse.cdt.core.parser.ast.IASTScope;
@@ -28,7 +33,8 @@
import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
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;
/**
@@ -40,7 +46,7 @@
/* (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)
*/
- public IASTUsingDirective createUsingDirective(IASTScope scope, TokenDuple duple) throws Backtrack {
+ public IASTUsingDirective createUsingDirective(IASTScope scope, ITokenDuple duple) throws Backtrack {
return new ASTUsingDirective( scope, duple.toString() );
}
@@ -81,7 +87,7 @@
/* (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)
*/
- 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() );
}
@@ -126,5 +132,26 @@
{
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 );
+ }
}