summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjkohnlein2008-03-07 04:40:03 (EST)
committer jkohnlein2008-03-07 04:40:03 (EST)
commita15531c23e89a1e4447dc582b9c6fd002f6f0d78 (patch)
treee1196b2a40341ff71030c0bbc33a2f8e80cc4650
parent354e78f465d4e99ab519bda799c813e4c60c9a9b (diff)
downloadorg.eclipse.xpand-a15531c23e89a1e4447dc582b9c6fd002f6f0d78.zip
org.eclipse.xpand-a15531c23e89a1e4447dc582b9c6fd002f6f0d78.tar.gz
org.eclipse.xpand-a15531c23e89a1e4447dc582b9c6fd002f6f0d78.tar.bz2
Added prefixes to rules
-rw-r--r--tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/AbstractXpand3NodeParserTest.java9
-rw-r--r--tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/StatementParserTest.java2
-rw-r--r--tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/Xpand3MigratedNodeParserTest.java2
-rw-r--r--tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/Xpand3NodeParserTest.java4
-rw-r--r--tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/node2ast/Node2AstTest.java4
-rw-r--r--tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/node2ast/ParseStuff.java2
6 files changed, 16 insertions, 7 deletions
diff --git a/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/AbstractXpand3NodeParserTest.java b/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/AbstractXpand3NodeParserTest.java
index 3c19b26..c317aa7 100644
--- a/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/AbstractXpand3NodeParserTest.java
+++ b/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/AbstractXpand3NodeParserTest.java
@@ -25,10 +25,17 @@ public abstract class AbstractXpand3NodeParserTest extends TestCase {
super(name);
}
+ protected String getNodeClassName(String ruleName) {
+ return ruleName.substring(0, 1).toUpperCase() + ruleName.substring(1)
+ + "NodeImpl";
+ }
+
protected CompositeNode checkIsRule(Node node, String ruleName,
int numChildren) {
assertTrue(node instanceof CompositeNode);
- assertEquals(ruleName, ((CompositeNode) node).getRule());
+ String className = node.getClass().getName();
+ assertEquals(getNodeClassName(ruleName), className.substring(className
+ .lastIndexOf('.') + 1));
assertEquals(numChildren, ((CompositeNode) node).getChildren().size());
return (CompositeNode) node;
}
diff --git a/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/StatementParserTest.java b/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/StatementParserTest.java
index 3fb15da..b5c753f 100644
--- a/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/StatementParserTest.java
+++ b/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/StatementParserTest.java
@@ -28,7 +28,7 @@ public class StatementParserTest extends AbstractXpand3NodeParserTest {
CommonTokenStream tokenStream = new CommonTokenStream(lexer);
Xpand3NodeParser xpand3NodeParser = new Xpand3NodeParser(tokenStream);
- Node rootNode = xpand3NodeParser.file();
+ Node rootNode = xpand3NodeParser.r_file();
if (rootNode == null) {
System.out.println("Nothing parsed.");
} else {
diff --git a/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/Xpand3MigratedNodeParserTest.java b/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/Xpand3MigratedNodeParserTest.java
index 5f1e092..73400e9 100644
--- a/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/Xpand3MigratedNodeParserTest.java
+++ b/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/Xpand3MigratedNodeParserTest.java
@@ -192,7 +192,7 @@ public class Xpand3MigratedNodeParserTest extends AbstractXpand3NodeParserTest {
Xpand3NodeLexer lexer = new Xpand3NodeLexer(stream);
CommonTokenStream tokenStream = new CommonTokenStream(lexer);
Xpand3NodeParser xpand3NodeParser = new Xpand3NodeParser(tokenStream);
- Node rootNode = xpand3NodeParser.test_expression();
+ Node rootNode = xpand3NodeParser.r_test_expression();
System.out.println(NodeUtil.toString(rootNode));
return (CompositeNode) rootNode;
}
diff --git a/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/Xpand3NodeParserTest.java b/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/Xpand3NodeParserTest.java
index 8fe498d..31298e4 100644
--- a/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/Xpand3NodeParserTest.java
+++ b/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/Xpand3NodeParserTest.java
@@ -13,7 +13,7 @@ public class Xpand3NodeParserTest extends TestCase {
private Node parse(String s) throws Exception {
Xpand3NodeParser parser = createParser(s);
- Node rootNode = parser.file();
+ Node rootNode = parser.r_file();
return rootNode;
}
@@ -48,7 +48,7 @@ public class Xpand3NodeParserTest extends TestCase {
}
Xpand3NodeParser parser = createParser(s);
long n = System.currentTimeMillis();
- parser.expression();
+ parser.r_expression();
long after = System.currentTimeMillis();
System.out.println("Time : " + (after - n) / 1000.
+ " Expressionlength was : " + s.length());
diff --git a/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/node2ast/Node2AstTest.java b/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/node2ast/Node2AstTest.java
index 19d576e..87b68e9 100644
--- a/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/node2ast/Node2AstTest.java
+++ b/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/node2ast/Node2AstTest.java
@@ -7,6 +7,7 @@ import org.antlr.runtime.CommonTokenStream;
import org.eclipse.tmf.common.node.Node;
import org.eclipse.tmf.common.node.NodeUtil;
import org.eclipse.xpand3.SyntaxElement;
+import org.eclipse.xpand3.declaration.Extension;
import org.eclipse.xpand3.parser.Xpand3NodeLexer;
import org.eclipse.xpand3.parser.Xpand3NodeParser;
@@ -19,7 +20,7 @@ public class Node2AstTest extends TestCase {
CommonTokenStream tokenStream = new CommonTokenStream(lexer);
Xpand3NodeParser xpand3NodeParser = new Xpand3NodeParser(tokenStream);
- Node rootNode = xpand3NodeParser.file();
+ Node rootNode = xpand3NodeParser.r_file();
if (rootNode == null) {
System.out.println("Nothing parsed.");
} else {
@@ -32,5 +33,6 @@ public class Node2AstTest extends TestCase {
public void testExpression() throws Exception {
String expr = "foo(Object this, Object that):\n\tthis.toString()==that.toString();";
SyntaxElement ast = parseAndTransform(expr);
+ assertTrue(ast instanceof Extension);
}
}
diff --git a/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/node2ast/ParseStuff.java b/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/node2ast/ParseStuff.java
index 3aa9ad5..719a49f 100644
--- a/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/node2ast/ParseStuff.java
+++ b/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/node2ast/ParseStuff.java
@@ -42,7 +42,7 @@ public class ParseStuff {
CommonTokenStream tokenStream = new CommonTokenStream(lexer);
Xpand3NodeParser xpand3NodeParser = new Xpand3NodeParser(tokenStream);
- Node rootNode = xpand3NodeParser.file();
+ Node rootNode = xpand3NodeParser.r_file();
// if (rootNode == null) {
// System.out.println("Nothing parsed.");
// } else {