本文整理汇总了C#中IScanner.Read方法的典型用法代码示例。如果您正苦于以下问题:C# IScanner.Read方法的具体用法?C# IScanner.Read怎么用?C# IScanner.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IScanner
的用法示例。
在下文中一共展示了IScanner.Read方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseMain
/// <summary>
/// Inner parse method
/// </summary>
/// <param name="scanner">scanner</param>
/// <returns>the match</returns>
protected override ParserMatch ParseMain(IScanner scanner)
{
long offset = scanner.Offset;
int len = 0;
if (scanner.Peek() == '\r') // CR
{
scanner.Read();
++len;
}
if (scanner.Peek() == '\n') // LF
{
scanner.Read();
++len;
}
if (len>0)
{
ParserMatch m = ParserMatch.CreateSuccessfulMatch(scanner, offset, len);
return m;
}
scanner.Seek(offset);
return ParserMatch.CreateFailureMatch(scanner);
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: ParseMain
/// <summary>
/// Inner parse method
/// </summary>
/// <param name="scanner">scanner</param>
/// <returns>the match</returns>
protected override ParserMatch ParseMain(IScanner scanner)
{
long offset = scanner.Offset;
foreach(Char c in MatchedString)
{
// if input consummed return null
if (scanner.AtEnd || c != scanner.Peek() )
{
ParserMatch noMatch = ParserMatch.CreateFailureMatch(scanner, offset);
scanner.Seek(offset);
return noMatch;
}
// read next characted
scanner.Read();
}
// if we arrive at this point, we have a match
ParserMatch m = ParserMatch.CreateSuccessfulMatch(scanner, offset, MatchedString.Length);
// return match
return m;
}
示例6: ParseMain
/// <summary>
/// Inner parse method
/// </summary>
/// <param name="scanner">scanner</param>
/// <returns>the match</returns>
protected override ParserMatch ParseMain(IScanner scanner)
{
long offset = scanner.Offset;
bool isAccepted = Accepts(scanner.Peek());
if (isAccepted && Negate || !isAccepted && !Negate)
{
return ParserMatch.CreateFailureMatch(scanner);
}
// match character
scanner.Peek();
// if we arrive at this point, we have a match
ParserMatch m = ParserMatch.CreateSuccessfulMatch(scanner, offset, 1);
// updating offset
scanner.Read();
// return match
return m;
}
示例7: CountLineEnds
int CountLineEnds(IScanner scanner)
{
int count = 0;
while (!scanner.EndOfInput)
{
if ( ! subject.TryMatch(scanner).Success) scanner.Read();
else count++;
}
return count;
}