Merge remote-tracking branch 'parrt/master'

This commit is contained in:
sharwell 2012-02-08 12:34:17 -06:00
commit 66d82fab9b
6 changed files with 28 additions and 15 deletions

View File

@ -2,7 +2,7 @@ import org.antlr.runtime.debug.BlankDebugEventListener;
import org.antlr.v4.runtime.ANTLRFileStream;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.atn.LexerATNSimulator;
import org.antlr.v4.runtime.atn.v2ParserATNSimulator;
import org.antlr.v4.runtime.atn.ParserATNSimulator;
import java.io.File;
@ -41,10 +41,10 @@ class TestJava {
System.out.println("finished parsing OK");
System.out.println(LexerATNSimulator.ATN_failover+" lexer failovers");
System.out.println(LexerATNSimulator.match_calls+" lexer match calls");
System.out.println(v2ParserATNSimulator.ATN_failover+" parser failovers");
System.out.println(v2ParserATNSimulator.predict_calls +" parser predict calls");
System.out.println(v2ParserATNSimulator.retry_with_context +" retry_with_context after SLL conflict");
System.out.println(v2ParserATNSimulator.retry_with_context_indicates_no_conflict +" retry sees no conflict");
System.out.println(ParserATNSimulator.ATN_failover+" parser failovers");
System.out.println(ParserATNSimulator.predict_calls +" parser predict calls");
System.out.println(ParserATNSimulator.retry_with_context +" retry_with_context after SLL conflict");
System.out.println(ParserATNSimulator.retry_with_context_indicates_no_conflict +" retry sees no conflict");
if ( profile ) {
System.out.println("num decisions "+profiler.numDecisions);
}

View File

@ -33,7 +33,7 @@ import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.atn.LexerATNSimulator;
import org.antlr.v4.runtime.atn.v2ParserATNSimulator;
import org.antlr.v4.runtime.atn.ParserATNSimulator;
import java.io.File;
@ -71,10 +71,10 @@ class TestJavaLR {
System.out.println("finished parsing OK");
System.out.println(LexerATNSimulator.ATN_failover+" lexer failovers");
System.out.println(LexerATNSimulator.match_calls+" lexer match calls");
System.out.println(v2ParserATNSimulator.ATN_failover+" parser failovers");
System.out.println(v2ParserATNSimulator.predict_calls +" parser predict calls");
System.out.println(v2ParserATNSimulator.retry_with_context +" retry_with_context after SLL conflict");
System.out.println(v2ParserATNSimulator.retry_with_context_indicates_no_conflict +" retry sees no conflict");
System.out.println(ParserATNSimulator.ATN_failover+" parser failovers");
System.out.println(ParserATNSimulator.predict_calls +" parser predict calls");
System.out.println(ParserATNSimulator.retry_with_context +" retry_with_context after SLL conflict");
System.out.println(ParserATNSimulator.retry_with_context_indicates_no_conflict +" retry sees no conflict");
if ( profile ) {
System.out.println("num decisions "+profiler.numDecisions);
}

View File

@ -2,7 +2,7 @@ import org.antlr.runtime.debug.BlankDebugEventListener;
import org.antlr.v4.runtime.ANTLRFileStream;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.atn.LexerATNSimulator;
import org.antlr.v4.runtime.atn.v2ParserATNSimulator;
import org.antlr.v4.runtime.atn.ParserATNSimulator;
import java.io.File;
@ -34,8 +34,8 @@ class TestYang {
System.out.println("finished parsing OK");
System.out.println(LexerATNSimulator.ATN_failover+" lexer failovers");
System.out.println(LexerATNSimulator.match_calls+" lexer match calls");
System.out.println(v2ParserATNSimulator.ATN_failover+" parser failovers");
System.out.println(v2ParserATNSimulator.predict_calls +" parser predict calls");
System.out.println(ParserATNSimulator.ATN_failover+" parser failovers");
System.out.println(ParserATNSimulator.predict_calls +" parser predict calls");
if ( profile ) {
System.out.println("num decisions "+profiler.numDecisions);
}

View File

@ -130,7 +130,7 @@ case <f.ruleIndex> : return <f.name>_sempred((<f.ctxType>)_localctx, predIndex);
parser_ctor(p) ::= <<
public <p.name>(TokenStream input) {
super(input);
_interp = new v2ParserATNSimulator\<Token>(this,_ATN);
_interp = new ParserATNSimulator\<Token>(this,_ATN);
}
>>

View File

@ -248,7 +248,7 @@ options {k=1;}
fragment
LEXER_CHAR_SET
: '[' ('\\]'|'\\'|~('\\'|']'))* ']'
: '[' ('\\]'|'\\' ~']'|~('\\'|']'))* ']'
;
// --------------

View File

@ -343,4 +343,17 @@ public class TestLexerExec extends BaseTest {
assertEquals(expecting, found);
}
@Test public void testCharSetWithQuote2() throws Exception {
String grammar =
"lexer grammar L;\n"+
"A : [\"\\\\ab]+ {System.out.println(\"A\");} ;\n"+
"WS : [ \n\t]+ -> skip ;";
String found = execLexer("L.g", grammar, "L", "b\"\\a");
String expecting =
"A\n" +
"[@0,0:3='b\"\\a',<3>,1:0]\n" +
"[@1,4:3='<EOF>',<-1>,1:4]\n";
assertEquals(expecting, found);
}
}