本文整理汇总了C#中IScanner.CreateMatch方法的典型用法代码示例。如果您正苦于以下问题:C# IScanner.CreateMatch方法的具体用法?C# IScanner.CreateMatch怎么用?C# IScanner.CreateMatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IScanner
的用法示例。
在下文中一共展示了IScanner.CreateMatch方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryMatch
public ParserMatch TryMatch(IScanner scan)
{
int offset = scan.Offset;
int len = 0;
if (!scan.EndOfInput && scan.Peek() == '\r') // CR
{
scan.Read();
len++;
}
if (!scan.EndOfInput && scan.Peek() == '\n') // LF
{
scan.Read();
len++;
}
if (len > 0)
{
return scan.CreateMatch(this, offset, len);
}
scan.Seek(offset);
return scan.NoMatch;
}
示例2: TryMatch
public ParserMatch TryMatch(IScanner scan)
{
if (scan.EndOfInput) return scan.NoMatch;
int offset = scan.Offset;
var m = scan.CreateMatch(this, offset, 1);
scan.Read();
return m;
}
示例3: TryMatch
/// <summary>
/// Test the regular expression.
/// </summary>
/// <remarks>This is done on the entire input.
/// This might cause problems with file-stream parsing.</remarks>
public ParserMatch TryMatch(IScanner scan)
{
int offset = scan.Offset;
string remains = scan.RemainingData();
var result = test.Match(remains);
if (result.Success && result.Index == 0)
{
scan.Seek(offset + result.Length);
return scan.CreateMatch(this, offset, result.Length);
}
return scan.NoMatch;
}
示例4: TryMatch
public ParserMatch TryMatch(IScanner scan)
{
int offset = scan.Offset;
string compare = scan.Substring(offset, test.Length);
if (compare == test)
{
scan.Seek(offset + test.Length);
return scan.CreateMatch(this, offset, test.Length);
}
scan.Seek(offset);
return scan.NoMatch;
}
示例5: TryMatch
public ParserMatch TryMatch(IScanner scan)
{
int offset = scan.Offset;
if (scan.EndOfInput) return scan.NoMatch;
char c = scan.Peek();
if (c != test) return scan.NoMatch;
// if we arrive at this point, we have a match
var m = scan.CreateMatch(this, offset, 1);
// updating offset
scan.Read();
// return match
return m;
}
示例6: TryMatch
public ParserMatch TryMatch(IScanner scan)
{
int offset = scan.Offset;
var m = scan.CreateMatch(this, offset, 0);
return m;
}