forked from jasder/antlr
recursive calls work
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 6832]
This commit is contained in:
parent
f6f444db52
commit
16ad680adb
|
@ -177,7 +177,7 @@ workLoop:
|
||||||
boolean accepted = false;
|
boolean accepted = false;
|
||||||
processOneChar:
|
processOneChar:
|
||||||
while ( i<closure.size() ) {
|
while ( i<closure.size() ) {
|
||||||
System.out.println("input["+input.index()+"]=="+(char)c+" closure="+closure+", i="+i+", reach="+ reach);
|
//System.out.println("input["+input.index()+"]=="+(char)c+" closure="+closure+", i="+i+", reach="+ reach);
|
||||||
ThreadState t = closure.get(i);
|
ThreadState t = closure.get(i);
|
||||||
ip = t.addr;
|
ip = t.addr;
|
||||||
NFAStack context = t.context;
|
NFAStack context = t.context;
|
||||||
|
@ -238,7 +238,7 @@ processOneChar:
|
||||||
int j=i+1;
|
int j=i+1;
|
||||||
while ( j<closure.size() ) {
|
while ( j<closure.size() ) {
|
||||||
ThreadState cl = closure.get(j);
|
ThreadState cl = closure.get(j);
|
||||||
System.out.println("remaining "+ cl);
|
//System.out.println("remaining "+ cl);
|
||||||
if ( cl.alt==alt ) closure.remove(j);
|
if ( cl.alt==alt ) closure.remove(j);
|
||||||
else j++;
|
else j++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,11 +77,22 @@ public class TestNFABytecodeInterp extends BaseTest {
|
||||||
|
|
||||||
@Test public void testRecursiveCall() throws Exception {
|
@Test public void testRecursiveCall() throws Exception {
|
||||||
LexerGrammar g = new LexerGrammar(
|
LexerGrammar g = new LexerGrammar(
|
||||||
"lexer grammar L;\n" + //TODO
|
"lexer grammar L;\n" +
|
||||||
"I : D+ ;\n" +
|
"ACTION : '{' (ACTION|.)* '}' ;\n");
|
||||||
"fragment D : '0'..'9'+ ;\n");
|
String expecting = "ACTION, EOF";
|
||||||
String expecting = "I, EOF";
|
checkMatches(g, "{hi}", expecting);
|
||||||
checkMatches(g, "32", expecting);
|
checkMatches(g, "{{hi}}", expecting);
|
||||||
|
checkMatches(g, "{{x}{y}}", expecting);
|
||||||
|
checkMatches(g, "{{{{{{x}}}}}}", expecting);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test public void testAltOrWildcard() throws Exception {
|
||||||
|
LexerGrammar g = new LexerGrammar(
|
||||||
|
"lexer grammar L;\n" +
|
||||||
|
"A : 'a' ;\n" +
|
||||||
|
"ELSE : . ;\n");
|
||||||
|
String expecting = "A, A, ELSE, A, EOF";
|
||||||
|
checkMatches(g, "aaxa", expecting);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void _template() throws Exception {
|
public void _template() throws Exception {
|
||||||
|
|
Loading…
Reference in New Issue