本文整理汇总了Java中org.antlr.analysis.DecisionProbe.verbose方法的典型用法代码示例。如果您正苦于以下问题:Java DecisionProbe.verbose方法的具体用法?Java DecisionProbe.verbose怎么用?Java DecisionProbe.verbose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.antlr.analysis.DecisionProbe
的用法示例。
在下文中一共展示了DecisionProbe.verbose方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
示例4: 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);
}
示例5: 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);
}
示例6: testLeftRecursivePred
import org.antlr.analysis.DecisionProbe; //导入方法依赖的package包/类
public void testLeftRecursivePred() throws Exception {
Grammar g = new Grammar(
"parser grammar P;\n"+
"s : a ;\n" +
"a : {p1}? a | ID ;\n");
String expecting =
".s0-ID->.s1\n" +
".s1-{p1}?->:s2=>1\n" +
".s1-{true}?->:s3=>2\n";
DecisionProbe.verbose=true; // make sure we get all error info
ErrorQueue equeue = new ErrorQueue();
ErrorManager.setErrorListener(equeue);
CodeGenerator generator = new CodeGenerator(newTool(), g, "Java");
g.setCodeGenerator(generator);
if ( g.getNumberOfDecisions()==0 ) {
g.createNFAs();
g.createLookaheadDFAs();
}
DFA dfa = g.getLookaheadDFA(1);
FASerializer serializer = new FASerializer(g);
String result = serializer.serialize(dfa.startState);
assertEquals(expecting, result);
assertEquals("unexpected number of expected problems", 1, equeue.size());
Message msg = (Message)equeue.warnings.get(0);
assertTrue("warning must be a recursion overflow msg",
msg instanceof RecursionOverflowMessage);
}
示例7: testPredsUsedAfterRecursionOverflow
import org.antlr.analysis.DecisionProbe; //导入方法依赖的package包/类
public void testPredsUsedAfterRecursionOverflow() throws Exception {
Grammar g = new Grammar(
"grammar P;\n"+
"s : {p1}? e '.' | {p2}? e ':' ;\n" +
"e : '(' e ')' | INT ;\n");
String expecting =
".s0-'('->.s1\n" +
".s0-INT->.s7\n" +
".s1-'('->.s2\n" +
".s1-INT->.s5\n" +
".s2-{p1}?->:s3=>1\n" +
".s2-{p2}?->:s4=>2\n" +
".s5-')'->.s6\n" +
".s6-'.'->:s3=>1\n" +
".s6-':'->:s4=>2\n" +
".s7-'.'->:s3=>1\n" +
".s7-':'->:s4=>2\n";
DecisionProbe.verbose=true; // make sure we get all error info
ErrorQueue equeue = new ErrorQueue();
ErrorManager.setErrorListener(equeue);
CodeGenerator generator = new CodeGenerator(newTool(), g, "Java");
g.setCodeGenerator(generator);
if ( g.getNumberOfDecisions()==0 ) {
g.createNFAs();
g.createLookaheadDFAs();
}
assertEquals("unexpected number of expected problems", 0, equeue.size());
checkDecision(g, 1, expecting, null, null, null, null, null, 0);
}
示例8: 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<Rule> leftRecursive = g.getLeftRecursiveRules();
Set expectedRules =
new HashSet() {{add("a"); add("b");}};
assertEquals(expectedRules, ruleNames(leftRecursive));
g.createLookaheadDFAs(false);
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;
Set expecting = new HashSet() {{add("a"); add("b");}};
assertEquals(expecting, ruleNames2(result));
}
示例9: 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, ruleNames(leftRecursive));
g.createLookaheadDFAs(false);
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;
Set expecting = new HashSet() {{add("a"); add("b");}};
assertEquals(expecting, ruleNames2(result));
}
示例10: 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, ruleNames(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;
Set expecting = new HashSet() {{add("a"); add("b"); add("d"); add("e");}};
assertEquals(expecting, ruleNames2(result));
}
示例11: testLeftRecursivePred
import org.antlr.analysis.DecisionProbe; //导入方法依赖的package包/类
public void testLeftRecursivePred() throws Exception {
// No analysis possible. but probably good to fail. Not sure we really want
// left-recursion even if guarded with pred.
Grammar g = new Grammar(
"parser grammar P;\n"+
"s : a ;\n" +
"a : {p1}? a | ID ;\n");
String expecting =
".s0-ID->.s1\n" +
".s1-{p1}?->:s2=>1\n" +
".s1-{true}?->:s3=>2\n";
DecisionProbe.verbose=true; // make sure we get all error info
ErrorQueue equeue = new ErrorQueue();
ErrorManager.setErrorListener(equeue);
CodeGenerator generator = new CodeGenerator(newTool(), g, "Java");
g.setCodeGenerator(generator);
if ( g.getNumberOfDecisions()==0 ) {
g.buildNFA();
g.createLookaheadDFAs(false);
}
DFA dfa = g.getLookaheadDFA(1);
assertEquals(null, dfa); // can't analyze.
/*
String result = serializer.serialize(dfa.startState);
assertEquals(expecting, result);
*/
assertEquals("unexpected number of expected problems", 1, equeue.size());
Message msg = (Message)equeue.warnings.get(0);
assertTrue("warning must be a left recursion msg",
msg instanceof LeftRecursionCyclesMessage);
}
示例12: testPredsUsedAfterRecursionOverflow
import org.antlr.analysis.DecisionProbe; //导入方法依赖的package包/类
public void testPredsUsedAfterRecursionOverflow() throws Exception {
// analysis must bail out due to non-LL(*) nature (ovf)
// retries with k=1 (but with LL(*) algorithm not optimized version
// as it has preds)
Grammar g = new Grammar(
"parser grammar P;\n"+
"s : {p1}? e '.' | {p2}? e ':' ;\n" +
"e : '(' e ')' | INT ;\n");
String expecting =
".s0-'('->.s1\n" +
".s0-INT->.s4\n" +
".s1-{p1}?->:s2=>1\n" +
".s1-{p2}?->:s3=>2\n" +
".s4-{p1}?->:s2=>1\n" +
".s4-{p2}?->:s3=>2\n";
DecisionProbe.verbose=true; // make sure we get all error info
ErrorQueue equeue = new ErrorQueue();
ErrorManager.setErrorListener(equeue);
CodeGenerator generator = new CodeGenerator(newTool(), g, "Java");
g.setCodeGenerator(generator);
if ( g.getNumberOfDecisions()==0 ) {
g.buildNFA();
g.createLookaheadDFAs(false);
}
assertEquals("unexpected number of expected problems", 0, equeue.size());
checkDecision(g, 1, expecting, null, null, null, null, null, 0, false);
}
示例13: testPredsUsedAfterK2FailsNoRecursionOverflow
import org.antlr.analysis.DecisionProbe; //导入方法依赖的package包/类
public void testPredsUsedAfterK2FailsNoRecursionOverflow() throws Exception {
// analysis must bail out due to non-LL(*) nature (ovf)
// retries with k=1 (but with LL(*) algorithm not optimized version
// as it has preds)
Grammar g = new Grammar(
"grammar P;\n" +
"options {k=2;}\n"+
"s : {p1}? e '.' | {p2}? e ':' ;\n" +
"e : '(' e ')' | INT ;\n");
String expecting =
".s0-'('->.s1\n" +
".s0-INT->.s6\n" +
".s1-'('->.s2\n" +
".s1-INT->.s5\n" +
".s2-{p1}?->:s3=>1\n" +
".s2-{p2}?->:s4=>2\n" +
".s5-{p1}?->:s3=>1\n" +
".s5-{p2}?->:s4=>2\n" +
".s6-'.'->:s3=>1\n" +
".s6-':'->:s4=>2\n";
DecisionProbe.verbose=true; // make sure we get all error info
ErrorQueue equeue = new ErrorQueue();
ErrorManager.setErrorListener(equeue);
CodeGenerator generator = new CodeGenerator(newTool(), g, "Java");
g.setCodeGenerator(generator);
if ( g.getNumberOfDecisions()==0 ) {
g.buildNFA();
g.createLookaheadDFAs(false);
}
assertEquals("unexpected number of expected problems", 0, equeue.size());
checkDecision(g, 1, expecting, null, null, null, null, null, 0, false);
}