Updated runtime tests with updated generation templates.
This commit is contained in:
parent
00083a77e8
commit
358bde8844
|
@ -4,7 +4,7 @@ IgnoredTests ::= [
|
|||
|
||||
TestFile(file) ::= <<
|
||||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.python2;
|
||||
package org.antlr.v4.test.runtime.cpp;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
@ -18,7 +18,7 @@ import org.antlr.v4.tool.Grammar;
|
|||
<endif>
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Test<file.name> extends BasePython2Test {
|
||||
public class Test<file.name> extends BaseCppTest {
|
||||
|
||||
<file.tests:{test | <test>}; separator="\n", wrap, anchor>
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ import org.stringtemplate.v4.gui.STViz;
|
|||
|
||||
public class TestGenerator {
|
||||
|
||||
public final static String[] targets = {"CSharp", "Java", "Python2", "Python3", "JavaScript/Node", "JavaScript/Safari", "JavaScript/Firefox", "JavaScript/Explorer", "JavaScript/Chrome"};
|
||||
public final static String[] targets = {"Cpp", "CSharp", "Java", "Python2", "Python3", "JavaScript/Node", "JavaScript/Safari", "JavaScript/Firefox", "JavaScript/Explorer", "JavaScript/Chrome"};
|
||||
|
||||
/** Execute from antlr4 root dir:
|
||||
* *
|
||||
|
|
|
@ -100,7 +100,7 @@ import static org.junit.Assert.assertFalse;
|
|||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public abstract class BasePythonTest {
|
||||
public abstract class BaseCppTest {
|
||||
// -J-Dorg.antlr.v4.test.BaseTest.level=FINE
|
||||
// private static final Logger LOGGER = Logger.getLogger(BaseTest.class.getName());
|
||||
public static final String newline = System.getProperty("line.separator");
|
||||
|
@ -320,7 +320,9 @@ public abstract class BasePythonTest {
|
|||
return null;
|
||||
}
|
||||
|
||||
protected abstract String getLanguage();
|
||||
protected String getLanguage() {
|
||||
return "Cpp";
|
||||
}
|
||||
|
||||
/** Return true if all is ok, no errors */
|
||||
protected ErrorQueue antlr(String fileName, String grammarFileName, String grammarStr, boolean defaultListener, String... extraOptions) {
|
||||
|
@ -566,14 +568,16 @@ public abstract class BasePythonTest {
|
|||
String propName = getPropertyPrefix() + "-python";
|
||||
String prop = System.getProperty(propName);
|
||||
if(prop==null || prop.length()==0)
|
||||
prop = locateTool(getPythonExecutable());
|
||||
prop = locateTool(getCompilerExecutable());
|
||||
File file = new File(prop);
|
||||
if(!file.exists())
|
||||
throw new RuntimeException("Missing system property:" + propName);
|
||||
return file.getAbsolutePath();
|
||||
}
|
||||
|
||||
protected abstract String getPythonExecutable();
|
||||
protected String getCompilerExecutable() {
|
||||
return "cpp";
|
||||
}
|
||||
|
||||
protected String locateRuntime() { return locateRuntime(getLanguage()); }
|
||||
|
||||
|
@ -849,17 +853,80 @@ public abstract class BasePythonTest {
|
|||
f.mkdirs();
|
||||
}
|
||||
|
||||
protected abstract void writeParserTestFile(String parserName,
|
||||
String lexerName,
|
||||
String listenerName,
|
||||
String visitorName,
|
||||
String parserStartRuleName,
|
||||
boolean debug,
|
||||
boolean setTrace);
|
||||
protected void writeParserTestFile(String parserName, String lexerName,
|
||||
String listenerName, String visitorName,
|
||||
String parserStartRuleName, boolean debug, boolean trace) {
|
||||
if(!parserStartRuleName.endsWith(")"))
|
||||
parserStartRuleName += "()";
|
||||
ST outputFileST = new ST(
|
||||
"import sys\n"
|
||||
+ "from antlr4 import *\n"
|
||||
+ "from <lexerName> import <lexerName>\n"
|
||||
+ "from <parserName> import <parserName>\n"
|
||||
+ "from <listenerName> import <listenerName>\n"
|
||||
+ "from <visitorName> import <visitorName>\n"
|
||||
+ "\n"
|
||||
+ "class TreeShapeListener(ParseTreeListener):\n"
|
||||
+ "\n"
|
||||
+ " def visitTerminal(self, node):\n"
|
||||
+ " pass\n"
|
||||
+ "\n"
|
||||
+ " def visitErrorNode(self, node):\n"
|
||||
+ " pass\n"
|
||||
+ "\n"
|
||||
+ " def exitEveryRule(self, ctx):\n"
|
||||
+ " pass\n"
|
||||
+ "\n"
|
||||
+ " def enterEveryRule(self, ctx):\n"
|
||||
+ " for child in ctx.getChildren():\n"
|
||||
+ " parent = child.parentCtx\n"
|
||||
+ " if not isinstance(parent, RuleNode) or parent.getRuleContext() != ctx:\n"
|
||||
+ " raise IllegalStateException(\"Invalid parse tree shape detected.\")\n"
|
||||
+ "\n"
|
||||
+ "def main(argv):\n"
|
||||
+ " input = FileStream(argv[1])\n"
|
||||
+ " lexer = <lexerName>(input)\n"
|
||||
+ " stream = CommonTokenStream(lexer)\n"
|
||||
+ "<createParser>"
|
||||
+ " parser.buildParseTrees = True\n"
|
||||
+ " tree = parser.<parserStartRuleName>\n"
|
||||
+ " ParseTreeWalker.DEFAULT.walk(TreeShapeListener(), tree)\n"
|
||||
+ "\n" + "if __name__ == '__main__':\n"
|
||||
+ " main(sys.argv)\n" + "\n");
|
||||
String stSource = " parser = <parserName>(stream)\n";
|
||||
if(debug)
|
||||
stSource += " parser.addErrorListener(DiagnosticErrorListener())\n";
|
||||
if(trace)
|
||||
stSource += " parser.setTrace(True)\n";
|
||||
ST createParserST = new ST(stSource);
|
||||
outputFileST.add("createParser", createParserST);
|
||||
outputFileST.add("parserName", parserName);
|
||||
outputFileST.add("lexerName", lexerName);
|
||||
outputFileST.add("listenerName", listenerName);
|
||||
outputFileST.add("visitorName", visitorName);
|
||||
outputFileST.add("parserStartRuleName", parserStartRuleName);
|
||||
writeFile(tmpdir, "Test.py", outputFileST.render());
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected abstract void writeLexerTestFile(String lexerName, boolean showDFA);
|
||||
protected void writeLexerTestFile(String lexerName, boolean showDFA) {
|
||||
ST outputFileST = new ST(
|
||||
"from __future__ import print_function\n"
|
||||
+ "import sys\n"
|
||||
+ "from antlr4 import *\n"
|
||||
+ "from <lexerName> import <lexerName>\n"
|
||||
+ "\n"
|
||||
+ "def main(argv):\n"
|
||||
+ " input = FileStream(argv[1])\n"
|
||||
+ " lexer = <lexerName>(input)\n"
|
||||
+ " stream = CommonTokenStream(lexer)\n"
|
||||
+ " stream.fill()\n"
|
||||
+ " [ print(str(t)) for t in stream.tokens ]\n"
|
||||
+ (showDFA ? " print(lexer._interp.decisionToDFA[Lexer.DEFAULT_MODE].toLexerString(), end='')\n"
|
||||
: "") + "\n" + "if __name__ == '__main__':\n"
|
||||
+ " main(sys.argv)\n" + "\n");
|
||||
outputFileST.add("lexerName", lexerName);
|
||||
writeFile(tmpdir, "Test.py", outputFileST.render());
|
||||
}
|
||||
|
||||
public void writeRecognizer(String parserName, String lexerName,
|
||||
String listenerName, String visitorName,
|
|
@ -1,94 +0,0 @@
|
|||
package org.antlr.v4.test.runtime.cpp;
|
||||
|
||||
import org.antlr.v4.test.runtime.cpp.BasePythonTest;
|
||||
import org.stringtemplate.v4.ST;
|
||||
|
||||
public abstract class BasePython2Test extends BasePythonTest {
|
||||
|
||||
@Override
|
||||
protected String getLanguage() {
|
||||
return "Python2";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPythonExecutable() {
|
||||
return "cpp.7";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeLexerTestFile(String lexerName, boolean showDFA) {
|
||||
ST outputFileST = new ST(
|
||||
"from __future__ import print_function\n"
|
||||
+ "import sys\n"
|
||||
+ "from antlr4 import *\n"
|
||||
+ "from <lexerName> import <lexerName>\n"
|
||||
+ "\n"
|
||||
+ "def main(argv):\n"
|
||||
+ " input = FileStream(argv[1])\n"
|
||||
+ " lexer = <lexerName>(input)\n"
|
||||
+ " stream = CommonTokenStream(lexer)\n"
|
||||
+ " stream.fill()\n"
|
||||
+ " [ print(str(t)) for t in stream.tokens ]\n"
|
||||
+ (showDFA ? " print(lexer._interp.decisionToDFA[Lexer.DEFAULT_MODE].toLexerString(), end='')\n"
|
||||
: "") + "\n" + "if __name__ == '__main__':\n"
|
||||
+ " main(sys.argv)\n" + "\n");
|
||||
outputFileST.add("lexerName", lexerName);
|
||||
writeFile(tmpdir, "Test.py", outputFileST.render());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeParserTestFile(String parserName, String lexerName,
|
||||
String listenerName, String visitorName,
|
||||
String parserStartRuleName, boolean debug, boolean trace) {
|
||||
if(!parserStartRuleName.endsWith(")"))
|
||||
parserStartRuleName += "()";
|
||||
ST outputFileST = new ST(
|
||||
"import sys\n"
|
||||
+ "from antlr4 import *\n"
|
||||
+ "from <lexerName> import <lexerName>\n"
|
||||
+ "from <parserName> import <parserName>\n"
|
||||
+ "from <listenerName> import <listenerName>\n"
|
||||
+ "from <visitorName> import <visitorName>\n"
|
||||
+ "\n"
|
||||
+ "class TreeShapeListener(ParseTreeListener):\n"
|
||||
+ "\n"
|
||||
+ " def visitTerminal(self, node):\n"
|
||||
+ " pass\n"
|
||||
+ "\n"
|
||||
+ " def visitErrorNode(self, node):\n"
|
||||
+ " pass\n"
|
||||
+ "\n"
|
||||
+ " def exitEveryRule(self, ctx):\n"
|
||||
+ " pass\n"
|
||||
+ "\n"
|
||||
+ " def enterEveryRule(self, ctx):\n"
|
||||
+ " for child in ctx.getChildren():\n"
|
||||
+ " parent = child.parentCtx\n"
|
||||
+ " if not isinstance(parent, RuleNode) or parent.getRuleContext() != ctx:\n"
|
||||
+ " raise IllegalStateException(\"Invalid parse tree shape detected.\")\n"
|
||||
+ "\n"
|
||||
+ "def main(argv):\n"
|
||||
+ " input = FileStream(argv[1])\n"
|
||||
+ " lexer = <lexerName>(input)\n"
|
||||
+ " stream = CommonTokenStream(lexer)\n"
|
||||
+ "<createParser>"
|
||||
+ " parser.buildParseTrees = True\n"
|
||||
+ " tree = parser.<parserStartRuleName>\n"
|
||||
+ " ParseTreeWalker.DEFAULT.walk(TreeShapeListener(), tree)\n"
|
||||
+ "\n" + "if __name__ == '__main__':\n"
|
||||
+ " main(sys.argv)\n" + "\n");
|
||||
String stSource = " parser = <parserName>(stream)\n";
|
||||
if(debug)
|
||||
stSource += " parser.addErrorListener(DiagnosticErrorListener())\n";
|
||||
if(trace)
|
||||
stSource += " parser.setTrace(True)\n";
|
||||
ST createParserST = new ST(stSource);
|
||||
outputFileST.add("createParser", createParserST);
|
||||
outputFileST.add("parserName", parserName);
|
||||
outputFileST.add("lexerName", lexerName);
|
||||
outputFileST.add("listenerName", listenerName);
|
||||
outputFileST.add("visitorName", visitorName);
|
||||
outputFileST.add("parserStartRuleName", parserStartRuleName);
|
||||
writeFile(tmpdir, "Test.py", outputFileST.render());
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ import org.junit.Test;
|
|||
import static org.junit.Assert.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestCompositeLexers extends BasePython2Test {
|
||||
public class TestCompositeLexers extends BaseCppTest {
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
|
@ -67,4 +67,4 @@ public class TestCompositeLexers extends BasePython2Test {
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ import org.antlr.v4.test.runtime.java.ErrorQueue;
|
|||
import org.antlr.v4.tool.Grammar;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestCompositeParsers extends BasePython2Test {
|
||||
public class TestCompositeParsers extends BaseCppTest {
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
|
@ -75,18 +75,18 @@ public class TestCompositeParsers extends BasePython2Test {
|
|||
public void testDelegatesSeeSameTokenType() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { C, B, A } // reverse order\n" +
|
||||
"y : A {print(\"T.y\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"tokens { A, B, C }\n" +
|
||||
"x : A {print(\"S.x\")};";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { C, B, A } // reverse order\n" +
|
||||
"y : A {print(\"T.y\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(598);
|
||||
grammarBuilder.append("// The lexer will create rules to match letters a, b, c.\n");
|
||||
grammarBuilder.append("// The associated token types A, B, C must have the same value\n");
|
||||
|
@ -245,17 +245,17 @@ public class TestCompositeParsers extends BasePython2Test {
|
|||
public void testDelegatorInvokesFirstVersionOfDelegateRule() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"a : B {print(\"T.a\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : b {print(\"S.a\")};\n" +
|
||||
"b : B;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"a : B {print(\"T.a\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(106);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S,T;\n");
|
||||
|
@ -305,18 +305,18 @@ public class TestCompositeParsers extends BasePython2Test {
|
|||
public void testDelegatorRuleOverridesDelegates() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { A }\n" +
|
||||
"b : 'b' {print(\"T.b\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : b {print(\"S.a\")};\n" +
|
||||
"b : 'b' ;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { A }\n" +
|
||||
"b : 'b' {print(\"T.b\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(81);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S, T;\n");
|
||||
|
@ -485,4 +485,4 @@ public class TestCompositeParsers extends BasePython2Test {
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ import org.junit.Test;
|
|||
import static org.junit.Assert.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestFullContextParsing extends BasePython2Test {
|
||||
public class TestFullContextParsing extends BaseCppTest {
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
|
@ -503,4 +503,4 @@ public class TestFullContextParsing extends BasePython2Test {
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ import org.junit.Test;
|
|||
import static org.junit.Assert.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestLeftRecursion extends BasePython2Test {
|
||||
public class TestLeftRecursion extends BaseCppTest {
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
|
@ -3401,4 +3401,4 @@ public class TestLeftRecursion extends BasePython2Test {
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ import org.junit.Test;
|
|||
import static org.junit.Assert.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestLexerErrors extends BasePython2Test {
|
||||
public class TestLexerErrors extends BaseCppTest {
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
|
@ -255,4 +255,4 @@ public class TestLexerErrors extends BasePython2Test {
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ import org.junit.Test;
|
|||
import static org.junit.Assert.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestLexerExec extends BasePython2Test {
|
||||
public class TestLexerExec extends BaseCppTest {
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
|
@ -4993,4 +4993,4 @@ public class TestLexerExec extends BasePython2Test {
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ import org.junit.Test;
|
|||
import static org.junit.Assert.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestListeners extends BasePython2Test {
|
||||
public class TestListeners extends BaseCppTest {
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
|
@ -388,4 +388,4 @@ public class TestListeners extends BasePython2Test {
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ import org.junit.Test;
|
|||
import static org.junit.Assert.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestParseTrees extends BasePython2Test {
|
||||
public class TestParseTrees extends BaseCppTest {
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
|
@ -297,4 +297,4 @@ public class TestParseTrees extends BasePython2Test {
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ import org.junit.Test;
|
|||
import static org.junit.Assert.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestParserErrors extends BasePython2Test {
|
||||
public class TestParserErrors extends BaseCppTest {
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
|
@ -715,4 +715,4 @@ public class TestParserErrors extends BasePython2Test {
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ import org.junit.Test;
|
|||
import static org.junit.Assert.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestParserExec extends BasePython2Test {
|
||||
public class TestParserExec extends BaseCppTest {
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
|
@ -787,4 +787,4 @@ public class TestParserExec extends BasePython2Test {
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ import org.junit.Test;
|
|||
import static org.junit.Assert.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestPerformance extends BasePython2Test {
|
||||
public class TestPerformance extends BaseCppTest {
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
|
@ -214,4 +214,4 @@ public class TestPerformance extends BasePython2Test {
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ import org.junit.Test;
|
|||
import static org.junit.Assert.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestSemPredEvalLexer extends BasePython2Test {
|
||||
public class TestSemPredEvalLexer extends BaseCppTest {
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
|
@ -214,4 +214,4 @@ public class TestSemPredEvalLexer extends BasePython2Test {
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ import org.junit.Test;
|
|||
import static org.junit.Assert.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestSemPredEvalParser extends BasePython2Test {
|
||||
public class TestSemPredEvalParser extends BaseCppTest {
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
|
@ -758,4 +758,4 @@ public class TestSemPredEvalParser extends BasePython2Test {
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ import org.junit.Test;
|
|||
import static org.junit.Assert.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestSets extends BasePython2Test {
|
||||
public class TestSets extends BaseCppTest {
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
|
@ -473,4 +473,4 @@ public class TestSets extends BasePython2Test {
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -58,18 +58,18 @@ public class TestCompositeParsers extends BaseTest {
|
|||
@Test
|
||||
public void testDelegatesSeeSameTokenType() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { C, B, A } // reverse order\n" +
|
||||
"y : A {Console.WriteLine(\"T.y\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"tokens { A, B, C }\n" +
|
||||
"x : A {Console.WriteLine(\"S.x\");};";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { C, B, A } // reverse order\n" +
|
||||
"y : A {Console.WriteLine(\"T.y\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(598);
|
||||
grammarBuilder.append("// The lexer will create rules to match letters a, b, c.\n");
|
||||
grammarBuilder.append("// The associated token types A, B, C must have the same value\n");
|
||||
|
@ -191,17 +191,17 @@ public class TestCompositeParsers extends BaseTest {
|
|||
@Test
|
||||
public void testDelegatorInvokesFirstVersionOfDelegateRule() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"a : B {Console.WriteLine(\"T.a\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : b {Console.WriteLine(\"S.a\");};\n" +
|
||||
"b : B;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"a : B {Console.WriteLine(\"T.a\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(106);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S,T;\n");
|
||||
|
@ -241,18 +241,18 @@ public class TestCompositeParsers extends BaseTest {
|
|||
@Test
|
||||
public void testDelegatorRuleOverridesDelegates() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { A }\n" +
|
||||
"b : 'b' {Console.WriteLine(\"T.b\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : b {Console.WriteLine(\"S.a\");};\n" +
|
||||
"b : 'b' ;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { A }\n" +
|
||||
"b : 'b' {Console.WriteLine(\"T.b\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(94);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S, T;\n");
|
||||
|
|
|
@ -72,18 +72,18 @@ public class TestCompositeParsers extends BaseTest {
|
|||
public void testDelegatesSeeSameTokenType() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { C, B, A } // reverse order\n" +
|
||||
"y : A {System.out.println(\"T.y\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"tokens { A, B, C }\n" +
|
||||
"x : A {System.out.println(\"S.x\");};";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { C, B, A } // reverse order\n" +
|
||||
"y : A {System.out.println(\"T.y\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(598);
|
||||
grammarBuilder.append("// The lexer will create rules to match letters a, b, c.\n");
|
||||
grammarBuilder.append("// The associated token types A, B, C must have the same value\n");
|
||||
|
@ -236,17 +236,17 @@ public class TestCompositeParsers extends BaseTest {
|
|||
public void testDelegatorInvokesFirstVersionOfDelegateRule() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"a : B {System.out.println(\"T.a\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : b {System.out.println(\"S.a\");};\n" +
|
||||
"b : B;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"a : B {System.out.println(\"T.a\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(106);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S,T;\n");
|
||||
|
@ -294,18 +294,18 @@ public class TestCompositeParsers extends BaseTest {
|
|||
public void testDelegatorRuleOverridesDelegates() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { A }\n" +
|
||||
"b : 'b' {System.out.println(\"T.b\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : b {System.out.println(\"S.a\");};\n" +
|
||||
"b : 'b' ;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { A }\n" +
|
||||
"b : 'b' {System.out.println(\"T.b\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(95);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S, T;\n");
|
||||
|
|
|
@ -64,18 +64,18 @@ public class TestCompositeParsers extends BaseTest {
|
|||
@Test
|
||||
public void testDelegatesSeeSameTokenType() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { C, B, A } // reverse order\n" +
|
||||
"y : A {console.log(\"T.y\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"tokens { A, B, C }\n" +
|
||||
"x : A {console.log(\"S.x\");};";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { C, B, A } // reverse order\n" +
|
||||
"y : A {console.log(\"T.y\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(598);
|
||||
grammarBuilder.append("// The lexer will create rules to match letters a, b, c.\n");
|
||||
grammarBuilder.append("// The associated token types A, B, C must have the same value\n");
|
||||
|
@ -207,17 +207,17 @@ public class TestCompositeParsers extends BaseTest {
|
|||
@Test
|
||||
public void testDelegatorInvokesFirstVersionOfDelegateRule() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"a : B {console.log(\"T.a\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : b {console.log(\"S.a\");};\n" +
|
||||
"b : B;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"a : B {console.log(\"T.a\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(106);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S,T;\n");
|
||||
|
@ -261,18 +261,18 @@ public class TestCompositeParsers extends BaseTest {
|
|||
@Test
|
||||
public void testDelegatorRuleOverridesDelegates() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { A }\n" +
|
||||
"b : 'b' {console.log(\"T.b\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : b {console.log(\"S.a\");};\n" +
|
||||
"b : 'b' ;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { A }\n" +
|
||||
"b : 'b' {console.log(\"T.b\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(88);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S, T;\n");
|
||||
|
|
|
@ -75,18 +75,18 @@ public class TestCompositeParsers extends BasePython2Test {
|
|||
public void testDelegatesSeeSameTokenType() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { C, B, A } // reverse order\n" +
|
||||
"y : A {print(\"T.y\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"tokens { A, B, C }\n" +
|
||||
"x : A {print(\"S.x\")};";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { C, B, A } // reverse order\n" +
|
||||
"y : A {print(\"T.y\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(598);
|
||||
grammarBuilder.append("// The lexer will create rules to match letters a, b, c.\n");
|
||||
grammarBuilder.append("// The associated token types A, B, C must have the same value\n");
|
||||
|
@ -245,17 +245,17 @@ public class TestCompositeParsers extends BasePython2Test {
|
|||
public void testDelegatorInvokesFirstVersionOfDelegateRule() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"a : B {print(\"T.a\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : b {print(\"S.a\")};\n" +
|
||||
"b : B;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"a : B {print(\"T.a\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(106);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S,T;\n");
|
||||
|
@ -305,18 +305,18 @@ public class TestCompositeParsers extends BasePython2Test {
|
|||
public void testDelegatorRuleOverridesDelegates() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { A }\n" +
|
||||
"b : 'b' {print(\"T.b\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : b {print(\"S.a\")};\n" +
|
||||
"b : 'b' ;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { A }\n" +
|
||||
"b : 'b' {print(\"T.b\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(81);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S, T;\n");
|
||||
|
|
|
@ -75,18 +75,18 @@ public class TestCompositeParsers extends BasePython3Test {
|
|||
public void testDelegatesSeeSameTokenType() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { C, B, A } // reverse order\n" +
|
||||
"y : A {print(\"T.y\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"tokens { A, B, C }\n" +
|
||||
"x : A {print(\"S.x\")};";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { C, B, A } // reverse order\n" +
|
||||
"y : A {print(\"T.y\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(598);
|
||||
grammarBuilder.append("// The lexer will create rules to match letters a, b, c.\n");
|
||||
grammarBuilder.append("// The associated token types A, B, C must have the same value\n");
|
||||
|
@ -245,17 +245,17 @@ public class TestCompositeParsers extends BasePython3Test {
|
|||
public void testDelegatorInvokesFirstVersionOfDelegateRule() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"a : B {print(\"T.a\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : b {print(\"S.a\")};\n" +
|
||||
"b : B;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"a : B {print(\"T.a\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(106);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S,T;\n");
|
||||
|
@ -305,18 +305,18 @@ public class TestCompositeParsers extends BasePython3Test {
|
|||
public void testDelegatorRuleOverridesDelegates() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { A }\n" +
|
||||
"b : 'b' {print(\"T.b\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : b {print(\"S.a\")};\n" +
|
||||
"b : 'b' ;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { A }\n" +
|
||||
"b : 'b' {print(\"T.b\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(81);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S, T;\n");
|
||||
|
|
Loading…
Reference in New Issue