本文整理匯總了C#中Antlr3.Tool.Grammar.ToString方法的典型用法代碼示例。如果您正苦於以下問題:C# Antlr3.Tool.Grammar.ToString方法的具體用法?C# Antlr3.Tool.Grammar.ToString怎麽用?C# Antlr3.Tool.Grammar.ToString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Antlr3.Tool.Grammar
的用法示例。
在下文中一共展示了Antlr3.Tool.Grammar.ToString方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: TestLabeledNotSet
public void TestLabeledNotSet()
{
Grammar g = new Grammar(
"parser grammar P;\n" +
"tokens { A; B; C; }\n" +
"a : t=~A ;\n" );
string expecting =
".s0->.s1" + NewLine +
".s1->.s2" + NewLine +
".s2-B..C->.s3" + NewLine +
".s3->:s4" + NewLine +
":s4-EOF->.s5" + NewLine;
checkRule( g, "a", expecting );
string expectingGrammarStr =
"1:8: parser grammar P;\n" +
"a : t=~ A ;";
Assert.AreEqual( expectingGrammarStr, g.ToString() );
}
示例2: TestLabeledNotCharSet
public void TestLabeledNotCharSet()
{
Grammar g = new Grammar(
"lexer grammar P;\n" +
"A : t=~'3' ;\n" );
string expecting =
".s0->.s1" + NewLine +
".s1->.s2" + NewLine +
".s2-{'\\u0000'..'2', '4'..'\\uFFFF'}->.s3" + NewLine +
".s3->:s4" + NewLine +
":s4-<EOT>->.s5" + NewLine;
checkRule( g, "A", expecting );
string expectingGrammarStr =
"1:7: lexer grammar P;\n" +
"A : t=~ '3' ;\n" +
"Tokens : A ;";
Assert.AreEqual( expectingGrammarStr, g.ToString() );
}
示例3: TestNotSetLoop
public void TestNotSetLoop()
{
Grammar g = new Grammar(
"lexer grammar P;\n" +
"A : ~('3')* ;\n" );
string expecting =
".s0->.s1" + NewLine +
".s1->.s2" + NewLine +
".s2->.s3" + NewLine +
".s2->.s9" + NewLine +
".s3->.s4" + NewLine +
".s4-{'\\u0000'..'2', '4'..'\\uFFFF'}->.s5" + NewLine +
".s5->.s3" + NewLine +
".s5->.s6" + NewLine +
".s6->:s7" + NewLine +
".s9->.s6" + NewLine +
":s7-<EOT>->.s8" + NewLine;
checkRule( g, "A", expecting );
string expectingGrammarStr =
"1:7: lexer grammar P;\n" +
"A : (~ ( '3' ) )* ;\n" +
"Tokens : A ;";
Assert.AreEqual( expectingGrammarStr, g.ToString() );
}
示例4: TestLabeledNotSet
public void TestLabeledNotSet()
{
Grammar g = new Grammar(
"parser grammar P;\n" +
"tokens { A; B; C; }\n" +
"a : t=~A ;\n" );
string expecting =
".s0->.s1\n" +
".s1->.s2\n" +
".s2-B..C->.s3\n" +
".s3->:s4\n" +
":s4-EOF->.s5\n";
checkRule( g, "a", expecting );
string expectingGrammarStr =
"1:8: parser grammar P;\n" +
"a : t=~ A ;";
assertEquals( expectingGrammarStr, g.ToString() );
}
示例5: TestLabeledNotBlockSet
public void TestLabeledNotBlockSet()
{
Grammar g = new Grammar(
"lexer grammar P;\n" +
"A : t=~('3'|'b') ;\n" );
string expecting =
".s0->.s1\n" +
".s1->.s2\n" +
".s2-{'\\u0000'..'2', '4'..'a', 'c'..'\\uFFFF'}->.s3\n" +
".s3->:s4\n" +
":s4-<EOT>->.s5\n";
checkRule( g, "A", expecting );
string expectingGrammarStr =
"1:7: lexer grammar P;\n" +
"A : t=~ ( '3' | 'b' ) ;\n" +
"Tokens : A ;";
assertEquals( expectingGrammarStr, g.ToString() );
}
示例6: TestNotSetLoop
public void TestNotSetLoop()
{
Grammar g = new Grammar(
"lexer grammar P;\n" +
"A : ~('3')* ;\n" );
string expecting =
".s0->.s1\n" +
".s1->.s2\n" +
".s2->.s3\n" +
".s2->.s9\n" +
".s3->.s4\n" +
".s4-{'\\u0000'..'2', '4'..'\\uFFFF'}->.s5\n" +
".s5->.s3\n" +
".s5->.s6\n" +
".s6->:s7\n" +
".s9->.s6\n" +
":s7-<EOT>->.s8\n";
checkRule( g, "A", expecting );
string expectingGrammarStr =
"1:7: lexer grammar P;\n" +
"A : (~ ( '3' ) )* ;\n" +
"Tokens : A ;";
assertEquals( expectingGrammarStr, g.ToString() );
}