本文整理汇总了C#中Antlr3.Tool.GrammarSemanticsMessage.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# GrammarSemanticsMessage.ToString方法的具体用法?C# GrammarSemanticsMessage.ToString怎么用?C# GrammarSemanticsMessage.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Antlr3.Tool.GrammarSemanticsMessage
的用法示例。
在下文中一共展示了GrammarSemanticsMessage.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestMessageStringificationIsConsistent
public void TestMessageStringificationIsConsistent()
{
string action = "$other.tree = null;";
ErrorQueue equeue = new ErrorQueue();
ErrorManager.SetErrorListener( equeue );
Grammar g = new Grammar(
"grammar a;\n" +
"options { output = AST;}" +
"otherrule\n" +
" : 'y' ;" +
"rule\n" +
" : other=otherrule {" + action + "}\n" +
" ;" );
AntlrTool antlr = newTool();
CodeGenerator generator = new CodeGenerator( antlr, g, "Java" );
g.CodeGenerator = generator;
generator.GenRecognizer(); // forces load of templates
ActionTranslator translator = new ActionTranslator( generator,
"rule",
new CommonToken( ANTLRParser.ACTION, action ), 1 );
string rawTranslation =
translator.Translate();
int expectedMsgID = ErrorManager.MSG_WRITE_TO_READONLY_ATTR;
object expectedArg = "other";
object expectedArg2 = "tree";
GrammarSemanticsMessage expectedMessage =
new GrammarSemanticsMessage( expectedMsgID, g, null, expectedArg, expectedArg2 );
string expectedMessageString = expectedMessage.ToString();
Assert.AreEqual( expectedMessageString, expectedMessage.ToString() );
}