String fileName = probe.dfa.nfa.grammar.getFileName();
if ( fileName!=null ) {
file = fileName;
}
ST st = getMessageTemplate();
// Now fill template with information about problemState
List<Label> labels = probe.getSampleNonDeterministicInputSequence(problemState);
String input = probe.getInputSequenceDisplay(labels);
st.add("input", input);
if ( probe.dfa.isTokensRuleDecision() ) {
Set<Integer> disabledAlts = probe.getDisabledAlternatives(problemState);
for (Integer altI : disabledAlts) {
String tokenName =
probe.getTokenNameForTokensRuleAlt(altI);
// reset the line/col to the token definition (pick last one)
NFAState ruleStart =
probe.dfa.nfa.grammar.getRuleStartState(tokenName);
line = ruleStart.associatedASTNode.getLine();
column = ruleStart.associatedASTNode.getCharPositionInLine();
st.add("disabled", tokenName);
}
}
else {
st.add("disabled", probe.getDisabledAlternatives(problemState));
}
List<Integer> nondetAlts = probe.getNonDeterministicAltsForState(problemState);
NFAState nfaStart = probe.dfa.getNFADecisionStartState();
// all state paths have to begin with same NFA state
int firstAlt = 0;
if ( nondetAlts!=null ) {
for (Integer displayAltI : nondetAlts) {
if ( DecisionProbe.verbose ) {
int tracePathAlt =
nfaStart.translateDisplayAltToWalkAlt(displayAltI);
if ( firstAlt == 0 ) {
firstAlt = tracePathAlt;
}
List<? extends NFAState> path =
probe.getNFAPathStatesForAlt(firstAlt,
tracePathAlt,
labels);
st.addAggr("paths.{alt, states}", displayAltI, path);
}
else {
if ( probe.dfa.isTokensRuleDecision() ) {
// alts are token rules, convert to the names instead of numbers
String tokenName =
probe.getTokenNameForTokensRuleAlt(displayAltI);
st.add("conflictingTokens", tokenName);
}
else {
st.add("conflictingAlts", displayAltI);
}
}
}
}
st.add("hasPredicateBlockedByAction", problemState.dfa.hasPredicateBlockedByAction);
return super.toString(st);
}