当前位置: 首页>>代码示例>>Java>>正文


Java ErrorManager.MSG_UNDEFINED_TOKEN_REF_IN_REWRITE属性代码示例

本文整理汇总了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);
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:27,代码来源:TestRewriteAST.java

示例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);
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:27,代码来源:TestRewriteAST.java

示例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);
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:27,代码来源:TestRewriteAST.java


注:本文中的org.antlr.tool.ErrorManager.MSG_UNDEFINED_TOKEN_REF_IN_REWRITE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。