本文整理汇总了Java中org.antlr.tool.ErrorManager.MSG_UNDEFINED_TOKEN_REF_IN_REWRITE属性的典型用法代码示例。如果您正苦于以下问题:Java ErrorManager.MSG_UNDEFINED_TOKEN_REF_IN_REWRITE属性的具体用法?Java ErrorManager.MSG_UNDEFINED_TOKEN_REF_IN_REWRITE怎么用?Java ErrorManager.MSG_UNDEFINED_TOKEN_REF_IN_REWRITE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.antlr.tool.ErrorManager
的用法示例。
在下文中一共展示了ErrorManager.MSG_UNDEFINED_TOKEN_REF_IN_REWRITE属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testUnknownToken
public void testUnknownToken() throws Exception {
ErrorQueue equeue = new ErrorQueue();
ErrorManager.setErrorListener(equeue);
String grammar =
"grammar T;\n" +
"options {output=AST;}\n" +
"a : INT -> ICK ;\n" +
"ID : 'a'..'z'+ ;\n" +
"INT : '0'..'9'+;\n" +
"WS : (' '|'\\n') {$channel=HIDDEN;} ;\n";
Grammar g = new Grammar(grammar);
Tool antlr = newTool();
antlr.setOutputDirectory(null); // write to /dev/null
CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
g.setCodeGenerator(generator);
generator.genRecognizer();
int expectedMsgID = ErrorManager.MSG_UNDEFINED_TOKEN_REF_IN_REWRITE;
Object expectedArg = "ICK";
Object expectedArg2 = null;
GrammarSemanticsMessage expectedMessage =
new GrammarSemanticsMessage(expectedMsgID, g, null, expectedArg, expectedArg2);
checkError(equeue, expectedMessage);
}
示例2: testUnknownCharLiteralToken
public void testUnknownCharLiteralToken() throws Exception {
ErrorQueue equeue = new ErrorQueue();
ErrorManager.setErrorListener(equeue);
String grammar =
"grammar T;\n" +
"options {output=AST;}\n" +
"a : INT -> 'a' ;\n" +
"ID : 'a'..'z'+ ;\n" +
"INT : '0'..'9'+;\n" +
"WS : (' '|'\\n') {$channel=HIDDEN;} ;\n";
Grammar g = new Grammar(grammar);
Tool antlr = newTool();
antlr.setOutputDirectory(null); // write to /dev/null
CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
g.setCodeGenerator(generator);
generator.genRecognizer();
int expectedMsgID = ErrorManager.MSG_UNDEFINED_TOKEN_REF_IN_REWRITE;
Object expectedArg = "'a'";
Object expectedArg2 = null;
GrammarSemanticsMessage expectedMessage =
new GrammarSemanticsMessage(expectedMsgID, g, null, expectedArg, expectedArg2);
checkError(equeue, expectedMessage);
}
示例3: testUnknownStringLiteralToken
public void testUnknownStringLiteralToken() throws Exception {
ErrorQueue equeue = new ErrorQueue();
ErrorManager.setErrorListener(equeue);
String grammar =
"grammar T;\n" +
"options {output=AST;}\n" +
"a : INT -> 'foo' ;\n" +
"ID : 'a'..'z'+ ;\n" +
"INT : '0'..'9'+;\n" +
"WS : (' '|'\\n') {$channel=HIDDEN;} ;\n";
Grammar g = new Grammar(grammar);
Tool antlr = newTool();
antlr.setOutputDirectory(null); // write to /dev/null
CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
g.setCodeGenerator(generator);
generator.genRecognizer();
int expectedMsgID = ErrorManager.MSG_UNDEFINED_TOKEN_REF_IN_REWRITE;
Object expectedArg = "'foo'";
Object expectedArg2 = null;
GrammarSemanticsMessage expectedMessage =
new GrammarSemanticsMessage(expectedMsgID, g, null, expectedArg, expectedArg2);
checkError(equeue, expectedMessage);
}