本文整理汇总了Java中org.antlr.analysis.DecisionProbe类的典型用法代码示例。如果您正苦于以下问题:Java DecisionProbe类的具体用法?Java DecisionProbe怎么用?Java DecisionProbe使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DecisionProbe类属于org.antlr.analysis包,在下文中一共展示了DecisionProbe类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertNonLLStar
import org.antlr.analysis.DecisionProbe; //导入依赖的package包/类
protected void assertNonLLStar(Grammar g, List expectedBadAlts) {
DecisionProbe.verbose=true; // make sure we get all error info
ErrorQueue equeue = new ErrorQueue();
ErrorManager.setErrorListener(equeue);
// mimic actions of org.antlr.Tool first time for grammar g
if ( g.getNumberOfDecisions()==0 ) {
g.buildNFA();
g.createLookaheadDFAs(false);
}
NonRegularDecisionMessage msg = getNonRegularDecisionMessage(equeue.errors);
assertTrue("expected fatal non-LL(*) msg", msg!=null);
List<Integer> alts = new ArrayList();
alts.addAll(msg.altsWithRecursion);
Collections.sort(alts);
assertEquals(expectedBadAlts,alts);
}
示例2: assertRecursionOverflow
import org.antlr.analysis.DecisionProbe; //导入依赖的package包/类
protected void assertRecursionOverflow(Grammar g,
List expectedTargetRules,
int expectedAlt) {
DecisionProbe.verbose=true; // make sure we get all error info
ErrorQueue equeue = new ErrorQueue();
ErrorManager.setErrorListener(equeue);
// mimic actions of org.antlr.Tool first time for grammar g
if ( g.getNumberOfDecisions()==0 ) {
g.buildNFA();
g.createLookaheadDFAs(false);
}
RecursionOverflowMessage msg = getRecursionOverflowMessage(equeue.errors);
assertTrue("missing expected recursion overflow msg"+msg, msg!=null);
assertEquals("target rules mismatch",
expectedTargetRules.toString(), msg.targetRules.toString());
assertEquals("mismatched alt", expectedAlt, msg.alt);
}
示例3: GrammarInsufficientPredicatesMessage
import org.antlr.analysis.DecisionProbe; //导入依赖的package包/类
public GrammarInsufficientPredicatesMessage(DecisionProbe probe,
List alts)
{
super(ErrorManager.MSG_INSUFFICIENT_PREDICATES);
this.probe = probe;
this.alts = alts;
}
示例4: GrammarNonDeterminismMessage
import org.antlr.analysis.DecisionProbe; //导入依赖的package包/类
public GrammarNonDeterminismMessage(DecisionProbe probe,
DFAState problemState)
{
super(ErrorManager.MSG_GRAMMAR_NONDETERMINISM);
this.probe = probe;
this.problemState = problemState;
// flip msg ID if alts are actually token refs in Tokens rule
if ( probe.dfa.isTokensRuleDecision() ) {
setMessageID(ErrorManager.MSG_TOKEN_NONDETERMINISM);
}
}
示例5: nondeterminism
import org.antlr.analysis.DecisionProbe; //导入依赖的package包/类
public static void nondeterminism(DecisionProbe probe,
DFAState d)
{
getErrorState().warnings++;
Message msg = new GrammarNonDeterminismMessage(probe,d);
getErrorState().warningMsgIDs.add(msg.msgID);
getErrorListener().warning(msg);
}
示例6: danglingState
import org.antlr.analysis.DecisionProbe; //导入依赖的package包/类
public static void danglingState(DecisionProbe probe,
DFAState d)
{
getErrorState().warnings++;
Message msg = new GrammarDanglingStateMessage(probe,d);
getErrorState().warningMsgIDs.add(msg.msgID);
Set seen = (Set)emitSingleError.get("danglingState");
if ( !seen.contains(d.dfa.decisionNumber+"|"+d.getAltSet()) ) {
getErrorListener().warning(msg);
// we've seen this decision and this alt set; never again
seen.add(d.dfa.decisionNumber+"|"+d.getAltSet());
}
}
示例7: analysisAborted
import org.antlr.analysis.DecisionProbe; //导入依赖的package包/类
public static void analysisAborted(DecisionProbe probe)
{
getErrorState().warnings++;
Message msg = new GrammarAnalysisAbortedMessage(probe);
getErrorState().warningMsgIDs.add(msg.msgID);
getErrorListener().warning(msg);
}
示例8: unreachableAlts
import org.antlr.analysis.DecisionProbe; //导入依赖的package包/类
public static void unreachableAlts(DecisionProbe probe,
List alts)
{
getErrorState().warnings++;
Message msg = new GrammarUnreachableAltsMessage(probe,alts);
getErrorState().warningMsgIDs.add(msg.msgID);
getErrorListener().warning(msg);
}
示例9: insufficientPredicates
import org.antlr.analysis.DecisionProbe; //导入依赖的package包/类
public static void insufficientPredicates(DecisionProbe probe,
List alts)
{
getErrorState().warnings++;
Message msg = new GrammarInsufficientPredicatesMessage(probe,alts);
getErrorState().warningMsgIDs.add(msg.msgID);
getErrorListener().warning(msg);
}
示例10: recursionOverflow
import org.antlr.analysis.DecisionProbe; //导入依赖的package包/类
public static void recursionOverflow(DecisionProbe probe,
DFAState sampleBadState,
int alt,
Collection targetRules,
Collection callSiteStates)
{
getErrorState().warnings++;
Message msg = new RecursionOverflowMessage(probe,sampleBadState, alt,
targetRules, callSiteStates);
getErrorState().warningMsgIDs.add(msg.msgID);
getErrorListener().warning(msg);
}
示例11: GrammarUnreachableAltsMessage
import org.antlr.analysis.DecisionProbe; //导入依赖的package包/类
public GrammarUnreachableAltsMessage(DecisionProbe probe,
List alts)
{
super(ErrorManager.MSG_UNREACHABLE_ALTS);
this.probe = probe;
this.alts = alts;
// flip msg ID if alts are actually token refs in Tokens rule
if ( probe.dfa.isTokensRuleDecision() ) {
setMessageID(ErrorManager.MSG_UNREACHABLE_TOKENS);
}
}
示例12: GrammarDanglingStateMessage
import org.antlr.analysis.DecisionProbe; //导入依赖的package包/类
public GrammarDanglingStateMessage(DecisionProbe probe,
DFAState problemState)
{
super(ErrorManager.MSG_DANGLING_STATE);
this.probe = probe;
this.problemState = problemState;
}
示例13: testIndirectRecursionLoop
import org.antlr.analysis.DecisionProbe; //导入依赖的package包/类
public void testIndirectRecursionLoop() throws Exception {
Grammar g = new Grammar(
"parser grammar t;\n"+
"s : a ;\n" +
"a : b X ;\n"+
"b : a B ;\n");
DecisionProbe.verbose=true; // make sure we get all error info
ErrorQueue equeue = new ErrorQueue();
ErrorManager.setErrorListener(equeue);
Set leftRecursive = g.getLeftRecursiveRules();
Set expectedRules =
new HashSet() {{add("a"); add("b");}};
assertEquals(expectedRules, leftRecursive);
g.createLookaheadDFAs();
Message msg = (Message)equeue.warnings.get(0);
assertTrue("expecting left recursion cycles; found "+msg.getClass().getName(),
msg instanceof LeftRecursionCyclesMessage);
LeftRecursionCyclesMessage cyclesMsg = (LeftRecursionCyclesMessage)msg;
// cycle of [a, b]
Collection result = cyclesMsg.cycles;
List expecting = new ArrayList();
expecting.add(new HashSet() {{add("a"); add("b");}});
assertEquals(expecting, result);
}
示例14: testIndirectRecursionLoop2
import org.antlr.analysis.DecisionProbe; //导入依赖的package包/类
public void testIndirectRecursionLoop2() throws Exception {
Grammar g = new Grammar(
"parser grammar t;\n"+
"s : a ;\n" +
"a : i b X ;\n"+ // should see through i
"b : a B ;\n" +
"i : ;\n");
DecisionProbe.verbose=true; // make sure we get all error info
ErrorQueue equeue = new ErrorQueue();
ErrorManager.setErrorListener(equeue);
Set leftRecursive = g.getLeftRecursiveRules();
Set expectedRules =
new HashSet() {{add("a"); add("b");}};
assertEquals(expectedRules, leftRecursive);
g.createLookaheadDFAs();
Message msg = (Message)equeue.warnings.get(0);
assertTrue("expecting left recursion cycles; found "+msg.getClass().getName(),
msg instanceof LeftRecursionCyclesMessage);
LeftRecursionCyclesMessage cyclesMsg = (LeftRecursionCyclesMessage)msg;
// cycle of [a, b]
Collection result = cyclesMsg.cycles;
List expecting = new ArrayList();
expecting.add(new HashSet() {{add("a"); add("b");}});
assertEquals(expecting, result);
}
示例15: testIndirectRecursionLoop3
import org.antlr.analysis.DecisionProbe; //导入依赖的package包/类
public void testIndirectRecursionLoop3() throws Exception {
Grammar g = new Grammar(
"parser grammar t;\n"+
"s : a ;\n" +
"a : i b X ;\n"+ // should see through i
"b : a B ;\n" +
"i : ;\n" +
"d : e ;\n" +
"e : d ;\n");
DecisionProbe.verbose=true; // make sure we get all error info
ErrorQueue equeue = new ErrorQueue();
ErrorManager.setErrorListener(equeue);
Set leftRecursive = g.getLeftRecursiveRules();
Set expectedRules =
new HashSet() {{add("a"); add("b"); add("e"); add("d");}};
assertEquals(expectedRules, leftRecursive);
Message msg = (Message)equeue.warnings.get(0);
assertTrue("expecting left recursion cycles; found "+msg.getClass().getName(),
msg instanceof LeftRecursionCyclesMessage);
LeftRecursionCyclesMessage cyclesMsg = (LeftRecursionCyclesMessage)msg;
// cycle of [a, b]
Collection result = cyclesMsg.cycles;
List expecting = new ArrayList();
expecting.add(new HashSet() {{add("a"); add("b");}});
expecting.add(new HashSet() {{add("d"); add("e");}});
assertEquals(expecting, result);
}