本文整理汇总了C#中Antlr.Runtime.CommonTokenStream.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# CommonTokenStream.ToString方法的具体用法?C# CommonTokenStream.ToString怎么用?C# CommonTokenStream.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Antlr.Runtime.CommonTokenStream
的用法示例。
在下文中一共展示了CommonTokenStream.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main(string[] args)
{
if (args.Length > 0 )
{
for (int i = 0; i < args.Length; i++)
{
string inputFileName = args[i];
if (!Path.IsPathRooted(inputFileName))
{
inputFileName = Path.Combine(Environment.CurrentDirectory, inputFileName);
}
ICharStream input = new ANTLRFileStream(inputFileName);
FuzzyJava lex = new FuzzyJava(input);
ITokenStream tokens = new CommonTokenStream(lex);
tokens.ToString();
//System.out.println(tokens);
}
}
else
Console.Error.WriteLine("Usage: fuzzy <input-file-list>");
}
示例2: TestTokensRules
public void TestTokensRules()
{
Grammar pg = new Grammar(
"parser grammar p;\n" +
"a : (INT|FLOAT|WS)+;\n" );
Grammar g = new Grammar();
g.ImportTokenVocabulary( pg );
g.FileName = "<string>";
g.SetGrammarContent(
"lexer grammar t;\n" +
"INT : (DIGIT)+ ;\n" +
"FLOAT : (DIGIT)+ '.' (DIGIT)* ;\n" +
"fragment DIGIT : '0'..'9';\n" +
"WS : (' ')+ {channel=99;};\n" );
ICharStream input = new ANTLRStringStream( "123 139.52" );
Interpreter lexEngine = new Interpreter( g, input );
CommonTokenStream tokens = new CommonTokenStream( lexEngine );
tokens.LT(5); // make sure it grabs all tokens
string result = tokens.ToString();
//System.out.println(result);
string expecting = "123 139.52";
Assert.AreEqual( expecting, result );
}