private void updateLineColumnToLookaheadDFAMap(DFA lookaheadDFA) { GrammarAST decisionAST = nfa.grammar.getDecisionBlockAST(lookaheadDFA.decisionNumber); int line = decisionAST.getLine(); int col = decisionAST.getCharPositionInLine(); lineColumnToLookaheadDFAMap.put(new StringBuffer().append(line).append(":") .append(col).toString(), lookaheadDFA); }
private void updateLineColumnToLookaheadDFAMap(DFA lookaheadDFA) { GrammarAST decisionAST = nfa.grammar.getDecisionBlockAST(lookaheadDFA.decisionNumber); int line = decisionAST.getLine(); int col = decisionAST.getCharPositionInLine(); lineColumnToLookaheadDFAMap.put(new StringBuffer().append(line).append(":") .append(col).toString(), lookaheadDFA); }
protected String getDFALocations(Set<DFA> dfas) { Set<Integer> decisions = new HashSet<Integer>(); StringBuilder buf = new StringBuilder(); for (DFA dfa : dfas) { // if we aborted a DFA and redid with k=1, the backtrackin if ( decisions.contains(Utils.integer(dfa.decisionNumber)) ) { continue; } decisions.add(Utils.integer(dfa.decisionNumber)); buf.append("Rule "); buf.append(dfa.decisionNFAStartState.enclosingRule.name); buf.append(" decision "); buf.append(dfa.decisionNumber); buf.append(" location "); GrammarAST decisionAST = dfa.decisionNFAStartState.associatedASTNode; buf.append(decisionAST.getLine()); buf.append(":"); buf.append(decisionAST.getCharPositionInLine()); buf.append(newline); } return buf.toString(); }
protected String getDFALocations(Set<DFA> dfas) { Set<Integer> decisions = new HashSet<Integer>(); StringBuilder buf = new StringBuilder(); for (DFA dfa : dfas) { // if we aborted a DFA and redid with k=1, the backtrackin if ( decisions.contains(Utils.integer(dfa.decisionNumber)) ) { continue; } decisions.add(Utils.integer(dfa.decisionNumber)); buf.append("Rule "); buf.append(dfa.decisionNFAStartState.enclosingRule.name); buf.append(" decision "); buf.append(dfa.decisionNumber); buf.append(" location "); GrammarAST decisionAST = dfa.decisionNFAStartState.associatedASTNode; buf.append(decisionAST.getLine()); buf.append(":"); buf.append(decisionAST.getCharPositionInLine()); buf.append(newline); } return buf.toString(); }
GrammarAST decisionASTNode = probe.dfa.getDecisionASTNode(); line = decisionASTNode.getLine(); column = decisionASTNode.getCharPositionInLine(); String fileName = probe.dfa.nfa.grammar.getFileName(); if ( fileName!=null ) {
GrammarAST decisionASTNode = probe.dfa.getDecisionASTNode(); line = decisionASTNode.getLine(); column = decisionASTNode.getCharPositionInLine(); String fileName = probe.dfa.nfa.grammar.getFileName(); if ( fileName!=null ) {
public String grammarTreeToString(GrammarAST t, boolean showActions) { String s; try { s = t.getLine()+":"+(t.getCharPositionInLine()+1)+": "; s += new ANTLRTreePrinter(new CommonTreeNodeStream(t)).toString(this, showActions); } catch (Exception e) { s = "<invalid or missing tree structure>"; } return s; }
@Override public String toString() { GrammarAST decisionASTNode = probe.dfa.getDecisionASTNode(); line = decisionASTNode.getLine(); column = decisionASTNode.getCharPositionInLine(); String fileName = probe.dfa.nfa.grammar.getFileName(); if ( fileName!=null ) { file = fileName; } ST st = getMessageTemplate(); String ruleName = probe.dfa.getNFADecisionStartState().enclosingRule.name; st.add("ruleName", ruleName); List<Integer> sortedAlts = new ArrayList<Integer>(); sortedAlts.addAll(altsWithRecursion); Collections.sort(sortedAlts); // make sure it's 1, 2, ... st.add("alts", sortedAlts); return super.toString(st); }
public String grammarTreeToString(GrammarAST t, boolean showActions) { String s; try { s = t.getLine()+":"+(t.getCharPositionInLine()+1)+": "; s += new ANTLRTreePrinter(new CommonTreeNodeStream(t)).toString(this, showActions); } catch (Exception e) { s = "<invalid or missing tree structure>"; } return s; }
@Override public String toString() { GrammarAST decisionASTNode = probe.dfa.getDecisionASTNode(); line = decisionASTNode.getLine(); column = decisionASTNode.getCharPositionInLine(); String fileName = probe.dfa.nfa.grammar.getFileName(); if ( fileName!=null ) { file = fileName; } ST st = getMessageTemplate(); String ruleName = probe.dfa.getNFADecisionStartState().enclosingRule.name; st.add("ruleName", ruleName); List<Integer> sortedAlts = new ArrayList<Integer>(); sortedAlts.addAll(altsWithRecursion); Collections.sort(sortedAlts); // make sure it's 1, 2, ... st.add("alts", sortedAlts); return super.toString(st); }
/** Make nodes unique based upon Token so we can add them to a Set; if * not a GrammarAST, check type. */ @Override public boolean equals(Object ast) { if ( this == ast ) { return true; } if ( !(ast instanceof GrammarAST) ) { return this.getType() == ((Tree)ast).getType(); } GrammarAST t = (GrammarAST)ast; return token.getLine() == t.getLine() && token.getCharPositionInLine() == t.getCharPositionInLine(); }
/** Make nodes unique based upon Token so we can add them to a Set; if * not a GrammarAST, check type. */ @Override public boolean equals(Object ast) { if ( this == ast ) { return true; } if ( !(ast instanceof GrammarAST) ) { return this.getType() == ((Tree)ast).getType(); } GrammarAST t = (GrammarAST)ast; return token.getLine() == t.getLine() && token.getCharPositionInLine() == t.getCharPositionInLine(); }
@Override public String toString() { GrammarAST decisionASTNode = probe.dfa.getDecisionASTNode(); line = decisionASTNode.getLine(); column = decisionASTNode.getCharPositionInLine(); String fileName = probe.dfa.nfa.grammar.getFileName(); if ( fileName!=null ) { file = fileName; } List<Label> labels = probe.getSampleNonDeterministicInputSequence(problemState); String input = probe.getInputSequenceDisplay(labels); ST st = getMessageTemplate(); List<Integer> alts = new ArrayList<Integer>(); alts.addAll(problemState.getAltSet()); Collections.sort(alts); st.add("danglingAlts", alts); st.add("input", input); return super.toString(st); }
@Override public String toString() { GrammarAST decisionASTNode = probe.dfa.getDecisionASTNode(); line = decisionASTNode.getLine(); column = decisionASTNode.getCharPositionInLine(); String fileName = probe.dfa.nfa.grammar.getFileName(); if ( fileName!=null ) { file = fileName; } List<Label> labels = probe.getSampleNonDeterministicInputSequence(problemState); String input = probe.getInputSequenceDisplay(labels); ST st = getMessageTemplate(); List<Integer> alts = new ArrayList<Integer>(); alts.addAll(problemState.getAltSet()); Collections.sort(alts); st.add("danglingAlts", alts); st.add("input", input); return super.toString(st); }
@Override public String toString() { GrammarAST decisionASTNode = probe.dfa.getDecisionASTNode(); line = decisionASTNode.getLine(); column = decisionASTNode.getCharPositionInLine(); String fileName = probe.dfa.nfa.grammar.getFileName(); if ( fileName!=null ) { file = fileName; } ST st = getMessageTemplate(); if ( probe.dfa.isTokensRuleDecision() ) { // alts are token rules, convert to the names instead of numbers for (int i = 0; i < alts.size(); i++) { Integer altI = alts.get(i); String tokenName = probe.getTokenNameForTokensRuleAlt(altI); // reset the line/col to the token definition NFAState ruleStart = probe.dfa.nfa.grammar.getRuleStartState(tokenName); line = ruleStart.associatedASTNode.getLine(); column = ruleStart.associatedASTNode.getCharPositionInLine(); st.add("tokens", tokenName); } } else { // regular alt numbers, show the alts st.add("alts", alts); } return super.toString(st); }
@Override public String toString() { GrammarAST decisionASTNode = probe.dfa.getDecisionASTNode(); line = decisionASTNode.getLine(); column = decisionASTNode.getCharPositionInLine(); String fileName = probe.dfa.nfa.grammar.getFileName(); if ( fileName!=null ) { file = fileName; } ST st = getMessageTemplate(); if ( probe.dfa.isTokensRuleDecision() ) { // alts are token rules, convert to the names instead of numbers for (int i = 0; i < alts.size(); i++) { Integer altI = alts.get(i); String tokenName = probe.getTokenNameForTokensRuleAlt(altI); // reset the line/col to the token definition NFAState ruleStart = probe.dfa.nfa.grammar.getRuleStartState(tokenName); line = ruleStart.associatedASTNode.getLine(); column = ruleStart.associatedASTNode.getCharPositionInLine(); st.add("tokens", tokenName); } } else { // regular alt numbers, show the alts st.add("alts", alts); } return super.toString(st); }
@Override public String toString() { GrammarAST decisionASTNode = probe.dfa.getDecisionASTNode(); line = decisionASTNode.getLine(); column = decisionASTNode.getCharPositionInLine(); String fileName = probe.dfa.nfa.grammar.getFileName(); if ( fileName!=null ) { file = fileName; } ST st = getMessageTemplate(); st.add("enclosingRule", probe.dfa.getNFADecisionStartState().enclosingRule.name); return super.toString(st); }
@Override public String toString() { GrammarAST decisionASTNode = probe.dfa.getDecisionASTNode(); line = decisionASTNode.getLine(); column = decisionASTNode.getCharPositionInLine(); String fileName = probe.dfa.nfa.grammar.getFileName(); if ( fileName!=null ) { file = fileName; } ST st = getMessageTemplate(); st.add("enclosingRule", probe.dfa.getNFADecisionStartState().enclosingRule.name); return super.toString(st); }
@Override public String toString() { GrammarAST decisionASTNode = probe.dfa.getDecisionASTNode(); line = decisionASTNode.getLine(); column = decisionASTNode.getCharPositionInLine(); String fileName = probe.dfa.nfa.grammar.getFileName(); if ( fileName!=null ) { file = fileName; } ST st = getMessageTemplate(); st.add("targetRules", targetRules); st.add("alt", alt); st.add("callSiteStates", callSiteStates); List<Label> labels = probe.getSampleNonDeterministicInputSequence(sampleBadState); String input = probe.getInputSequenceDisplay(labels); st.add("input", input); return super.toString(st); }
@Override public String toString() { GrammarAST decisionASTNode = probe.dfa.getDecisionASTNode(); line = decisionASTNode.getLine(); column = decisionASTNode.getCharPositionInLine(); String fileName = probe.dfa.nfa.grammar.getFileName(); if ( fileName!=null ) { file = fileName; } ST st = getMessageTemplate(); st.add("targetRules", targetRules); st.add("alt", alt); st.add("callSiteStates", callSiteStates); List<Label> labels = probe.getSampleNonDeterministicInputSequence(sampleBadState); String input = probe.getInputSequenceDisplay(labels); st.add("input", input); return super.toString(st); }