Skip to content

Commit 6339ee6

Browse files
committed
Merge pull request #6 from parrt/master
tweaks to get tests running in latest 4.4 dev
2 parents 530d1b9 + 072f578 commit 6339ee6

File tree

4 files changed

+33
-33
lines changed

4 files changed

+33
-33
lines changed

tool/src/org/antlr/v4/codegen/AbstractPythonTarget.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ public int getSerializedATNSegmentLimit() {
151151
// set to something stupid to avoid segmentation
152152
return 2 ^ 31;
153153
}
154-
154+
155155
public abstract Set<String> getBadWords();
156-
156+
157157
@Override
158158
protected boolean visibleGrammarSymbolCausesIssueInGeneratedCode(GrammarAST idNode) {
159159
return getBadWords().contains(idNode.getText());
@@ -188,6 +188,6 @@ public boolean wantsBaseVisitor() {
188188
public boolean supportsOverloadedMethods() {
189189
return false;
190190
}
191-
192-
191+
192+
193193
}

tool/src/org/antlr/v4/codegen/Python2Target.java

+16-16
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,23 @@
4141
public class Python2Target extends AbstractPythonTarget {
4242

4343
protected static final String[] python2Keywords = {
44-
"abs", "all", "any", "apply", "as",
45-
"bin", "bool", "buffer", "bytearray",
46-
"callable", "chr", "classmethod", "coerce", "compile", "complex",
47-
"delattr", "dict", "dir", "divmod",
44+
"abs", "all", "any", "apply", "as",
45+
"bin", "bool", "buffer", "bytearray",
46+
"callable", "chr", "classmethod", "coerce", "compile", "complex",
47+
"delattr", "dict", "dir", "divmod",
4848
"enumerate", "eval", "execfile",
49-
"file", "filter", "float", "format", "frozenset",
50-
"getattr", "globals",
51-
"hasattr", "hash", "help", "hex",
52-
"id", "input", "int", "intern", "isinstance", "issubclass", "iter",
53-
"len", "list", "locals",
54-
"map", "max", "min", "next",
55-
"memoryview",
56-
"object", "oct", "open", "ord",
57-
"pow", "print", "property",
58-
"range", "raw_input", "reduce", "reload", "repr", "reversed", "round",
49+
"file", "filter", "float", "format", "frozenset",
50+
"getattr", "globals",
51+
"hasattr", "hash", "help", "hex",
52+
"id", "input", "int", "intern", "isinstance", "issubclass", "iter",
53+
"len", "list", "locals",
54+
"map", "max", "min", "next",
55+
"memoryview",
56+
"object", "oct", "open", "ord",
57+
"pow", "print", "property",
58+
"range", "raw_input", "reduce", "reload", "repr", "reversed", "round",
5959
"set", "setattr", "slice", "sorted", "staticmethod", "str", "sum", "super",
60-
"tuple", "type",
60+
"tuple", "type",
6161
"unichr", "unicode",
6262
"vars",
6363
"with",
@@ -74,7 +74,7 @@ public Python2Target(CodeGenerator gen) {
7474
super(gen, "Python2");
7575
}
7676

77-
77+
7878
@Override
7979
public String getVersion() {
8080
return "4.4.0";

tool/test/org/antlr/v4/py2/test/TestLeftRecursion.java

+12-12
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ public class TestLeftRecursion extends BasePython2Test {
5454
String expecting = "(s (a x))\n";
5555
assertEquals(expecting, found);
5656

57-
found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor",
57+
found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor",
5858
"s", "x y", debug);
5959
expecting = "(s (a (a x) y))\n";
6060
assertEquals(expecting, found);
6161

62-
found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor",
62+
found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor",
6363
"s", "x y z", debug);
6464
expecting = "(s (a (a (a x) y) z))\n";
6565
assertEquals(expecting, found);
@@ -78,17 +78,17 @@ public class TestLeftRecursion extends BasePython2Test {
7878
" ;\n" +
7979
"ID : 'a'..'z'+ ;\n" +
8080
"WS : (' '|'\\n') -> skip ;\n";
81-
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor",
81+
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor",
8282
"a", "x", debug);
8383
String expecting = "(a x)\n";
8484
assertEquals(expecting, found);
8585

86-
found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor",
86+
found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor",
8787
"a", "x y", debug);
8888
expecting = "(a (a x) y)\n";
8989
assertEquals(expecting, found);
9090

91-
found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor",
91+
found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor",
9292
"a", "x y z", debug);
9393
expecting = "(a (a (a x) y) z)\n";
9494
assertEquals(expecting, found);
@@ -103,7 +103,7 @@ public class TestLeftRecursion extends BasePython2Test {
103103
" ;\n" +
104104
"ID : 'a'..'z'+ ;\n" +
105105
"WS : (' '|'\\n') -> skip ;\n";
106-
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor",
106+
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor",
107107
"s", "x y z", debug);
108108
String expecting = "(s (a (a (a x) y) z))\n";
109109
assertEquals(expecting, found);
@@ -226,7 +226,7 @@ public class TestLeftRecursion extends BasePython2Test {
226226
"INT : '0'..'9'+ ;\n" +
227227
"WS : (' '|'\\n') -> skip ;\n";
228228
String[] tests = {
229-
"a|b&c", "(s (e (e a) | (e (e b) & (e c))) <EOF>)",
229+
"a|b&c", "(s (e (e a) | (e (e b) & (e c))) <EOF>)",
230230
"(a|b)&c", "(s (e (e ( (e (e a) | (e b)) )) & (e c)) <EOF>)",
231231
"a > b", "(s (e (e a) > (e b)) <EOF>)",
232232
"a >> b", "(s (e (e a) >> (e b)) <EOF>)",
@@ -237,7 +237,7 @@ public class TestLeftRecursion extends BasePython2Test {
237237
"(T)t.f()", "(s (e (e ( (type T) ) (e (e t) . f)) ( )) <EOF>)",
238238
"a.f(x)==T.c", "(s (e (e (e (e a) . f) ( (expressionList (e x)) )) == (e (e T) . c)) <EOF>)",
239239
"a.f().g(x,1)", "(s (e (e (e (e (e a) . f) ( )) . g) ( (expressionList (e x) , (e 1)) )) <EOF>)",
240-
"new T[((n-1) * x) + 1]", "(s (e new (type T) [ (e (e ( (e (e ( (e (e n) - (e 1)) )) * (e x)) )) + (e 1)) ]) <EOF>)",
240+
"new T[((n-1) * x) + 1]", "(s (e new (type T) [ (e (e ( (e (e ( (e (e n) - (e 1)) )) * (e x)) )) + (e 1)) ]) <EOF>)",
241241
};
242242
runTests(grammar, tests, "s");
243243
}
@@ -305,9 +305,9 @@ public class TestLeftRecursion extends BasePython2Test {
305305
"INT : '0'..'9'+ ;\n" +
306306
"WS : (' '|'\\n') -> skip ;\n";
307307
String[] tests = {
308-
"4", "(s (e 4))",
308+
"4", "(s (e 4))",
309309
"1*2/3", "(s (e (e (e 1) * (e 2)) / (e 3)))",
310-
"(1/2)*3", "(s (e (e ( (e (e 1) / (e 2)) )) * (e 3)))",
310+
"(1/2)*3", "(s (e (e ( (e (e 1) / (e 2)) )) * (e 3)))",
311311
};
312312
runTests(grammar, tests, "s");
313313
}
@@ -444,7 +444,7 @@ public void testAmbigLR() throws Exception {
444444
"ID : 'a'..'z'+ ;\n" +
445445
"WS : (' '|'\\n') -> skip ;\n";
446446
String expected =
447-
"error(" + ErrorType.NO_NON_LR_ALTS.code + "): T.g4:3:0: left recursive rule 'a' must contain an alternative which is not left recursive\n";
447+
"error(" + ErrorType.NO_NON_LR_ALTS.code + "): T.g4:3:0: left recursive rule a must contain an alternative which is not left recursive\n";
448448
testErrors(new String[] { grammar, expected }, false);
449449
}
450450

@@ -458,7 +458,7 @@ public void testAmbigLR() throws Exception {
458458
"ID : 'a'..'z'+ ;\n" +
459459
"WS : (' '|'\\n') -> skip ;\n";
460460
String expected =
461-
"error(" + ErrorType.EPSILON_LR_FOLLOW.code + "): T.g4:3:0: left recursive rule 'a' contains a left recursive alternative which can be followed by the empty string\n";
461+
"error(" + ErrorType.EPSILON_LR_FOLLOW.code + "): T.g4:3:0: left recursive rule a contains a left recursive alternative which can be followed by the empty string\n";
462462
testErrors(new String[] { grammar, expected }, false);
463463
}
464464

tool/test/org/antlr/v4/py2/test/TestSets.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public TestSets() {
238238
"a : A {print($A.text)} ;\n" +
239239
"A : ~('a'|B) ;\n" +
240240
"B : 'b' ;\n",
241-
"error(" + ErrorType.UNSUPPORTED_REFERENCE_IN_LEXER_SET.code + "): T.g4:3:10: rule reference 'B' is not currently supported in a set\n"
241+
"error(" + ErrorType.UNSUPPORTED_REFERENCE_IN_LEXER_SET.code + "): T.g4:3:10: rule reference B is not currently supported in a set\n"
242242
};
243243
super.testErrors(pair, true);
244244
}

0 commit comments

Comments
 (0)