minor changes for Safari support

This commit is contained in:
ericvergnaud 2014-10-27 03:38:24 +08:00
parent 129cbbbece
commit 537819ba47
4 changed files with 40 additions and 28 deletions

View File

@ -34,6 +34,8 @@ public class Generator {
Map<String, File> configs = new HashMap<String, File>();
configs.put("Source", readGrammarDir()); // source of test templates
configs.put("Java", readJavaDir()); // generated Java tests
configs.put("NodeJS", readNodeJSDir()); // generated NodeJS tests
configs.put("Safari", readSafariDir()); // generated Firefox tests
configs.put("Firefox", readFirefoxDir()); // generated Firefox tests
return configs;
}
@ -46,6 +48,16 @@ public class Generator {
return new File(new URI(uri));
}
private static File readNodeJSDir() {
// TODO Auto-generated method stub
return new File("/Users/ericvergnaud/Development/antlr4/antlr/antlr4-javascript/tool/test/org/antlr/v4/test/rt/js/node");
}
private static File readSafariDir() {
// TODO read from env variable
return new File("/Users/ericvergnaud/Development/antlr4/antlr/antlr4-javascript/tool/test/org/antlr/v4/test/rt/js/safari");
}
private static File readFirefoxDir() {
// TODO read from env variable
return new File("/Users/ericvergnaud/Development/antlr4/antlr/antlr4-javascript/tool/test/org/antlr/v4/test/rt/js/firefox");
@ -1189,18 +1201,18 @@ public class Generator {
file.addLexerTest(input, "EOFSuffixInFirstRule", "L", "a",
"[@0,0:0='a',<1>,1:0]\n" +
"[@1,1:0='<EOF>',<-1>,1:1]\n", null, 2);
file.addLexerTest(input, "CharSet", "L", "34\r\n 34",
file.addLexerTest(input, "CharSet", "L", "34\n 34",
"I\n" +
"I\n" +
"[@0,0:1='34',<1>,1:0]\n" +
"[@1,5:6='34',<1>,2:1]\n" +
"[@2,7:6='<EOF>',<-1>,2:3]\n", null);
file.addLexerTest(input, "CharSetPlus", "L", "34\r\n 34",
"[@1,4:5='34',<1>,2:1]\n" +
"[@2,6:5='<EOF>',<-1>,2:3]\n", null);
file.addLexerTest(input, "CharSetPlus", "L", "34\n 34",
"I\n" +
"I\n" +
"[@0,0:1='34',<1>,1:0]\n" +
"[@1,5:6='34',<1>,2:1]\n" +
"[@2,7:6='<EOF>',<-1>,2:3]\n", null);
"[@1,4:5='34',<1>,2:1]\n" +
"[@2,6:5='<EOF>',<-1>,2:3]\n", null);
file.addLexerTest(input, "CharSetNot", "L", "xaf",
"I\n" +
"[@0,0:2='xaf',<1>,1:0]\n" +
@ -1211,20 +1223,20 @@ public class Generator {
"[@0,0:0='a',<1>,1:0]\n" +
"[@1,2:2='x',<1>,1:2]\n" +
"[@2,3:2='<EOF>',<-1>,1:3]\n", null);
file.addLexerTest(input, "CharSetRange", "L", "34\r 34 a2 abc \n ",
file.addLexerTest(input, "CharSetRange", "L", "34\n 34 a2 abc \n ",
"I\n" +
"I\n" +
"ID\n" +
"ID\n" +
"[@0,0:1='34',<1>,1:0]\n" +
"[@1,4:5='34',<1>,1:4]\n" +
"[@2,7:8='a2',<2>,1:7]\n" +
"[@3,10:12='abc',<2>,1:10]\n" +
"[@4,18:17='<EOF>',<-1>,2:3]\n", null);
file.addLexerTest(input, "CharSetWithMissingEndRange", "L", "00\r\n",
"[@1,4:5='34',<1>,2:1]\n" +
"[@2,7:8='a2',<2>,2:4]\n" +
"[@3,10:12='abc',<2>,2:7]\n" +
"[@4,18:17='<EOF>',<-1>,3:3]\n", null);
file.addLexerTest(input, "CharSetWithMissingEndRange", "L", "00\n",
"I\n" +
"[@0,0:1='00',<1>,1:0]\n" +
"[@1,4:3='<EOF>',<-1>,2:0]\n", null);
"[@1,3:2='<EOF>',<-1>,2:0]\n", null);
file.addLexerTest(input, "CharSetWithMissingEscapeChar", "L", "34 ",
"I\n" +
"[@0,0:1='34',<1>,1:0]\n" +

View File

@ -8,5 +8,5 @@ s
}
: r=a ;
a : 'x' {
<WriteRuleInvocationStack()>
<RuleInvocationStack():writeln()>
} ;

View File

@ -161,7 +161,7 @@ ImportListener(X) ::= ""
GetExpectedTokenNames() ::= "this.getExpectedTokens().toString(this.tokenNames)"
WriteRuleInvocationStack() ::= "System.out.println(getRuleInvocationStack());"
RuleInvocationStack() ::= "getRuleInvocationStack()"
LL_EXACT_AMBIG_DETECTION() ::= <<_interp.setPredictionMode(PredictionMode.LL_EXACT_AMBIG_DETECTION);>>

View File

@ -341,12 +341,12 @@ public class TestLexerExec extends BaseTest {
String grammar = "lexer grammar L;\n" +
"I : '0'..'9'+ {System.out.println(\"I\");} ;\n" +
"WS : [ \\n\\u000D] -> skip ;";
String found = execLexer("L.g4", grammar, "L", "34\r\n 34", false);
String found = execLexer("L.g4", grammar, "L", "34\n 34", false);
assertEquals("I\n" +
"I\n" +
"[@0,0:1='34',<1>,1:0]\n" +
"[@1,5:6='34',<1>,2:1]\n" +
"[@2,7:6='<EOF>',<-1>,2:3]\n", found);
"[@1,4:5='34',<1>,2:1]\n" +
"[@2,6:5='<EOF>',<-1>,2:3]\n", found);
assertNull(this.stderrDuringParse);
}
@ -355,12 +355,12 @@ public class TestLexerExec extends BaseTest {
String grammar = "lexer grammar L;\n" +
"I : '0'..'9'+ {System.out.println(\"I\");} ;\n" +
"WS : [ \\n\\u000D]+ -> skip ;";
String found = execLexer("L.g4", grammar, "L", "34\r\n 34", false);
String found = execLexer("L.g4", grammar, "L", "34\n 34", false);
assertEquals("I\n" +
"I\n" +
"[@0,0:1='34',<1>,1:0]\n" +
"[@1,5:6='34',<1>,2:1]\n" +
"[@2,7:6='<EOF>',<-1>,2:3]\n", found);
"[@1,4:5='34',<1>,2:1]\n" +
"[@2,6:5='<EOF>',<-1>,2:3]\n", found);
assertNull(this.stderrDuringParse);
}
@ -397,16 +397,16 @@ public class TestLexerExec extends BaseTest {
"I : [0-9]+ {System.out.println(\"I\");} ;\n" +
"ID : [a-zA-Z] [a-zA-Z0-9]* {System.out.println(\"ID\");} ;\n" +
"WS : [ \\n\\u0009\\r]+ -> skip ;";
String found = execLexer("L.g4", grammar, "L", "34\r 34 a2 abc \n ", false);
String found = execLexer("L.g4", grammar, "L", "34\n 34 a2 abc \n ", false);
assertEquals("I\n" +
"I\n" +
"ID\n" +
"ID\n" +
"[@0,0:1='34',<1>,1:0]\n" +
"[@1,4:5='34',<1>,1:4]\n" +
"[@2,7:8='a2',<2>,1:7]\n" +
"[@3,10:12='abc',<2>,1:10]\n" +
"[@4,18:17='<EOF>',<-1>,2:3]\n", found);
"[@1,4:5='34',<1>,2:1]\n" +
"[@2,7:8='a2',<2>,2:4]\n" +
"[@3,10:12='abc',<2>,2:7]\n" +
"[@4,18:17='<EOF>',<-1>,3:3]\n", found);
assertNull(this.stderrDuringParse);
}
@ -415,10 +415,10 @@ public class TestLexerExec extends BaseTest {
String grammar = "lexer grammar L;\n" +
"I : [0-]+ {System.out.println(\"I\");} ;\n" +
"WS : [ \\n\\u000D]+ -> skip ;";
String found = execLexer("L.g4", grammar, "L", "00\r\n", false);
String found = execLexer("L.g4", grammar, "L", "00\n", false);
assertEquals("I\n" +
"[@0,0:1='00',<1>,1:0]\n" +
"[@1,4:3='<EOF>',<-1>,2:0]\n", found);
"[@1,3:2='<EOF>',<-1>,2:0]\n", found);
assertNull(this.stderrDuringParse);
}