got actions into lexer; reorg'd

[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 6872]
This commit is contained in:
parrt 2010-05-17 13:28:04 -08:00
parent f5cc4efc1b
commit 118d225066
27 changed files with 480 additions and 280 deletions

View File

@ -30,6 +30,7 @@ package org.antlr.v4.runtime;
import org.antlr.runtime.CharStream; import org.antlr.runtime.CharStream;
import org.antlr.runtime.Token; import org.antlr.runtime.Token;
import org.antlr.runtime.TokenSource; import org.antlr.runtime.TokenSource;
import org.antlr.v4.runtime.pda.PDA;
/** A lexer is recognizer that draws input symbols from a character stream. /** A lexer is recognizer that draws input symbols from a character stream.
* lexer grammars result in a subclass of this object. A Lexer object * lexer grammars result in a subclass of this object. A Lexer object
@ -37,8 +38,14 @@ import org.antlr.runtime.TokenSource;
* of speed. * of speed.
*/ */
public abstract class Lexer extends BaseRecognizer implements TokenSource { public abstract class Lexer extends BaseRecognizer implements TokenSource {
public static final int DEFAULT_MODE = 0;
/** Where is the lexer drawing characters from? */ /** Where is the lexer drawing characters from? */
protected CharStream input; public CharStream input;
public int _mode = DEFAULT_MODE;
public static PDA[] modeToPDA;
public Lexer() { public Lexer() {
} }
@ -89,8 +96,8 @@ public abstract class Lexer extends BaseRecognizer implements TokenSource {
eof.setCharPositionInLine(getCharPositionInLine()); eof.setCharPositionInLine(getCharPositionInLine());
return eof; return eof;
} }
try { {
_nextToken(); state.type = modeToPDA[_mode].execThompson(input);
if ( state.token==null ) { if ( state.token==null ) {
emit(); emit();
} }
@ -99,14 +106,14 @@ public abstract class Lexer extends BaseRecognizer implements TokenSource {
} }
return state.token; return state.token;
} }
catch (NoViableAltException nva) { // catch (NoViableAltException nva) {
reportError(nva); // reportError(nva);
recover(nva); // throw out current char and try again // recover(nva); // throw out current char and try again
} // }
catch (RecognitionException re) { // catch (RecognitionException re) {
reportError(re); // reportError(re);
// match() routine has already called recover() // // match() routine has already called recover()
} // }
} }
} }
@ -120,9 +127,6 @@ public abstract class Lexer extends BaseRecognizer implements TokenSource {
state.token = Token.SKIP_TOKEN; state.token = Token.SKIP_TOKEN;
} }
/** This is the lexer entry point that sets instance var 'token' */
public abstract void _nextToken() throws RecognitionException;
/** Set the char stream and reset the lexer */ /** Set the char stream and reset the lexer */
public void setCharStream(CharStream input) { public void setCharStream(CharStream input) {
this.input = null; this.input = null;

View File

@ -12,8 +12,14 @@ import java.util.Map;
/** A (nondeterministic) pushdown bytecode machine for lexing and LL prediction. /** A (nondeterministic) pushdown bytecode machine for lexing and LL prediction.
* Derived partially from Cox' description of Thompson's 1960s work: * Derived partially from Cox' description of Thompson's 1960s work:
* http://swtch.com/~rsc/regexp/regexp2.html * http://swtch.com/~rsc/regexp/regexp2.html
*
* Primary difference is that I've extended to have actions, semantic predicates
* and a stack for rule invocation.
*/ */
public class PDA { public class PDA {
public interface action_fptr { void exec(int action); }
public interface sempred_fptr { boolean eval(int predIndex); }
public byte[] code; public byte[] code;
public Map<String, Integer> ruleToAddr; public Map<String, Integer> ruleToAddr;
public int[] tokenTypeToAddr; public int[] tokenTypeToAddr;
@ -163,12 +169,12 @@ processOneChar:
// then, move to next char, looking for longer match // then, move to next char, looking for longer match
// (we continue processing if there are states in reach) // (we continue processing if there are states in reach)
break; break;
case Bytecode.JMP : // ignore // case Bytecode.JMP : // ignore
case Bytecode.SPLIT : // case Bytecode.SPLIT :
case Bytecode.CALL : // case Bytecode.CALL :
case Bytecode.RET : // case Bytecode.RET :
case Bytecode.SEMPRED : // case Bytecode.SEMPRED :
break; // break;
default : default :
throw new RuntimeException("invalid instruction @ "+ip+": "+opcode); throw new RuntimeException("invalid instruction @ "+ip+": "+opcode);
} }
@ -248,9 +254,9 @@ processOneChar:
case Bytecode.SEMPRED : case Bytecode.SEMPRED :
// add next instruction only if sempred succeeds // add next instruction only if sempred succeeds
int ruleIndex = getShort(code, ip); int ruleIndex = getShort(code, ip);
int actionIndex = getShort(code, ip+2); int predIndex = getShort(code, ip+2);
System.out.println("eval sempred "+ ruleIndex+", "+actionIndex); System.out.println("eval sempred "+ ruleIndex+", "+predIndex);
if ( sempred(ruleIndex, actionIndex) ) { if ( sempred(ruleIndex, predIndex) ) {
addToClosure(closure, ip+4, alt, context); addToClosure(closure, ip+4, alt, context);
} }
break; break;
@ -425,15 +431,6 @@ processOneChar:
} }
} }
void trace(int ip) {
String instr = Bytecode.disassembleInstruction(code, ip);
System.out.println(instr);
}
public static int getShort(byte[] memory, int index) {
return (memory[index]&0xFF) <<(8*1) | (memory[index+1]&0xFF); // prevent sign extension with mask
}
// subclass needs to override these if there are sempreds or actions in lexer rules // subclass needs to override these if there are sempreds or actions in lexer rules
public boolean sempred(int ruleIndex, int actionIndex) { public boolean sempred(int ruleIndex, int actionIndex) {
@ -443,6 +440,15 @@ processOneChar:
public void action(int ruleIndex, int actionIndex) { public void action(int ruleIndex, int actionIndex) {
} }
void trace(int ip) {
String instr = Bytecode.disassembleInstruction(code, ip);
System.out.println(instr);
}
public static int getShort(byte[] memory, int index) {
return (memory[index]&0xFF) <<(8*1) | (memory[index+1]&0xFF); // prevent sign extension with mask
}
/* /*
public int exec(CharStream input, String ruleName) { public int exec(CharStream input, String ruleName) {
return exec(input, ruleToAddr.get(ruleName)); return exec(input, ruleToAddr.get(ruleName));

View File

@ -229,10 +229,9 @@ import org.antlr.runtime.*;
<lexer> <lexer>
>> >>
Lexer(lexerName,modes,pdas) ::= << Lexer(lexerName,modes,pdas, actions, sempreds) ::= <<
public class <lexerName> extends Lexer { public class <lexerName> extends Lexer {
public static enum Mode { <modes:{m|<m>(<i0>)}; separator=", ">; int mode; Mode(int m) {mode=m;\}} <modes:{m| public static final int <m> = <i0>;}; separator="\n">
public Mode _mode = Mode.DEFAULT_MODE;
public <lexerName>() {;} public <lexerName>() {;}
public <lexerName>(CharStream input) { public <lexerName>(CharStream input) {
@ -243,27 +242,68 @@ public class <lexerName> extends Lexer {
} }
public String getGrammarFileName() { return "<fileName>"; } public String getGrammarFileName() { return "<fileName>"; }
public void _nextToken() throws RecognitionException { <actions>
state.type = modeToPDA[_mode.ordinal()].execThompson(input); <sempreds>
}
<pdas> <pdas>
public static PDA[] modeToPDA = { <modes:{m | new <m>_PDA()}; separator=", "> }; static {
modeToPDA = new PDA[] { <modes:{m | new <m>_PDA()}; separator=", "> };
}
} }
>> >>
PDA(name, model) ::= << PDA(name, model, actions, sempreds) ::= <<
public static final byte[] <name>_code = {
<model.code; separator=", ">
};
public static final int[] <name>_tokenTypeToAddr = {
<model.tokenTypeToAddr; separator=", ">
};
public static final class <name>_PDA extends PDA { public static final class <name>_PDA extends PDA {
<!byte[] code, Map<String, Integer> ruleToAddr, int[] tokenTypeToAddr, int nLabels!> public static final byte[] code = {
<model.code; separator=", ">
};
public static final int[] tokenTypeToAddr = {
<model.tokenTypeToAddr; separator=", ">
};
<if(actions)>
public void action(int r, int a) {
<actions:{a |
switch ( r ) {
case <i0> : <a.name>_actions(a); break;
}>
}
}
<endif>
<if(sempreds)>
public void sempred(int r, int a) {
<sempreds:{p |
switch ( r ) {
case <i0> : return <p.name>_sempreds(a);
}>
}
}
<endif>
public <name>_PDA() { public <name>_PDA() {
super(<name>_code, <name>_tokenTypeToAddr, <model.nLabels>); super(code, tokenTypeToAddr, <model.nLabels>);
}
}
>>
actionMethod(name, actions) ::= <<
public void <name>_actions(int action) {
switch ( action ) {
<actions:{a |
case <i0> :
<a>
break;
}>
}
}
>>
sempredMethod(name, preds) ::= <<
public boolean <name>_sempreds(int pred) {
switch ( pred ) {
<preds:{p |
case <i0> :
return <p>;
}>
default : return false;
} }
} }
>> >>

View File

@ -111,7 +111,6 @@ public class CodeGenerator {
public void write(ST code, String fileName) throws IOException { public void write(ST code, String fileName) throws IOException {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
Writer w = g.tool.getOutputFile(g, fileName); Writer w = g.tool.getOutputFile(g, fileName);
// Write the output to a StringWriter
STWriter wr = new AutoIndentWriter(w); STWriter wr = new AutoIndentWriter(w);
wr.setLineWidth(lineWidth); wr.setLineWidth(lineWidth);
code.write(wr); code.write(wr);

View File

@ -0,0 +1,24 @@
package org.antlr.v4.codegen;
import org.antlr.runtime.Token;
import org.antlr.v4.codegen.pda.Instr;
import org.antlr.v4.misc.DoubleKeyMap;
import org.antlr.v4.tool.Rule;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** */
public class CompiledPDA { public List<Instr> instrs = new ArrayList<Instr>();
public byte[] code; // instrs in bytecode form
public int ip = 0; // where to write next
public Map<String, Integer> ruleToAddr = new HashMap<String, Integer>();
public int[] tokenTypeToAddr;
public DoubleKeyMap<Rule, String, Integer> ruleLabels = new DoubleKeyMap<Rule, String, Integer>();
public DoubleKeyMap<Rule, Token, Integer> ruleActions = new DoubleKeyMap<Rule, Token, Integer>();
public DoubleKeyMap<Rule, Token, Integer> ruleSempreds = new DoubleKeyMap<Rule, Token, Integer>();
public int nLabels;
}

View File

@ -1,9 +1,12 @@
package org.antlr.v4.codegen; package org.antlr.v4.codegen;
import org.antlr.v4.runtime.pda.PDA; import org.antlr.runtime.Token;
import org.antlr.v4.tool.LexerGrammar; import org.antlr.v4.tool.LexerGrammar;
import org.antlr.v4.tool.Rule;
import org.stringtemplate.v4.ST; import org.stringtemplate.v4.ST;
import java.util.Set;
/** */ /** */
public class LexerFactory { public class LexerFactory {
public CodeGenerator gen; public CodeGenerator gen;
@ -20,8 +23,28 @@ public class LexerFactory {
fileST.add("fileName", gen.getRecognizerFileName()); fileST.add("fileName", gen.getRecognizerFileName());
fileST.add("lexer", lexerST); fileST.add("lexer", lexerST);
for (String modeName : lg.modes.keySet()) { // for each mode for (String modeName : lg.modes.keySet()) { // for each mode
PDA pda = NFABytecodeGenerator.getBytecode(lg, modeName); CompiledPDA pda = PDABytecodeGenerator.compileLexerMode(lg, modeName);
ST pdaST = gen.templates.getInstanceOf("PDA"); ST pdaST = gen.templates.getInstanceOf("PDA");
for (Rule r : pda.ruleActions.keySet()) {
Set<Token> actionTokens = pda.ruleActions.keySet(r);
ST actionST = gen.templates.getInstanceOf("actionMethod");
actionST.add("name", r.name);
for (Token t : actionTokens) {
actionST.add("actions", t.getText());
}
pdaST.add("actions", actionST);
lexerST.add("actions", actionST);
}
for (Rule r : pda.ruleSempreds.keySet()) {
Set<Token> sempredTokens = pda.ruleSempreds.keySet(r);
ST sempredST = gen.templates.getInstanceOf("sempredMethod");
sempredST.add("name", r.name);
for (Token t : sempredTokens) {
sempredST.add("preds", t.getText());
}
pdaST.add("sempreds", sempredST);
lexerST.add("sempreds", sempredST);
}
pdaST.add("name", modeName); pdaST.add("name", modeName);
pdaST.add("model", pda); pdaST.add("model", pda);
lexerST.add("pdas", pdaST); lexerST.add("pdas", pdaST);

View File

@ -4,9 +4,8 @@ import org.antlr.runtime.RecognizerSharedState;
import org.antlr.runtime.Token; import org.antlr.runtime.Token;
import org.antlr.runtime.tree.CommonTreeNodeStream; import org.antlr.runtime.tree.CommonTreeNodeStream;
import org.antlr.runtime.tree.TreeNodeStream; import org.antlr.runtime.tree.TreeNodeStream;
import org.antlr.v4.codegen.nfa.*; import org.antlr.v4.codegen.pda.*;
import org.antlr.v4.misc.CharSupport; import org.antlr.v4.misc.CharSupport;
import org.antlr.v4.misc.DoubleKeyMap;
import org.antlr.v4.parse.ANTLRParser; import org.antlr.v4.parse.ANTLRParser;
import org.antlr.v4.parse.GrammarASTAdaptor; import org.antlr.v4.parse.GrammarASTAdaptor;
import org.antlr.v4.runtime.pda.Bytecode; import org.antlr.v4.runtime.pda.Bytecode;
@ -16,64 +15,47 @@ import org.antlr.v4.tool.GrammarAST;
import org.antlr.v4.tool.LexerGrammar; import org.antlr.v4.tool.LexerGrammar;
import org.antlr.v4.tool.Rule; import org.antlr.v4.tool.Rule;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** http://swtch.com/~rsc/regexp/regexp2.html */ /** http://swtch.com/~rsc/regexp/regexp2.html */
public class NFABytecodeGenerator extends TreeParser { public class PDABytecodeGenerator extends TreeParser {
LexerGrammar lg;
public List<Instr> instrs = new ArrayList<Instr>();
public int ip = 0; // where to write next
Map<String, Integer> ruleToAddr = new HashMap<String, Integer>();
int[] tokenTypeToAddr;
DoubleKeyMap<Rule, String, Integer> ruleLabels = new DoubleKeyMap<Rule, String, Integer>();
DoubleKeyMap<Rule, Token, Integer> ruleActions = new DoubleKeyMap<Rule, Token, Integer>();
DoubleKeyMap<Rule, Token, Integer> ruleSempreds = new DoubleKeyMap<Rule, Token, Integer>();
public Rule currentRule; public Rule currentRule;
CompiledPDA pda = new CompiledPDA();
public int labelIndex = 0; // first time we ask for labels we index public int labelIndex = 0; // first time we ask for labels we index
// public abstract class LabelMaker<Key,Label> { public PDABytecodeGenerator(TreeNodeStream input, RecognizerSharedState state) {
// Map<Key,Label> labels = new HashMap<Key,Label>();
// public LabelMaker(Collection<Key> keys) {
// for (Key k : keys) labels.put(k, computeLabel(k));
// }
// public abstract Label computeLabel(Key k);
// }
public NFABytecodeGenerator(TreeNodeStream input, RecognizerSharedState state) {
super(input, state); super(input, state);
} }
public void emit(Instr I) { public void emit(Instr I) {
I.addr = ip; I.addr = pda.ip;
I.rule = currentRule; I.rule = currentRule;
I.gen = this; I.gen = this;
ip += I.nBytes(); pda.ip += I.nBytes();
instrs.add(I); pda.instrs.add(I);
} }
// indexed from 0 per rule // indexed from 0 per rule
public int getActionIndex(Rule r, Token actionToken) { public int getActionIndex(Rule r, Token actionToken) {
Integer I = ruleActions.get(r, actionToken); Integer I = pda.ruleActions.get(r, actionToken);
if ( I!=null ) return I; // already got its label if ( I!=null ) return I; // already got its label
Map<Token, Integer> labels = ruleActions.get(r); Map<Token, Integer> labels = pda.ruleActions.get(r);
int i = labels.size(); int i = 0;
ruleActions.put(r, actionToken, i); if ( labels!=null ) i = labels.size();
pda.ruleActions.put(r, actionToken, i);
return i; return i;
} }
// indexed from 0 per rule // indexed from 0 per rule
public int getSempredIndex(Rule r, Token actionToken) { public int getSempredIndex(Rule r, Token actionToken) {
Integer I = ruleSempreds.get(r, actionToken); Integer I = pda.ruleSempreds.get(r, actionToken);
if ( I!=null ) return I; // already got its label if ( I!=null ) return I; // already got its label
Map<Token, Integer> labels = ruleSempreds.get(r); Map<Token, Integer> labels = pda.ruleSempreds.get(r);
int i = labels.size(); int i = 0;
ruleSempreds.put(r, actionToken, i); if ( labels!=null ) i = labels.size();
pda.ruleSempreds.put(r, actionToken, i);
return i; return i;
} }
@ -82,10 +64,10 @@ public class NFABytecodeGenerator extends TreeParser {
* to an index in an action. * to an index in an action.
*/ */
public int getLabelIndex(Rule r, String labelName) { public int getLabelIndex(Rule r, String labelName) {
Integer I = ruleLabels.get(r, labelName); Integer I = pda.ruleLabels.get(r, labelName);
if ( I!=null ) return I; // already got its label if ( I!=null ) return I; // already got its label
int i = labelIndex++; int i = labelIndex++;
ruleLabels.put(r, labelName, i); pda.ruleLabels.put(r, labelName, i);
return i; return i;
} }
@ -96,30 +78,29 @@ public class NFABytecodeGenerator extends TreeParser {
} }
} }
public byte[] getBytecode() { public byte[] convertInstrsToBytecode() {
Instr last = instrs.get(instrs.size() - 1); Instr last = pda.instrs.get(pda.instrs.size() - 1);
int size = last.addr + last.nBytes(); int size = last.addr + last.nBytes();
byte[] code = new byte[size]; byte[] code = new byte[size];
// resolve CALL instruction targets before generating code // resolve CALL instruction targets before generating code
for (Instr I : instrs) { for (Instr I : pda.instrs) {
if ( I instanceof CallInstr ) { if ( I instanceof CallInstr ) {
CallInstr C = (CallInstr) I; CallInstr C = (CallInstr) I;
String ruleName = C.token.getText(); String ruleName = C.token.getText();
C.target = ruleToAddr.get(ruleName); C.target = pda.ruleToAddr.get(ruleName);
} }
} }
for (Instr I : instrs) { for (Instr I : pda.instrs) {
I.write(code); I.write(code);
} }
return code; return code;
} }
public static PDA getBytecode(LexerGrammar lg, String modeName) { public static CompiledPDA compileLexerMode(LexerGrammar lg, String modeName) {
GrammarASTAdaptor adaptor = new GrammarASTAdaptor(); GrammarASTAdaptor adaptor = new GrammarASTAdaptor();
NFABytecodeTriggers gen = new NFABytecodeTriggers(null); PDABytecodeTriggers gen = new PDABytecodeTriggers(null);
gen.lg = lg; gen.pda.tokenTypeToAddr = new int[lg.getMaxTokenType()+1];
gen.tokenTypeToAddr = new int[lg.getMaxTokenType()+1];
// add split for s0 to hook up rules (fill in operands as we gen rules) // add split for s0 to hook up rules (fill in operands as we gen rules)
int numRules = lg.modes.get(modeName).size(); int numRules = lg.modes.get(modeName).size();
@ -135,10 +116,10 @@ public class NFABytecodeGenerator extends TreeParser {
CommonTreeNodeStream nodes = new CommonTreeNodeStream(adaptor,blk); CommonTreeNodeStream nodes = new CommonTreeNodeStream(adaptor,blk);
gen.setTreeNodeStream(nodes); gen.setTreeNodeStream(nodes);
int ttype = lg.getTokenType(r.name); int ttype = lg.getTokenType(r.name);
gen.ruleToAddr.put(r.name, gen.ip); gen.pda.ruleToAddr.put(r.name, gen.pda.ip);
if ( !r.isFragment() ) { if ( !r.isFragment() ) {
s0.addrs.add(gen.ip); s0.addrs.add(gen.pda.ip);
gen.tokenTypeToAddr[ttype] = gen.ip; gen.pda.tokenTypeToAddr[ttype] = gen.pda.ip;
} }
try { try {
gen.block(); // GEN Instr OBJECTS gen.block(); // GEN Instr OBJECTS
@ -154,11 +135,17 @@ public class NFABytecodeGenerator extends TreeParser {
e.printStackTrace(System.err); e.printStackTrace(System.err);
} }
} }
byte[] code = gen.getBytecode(); gen.pda.code = gen.convertInstrsToBytecode();
System.out.println(Bytecode.disassemble(code)); gen.pda.nLabels = gen.labelIndex;
System.out.println("rule addrs="+gen.ruleToAddr); System.out.println(Bytecode.disassemble(gen.pda.code));
System.out.println("rule addrs="+gen.pda.ruleToAddr);
return gen.pda;
}
return new PDA(code, gen.ruleToAddr, gen.tokenTypeToAddr, gen.labelIndex); // testing
public static PDA getPDA(LexerGrammar lg, String modeName) {
CompiledPDA info = compileLexerMode(lg, modeName);
return new PDA(info.code, info.ruleToAddr, info.tokenTypeToAddr, info.nLabels);
} }
/** Write value at index into a byte array highest to lowest byte, /** Write value at index into a byte array highest to lowest byte,

View File

@ -1,14 +1,14 @@
tree grammar NFABytecodeTriggers; tree grammar PDABytecodeTriggers;
options { options {
language = Java; language = Java;
tokenVocab = ANTLRParser; tokenVocab = ANTLRParser;
ASTLabelType = GrammarAST; ASTLabelType = GrammarAST;
superClass = NFABytecodeGenerator; superClass = PDABytecodeGenerator;
} }
@header { @header {
package org.antlr.v4.codegen; package org.antlr.v4.codegen;
import org.antlr.v4.codegen.nfa.*; import org.antlr.v4.codegen.pda.*;
import org.antlr.v4.tool.GrammarAST; import org.antlr.v4.tool.GrammarAST;
import org.antlr.v4.tool.GrammarASTWithOptions; import org.antlr.v4.tool.GrammarASTWithOptions;
import org.antlr.v4.tool.LexerGrammar; import org.antlr.v4.tool.LexerGrammar;
@ -29,7 +29,7 @@ block
if ( nAlts>1 ) { if ( nAlts>1 ) {
S = new SplitInstr(nAlts); S = new SplitInstr(nAlts);
emit(S); emit(S);
S.addrs.add(ip); S.addrs.add(pda.ip);
} }
int alt = 1; int alt = 1;
} }
@ -39,13 +39,13 @@ block
JumpInstr J = new JumpInstr(); JumpInstr J = new JumpInstr();
jumps.add(J); jumps.add(J);
emit(J); emit(J);
S.addrs.add(ip); S.addrs.add(pda.ip);
} }
alt++; alt++;
} }
)+ )+
{ {
int END = ip; int END = pda.ip;
for (JumpInstr J : jumps) J.target = END; for (JumpInstr J : jumps) J.target = END;
} }
) )
@ -87,17 +87,17 @@ ebnf
| { | {
SplitInstr S = new SplitInstr(2); SplitInstr S = new SplitInstr(2);
emit(S); emit(S);
S.addrs.add(ip); S.addrs.add(pda.ip);
} }
^(OPTIONAL block) ^(OPTIONAL block)
{ {
S.addrs.add(ip); S.addrs.add(pda.ip);
} }
| { | {
int start=ip; int start=pda.ip;
SplitInstr S = new SplitInstr(2); SplitInstr S = new SplitInstr(2);
emit(S); emit(S);
int blkStart = ip; int blkStart = pda.ip;
} }
^(CLOSURE block) ^(CLOSURE block)
{ {
@ -105,14 +105,14 @@ ebnf
emit(J); emit(J);
J.target = start; J.target = start;
S.addrs.add(blkStart); S.addrs.add(blkStart);
S.addrs.add(ip); S.addrs.add(pda.ip);
if ( greedyOption!=null && greedyOption.equals("false") ) Collections.reverse(S.addrs); if ( greedyOption!=null && greedyOption.equals("false") ) Collections.reverse(S.addrs);
} }
| {int start=ip;} ^(POSITIVE_CLOSURE block) | {int start=pda.ip;} ^(POSITIVE_CLOSURE block)
{ {
SplitInstr S = new SplitInstr(2); SplitInstr S = new SplitInstr(2);
emit(S); emit(S);
int stop = ip; int stop = pda.ip;
S.addrs.add(start); S.addrs.add(start);
S.addrs.add(stop); S.addrs.add(stop);
if ( greedyOption!=null && greedyOption.equals("false") ) Collections.reverse(S.addrs); if ( greedyOption!=null && greedyOption.equals("false") ) Collections.reverse(S.addrs);

View File

@ -1,11 +1,11 @@
// $ANTLR ${project.version} ${buildNumber} NFABytecodeTriggers.g 2010-05-03 15:53:49 // $ANTLR ${project.version} ${buildNumber} PDABytecodeTriggers.g 2010-05-17 12:41:45
package org.antlr.v4.codegen; package org.antlr.v4.codegen;
import org.antlr.runtime.*; import org.antlr.runtime.*;
import org.antlr.runtime.tree.TreeNodeStream; import org.antlr.runtime.tree.TreeNodeStream;
import org.antlr.runtime.tree.TreeRuleReturnScope; import org.antlr.runtime.tree.TreeRuleReturnScope;
import org.antlr.v4.codegen.nfa.*; import org.antlr.v4.codegen.pda.*;
import org.antlr.v4.tool.GrammarAST; import org.antlr.v4.tool.GrammarAST;
import org.antlr.v4.tool.GrammarASTWithOptions; import org.antlr.v4.tool.GrammarASTWithOptions;
@ -13,7 +13,7 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
public class NFABytecodeTriggers extends NFABytecodeGenerator { public class PDABytecodeTriggers extends PDABytecodeGenerator {
public static final String[] tokenNames = new String[] { public static final String[] tokenNames = new String[] {
"<invalid>", "<EOR>", "<DOWN>", "<UP>", "SEMPRED", "FORCED_ACTION", "DOC_COMMENT", "SRC", "NLCHARS", "COMMENT", "DOUBLE_QUOTE_STRING_LITERAL", "DOUBLE_ANGLE_STRING_LITERAL", "ACTION_STRING_LITERAL", "ACTION_CHAR_LITERAL", "ARG_ACTION", "NESTED_ACTION", "ACTION", "ACTION_ESC", "WSNLCHARS", "OPTIONS", "TOKENS", "SCOPE", "IMPORT", "FRAGMENT", "LEXER", "PARSER", "TREE", "GRAMMAR", "PROTECTED", "PUBLIC", "PRIVATE", "RETURNS", "THROWS", "CATCH", "FINALLY", "TEMPLATE", "MODE", "COLON", "COLONCOLON", "COMMA", "SEMI", "LPAREN", "RPAREN", "IMPLIES", "LT", "GT", "ASSIGN", "QUESTION", "BANG", "STAR", "PLUS", "PLUS_ASSIGN", "OR", "ROOT", "DOLLAR", "DOT", "RANGE", "ETC", "RARROW", "TREE_BEGIN", "AT", "NOT", "RBRACE", "TOKEN_REF", "RULE_REF", "INT", "WSCHARS", "ESC_SEQ", "STRING_LITERAL", "HEX_DIGIT", "UNICODE_ESC", "WS", "ERRCHAR", "RULE", "RULES", "RULEMODIFIERS", "RULEACTIONS", "BLOCK", "REWRITE_BLOCK", "OPTIONAL", "CLOSURE", "POSITIVE_CLOSURE", "SYNPRED", "CHAR_RANGE", "EPSILON", "ALT", "ALTLIST", "ID", "ARG", "ARGLIST", "RET", "COMBINED", "INITACTION", "LABEL", "GATED_SEMPRED", "SYN_SEMPRED", "BACKTRACK_SEMPRED", "WILDCARD", "LIST", "ELEMENT_OPTIONS", "ST_RESULT", "RESULT", "ALT_REWRITE" "<invalid>", "<EOR>", "<DOWN>", "<UP>", "SEMPRED", "FORCED_ACTION", "DOC_COMMENT", "SRC", "NLCHARS", "COMMENT", "DOUBLE_QUOTE_STRING_LITERAL", "DOUBLE_ANGLE_STRING_LITERAL", "ACTION_STRING_LITERAL", "ACTION_CHAR_LITERAL", "ARG_ACTION", "NESTED_ACTION", "ACTION", "ACTION_ESC", "WSNLCHARS", "OPTIONS", "TOKENS", "SCOPE", "IMPORT", "FRAGMENT", "LEXER", "PARSER", "TREE", "GRAMMAR", "PROTECTED", "PUBLIC", "PRIVATE", "RETURNS", "THROWS", "CATCH", "FINALLY", "TEMPLATE", "MODE", "COLON", "COLONCOLON", "COMMA", "SEMI", "LPAREN", "RPAREN", "IMPLIES", "LT", "GT", "ASSIGN", "QUESTION", "BANG", "STAR", "PLUS", "PLUS_ASSIGN", "OR", "ROOT", "DOLLAR", "DOT", "RANGE", "ETC", "RARROW", "TREE_BEGIN", "AT", "NOT", "RBRACE", "TOKEN_REF", "RULE_REF", "INT", "WSCHARS", "ESC_SEQ", "STRING_LITERAL", "HEX_DIGIT", "UNICODE_ESC", "WS", "ERRCHAR", "RULE", "RULES", "RULEMODIFIERS", "RULEACTIONS", "BLOCK", "REWRITE_BLOCK", "OPTIONAL", "CLOSURE", "POSITIVE_CLOSURE", "SYNPRED", "CHAR_RANGE", "EPSILON", "ALT", "ALTLIST", "ID", "ARG", "ARGLIST", "RET", "COMBINED", "INITACTION", "LABEL", "GATED_SEMPRED", "SYN_SEMPRED", "BACKTRACK_SEMPRED", "WILDCARD", "LIST", "ELEMENT_OPTIONS", "ST_RESULT", "RESULT", "ALT_REWRITE"
}; };
@ -122,36 +122,36 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
// delegators // delegators
public NFABytecodeTriggers(TreeNodeStream input) { public PDABytecodeTriggers(TreeNodeStream input) {
this(input, new RecognizerSharedState()); this(input, new RecognizerSharedState());
} }
public NFABytecodeTriggers(TreeNodeStream input, RecognizerSharedState state) { public PDABytecodeTriggers(TreeNodeStream input, RecognizerSharedState state) {
super(input, state); super(input, state);
} }
public String[] getTokenNames() { return NFABytecodeTriggers.tokenNames; } public String[] getTokenNames() { return PDABytecodeTriggers.tokenNames; }
public String getGrammarFileName() { return "NFABytecodeTriggers.g"; } public String getGrammarFileName() { return "PDABytecodeTriggers.g"; }
public static class block_return extends TreeRuleReturnScope { public static class block_return extends TreeRuleReturnScope {
}; };
// $ANTLR start "block" // $ANTLR start "block"
// NFABytecodeTriggers.g:20:1: block : ^( BLOCK ( ^( OPTIONS ( . )+ ) )? ( alternative )+ ) ; // PDABytecodeTriggers.g:20:1: block : ^( BLOCK ( ^( OPTIONS ( . )+ ) )? ( alternative )+ ) ;
public final NFABytecodeTriggers.block_return block() throws RecognitionException { public final PDABytecodeTriggers.block_return block() throws RecognitionException {
NFABytecodeTriggers.block_return retval = new NFABytecodeTriggers.block_return(); PDABytecodeTriggers.block_return retval = new PDABytecodeTriggers.block_return();
retval.start = input.LT(1); retval.start = input.LT(1);
try { try {
// NFABytecodeTriggers.g:21:5: ( ^( BLOCK ( ^( OPTIONS ( . )+ ) )? ( alternative )+ ) ) // PDABytecodeTriggers.g:21:5: ( ^( BLOCK ( ^( OPTIONS ( . )+ ) )? ( alternative )+ ) )
// NFABytecodeTriggers.g:21:7: ^( BLOCK ( ^( OPTIONS ( . )+ ) )? ( alternative )+ ) // PDABytecodeTriggers.g:21:7: ^( BLOCK ( ^( OPTIONS ( . )+ ) )? ( alternative )+ )
{ {
match(input,BLOCK,FOLLOW_BLOCK_in_block68); match(input,BLOCK,FOLLOW_BLOCK_in_block68);
match(input, Token.DOWN, null); match(input, Token.DOWN, null);
// NFABytecodeTriggers.g:21:16: ( ^( OPTIONS ( . )+ ) )? // PDABytecodeTriggers.g:21:16: ( ^( OPTIONS ( . )+ ) )?
int alt2=2; int alt2=2;
int LA2_0 = input.LA(1); int LA2_0 = input.LA(1);
@ -160,12 +160,12 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
switch (alt2) { switch (alt2) {
case 1 : case 1 :
// NFABytecodeTriggers.g:21:17: ^( OPTIONS ( . )+ ) // PDABytecodeTriggers.g:21:17: ^( OPTIONS ( . )+ )
{ {
match(input,OPTIONS,FOLLOW_OPTIONS_in_block72); match(input,OPTIONS,FOLLOW_OPTIONS_in_block72);
match(input, Token.DOWN, null); match(input, Token.DOWN, null);
// NFABytecodeTriggers.g:21:27: ( . )+ // PDABytecodeTriggers.g:21:27: ( . )+
int cnt1=0; int cnt1=0;
loop1: loop1:
do { do {
@ -182,7 +182,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
switch (alt1) { switch (alt1) {
case 1 : case 1 :
// NFABytecodeTriggers.g:21:27: . // PDABytecodeTriggers.g:21:27: .
{ {
matchAny(input); matchAny(input);
@ -216,11 +216,11 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
if ( nAlts>1 ) { if ( nAlts>1 ) {
S = new SplitInstr(nAlts); S = new SplitInstr(nAlts);
emit(S); emit(S);
S.addrs.add(ip); S.addrs.add(pda.ip);
} }
int alt = 1; int alt = 1;
// NFABytecodeTriggers.g:36:7: ( alternative )+ // PDABytecodeTriggers.g:36:7: ( alternative )+
int cnt3=0; int cnt3=0;
loop3: loop3:
do { do {
@ -234,7 +234,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
switch (alt3) { switch (alt3) {
case 1 : case 1 :
// NFABytecodeTriggers.g:36:9: alternative // PDABytecodeTriggers.g:36:9: alternative
{ {
pushFollow(FOLLOW_alternative_in_block96); pushFollow(FOLLOW_alternative_in_block96);
alternative(); alternative();
@ -246,7 +246,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
JumpInstr J = new JumpInstr(); JumpInstr J = new JumpInstr();
jumps.add(J); jumps.add(J);
emit(J); emit(J);
S.addrs.add(ip); S.addrs.add(pda.ip);
} }
alt++; alt++;
@ -264,7 +264,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} while (true); } while (true);
int END = ip; int END = pda.ip;
for (JumpInstr J : jumps) J.target = END; for (JumpInstr J : jumps) J.target = END;
@ -285,10 +285,10 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
// $ANTLR start "alternative" // $ANTLR start "alternative"
// NFABytecodeTriggers.g:54:1: alternative : ( ^( ALT_REWRITE a= alternative . ) | ^( ALT EPSILON ) | ^( ALT (e= element )+ ) ); // PDABytecodeTriggers.g:54:1: alternative : ( ^( ALT_REWRITE a= alternative . ) | ^( ALT EPSILON ) | ^( ALT (e= element )+ ) );
public final void alternative() throws RecognitionException { public final void alternative() throws RecognitionException {
try { try {
// NFABytecodeTriggers.g:55:5: ( ^( ALT_REWRITE a= alternative . ) | ^( ALT EPSILON ) | ^( ALT (e= element )+ ) ) // PDABytecodeTriggers.g:55:5: ( ^( ALT_REWRITE a= alternative . ) | ^( ALT EPSILON ) | ^( ALT (e= element )+ ) )
int alt5=3; int alt5=3;
int LA5_0 = input.LA(1); int LA5_0 = input.LA(1);
@ -329,7 +329,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
switch (alt5) { switch (alt5) {
case 1 : case 1 :
// NFABytecodeTriggers.g:55:7: ^( ALT_REWRITE a= alternative . ) // PDABytecodeTriggers.g:55:7: ^( ALT_REWRITE a= alternative . )
{ {
match(input,ALT_REWRITE,FOLLOW_ALT_REWRITE_in_alternative147); match(input,ALT_REWRITE,FOLLOW_ALT_REWRITE_in_alternative147);
@ -346,7 +346,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 2 : case 2 :
// NFABytecodeTriggers.g:56:7: ^( ALT EPSILON ) // PDABytecodeTriggers.g:56:7: ^( ALT EPSILON )
{ {
match(input,ALT,FOLLOW_ALT_in_alternative164); match(input,ALT,FOLLOW_ALT_in_alternative164);
@ -358,12 +358,12 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 3 : case 3 :
// NFABytecodeTriggers.g:57:9: ^( ALT (e= element )+ ) // PDABytecodeTriggers.g:57:9: ^( ALT (e= element )+ )
{ {
match(input,ALT,FOLLOW_ALT_in_alternative183); match(input,ALT,FOLLOW_ALT_in_alternative183);
match(input, Token.DOWN, null); match(input, Token.DOWN, null);
// NFABytecodeTriggers.g:57:15: (e= element )+ // PDABytecodeTriggers.g:57:15: (e= element )+
int cnt4=0; int cnt4=0;
loop4: loop4:
do { do {
@ -377,7 +377,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
switch (alt4) { switch (alt4) {
case 1 : case 1 :
// NFABytecodeTriggers.g:57:16: e= element // PDABytecodeTriggers.g:57:16: e= element
{ {
pushFollow(FOLLOW_element_in_alternative188); pushFollow(FOLLOW_element_in_alternative188);
element(); element();
@ -417,19 +417,19 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
// $ANTLR start "element" // $ANTLR start "element"
// NFABytecodeTriggers.g:60:1: element : ( labeledElement | atom | ebnf | ACTION | SEMPRED | GATED_SEMPRED | treeSpec ); // PDABytecodeTriggers.g:60:1: element : ( labeledElement | atom | ebnf | ACTION | SEMPRED | GATED_SEMPRED | treeSpec );
public final void element() throws RecognitionException { public final void element() throws RecognitionException {
GrammarAST ACTION1=null; GrammarAST ACTION1=null;
GrammarAST SEMPRED2=null; GrammarAST SEMPRED2=null;
GrammarAST GATED_SEMPRED3=null; GrammarAST GATED_SEMPRED3=null;
try { try {
// NFABytecodeTriggers.g:61:2: ( labeledElement | atom | ebnf | ACTION | SEMPRED | GATED_SEMPRED | treeSpec ) // PDABytecodeTriggers.g:61:2: ( labeledElement | atom | ebnf | ACTION | SEMPRED | GATED_SEMPRED | treeSpec )
int alt6=7; int alt6=7;
alt6 = dfa6.predict(input); alt6 = dfa6.predict(input);
switch (alt6) { switch (alt6) {
case 1 : case 1 :
// NFABytecodeTriggers.g:61:4: labeledElement // PDABytecodeTriggers.g:61:4: labeledElement
{ {
pushFollow(FOLLOW_labeledElement_in_element219); pushFollow(FOLLOW_labeledElement_in_element219);
labeledElement(); labeledElement();
@ -440,7 +440,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 2 : case 2 :
// NFABytecodeTriggers.g:62:4: atom // PDABytecodeTriggers.g:62:4: atom
{ {
pushFollow(FOLLOW_atom_in_element228); pushFollow(FOLLOW_atom_in_element228);
atom(); atom();
@ -451,7 +451,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 3 : case 3 :
// NFABytecodeTriggers.g:63:4: ebnf // PDABytecodeTriggers.g:63:4: ebnf
{ {
pushFollow(FOLLOW_ebnf_in_element239); pushFollow(FOLLOW_ebnf_in_element239);
ebnf(); ebnf();
@ -462,7 +462,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 4 : case 4 :
// NFABytecodeTriggers.g:64:6: ACTION // PDABytecodeTriggers.g:64:6: ACTION
{ {
ACTION1=(GrammarAST)match(input,ACTION,FOLLOW_ACTION_in_element252); ACTION1=(GrammarAST)match(input,ACTION,FOLLOW_ACTION_in_element252);
emit(new ActionInstr(ACTION1.token)); emit(new ActionInstr(ACTION1.token));
@ -470,7 +470,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 5 : case 5 :
// NFABytecodeTriggers.g:65:6: SEMPRED // PDABytecodeTriggers.g:65:6: SEMPRED
{ {
SEMPRED2=(GrammarAST)match(input,SEMPRED,FOLLOW_SEMPRED_in_element266); SEMPRED2=(GrammarAST)match(input,SEMPRED,FOLLOW_SEMPRED_in_element266);
emit(new SemPredInstr(SEMPRED2.token)); emit(new SemPredInstr(SEMPRED2.token));
@ -478,7 +478,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 6 : case 6 :
// NFABytecodeTriggers.g:66:4: GATED_SEMPRED // PDABytecodeTriggers.g:66:4: GATED_SEMPRED
{ {
GATED_SEMPRED3=(GrammarAST)match(input,GATED_SEMPRED,FOLLOW_GATED_SEMPRED_in_element277); GATED_SEMPRED3=(GrammarAST)match(input,GATED_SEMPRED,FOLLOW_GATED_SEMPRED_in_element277);
emit(new SemPredInstr(GATED_SEMPRED3.token)); emit(new SemPredInstr(GATED_SEMPRED3.token));
@ -486,7 +486,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 7 : case 7 :
// NFABytecodeTriggers.g:67:4: treeSpec // PDABytecodeTriggers.g:67:4: treeSpec
{ {
pushFollow(FOLLOW_treeSpec_in_element284); pushFollow(FOLLOW_treeSpec_in_element284);
treeSpec(); treeSpec();
@ -511,17 +511,17 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
// $ANTLR start "labeledElement" // $ANTLR start "labeledElement"
// NFABytecodeTriggers.g:70:1: labeledElement : ( ^( ASSIGN ID atom ) | ^( ASSIGN ID block ) | ^( PLUS_ASSIGN ID atom ) | ^( PLUS_ASSIGN ID block ) ); // PDABytecodeTriggers.g:70:1: labeledElement : ( ^( ASSIGN ID atom ) | ^( ASSIGN ID block ) | ^( PLUS_ASSIGN ID atom ) | ^( PLUS_ASSIGN ID block ) );
public final void labeledElement() throws RecognitionException { public final void labeledElement() throws RecognitionException {
GrammarAST ID4=null; GrammarAST ID4=null;
try { try {
// NFABytecodeTriggers.g:71:2: ( ^( ASSIGN ID atom ) | ^( ASSIGN ID block ) | ^( PLUS_ASSIGN ID atom ) | ^( PLUS_ASSIGN ID block ) ) // PDABytecodeTriggers.g:71:2: ( ^( ASSIGN ID atom ) | ^( ASSIGN ID block ) | ^( PLUS_ASSIGN ID atom ) | ^( PLUS_ASSIGN ID block ) )
int alt7=4; int alt7=4;
alt7 = dfa7.predict(input); alt7 = dfa7.predict(input);
switch (alt7) { switch (alt7) {
case 1 : case 1 :
// NFABytecodeTriggers.g:71:4: ^( ASSIGN ID atom ) // PDABytecodeTriggers.g:71:4: ^( ASSIGN ID atom )
{ {
match(input,ASSIGN,FOLLOW_ASSIGN_in_labeledElement302); match(input,ASSIGN,FOLLOW_ASSIGN_in_labeledElement302);
@ -540,7 +540,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 2 : case 2 :
// NFABytecodeTriggers.g:72:4: ^( ASSIGN ID block ) // PDABytecodeTriggers.g:72:4: ^( ASSIGN ID block )
{ {
match(input,ASSIGN,FOLLOW_ASSIGN_in_labeledElement318); match(input,ASSIGN,FOLLOW_ASSIGN_in_labeledElement318);
@ -557,7 +557,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 3 : case 3 :
// NFABytecodeTriggers.g:73:4: ^( PLUS_ASSIGN ID atom ) // PDABytecodeTriggers.g:73:4: ^( PLUS_ASSIGN ID atom )
{ {
match(input,PLUS_ASSIGN,FOLLOW_PLUS_ASSIGN_in_labeledElement332); match(input,PLUS_ASSIGN,FOLLOW_PLUS_ASSIGN_in_labeledElement332);
@ -574,7 +574,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 4 : case 4 :
// NFABytecodeTriggers.g:74:4: ^( PLUS_ASSIGN ID block ) // PDABytecodeTriggers.g:74:4: ^( PLUS_ASSIGN ID block )
{ {
match(input,PLUS_ASSIGN,FOLLOW_PLUS_ASSIGN_in_labeledElement345); match(input,PLUS_ASSIGN,FOLLOW_PLUS_ASSIGN_in_labeledElement345);
@ -605,16 +605,16 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
// $ANTLR start "treeSpec" // $ANTLR start "treeSpec"
// NFABytecodeTriggers.g:77:1: treeSpec : ^( TREE_BEGIN (e= element )+ ) ; // PDABytecodeTriggers.g:77:1: treeSpec : ^( TREE_BEGIN (e= element )+ ) ;
public final void treeSpec() throws RecognitionException { public final void treeSpec() throws RecognitionException {
try { try {
// NFABytecodeTriggers.g:78:5: ( ^( TREE_BEGIN (e= element )+ ) ) // PDABytecodeTriggers.g:78:5: ( ^( TREE_BEGIN (e= element )+ ) )
// NFABytecodeTriggers.g:78:7: ^( TREE_BEGIN (e= element )+ ) // PDABytecodeTriggers.g:78:7: ^( TREE_BEGIN (e= element )+ )
{ {
match(input,TREE_BEGIN,FOLLOW_TREE_BEGIN_in_treeSpec367); match(input,TREE_BEGIN,FOLLOW_TREE_BEGIN_in_treeSpec367);
match(input, Token.DOWN, null); match(input, Token.DOWN, null);
// NFABytecodeTriggers.g:78:21: (e= element )+ // PDABytecodeTriggers.g:78:21: (e= element )+
int cnt8=0; int cnt8=0;
loop8: loop8:
do { do {
@ -628,7 +628,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
switch (alt8) { switch (alt8) {
case 1 : case 1 :
// NFABytecodeTriggers.g:78:22: e= element // PDABytecodeTriggers.g:78:22: e= element
{ {
pushFollow(FOLLOW_element_in_treeSpec373); pushFollow(FOLLOW_element_in_treeSpec373);
element(); element();
@ -668,9 +668,9 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
}; };
// $ANTLR start "ebnf" // $ANTLR start "ebnf"
// NFABytecodeTriggers.g:81:1: ebnf : ( ^( astBlockSuffix block ) | ^( OPTIONAL block ) | ^( CLOSURE block ) | ^( POSITIVE_CLOSURE block ) | block ); // PDABytecodeTriggers.g:81:1: ebnf : ( ^( astBlockSuffix block ) | ^( OPTIONAL block ) | ^( CLOSURE block ) | ^( POSITIVE_CLOSURE block ) | block );
public final NFABytecodeTriggers.ebnf_return ebnf() throws RecognitionException { public final PDABytecodeTriggers.ebnf_return ebnf() throws RecognitionException {
NFABytecodeTriggers.ebnf_return retval = new NFABytecodeTriggers.ebnf_return(); PDABytecodeTriggers.ebnf_return retval = new PDABytecodeTriggers.ebnf_return();
retval.start = input.LT(1); retval.start = input.LT(1);
@ -678,7 +678,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
String greedyOption = blk.getOption("greedy"); String greedyOption = blk.getOption("greedy");
try { try {
// NFABytecodeTriggers.g:86:2: ( ^( astBlockSuffix block ) | ^( OPTIONAL block ) | ^( CLOSURE block ) | ^( POSITIVE_CLOSURE block ) | block ) // PDABytecodeTriggers.g:86:2: ( ^( astBlockSuffix block ) | ^( OPTIONAL block ) | ^( CLOSURE block ) | ^( POSITIVE_CLOSURE block ) | block )
int alt9=5; int alt9=5;
switch ( input.LA(1) ) { switch ( input.LA(1) ) {
case IMPLIES: case IMPLIES:
@ -717,7 +717,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
switch (alt9) { switch (alt9) {
case 1 : case 1 :
// NFABytecodeTriggers.g:86:4: ^( astBlockSuffix block ) // PDABytecodeTriggers.g:86:4: ^( astBlockSuffix block )
{ {
pushFollow(FOLLOW_astBlockSuffix_in_ebnf398); pushFollow(FOLLOW_astBlockSuffix_in_ebnf398);
astBlockSuffix(); astBlockSuffix();
@ -737,12 +737,12 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 2 : case 2 :
// NFABytecodeTriggers.g:87:4: ^( OPTIONAL block ) // PDABytecodeTriggers.g:87:4: ^( OPTIONAL block )
{ {
SplitInstr S = new SplitInstr(2); SplitInstr S = new SplitInstr(2);
emit(S); emit(S);
S.addrs.add(ip); S.addrs.add(pda.ip);
match(input,OPTIONAL,FOLLOW_OPTIONAL_in_ebnf413); match(input,OPTIONAL,FOLLOW_OPTIONAL_in_ebnf413);
@ -755,19 +755,19 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
match(input, Token.UP, null); match(input, Token.UP, null);
S.addrs.add(ip); S.addrs.add(pda.ip);
} }
break; break;
case 3 : case 3 :
// NFABytecodeTriggers.g:96:4: ^( CLOSURE block ) // PDABytecodeTriggers.g:96:4: ^( CLOSURE block )
{ {
int start=ip; int start=pda.ip;
SplitInstr S = new SplitInstr(2); SplitInstr S = new SplitInstr(2);
emit(S); emit(S);
int blkStart = ip; int blkStart = pda.ip;
match(input,CLOSURE,FOLLOW_CLOSURE_in_ebnf433); match(input,CLOSURE,FOLLOW_CLOSURE_in_ebnf433);
@ -784,16 +784,16 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
emit(J); emit(J);
J.target = start; J.target = start;
S.addrs.add(blkStart); S.addrs.add(blkStart);
S.addrs.add(ip); S.addrs.add(pda.ip);
if ( greedyOption!=null && greedyOption.equals("false") ) Collections.reverse(S.addrs); if ( greedyOption!=null && greedyOption.equals("false") ) Collections.reverse(S.addrs);
} }
break; break;
case 4 : case 4 :
// NFABytecodeTriggers.g:111:4: ^( POSITIVE_CLOSURE block ) // PDABytecodeTriggers.g:111:4: ^( POSITIVE_CLOSURE block )
{ {
int start=ip; int start=pda.ip;
match(input,POSITIVE_CLOSURE,FOLLOW_POSITIVE_CLOSURE_in_ebnf451); match(input,POSITIVE_CLOSURE,FOLLOW_POSITIVE_CLOSURE_in_ebnf451);
match(input, Token.DOWN, null); match(input, Token.DOWN, null);
@ -807,7 +807,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
SplitInstr S = new SplitInstr(2); SplitInstr S = new SplitInstr(2);
emit(S); emit(S);
int stop = ip; int stop = pda.ip;
S.addrs.add(start); S.addrs.add(start);
S.addrs.add(stop); S.addrs.add(stop);
if ( greedyOption!=null && greedyOption.equals("false") ) Collections.reverse(S.addrs); if ( greedyOption!=null && greedyOption.equals("false") ) Collections.reverse(S.addrs);
@ -816,7 +816,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 5 : case 5 :
// NFABytecodeTriggers.g:120:5: block // PDABytecodeTriggers.g:120:5: block
{ {
pushFollow(FOLLOW_block_in_ebnf464); pushFollow(FOLLOW_block_in_ebnf464);
block(); block();
@ -841,11 +841,11 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
// $ANTLR start "astBlockSuffix" // $ANTLR start "astBlockSuffix"
// NFABytecodeTriggers.g:123:1: astBlockSuffix : ( ROOT | IMPLIES | BANG ); // PDABytecodeTriggers.g:123:1: astBlockSuffix : ( ROOT | IMPLIES | BANG );
public final void astBlockSuffix() throws RecognitionException { public final void astBlockSuffix() throws RecognitionException {
try { try {
// NFABytecodeTriggers.g:124:5: ( ROOT | IMPLIES | BANG ) // PDABytecodeTriggers.g:124:5: ( ROOT | IMPLIES | BANG )
// NFABytecodeTriggers.g: // PDABytecodeTriggers.g:
{ {
if ( input.LA(1)==IMPLIES||input.LA(1)==BANG||input.LA(1)==ROOT ) { if ( input.LA(1)==IMPLIES||input.LA(1)==BANG||input.LA(1)==ROOT ) {
input.consume(); input.consume();
@ -872,18 +872,18 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
// $ANTLR start "atom" // $ANTLR start "atom"
// NFABytecodeTriggers.g:129:1: atom : ( ^( ROOT range ) | ^( BANG range ) | ^( ROOT notSet ) | ^( BANG notSet ) | notSet | range | ^( DOT ID terminal ) | ^( DOT ID ruleref ) | ^( WILDCARD . ) | WILDCARD | terminal | ruleref ); // PDABytecodeTriggers.g:129:1: atom : ( ^( ROOT range ) | ^( BANG range ) | ^( ROOT notSet ) | ^( BANG notSet ) | notSet | range | ^( DOT ID terminal ) | ^( DOT ID ruleref ) | ^( WILDCARD . ) | WILDCARD | terminal | ruleref );
public final void atom() throws RecognitionException { public final void atom() throws RecognitionException {
GrammarAST WILDCARD5=null; GrammarAST WILDCARD5=null;
GrammarAST WILDCARD6=null; GrammarAST WILDCARD6=null;
try { try {
// NFABytecodeTriggers.g:130:2: ( ^( ROOT range ) | ^( BANG range ) | ^( ROOT notSet ) | ^( BANG notSet ) | notSet | range | ^( DOT ID terminal ) | ^( DOT ID ruleref ) | ^( WILDCARD . ) | WILDCARD | terminal | ruleref ) // PDABytecodeTriggers.g:130:2: ( ^( ROOT range ) | ^( BANG range ) | ^( ROOT notSet ) | ^( BANG notSet ) | notSet | range | ^( DOT ID terminal ) | ^( DOT ID ruleref ) | ^( WILDCARD . ) | WILDCARD | terminal | ruleref )
int alt10=12; int alt10=12;
alt10 = dfa10.predict(input); alt10 = dfa10.predict(input);
switch (alt10) { switch (alt10) {
case 1 : case 1 :
// NFABytecodeTriggers.g:130:4: ^( ROOT range ) // PDABytecodeTriggers.g:130:4: ^( ROOT range )
{ {
match(input,ROOT,FOLLOW_ROOT_in_atom518); match(input,ROOT,FOLLOW_ROOT_in_atom518);
@ -899,7 +899,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 2 : case 2 :
// NFABytecodeTriggers.g:131:4: ^( BANG range ) // PDABytecodeTriggers.g:131:4: ^( BANG range )
{ {
match(input,BANG,FOLLOW_BANG_in_atom530); match(input,BANG,FOLLOW_BANG_in_atom530);
@ -915,7 +915,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 3 : case 3 :
// NFABytecodeTriggers.g:132:4: ^( ROOT notSet ) // PDABytecodeTriggers.g:132:4: ^( ROOT notSet )
{ {
match(input,ROOT,FOLLOW_ROOT_in_atom542); match(input,ROOT,FOLLOW_ROOT_in_atom542);
@ -931,7 +931,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 4 : case 4 :
// NFABytecodeTriggers.g:133:4: ^( BANG notSet ) // PDABytecodeTriggers.g:133:4: ^( BANG notSet )
{ {
match(input,BANG,FOLLOW_BANG_in_atom554); match(input,BANG,FOLLOW_BANG_in_atom554);
@ -947,7 +947,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 5 : case 5 :
// NFABytecodeTriggers.g:134:4: notSet // PDABytecodeTriggers.g:134:4: notSet
{ {
pushFollow(FOLLOW_notSet_in_atom565); pushFollow(FOLLOW_notSet_in_atom565);
notSet(); notSet();
@ -958,7 +958,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 6 : case 6 :
// NFABytecodeTriggers.g:135:4: range // PDABytecodeTriggers.g:135:4: range
{ {
pushFollow(FOLLOW_range_in_atom575); pushFollow(FOLLOW_range_in_atom575);
range(); range();
@ -969,7 +969,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 7 : case 7 :
// NFABytecodeTriggers.g:136:4: ^( DOT ID terminal ) // PDABytecodeTriggers.g:136:4: ^( DOT ID terminal )
{ {
match(input,DOT,FOLLOW_DOT_in_atom586); match(input,DOT,FOLLOW_DOT_in_atom586);
@ -986,7 +986,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 8 : case 8 :
// NFABytecodeTriggers.g:137:4: ^( DOT ID ruleref ) // PDABytecodeTriggers.g:137:4: ^( DOT ID ruleref )
{ {
match(input,DOT,FOLLOW_DOT_in_atom599); match(input,DOT,FOLLOW_DOT_in_atom599);
@ -1003,7 +1003,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 9 : case 9 :
// NFABytecodeTriggers.g:138:7: ^( WILDCARD . ) // PDABytecodeTriggers.g:138:7: ^( WILDCARD . )
{ {
WILDCARD5=(GrammarAST)match(input,WILDCARD,FOLLOW_WILDCARD_in_atom615); WILDCARD5=(GrammarAST)match(input,WILDCARD,FOLLOW_WILDCARD_in_atom615);
@ -1016,7 +1016,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 10 : case 10 :
// NFABytecodeTriggers.g:139:7: WILDCARD // PDABytecodeTriggers.g:139:7: WILDCARD
{ {
WILDCARD6=(GrammarAST)match(input,WILDCARD,FOLLOW_WILDCARD_in_atom631); WILDCARD6=(GrammarAST)match(input,WILDCARD,FOLLOW_WILDCARD_in_atom631);
emit(new WildcardInstr(WILDCARD6.token)); emit(new WildcardInstr(WILDCARD6.token));
@ -1024,7 +1024,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 11 : case 11 :
// NFABytecodeTriggers.g:140:9: terminal // PDABytecodeTriggers.g:140:9: terminal
{ {
pushFollow(FOLLOW_terminal_in_atom646); pushFollow(FOLLOW_terminal_in_atom646);
terminal(); terminal();
@ -1035,7 +1035,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 12 : case 12 :
// NFABytecodeTriggers.g:141:9: ruleref // PDABytecodeTriggers.g:141:9: ruleref
{ {
pushFollow(FOLLOW_ruleref_in_atom660); pushFollow(FOLLOW_ruleref_in_atom660);
ruleref(); ruleref();
@ -1060,10 +1060,10 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
// $ANTLR start "notSet" // $ANTLR start "notSet"
// NFABytecodeTriggers.g:144:1: notSet : ( ^( NOT terminal ) | ^( NOT block ) ); // PDABytecodeTriggers.g:144:1: notSet : ( ^( NOT terminal ) | ^( NOT block ) );
public final void notSet() throws RecognitionException { public final void notSet() throws RecognitionException {
try { try {
// NFABytecodeTriggers.g:145:5: ( ^( NOT terminal ) | ^( NOT block ) ) // PDABytecodeTriggers.g:145:5: ( ^( NOT terminal ) | ^( NOT block ) )
int alt11=2; int alt11=2;
int LA11_0 = input.LA(1); int LA11_0 = input.LA(1);
@ -1101,7 +1101,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
switch (alt11) { switch (alt11) {
case 1 : case 1 :
// NFABytecodeTriggers.g:145:7: ^( NOT terminal ) // PDABytecodeTriggers.g:145:7: ^( NOT terminal )
{ {
match(input,NOT,FOLLOW_NOT_in_notSet683); match(input,NOT,FOLLOW_NOT_in_notSet683);
@ -1117,7 +1117,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 2 : case 2 :
// NFABytecodeTriggers.g:146:7: ^( NOT block ) // PDABytecodeTriggers.g:146:7: ^( NOT block )
{ {
match(input,NOT,FOLLOW_NOT_in_notSet697); match(input,NOT,FOLLOW_NOT_in_notSet697);
@ -1147,10 +1147,10 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
// $ANTLR start "ruleref" // $ANTLR start "ruleref"
// NFABytecodeTriggers.g:149:1: ruleref : ( ^( ROOT ^( RULE_REF ( ARG_ACTION )? ) ) | ^( BANG ^( RULE_REF ( ARG_ACTION )? ) ) | ^( RULE_REF ( ARG_ACTION )? ) ); // PDABytecodeTriggers.g:149:1: ruleref : ( ^( ROOT ^( RULE_REF ( ARG_ACTION )? ) ) | ^( BANG ^( RULE_REF ( ARG_ACTION )? ) ) | ^( RULE_REF ( ARG_ACTION )? ) );
public final void ruleref() throws RecognitionException { public final void ruleref() throws RecognitionException {
try { try {
// NFABytecodeTriggers.g:150:5: ( ^( ROOT ^( RULE_REF ( ARG_ACTION )? ) ) | ^( BANG ^( RULE_REF ( ARG_ACTION )? ) ) | ^( RULE_REF ( ARG_ACTION )? ) ) // PDABytecodeTriggers.g:150:5: ( ^( ROOT ^( RULE_REF ( ARG_ACTION )? ) ) | ^( BANG ^( RULE_REF ( ARG_ACTION )? ) ) | ^( RULE_REF ( ARG_ACTION )? ) )
int alt15=3; int alt15=3;
switch ( input.LA(1) ) { switch ( input.LA(1) ) {
case ROOT: case ROOT:
@ -1177,7 +1177,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
switch (alt15) { switch (alt15) {
case 1 : case 1 :
// NFABytecodeTriggers.g:150:7: ^( ROOT ^( RULE_REF ( ARG_ACTION )? ) ) // PDABytecodeTriggers.g:150:7: ^( ROOT ^( RULE_REF ( ARG_ACTION )? ) )
{ {
match(input,ROOT,FOLLOW_ROOT_in_ruleref721); match(input,ROOT,FOLLOW_ROOT_in_ruleref721);
@ -1186,7 +1186,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
if ( input.LA(1)==Token.DOWN ) { if ( input.LA(1)==Token.DOWN ) {
match(input, Token.DOWN, null); match(input, Token.DOWN, null);
// NFABytecodeTriggers.g:150:25: ( ARG_ACTION )? // PDABytecodeTriggers.g:150:25: ( ARG_ACTION )?
int alt12=2; int alt12=2;
int LA12_0 = input.LA(1); int LA12_0 = input.LA(1);
@ -1195,7 +1195,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
switch (alt12) { switch (alt12) {
case 1 : case 1 :
// NFABytecodeTriggers.g:150:25: ARG_ACTION // PDABytecodeTriggers.g:150:25: ARG_ACTION
{ {
match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_ruleref726); match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_ruleref726);
@ -1213,7 +1213,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 2 : case 2 :
// NFABytecodeTriggers.g:151:7: ^( BANG ^( RULE_REF ( ARG_ACTION )? ) ) // PDABytecodeTriggers.g:151:7: ^( BANG ^( RULE_REF ( ARG_ACTION )? ) )
{ {
match(input,BANG,FOLLOW_BANG_in_ruleref739); match(input,BANG,FOLLOW_BANG_in_ruleref739);
@ -1222,7 +1222,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
if ( input.LA(1)==Token.DOWN ) { if ( input.LA(1)==Token.DOWN ) {
match(input, Token.DOWN, null); match(input, Token.DOWN, null);
// NFABytecodeTriggers.g:151:25: ( ARG_ACTION )? // PDABytecodeTriggers.g:151:25: ( ARG_ACTION )?
int alt13=2; int alt13=2;
int LA13_0 = input.LA(1); int LA13_0 = input.LA(1);
@ -1231,7 +1231,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
switch (alt13) { switch (alt13) {
case 1 : case 1 :
// NFABytecodeTriggers.g:151:25: ARG_ACTION // PDABytecodeTriggers.g:151:25: ARG_ACTION
{ {
match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_ruleref744); match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_ruleref744);
@ -1249,13 +1249,13 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 3 : case 3 :
// NFABytecodeTriggers.g:152:7: ^( RULE_REF ( ARG_ACTION )? ) // PDABytecodeTriggers.g:152:7: ^( RULE_REF ( ARG_ACTION )? )
{ {
match(input,RULE_REF,FOLLOW_RULE_REF_in_ruleref757); match(input,RULE_REF,FOLLOW_RULE_REF_in_ruleref757);
if ( input.LA(1)==Token.DOWN ) { if ( input.LA(1)==Token.DOWN ) {
match(input, Token.DOWN, null); match(input, Token.DOWN, null);
// NFABytecodeTriggers.g:152:18: ( ARG_ACTION )? // PDABytecodeTriggers.g:152:18: ( ARG_ACTION )?
int alt14=2; int alt14=2;
int LA14_0 = input.LA(1); int LA14_0 = input.LA(1);
@ -1264,7 +1264,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
switch (alt14) { switch (alt14) {
case 1 : case 1 :
// NFABytecodeTriggers.g:152:18: ARG_ACTION // PDABytecodeTriggers.g:152:18: ARG_ACTION
{ {
match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_ruleref759); match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_ruleref759);
@ -1294,14 +1294,14 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
// $ANTLR start "range" // $ANTLR start "range"
// NFABytecodeTriggers.g:155:1: range : ^( RANGE a= STRING_LITERAL b= STRING_LITERAL ) ; // PDABytecodeTriggers.g:155:1: range : ^( RANGE a= STRING_LITERAL b= STRING_LITERAL ) ;
public final void range() throws RecognitionException { public final void range() throws RecognitionException {
GrammarAST a=null; GrammarAST a=null;
GrammarAST b=null; GrammarAST b=null;
try { try {
// NFABytecodeTriggers.g:156:5: ( ^( RANGE a= STRING_LITERAL b= STRING_LITERAL ) ) // PDABytecodeTriggers.g:156:5: ( ^( RANGE a= STRING_LITERAL b= STRING_LITERAL ) )
// NFABytecodeTriggers.g:156:7: ^( RANGE a= STRING_LITERAL b= STRING_LITERAL ) // PDABytecodeTriggers.g:156:7: ^( RANGE a= STRING_LITERAL b= STRING_LITERAL )
{ {
match(input,RANGE,FOLLOW_RANGE_in_range782); match(input,RANGE,FOLLOW_RANGE_in_range782);
@ -1327,7 +1327,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
// $ANTLR start "terminal" // $ANTLR start "terminal"
// NFABytecodeTriggers.g:160:1: terminal : ( ^( STRING_LITERAL . ) | STRING_LITERAL | ^( TOKEN_REF ARG_ACTION . ) | ^( TOKEN_REF . ) | TOKEN_REF | ^( ROOT terminal ) | ^( BANG terminal ) ); // PDABytecodeTriggers.g:160:1: terminal : ( ^( STRING_LITERAL . ) | STRING_LITERAL | ^( TOKEN_REF ARG_ACTION . ) | ^( TOKEN_REF . ) | TOKEN_REF | ^( ROOT terminal ) | ^( BANG terminal ) );
public final void terminal() throws RecognitionException { public final void terminal() throws RecognitionException {
GrammarAST STRING_LITERAL7=null; GrammarAST STRING_LITERAL7=null;
GrammarAST STRING_LITERAL8=null; GrammarAST STRING_LITERAL8=null;
@ -1336,12 +1336,12 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
GrammarAST TOKEN_REF11=null; GrammarAST TOKEN_REF11=null;
try { try {
// NFABytecodeTriggers.g:161:5: ( ^( STRING_LITERAL . ) | STRING_LITERAL | ^( TOKEN_REF ARG_ACTION . ) | ^( TOKEN_REF . ) | TOKEN_REF | ^( ROOT terminal ) | ^( BANG terminal ) ) // PDABytecodeTriggers.g:161:5: ( ^( STRING_LITERAL . ) | STRING_LITERAL | ^( TOKEN_REF ARG_ACTION . ) | ^( TOKEN_REF . ) | TOKEN_REF | ^( ROOT terminal ) | ^( BANG terminal ) )
int alt16=7; int alt16=7;
alt16 = dfa16.predict(input); alt16 = dfa16.predict(input);
switch (alt16) { switch (alt16) {
case 1 : case 1 :
// NFABytecodeTriggers.g:161:8: ^( STRING_LITERAL . ) // PDABytecodeTriggers.g:161:8: ^( STRING_LITERAL . )
{ {
STRING_LITERAL7=(GrammarAST)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_terminal817); STRING_LITERAL7=(GrammarAST)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_terminal817);
@ -1354,7 +1354,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 2 : case 2 :
// NFABytecodeTriggers.g:162:7: STRING_LITERAL // PDABytecodeTriggers.g:162:7: STRING_LITERAL
{ {
STRING_LITERAL8=(GrammarAST)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_terminal832); STRING_LITERAL8=(GrammarAST)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_terminal832);
emitString(STRING_LITERAL8.token); emitString(STRING_LITERAL8.token);
@ -1362,7 +1362,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 3 : case 3 :
// NFABytecodeTriggers.g:163:7: ^( TOKEN_REF ARG_ACTION . ) // PDABytecodeTriggers.g:163:7: ^( TOKEN_REF ARG_ACTION . )
{ {
TOKEN_REF9=(GrammarAST)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_terminal846); TOKEN_REF9=(GrammarAST)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_terminal846);
@ -1376,7 +1376,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 4 : case 4 :
// NFABytecodeTriggers.g:164:7: ^( TOKEN_REF . ) // PDABytecodeTriggers.g:164:7: ^( TOKEN_REF . )
{ {
TOKEN_REF10=(GrammarAST)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_terminal862); TOKEN_REF10=(GrammarAST)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_terminal862);
@ -1389,7 +1389,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 5 : case 5 :
// NFABytecodeTriggers.g:165:7: TOKEN_REF // PDABytecodeTriggers.g:165:7: TOKEN_REF
{ {
TOKEN_REF11=(GrammarAST)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_terminal878); TOKEN_REF11=(GrammarAST)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_terminal878);
emit(new CallInstr(TOKEN_REF11.token)); emit(new CallInstr(TOKEN_REF11.token));
@ -1397,7 +1397,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 6 : case 6 :
// NFABytecodeTriggers.g:166:7: ^( ROOT terminal ) // PDABytecodeTriggers.g:166:7: ^( ROOT terminal )
{ {
match(input,ROOT,FOLLOW_ROOT_in_terminal893); match(input,ROOT,FOLLOW_ROOT_in_terminal893);
@ -1413,7 +1413,7 @@ public class NFABytecodeTriggers extends NFABytecodeGenerator {
} }
break; break;
case 7 : case 7 :
// NFABytecodeTriggers.g:167:7: ^( BANG terminal ) // PDABytecodeTriggers.g:167:7: ^( BANG terminal )
{ {
match(input,BANG,FOLLOW_BANG_in_terminal908); match(input,BANG,FOLLOW_BANG_in_terminal908);

View File

@ -0,0 +1,99 @@
COMBINED=91
LT=44
STAR=49
BACKTRACK_SEMPRED=96
DOUBLE_ANGLE_STRING_LITERAL=11
FORCED_ACTION=5
ARGLIST=89
ALTLIST=86
NOT=61
SEMPRED=4
ACTION=16
TOKEN_REF=63
RULEMODIFIERS=75
ST_RESULT=100
RPAREN=42
RET=90
IMPORT=22
STRING_LITERAL=68
ARG=88
ARG_ACTION=14
DOUBLE_QUOTE_STRING_LITERAL=10
COMMENT=9
ACTION_CHAR_LITERAL=13
GRAMMAR=27
RULEACTIONS=76
WSCHARS=66
INITACTION=92
ALT_REWRITE=102
IMPLIES=43
RULE=73
RBRACE=62
ACTION_ESC=17
PRIVATE=30
SRC=7
THROWS=32
CHAR_RANGE=83
INT=65
EPSILON=84
LIST=98
COLONCOLON=38
WSNLCHARS=18
WS=71
LEXER=24
OR=52
GT=45
CATCH=33
CLOSURE=80
PARSER=25
DOLLAR=54
PROTECTED=28
ELEMENT_OPTIONS=99
NESTED_ACTION=15
FRAGMENT=23
ID=87
TREE_BEGIN=59
LPAREN=41
AT=60
ESC_SEQ=67
ALT=85
TREE=26
SCOPE=21
ETC=57
COMMA=39
WILDCARD=97
DOC_COMMENT=6
PLUS=50
REWRITE_BLOCK=78
DOT=55
MODE=36
RETURNS=31
RULES=74
RARROW=58
UNICODE_ESC=70
HEX_DIGIT=69
RANGE=56
TOKENS=20
RESULT=101
GATED_SEMPRED=94
BANG=48
ACTION_STRING_LITERAL=12
ROOT=53
SEMI=40
RULE_REF=64
NLCHARS=8
OPTIONAL=79
SYNPRED=82
COLON=37
QUESTION=47
FINALLY=34
TEMPLATE=35
LABEL=93
SYN_SEMPRED=95
ERRCHAR=72
BLOCK=77
ASSIGN=46
PLUS_ASSIGN=51
PUBLIC=29
POSITIVE_CLOSURE=81
OPTIONS=19

View File

@ -1,6 +1,6 @@
package org.antlr.v4.codegen.nfa; package org.antlr.v4.codegen.pda;
import org.antlr.v4.codegen.NFABytecodeGenerator; import org.antlr.v4.codegen.PDABytecodeGenerator;
import org.antlr.v4.runtime.pda.Bytecode; import org.antlr.v4.runtime.pda.Bytecode;
/** */ /** */
@ -13,7 +13,7 @@ public class AcceptInstr extends Instr {
public int nBytes() { return 1+2; } public int nBytes() { return 1+2; }
public void write(byte[] code) { public void write(byte[] code) {
super.write(code); super.write(code);
NFABytecodeGenerator.writeShort(code, addr+1, (short)ruleIndex); PDABytecodeGenerator.writeShort(code, addr+1, (short)ruleIndex);
} }
public String toString() { return addr+":AcceptInstr "+ruleIndex; } public String toString() { return addr+":AcceptInstr "+ruleIndex; }
} }

View File

@ -1,7 +1,7 @@
package org.antlr.v4.codegen.nfa; package org.antlr.v4.codegen.pda;
import org.antlr.runtime.Token; import org.antlr.runtime.Token;
import org.antlr.v4.codegen.NFABytecodeGenerator; import org.antlr.v4.codegen.PDABytecodeGenerator;
import org.antlr.v4.runtime.pda.Bytecode; import org.antlr.v4.runtime.pda.Bytecode;
/** */ /** */
@ -15,8 +15,8 @@ public class ActionInstr extends Instr {
public int nBytes() { return 1+2*2; } public int nBytes() { return 1+2*2; }
public void write(byte[] code) { public void write(byte[] code) {
super.write(code); super.write(code);
NFABytecodeGenerator.writeShort(code, addr+1, (short)rule.index); PDABytecodeGenerator.writeShort(code, addr+1, (short)rule.index);
NFABytecodeGenerator.writeShort(code, addr+1+2, (short)gen.getActionIndex(rule, token)); PDABytecodeGenerator.writeShort(code, addr+1+2, (short)gen.getActionIndex(rule, token));
} }
public String toString() { return addr+":ActionInstr "+actionIndex; } public String toString() { return addr+":ActionInstr "+actionIndex; }
} }

View File

@ -1,7 +1,7 @@
package org.antlr.v4.codegen.nfa; package org.antlr.v4.codegen.pda;
import org.antlr.runtime.Token; import org.antlr.runtime.Token;
import org.antlr.v4.codegen.NFABytecodeGenerator; import org.antlr.v4.codegen.PDABytecodeGenerator;
import org.antlr.v4.runtime.pda.Bytecode; import org.antlr.v4.runtime.pda.Bytecode;
/** */ /** */
@ -13,7 +13,7 @@ public class CallInstr extends Instr {
public int nBytes() { return 1+Bytecode.ADDR_SIZE; } public int nBytes() { return 1+Bytecode.ADDR_SIZE; }
public void write(byte[] code) { public void write(byte[] code) {
super.write(code); super.write(code);
NFABytecodeGenerator.writeShort(code, addr+1, (short)target); PDABytecodeGenerator.writeShort(code, addr+1, (short)target);
} }
@Override @Override

View File

@ -1,13 +1,13 @@
package org.antlr.v4.codegen.nfa; package org.antlr.v4.codegen.pda;
import org.antlr.v4.codegen.NFABytecodeGenerator; import org.antlr.v4.codegen.PDABytecodeGenerator;
import org.antlr.v4.tool.Rule; import org.antlr.v4.tool.Rule;
/** */ /** */
public abstract class Instr { public abstract class Instr {
public int addr; public int addr;
public Rule rule; public Rule rule;
public NFABytecodeGenerator gen; public PDABytecodeGenerator gen;
public abstract short opcode(); public abstract short opcode();
public abstract int nBytes(); public abstract int nBytes();

View File

@ -1,6 +1,6 @@
package org.antlr.v4.codegen.nfa; package org.antlr.v4.codegen.pda;
import org.antlr.v4.codegen.NFABytecodeGenerator; import org.antlr.v4.codegen.PDABytecodeGenerator;
import org.antlr.v4.runtime.pda.Bytecode; import org.antlr.v4.runtime.pda.Bytecode;
/** */ /** */
@ -10,7 +10,7 @@ public class JumpInstr extends Instr {
public int nBytes() { return 1+Bytecode.ADDR_SIZE; } public int nBytes() { return 1+Bytecode.ADDR_SIZE; }
public void write(byte[] code) { public void write(byte[] code) {
super.write(code); super.write(code);
NFABytecodeGenerator.writeShort(code, addr+1, (short)target); PDABytecodeGenerator.writeShort(code, addr+1, (short)target);
} }
@Override @Override

View File

@ -1,7 +1,7 @@
package org.antlr.v4.codegen.nfa; package org.antlr.v4.codegen.pda;
import org.antlr.runtime.Token; import org.antlr.runtime.Token;
import org.antlr.v4.codegen.NFABytecodeGenerator; import org.antlr.v4.codegen.PDABytecodeGenerator;
import org.antlr.v4.runtime.pda.Bytecode; import org.antlr.v4.runtime.pda.Bytecode;
/** */ /** */
@ -16,7 +16,7 @@ public class LabelInstr extends Instr {
public void write(byte[] code) { public void write(byte[] code) {
super.write(code); super.write(code);
labelIndex = gen.getLabelIndex(rule, token.getText()); labelIndex = gen.getLabelIndex(rule, token.getText());
NFABytecodeGenerator.writeShort(code, addr+1, (short)labelIndex); PDABytecodeGenerator.writeShort(code, addr+1, (short)labelIndex);
} }
public String toString() { return addr+":LabelInstr "+ labelIndex; } public String toString() { return addr+":LabelInstr "+ labelIndex; }
} }

View File

@ -1,7 +1,7 @@
package org.antlr.v4.codegen.nfa; package org.antlr.v4.codegen.pda;
import org.antlr.runtime.Token; import org.antlr.runtime.Token;
import org.antlr.v4.codegen.NFABytecodeGenerator; import org.antlr.v4.codegen.PDABytecodeGenerator;
import org.antlr.v4.runtime.pda.Bytecode; import org.antlr.v4.runtime.pda.Bytecode;
/** */ /** */
@ -14,7 +14,7 @@ public class MatchInstr extends Instr {
public void write(byte[] code) { public void write(byte[] code) {
super.write(code); super.write(code);
if ( charSize(c)==1 ) code[addr+1] = (byte)(c&0xFF); if ( charSize(c)==1 ) code[addr+1] = (byte)(c&0xFF);
else NFABytecodeGenerator.writeShort(code, addr+1, (short)c); else PDABytecodeGenerator.writeShort(code, addr+1, (short)c);
} }
@Override @Override

View File

@ -1,7 +1,7 @@
package org.antlr.v4.codegen.nfa; package org.antlr.v4.codegen.pda;
import org.antlr.runtime.Token; import org.antlr.runtime.Token;
import org.antlr.v4.codegen.NFABytecodeGenerator; import org.antlr.v4.codegen.PDABytecodeGenerator;
import org.antlr.v4.misc.CharSupport; import org.antlr.v4.misc.CharSupport;
import org.antlr.v4.runtime.pda.Bytecode; import org.antlr.v4.runtime.pda.Bytecode;
@ -24,8 +24,8 @@ public class RangeInstr extends Instr {
code[addr+2] = (byte)(b&0xFF); code[addr+2] = (byte)(b&0xFF);
} }
else { else {
NFABytecodeGenerator.writeShort(code, addr+1, (short)a); PDABytecodeGenerator.writeShort(code, addr+1, (short)a);
NFABytecodeGenerator.writeShort(code, addr+1+charSize(a,b), (short)b); PDABytecodeGenerator.writeShort(code, addr+1+charSize(a,b), (short)b);
} }
} }

View File

@ -1,4 +1,4 @@
package org.antlr.v4.codegen.nfa; package org.antlr.v4.codegen.pda;
import org.antlr.v4.runtime.pda.Bytecode; import org.antlr.v4.runtime.pda.Bytecode;

View File

@ -1,7 +1,7 @@
package org.antlr.v4.codegen.nfa; package org.antlr.v4.codegen.pda;
import org.antlr.runtime.Token; import org.antlr.runtime.Token;
import org.antlr.v4.codegen.NFABytecodeGenerator; import org.antlr.v4.codegen.PDABytecodeGenerator;
import org.antlr.v4.runtime.pda.Bytecode; import org.antlr.v4.runtime.pda.Bytecode;
/** */ /** */
@ -16,7 +16,7 @@ public class SaveInstr extends Instr {
public void write(byte[] code) { public void write(byte[] code) {
super.write(code); super.write(code);
labelIndex = gen.getLabelIndex(rule, token.getText()); labelIndex = gen.getLabelIndex(rule, token.getText());
NFABytecodeGenerator.writeShort(code, addr+1, (short) labelIndex); PDABytecodeGenerator.writeShort(code, addr+1, (short) labelIndex);
} }
public String toString() { return addr+":SaveInstr "+ labelIndex; } public String toString() { return addr+":SaveInstr "+ labelIndex; }
} }

View File

@ -1,7 +1,7 @@
package org.antlr.v4.codegen.nfa; package org.antlr.v4.codegen.pda;
import org.antlr.runtime.Token; import org.antlr.runtime.Token;
import org.antlr.v4.codegen.NFABytecodeGenerator; import org.antlr.v4.codegen.PDABytecodeGenerator;
import org.antlr.v4.runtime.pda.Bytecode; import org.antlr.v4.runtime.pda.Bytecode;
/** */ /** */
@ -15,8 +15,8 @@ public class SemPredInstr extends Instr {
public int nBytes() { return 1+2*2; } public int nBytes() { return 1+2*2; }
public void write(byte[] code) { public void write(byte[] code) {
super.write(code); super.write(code);
NFABytecodeGenerator.writeShort(code, addr+1, (short)rule.index); PDABytecodeGenerator.writeShort(code, addr+1, (short)rule.index);
NFABytecodeGenerator.writeShort(code, addr+1+2, (short)gen.getSempredIndex(rule, token)); PDABytecodeGenerator.writeShort(code, addr+1+2, (short)gen.getSempredIndex(rule, token));
} }
public String toString() { return addr+":SemPredInstr "+ predIndex; } public String toString() { return addr+":SemPredInstr "+ predIndex; }
} }

View File

@ -1,6 +1,6 @@
package org.antlr.v4.codegen.nfa; package org.antlr.v4.codegen.pda;
import org.antlr.v4.codegen.NFABytecodeGenerator; import org.antlr.v4.codegen.PDABytecodeGenerator;
import org.antlr.v4.runtime.pda.Bytecode; import org.antlr.v4.runtime.pda.Bytecode;
import java.util.ArrayList; import java.util.ArrayList;
@ -16,10 +16,10 @@ public class SplitInstr extends Instr {
public void write(byte[] code) { public void write(byte[] code) {
super.write(code); super.write(code);
int a = addr + 1; int a = addr + 1;
NFABytecodeGenerator.writeShort(code, a, (short)addrs.size()); PDABytecodeGenerator.writeShort(code, a, (short)addrs.size());
a += 2; a += 2;
for (int x : addrs) { for (int x : addrs) {
NFABytecodeGenerator.writeShort(code, a, (short)x); PDABytecodeGenerator.writeShort(code, a, (short)x);
a += Bytecode.ADDR_SIZE; a += Bytecode.ADDR_SIZE;
} }
} }

View File

@ -1,4 +1,4 @@
package org.antlr.v4.codegen.nfa; package org.antlr.v4.codegen.pda;
import org.antlr.runtime.Token; import org.antlr.runtime.Token;
import org.antlr.v4.runtime.pda.Bytecode; import org.antlr.v4.runtime.pda.Bytecode;

View File

@ -1,20 +1,22 @@
package org.antlr.v4.misc; package org.antlr.v4.misc;
import java.util.HashMap; import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import java.util.Set;
/** Sometimes we need to map a key to a value but key is two pieces of data. /** Sometimes we need to map a key to a value but key is two pieces of data.
* This nested hash table saves creating a single key each time we access * This nested hash table saves creating a single key each time we access
* map; avoids mem creation. * map; avoids mem creation.
*/ */
public class DoubleKeyMap<Key1, Key2, Value> { public class DoubleKeyMap<Key1, Key2, Value> {
Map<Key1, Map<Key2, Value>> data = new HashMap<Key1, Map<Key2, Value>>(); Map<Key1, Map<Key2, Value>> data = new LinkedHashMap<Key1, Map<Key2, Value>>();
public Value put(Key1 k1, Key2 k2, Value v) { public Value put(Key1 k1, Key2 k2, Value v) {
Map<Key2, Value> data2 = data.get(k1); Map<Key2, Value> data2 = data.get(k1);
Value prev = null; Value prev = null;
if ( data2==null ) { if ( data2==null ) {
data2 = new HashMap<Key2, Value>(); data2 = new LinkedHashMap<Key2, Value>();
data.put(k1, data2); data.put(k1, data2);
} }
else { else {
@ -26,12 +28,28 @@ public class DoubleKeyMap<Key1, Key2, Value> {
public Value get(Key1 k1, Key2 k2) { public Value get(Key1 k1, Key2 k2) {
Map<Key2, Value> data2 = data.get(k1); Map<Key2, Value> data2 = data.get(k1);
if ( data2==null ) { if ( data2==null ) return null;
data2 = new HashMap<Key2, Value>();
data.put(k1, data2);
}
return data2.get(k2); return data2.get(k2);
} }
public Map<Key2, Value> get(Key1 k1) { return data.get(k1); } public Map<Key2, Value> get(Key1 k1) { return data.get(k1); }
/** Get all values associated with primary key */
public Collection<Value> values(Key1 k1) {
Map<Key2, Value> data2 = data.get(k1);
if ( data2==null ) return null;
return data2.values();
}
/** get all primary keys */
public Set<Key1> keySet() {
return data.keySet();
}
/** get all secondary keys associated with a primary key */
public Set<Key2> keySet(Key1 k1) {
Map<Key2, Value> data2 = data.get(k1);
if ( data2==null ) return null;
return data2.keySet();
}
} }

View File

@ -1,7 +1,7 @@
package org.antlr.v4.test; package org.antlr.v4.test;
import org.antlr.v4.Tool; import org.antlr.v4.Tool;
import org.antlr.v4.codegen.NFABytecodeGenerator; import org.antlr.v4.codegen.PDABytecodeGenerator;
import org.antlr.v4.runtime.pda.Bytecode; import org.antlr.v4.runtime.pda.Bytecode;
import org.antlr.v4.runtime.pda.PDA; import org.antlr.v4.runtime.pda.PDA;
import org.antlr.v4.semantics.SemanticPipeline; import org.antlr.v4.semantics.SemanticPipeline;
@ -9,7 +9,7 @@ import org.antlr.v4.tool.Grammar;
import org.antlr.v4.tool.LexerGrammar; import org.antlr.v4.tool.LexerGrammar;
import org.junit.Test; import org.junit.Test;
public class TestNFABytecodeGeneration extends BaseTest { public class TestPDABytecodeGeneration extends BaseTest {
@Test public void testString() throws Exception { @Test public void testString() throws Exception {
LexerGrammar g = new LexerGrammar( LexerGrammar g = new LexerGrammar(
"lexer grammar L;\n"+ "lexer grammar L;\n"+
@ -215,7 +215,7 @@ public class TestNFABytecodeGeneration extends BaseTest {
} }
} }
} }
PDA PDA = NFABytecodeGenerator.getBytecode(g, LexerGrammar.DEFAULT_MODE_NAME); PDA PDA = PDABytecodeGenerator.getPDA(g, LexerGrammar.DEFAULT_MODE_NAME);
assertEquals(expecting, Bytecode.disassemble(PDA.code)); assertEquals(expecting, Bytecode.disassemble(PDA.code));
} }
} }

View File

@ -3,7 +3,7 @@ package org.antlr.v4.test;
import org.antlr.runtime.ANTLRStringStream; import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.Token; import org.antlr.runtime.Token;
import org.antlr.v4.Tool; import org.antlr.v4.Tool;
import org.antlr.v4.codegen.NFABytecodeGenerator; import org.antlr.v4.codegen.PDABytecodeGenerator;
import org.antlr.v4.runtime.pda.PDA; import org.antlr.v4.runtime.pda.PDA;
import org.antlr.v4.semantics.SemanticPipeline; import org.antlr.v4.semantics.SemanticPipeline;
import org.antlr.v4.tool.Grammar; import org.antlr.v4.tool.Grammar;
@ -15,7 +15,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
/** */ /** */
public class TestNFABytecodeInterp extends BaseTest { public class TestPDABytecodeInterp extends BaseTest {
@Test public void testString() throws Exception { @Test public void testString() throws Exception {
LexerGrammar g = new LexerGrammar( LexerGrammar g = new LexerGrammar(
"lexer grammar L;\n"+ "lexer grammar L;\n"+
@ -202,7 +202,7 @@ public class TestNFABytecodeInterp extends BaseTest {
} }
} }
PDA PDA = NFABytecodeGenerator.getBytecode(g, LexerGrammar.DEFAULT_MODE_NAME); PDA PDA = PDABytecodeGenerator.getPDA(g, LexerGrammar.DEFAULT_MODE_NAME);
ANTLRStringStream in = new ANTLRStringStream(input); ANTLRStringStream in = new ANTLRStringStream(input);
List<Integer> tokenTypes = new ArrayList<Integer>(); List<Integer> tokenTypes = new ArrayList<Integer>();
int ttype = 0; int ttype = 0;
@ -236,7 +236,7 @@ public class TestNFABytecodeInterp extends BaseTest {
} }
} }
PDA PDA = NFABytecodeGenerator.getBytecode(g, LexerGrammar.DEFAULT_MODE_NAME); PDA PDA = PDABytecodeGenerator.getPDA(g, LexerGrammar.DEFAULT_MODE_NAME);
ANTLRStringStream in = new ANTLRStringStream(input); ANTLRStringStream in = new ANTLRStringStream(input);
List<Integer> tokenTypes = new ArrayList<Integer>(); List<Integer> tokenTypes = new ArrayList<Integer>();
int ttype = PDA.execThompson(in); int ttype = PDA.execThompson(in);