本文整理汇总了C#中Parser.GetMatch方法的典型用法代码示例。如果您正苦于以下问题:C# Parser.GetMatch方法的具体用法?C# Parser.GetMatch怎么用?C# Parser.GetMatch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parser
的用法示例。
在下文中一共展示了Parser.GetMatch方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestStringsTwoSlashes
public void TestStringsTwoSlashes()
{
var literal = @"'\\'";
var parser = new Parser();
var result = parser.GetMatch(literal, parser.CSharpCodeItem);
Assert.IsTrue(result.Success);
}
示例2: Process
/// <summary>
/// Generate a parser from an IronMeta grammar.
/// </summary>
/// <param name="src_fname">The name of the source file (to use for error messages).</param>
/// <param name="input">Input stream.</param>
/// <param name="output">Output writer.</param>
/// <param name="name_space">Namespace to use in the generated parser.</param>
public static MatchResult<char, AST.AstNode> Process(string src_fname, IEnumerable<char> input, TextWriter output, string name_space)
{
var parser = new Parser();
var match = parser.GetMatch(input, parser.IronMetaFile);
if (match.Success)
{
var csgen = new CSharpGen(match.Result, name_space);
csgen.Generate(src_fname, output);
}
return match;
}
示例3: TestNoBaseClass
public void TestNoBaseClass()
{
var grammar = @"ironmeta TestGrammar<char, int> { One = ""1""; }";
var parser = new Parser();
var result = parser.GetMatch(grammar, parser.IronMetaFile);
Assert.IsTrue(result.Success);
var gen = new CSharpGen(result.Result, "TestNoBaseClass");
string src = null;
using (var ms = new MemoryStream())
using (var sw = new StreamWriter(ms))
{
gen.Generate("testNoBaseClass.ironmeta", sw);
src = Encoding.UTF8.GetString(ms.ToArray());
}
Assert.IsTrue(src.Contains("class TestGrammar : IronMeta.Matcher.Matcher<char, int>"));
}
示例4: TestParse
bool TestParse(string str)
{
var parser = new Parser();
var result = parser.GetMatch(str, parser.IronMetaFile);
return result.Success;
}
示例5: TestRegexp
public void TestRegexp()
{
var grammar = @"ironmeta TestRe<char, int> { One = /1/; }";
var parser = new Parser();
var result = parser.GetMatch(grammar, parser.IronMetaFile);
Assert.IsTrue(result.Success);
}