public int getCharPositionInLine() { return getColumn()-1; }
private void updateLineColumnToLookaheadDFAMap(DFA lookaheadDFA) { GrammarAST decisionAST = nfa.grammar.getDecisionBlockAST(lookaheadDFA.decisionNumber); int line = decisionAST.getLine(); int col = decisionAST.getColumn(); lineColumnToLookaheadDFAMap.put(new StringBuffer().append(line + ":") .append(col).toString(), lookaheadDFA); }
private void updateLineColumnToLookaheadDFAMap(DFA lookaheadDFA) { GrammarAST decisionAST = nfa.grammar.getDecisionBlockAST(lookaheadDFA.decisionNumber); int line = decisionAST.getLine(); int col = decisionAST.getColumn(); lineColumnToLookaheadDFAMap.put(new StringBuffer().append(line + ":") .append(col).toString(), lookaheadDFA); }
protected String getDFALocations(Set dfas) { Set decisions = new HashSet(); StringBuffer buf = new StringBuffer(); Iterator it = dfas.iterator(); while ( it.hasNext() ) { DFA dfa = (DFA) it.next(); // 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.getColumn()); buf.append(newline); } return buf.toString(); }
protected String getDFALocations(Set dfas) { Set decisions = new HashSet(); StringBuffer buf = new StringBuffer(); Iterator it = dfas.iterator(); while ( it.hasNext() ) { DFA dfa = (DFA) it.next(); // 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.getColumn()); buf.append(newline); } return buf.toString(); }
public String grammarTreeToString(GrammarAST t, boolean showActions) { String s = null; try { s = t.getLine()+":"+t.getColumn()+": "; s += new ANTLRTreePrinter().toString((AST)t, this, showActions); } catch (Exception e) { s = "<invalid or missing tree structure>"; } return s; }
public String grammarTreeToString(GrammarAST t, boolean showActions) { String s = null; try { s = t.getLine()+":"+t.getColumn()+": "; s += new ANTLRTreePrinter().toString((AST)t, this, showActions); } catch (Exception e) { s = "<invalid or missing tree structure>"; } return s; }
public String toString() { GrammarAST decisionASTNode = probe.dfa.getDecisionASTNode(); line = decisionASTNode.getLine(); column = decisionASTNode.getColumn(); String fileName = probe.dfa.nfa.grammar.getFileName(); if ( fileName!=null ) {
public String toString() { GrammarAST decisionASTNode = probe.dfa.getDecisionASTNode(); line = decisionASTNode.getLine(); column = decisionASTNode.getColumn(); String fileName = probe.dfa.nfa.grammar.getFileName(); if ( fileName!=null ) { file = fileName; } StringTemplate st = getMessageTemplate(); String ruleName = probe.dfa.getNFADecisionStartState().enclosingRule.name; st.setAttribute("ruleName", ruleName); List sortedAlts = new ArrayList(); sortedAlts.addAll(altsWithRecursion); Collections.sort(sortedAlts); // make sure it's 1, 2, ... st.setAttribute("alts", sortedAlts); return super.toString(st); }
public String toString() { GrammarAST decisionASTNode = probe.dfa.getDecisionASTNode(); line = decisionASTNode.getLine(); column = decisionASTNode.getColumn(); String fileName = probe.dfa.nfa.grammar.getFileName(); if ( fileName!=null ) { file = fileName; } StringTemplate st = getMessageTemplate(); String ruleName = probe.dfa.getNFADecisionStartState().enclosingRule.name; st.setAttribute("ruleName", ruleName); List sortedAlts = new ArrayList(); sortedAlts.addAll(altsWithRecursion); Collections.sort(sortedAlts); // make sure it's 1, 2, ... st.setAttribute("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. */ public boolean equals(Object ast) { if ( this == ast ) { return true; } if ( !(ast instanceof GrammarAST) ) { return this.getType() == ((AST)ast).getType(); } GrammarAST t = (GrammarAST)ast; return token.getLine() == t.getLine() && token.getColumn() == t.getColumn(); }
public String toString() { GrammarAST decisionASTNode = probe.dfa.getDecisionASTNode(); line = decisionASTNode.getLine(); column = decisionASTNode.getColumn(); String fileName = probe.dfa.nfa.grammar.getFileName(); if ( fileName!=null ) { file = fileName; } StringTemplate 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 = (Integer) alts.get(i); String tokenName = probe.getTokenNameForTokensRuleAlt(altI.intValue()); // reset the line/col to the token definition NFAState ruleStart = probe.dfa.nfa.grammar.getRuleStartState(tokenName); line = ruleStart.associatedASTNode.getLine(); column = ruleStart.associatedASTNode.getColumn(); st.setAttribute("tokens", tokenName); } } else { // regular alt numbers, show the alts st.setAttribute("alts", alts); } return super.toString(st); }
public String toString() { GrammarAST decisionASTNode = probe.dfa.getDecisionASTNode(); line = decisionASTNode.getLine(); column = decisionASTNode.getColumn(); String fileName = probe.dfa.nfa.grammar.getFileName(); if ( fileName!=null ) { file = fileName; } StringTemplate 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 = (Integer) alts.get(i); String tokenName = probe.getTokenNameForTokensRuleAlt(altI.intValue()); // reset the line/col to the token definition NFAState ruleStart = probe.dfa.nfa.grammar.getRuleStartState(tokenName); line = ruleStart.associatedASTNode.getLine(); column = ruleStart.associatedASTNode.getColumn(); st.setAttribute("tokens", tokenName); } } else { // regular alt numbers, show the alts st.setAttribute("alts", alts); } return super.toString(st); }
/** Make nodes unique based upon Token so we can add them to a Set; if * not a GrammarAST, check type. */ public boolean equals(Object ast) { if ( this == ast ) { return true; } if ( !(ast instanceof GrammarAST) ) { return this.getType() == ((AST)ast).getType(); } GrammarAST t = (GrammarAST)ast; return token.getLine() == t.getLine() && token.getColumn() == t.getColumn(); }
public String toString() { GrammarAST decisionASTNode = probe.dfa.getDecisionASTNode(); line = decisionASTNode.getLine(); column = decisionASTNode.getColumn(); String fileName = probe.dfa.nfa.grammar.getFileName(); if ( fileName!=null ) { file = fileName; } List labels = probe.getSampleNonDeterministicInputSequence(problemState); String input = probe.getInputSequenceDisplay(labels); StringTemplate st = getMessageTemplate(); List alts = new ArrayList(); alts.addAll(problemState.getAltSet()); Collections.sort(alts); st.setAttribute("danglingAlts", alts); st.setAttribute("input", input); return super.toString(st); }
public String toString() { GrammarAST decisionASTNode = probe.dfa.getDecisionASTNode(); line = decisionASTNode.getLine(); column = decisionASTNode.getColumn(); String fileName = probe.dfa.nfa.grammar.getFileName(); if ( fileName!=null ) { file = fileName; } List labels = probe.getSampleNonDeterministicInputSequence(problemState); String input = probe.getInputSequenceDisplay(labels); StringTemplate st = getMessageTemplate(); List alts = new ArrayList(); alts.addAll(problemState.getAltSet()); Collections.sort(alts); st.setAttribute("danglingAlts", alts); st.setAttribute("input", input); return super.toString(st); }
public String toString() { GrammarAST decisionASTNode = probe.dfa.getDecisionASTNode(); line = decisionASTNode.getLine(); column = decisionASTNode.getColumn(); String fileName = probe.dfa.nfa.grammar.getFileName(); if ( fileName!=null ) { file = fileName; } StringTemplate st = getMessageTemplate(); st.setAttribute("enclosingRule", probe.dfa.getNFADecisionStartState().enclosingRule.name); return super.toString(st); }
public String toString() { GrammarAST decisionASTNode = probe.dfa.getDecisionASTNode(); line = decisionASTNode.getLine(); column = decisionASTNode.getColumn(); String fileName = probe.dfa.nfa.grammar.getFileName(); if ( fileName!=null ) { file = fileName; } StringTemplate st = getMessageTemplate(); st.setAttribute("enclosingRule", probe.dfa.getNFADecisionStartState().enclosingRule.name); return super.toString(st); }
public String toString() { GrammarAST decisionASTNode = probe.dfa.getDecisionASTNode(); line = decisionASTNode.getLine(); column = decisionASTNode.getColumn(); String fileName = probe.dfa.nfa.grammar.getFileName(); if ( fileName!=null ) { file = fileName; } StringTemplate st = getMessageTemplate(); st.setAttribute("targetRules", targetRules); st.setAttribute("alt", alt); st.setAttribute("callSiteStates", callSiteStates); List labels = probe.getSampleNonDeterministicInputSequence(sampleBadState); String input = probe.getInputSequenceDisplay(labels); st.setAttribute("input", input); return super.toString(st); }
public String toString() { GrammarAST decisionASTNode = probe.dfa.getDecisionASTNode(); line = decisionASTNode.getLine(); column = decisionASTNode.getColumn(); String fileName = probe.dfa.nfa.grammar.getFileName(); if ( fileName!=null ) { file = fileName; } StringTemplate st = getMessageTemplate(); st.setAttribute("targetRules", targetRules); st.setAttribute("alt", alt); st.setAttribute("callSiteStates", callSiteStates); List labels = probe.getSampleNonDeterministicInputSequence(sampleBadState); String input = probe.getInputSequenceDisplay(labels); st.setAttribute("input", input); return super.toString(st); }