public LexerInterpreter(String grammarFileName, Vocabulary vocabulary, Collection<String> ruleNames, Collection<String> channelNames, Collection<String> modeNames, ATN atn, CharStream input) { super(input); if (atn.grammarType != ATNType.LEXER) { throw new IllegalArgumentException("The ATN must be a lexer ATN."); } this.grammarFileName = grammarFileName; this.atn = atn; this.tokenNames = new String[atn.maxTokenType]; for (int i = 0; i < tokenNames.length; i++) { tokenNames[i] = vocabulary.getDisplayName(i); } this.ruleNames = ruleNames.toArray(new String[ruleNames.size()]); this.channelNames = channelNames.toArray(new String[channelNames.size()]); this.modeNames = modeNames.toArray(new String[modeNames.size()]); this.vocabulary = vocabulary; this._decisionToDFA = new DFA[atn.getNumberOfDecisions()]; for (int i = 0; i < _decisionToDFA.length; i++) { _decisionToDFA[i] = new DFA(atn.getDecisionState(i), i); } this._interp = new LexerATNSimulator(this,atn,_decisionToDFA,_sharedContextCache); }
public ParserInterpreter(String grammarFileName, Vocabulary vocabulary, Collection<String> ruleNames, ATN atn, TokenStream input) { super(input); this.grammarFileName = grammarFileName; this.atn = atn; this.tokenNames = new String[atn.maxTokenType]; for (int i = 0; i < tokenNames.length; i++) { tokenNames[i] = vocabulary.getDisplayName(i); } this.ruleNames = ruleNames.toArray(new String[ruleNames.size()]); this.vocabulary = vocabulary; // init decision DFA int numberOfDecisions = atn.getNumberOfDecisions(); this.decisionToDFA = new DFA[numberOfDecisions]; for (int i = 0; i < numberOfDecisions; i++) { DecisionState decisionState = atn.getDecisionState(i); decisionToDFA[i] = new DFA(decisionState, i); } // get atn simulator that knows how to do predictions setInterpreter(new ParserATNSimulator(this, atn, decisionToDFA, sharedContextCache)); }
private DFA[] getDFA() { DFA[] result = new DFA[_ATN.getNumberOfDecisions()]; for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { result[i] = new DFA(_ATN.getDecisionState(i), i); } return result; } }
public LexerInterpreter(String grammarFileName, Vocabulary vocabulary, Collection<String> ruleNames, Collection<String> channelNames, Collection<String> modeNames, ATN atn, CharStream input) { super(input); if (atn.grammarType != ATNType.LEXER) { throw new IllegalArgumentException("The ATN must be a lexer ATN."); } this.grammarFileName = grammarFileName; this.atn = atn; this.tokenNames = new String[atn.maxTokenType]; for (int i = 0; i < tokenNames.length; i++) { tokenNames[i] = vocabulary.getDisplayName(i); } this.ruleNames = ruleNames.toArray(new String[ruleNames.size()]); this.channelNames = channelNames.toArray(new String[channelNames.size()]); this.modeNames = modeNames.toArray(new String[modeNames.size()]); this.vocabulary = vocabulary; this._decisionToDFA = new DFA[atn.getNumberOfDecisions()]; for (int i = 0; i < _decisionToDFA.length; i++) { _decisionToDFA[i] = new DFA(atn.getDecisionState(i), i); } this._interp = new LexerATNSimulator(this,atn,_decisionToDFA,_sharedContextCache); }
public LexerInterpreter(String grammarFileName, Vocabulary vocabulary, Collection<String> ruleNames, Collection<String> modeNames, ATN atn, CharStream input) { super(input); if (atn.grammarType != ATNType.LEXER) { throw new IllegalArgumentException("The ATN must be a lexer ATN."); } this.grammarFileName = grammarFileName; this.atn = atn; this.tokenNames = new String[atn.maxTokenType]; for (int i = 0; i < tokenNames.length; i++) { tokenNames[i] = vocabulary.getDisplayName(i); } this.ruleNames = ruleNames.toArray(new String[ruleNames.size()]); this.modeNames = modeNames.toArray(new String[modeNames.size()]); this.vocabulary = vocabulary; this._decisionToDFA = new DFA[atn.getNumberOfDecisions()]; for (int i = 0; i < _decisionToDFA.length; i++) { _decisionToDFA[i] = new DFA(atn.getDecisionState(i), i); } this._interp = new LexerATNSimulator(this,atn,_decisionToDFA,_sharedContextCache); }
public LexerInterpreter(String grammarFileName, Vocabulary vocabulary, Collection<String> ruleNames, Collection<String> modeNames, ATN atn, CharStream input) { super(input); if (atn.grammarType != ATNType.LEXER) { throw new IllegalArgumentException("The ATN must be a lexer ATN."); } this.grammarFileName = grammarFileName; this.atn = atn; this.tokenNames = new String[atn.maxTokenType]; for (int i = 0; i < tokenNames.length; i++) { tokenNames[i] = vocabulary.getDisplayName(i); } this.ruleNames = ruleNames.toArray(new String[ruleNames.size()]); this.modeNames = modeNames.toArray(new String[modeNames.size()]); this.vocabulary = vocabulary; this._decisionToDFA = new DFA[atn.getNumberOfDecisions()]; for (int i = 0; i < _decisionToDFA.length; i++) { _decisionToDFA[i] = new DFA(atn.getDecisionState(i), i); } this._interp = new LexerATNSimulator(this,atn,_decisionToDFA,_sharedContextCache); }
int numberOfDecisions = atn.getNumberOfDecisions(); for (int i = 0; i < numberOfDecisions; i++) { DecisionState decisionState = atn.getDecisionState(i);
int numberOfDecisions = atn.getNumberOfDecisions(); for (int i = 0; i < numberOfDecisions; i++) { DecisionState decisionState = atn.getDecisionState(i);
int numberOfDecisions = atn.getNumberOfDecisions(); for (int i = 0; i < numberOfDecisions; i++) { DecisionState decisionState = atn.getDecisionState(i);
int numberOfDecisions = atn.getNumberOfDecisions(); for (int i = 0; i < numberOfDecisions; i++) { DecisionState decisionState = atn.getDecisionState(i);
this.decisionToDFA = new DFA[atn.getNumberOfDecisions()]; for (int i = 0; i < decisionToDFA.length; i++) { decisionToDFA[i] = new DFA(atn.getDecisionState(i), i);
public ParserInterpreter(String grammarFileName, Vocabulary vocabulary, Collection<String> ruleNames, ATN atn, TokenStream input) { super(input); this.grammarFileName = grammarFileName; this.atn = atn; this.tokenNames = new String[atn.maxTokenType]; for (int i = 0; i < tokenNames.length; i++) { tokenNames[i] = vocabulary.getDisplayName(i); } this.ruleNames = ruleNames.toArray(new String[ruleNames.size()]); this.vocabulary = vocabulary; // init decision DFA int numberOfDecisions = atn.getNumberOfDecisions(); this.decisionToDFA = new DFA[numberOfDecisions]; for (int i = 0; i < numberOfDecisions; i++) { DecisionState decisionState = atn.getDecisionState(i); decisionToDFA[i] = new DFA(decisionState, i); } // get atn simulator that knows how to do predictions setInterpreter(new ParserATNSimulator(this, atn, decisionToDFA, sharedContextCache)); }
public ParserInterpreter(String grammarFileName, Vocabulary vocabulary, Collection<String> ruleNames, ATN atn, TokenStream input) { super(input); this.grammarFileName = grammarFileName; this.atn = atn; this.tokenNames = new String[atn.maxTokenType]; for (int i = 0; i < tokenNames.length; i++) { tokenNames[i] = vocabulary.getDisplayName(i); } this.ruleNames = ruleNames.toArray(new String[ruleNames.size()]); this.vocabulary = vocabulary; // init decision DFA int numberOfDecisions = atn.getNumberOfDecisions(); this.decisionToDFA = new DFA[numberOfDecisions]; for (int i = 0; i < numberOfDecisions; i++) { DecisionState decisionState = atn.getDecisionState(i); decisionToDFA[i] = new DFA(decisionState, i); } // get atn simulator that knows how to do predictions setInterpreter(new ParserATNSimulator(this, atn, decisionToDFA, sharedContextCache)); }
@Override public void valueChanged(ListSelectionEvent e) { // previewState, project set later if ( e.getValueIsAdjusting() ) { return; // this seems to be "mouse down" but not mouse up } // get state for current grammar editor tab if ( project==null ) { return; } if ( previewState!=null && profilerDataTable.getModel().getClass()!=DefaultTableModel.class ) { int selectedRow = profilerDataTable.getSelectedRow(); if ( selectedRow==-1 ) { selectedRow = 0; } int decision = profilerDataTable.convertRowIndexToModel(selectedRow); int numberOfDecisions = previewState.g.atn.getNumberOfDecisions(); if ( decision<=numberOfDecisions ) { selectDecisionInGrammar(previewState, decision); highlightInputPhrases(previewState, decision); } } } }
protected void processParser() { g.decisionLOOK = new ArrayList<IntervalSet[]>(g.atn.getNumberOfDecisions()+1); for (DecisionState s : g.atn.decisionToState) { g.tool.log("LL1", "\nDECISION "+s.decision+" in rule "+g.getRule(s.ruleIndex).name); IntervalSet[] look; if ( s.nonGreedy ) { // nongreedy decisions can't be LL(1) look = new IntervalSet[s.getNumberOfTransitions()+1]; } else { LL1Analyzer anal = new LL1Analyzer(g.atn); look = anal.getDecisionLookahead(s); g.tool.log("LL1", "look=" + Arrays.toString(look)); } assert s.decision + 1 >= g.decisionLOOK.size(); Utils.setSize(g.decisionLOOK, s.decision+1); g.decisionLOOK.set(s.decision, look); g.tool.log("LL1", "LL(1)? " + disjoint(look)); } }
protected void processParser() { g.decisionLOOK = new ArrayList<IntervalSet[]>(g.atn.getNumberOfDecisions()+1); for (DecisionState s : g.atn.decisionToState) { g.tool.log("LL1", "\nDECISION "+s.decision+" in rule "+g.getRule(s.ruleIndex).name); IntervalSet[] look; if ( s.nonGreedy ) { // nongreedy decisions can't be LL(1) look = new IntervalSet[s.getNumberOfTransitions()+1]; } else { LL1Analyzer anal = new LL1Analyzer(g.atn); look = anal.getDecisionLookahead(s); g.tool.log("LL1", "look=" + Arrays.toString(look)); } assert s.decision + 1 >= g.decisionLOOK.size(); Utils.setSize(g.decisionLOOK, s.decision+1); g.decisionLOOK.set(s.decision, look); g.tool.log("LL1", "LL(1)? " + disjoint(look)); } }
protected void processParser() { g.decisionLOOK = new ArrayList<IntervalSet[]>(g.atn.getNumberOfDecisions()+1); for (DecisionState s : g.atn.decisionToState) { g.tool.log("LL1", "\nDECISION "+s.decision+" in rule "+g.getRule(s.ruleIndex).name); IntervalSet[] look; if ( s.nonGreedy ) { // nongreedy decisions can't be LL(1) look = new IntervalSet[s.getNumberOfTransitions()+1]; } else { LL1Analyzer anal = new LL1Analyzer(g.atn); look = anal.getDecisionLookahead(s); g.tool.log("LL1", "look=" + Arrays.toString(look)); } assert s.decision + 1 >= g.decisionLOOK.size(); Utils.setSize(g.decisionLOOK, s.decision+1); g.decisionLOOK.set(s.decision, look); g.tool.log("LL1", "LL(1)? " + disjoint(look)); } }
protected void processParser() { g.decisionLOOK = new ArrayList<IntervalSet[]>(g.atn.getNumberOfDecisions()+1); for (DecisionState s : g.atn.decisionToState) { g.tool.log("LL1", "\nDECISION "+s.decision+" in rule "+g.getRule(s.ruleIndex).name); IntervalSet[] look; if ( s.nonGreedy ) { // nongreedy decisions can't be LL(1) look = new IntervalSet[s.getNumberOfTransitions()+1]; } else { LL1Analyzer anal = new LL1Analyzer(g.atn); look = anal.getDecisionLookahead(s); g.tool.log("LL1", "look=" + Arrays.toString(look)); } assert s.decision + 1 >= g.decisionLOOK.size(); Utils.setSize(g.decisionLOOK, s.decision+1); g.decisionLOOK.set(s.decision, look); g.tool.log("LL1", "LL(1)? " + disjoint(look)); } }
protected void processParser() { g.decisionLOOK = new ArrayList<IntervalSet[]>(g.atn.getNumberOfDecisions()+1); for (DecisionState s : g.atn.decisionToState) { g.tool.log("LL1", "\nDECISION "+s.decision+" in rule "+g.getRule(s.ruleIndex).name); IntervalSet[] look; if ( s.nonGreedy ) { // nongreedy decisions can't be LL(1) look = new IntervalSet[s.getNumberOfTransitions()+1]; } else { LL1Analyzer anal = new LL1Analyzer(g.atn); look = anal.getDecisionLookahead(s); g.tool.log("LL1", "look=" + Arrays.toString(look)); } assert s.decision + 1 >= g.decisionLOOK.size(); Utils.setSize(g.decisionLOOK, s.decision+1); g.decisionLOOK.set(s.decision, look); g.tool.log("LL1", "LL(1)? " + disjoint(look)); } }
DFA[] decisionToDFA = new DFA[parser.getATN().getNumberOfDecisions()]; for (int i = 0; i < parser.getATN().getNumberOfDecisions(); i++) { decisionToDFA[i] = new DFA(parser.getATN().getDecisionState(i), i);