本文整理汇总了C#中Lexer.Peek方法的典型用法代码示例。如果您正苦于以下问题:C# Lexer.Peek方法的具体用法?C# Lexer.Peek怎么用?C# Lexer.Peek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lexer
的用法示例。
在下文中一共展示了Lexer.Peek方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
public override ParseTree Parse(Lexer lexer, ParserState state)
{
lexer.Whitespace(state.RuntimeState);
int start = lexer.Position;
state.RuntimeState.Runtime.ParseTrace.Enter(this, lexer.CurrentSource(), range.ToString());
char character = lexer.Peek();
if (!range.Contains(character))
{
lexer.ErrorStrings[start].Add(range.ToString());
state.RuntimeState.Runtime.ParseTrace.No(this,
lexer.SourceFrom(start), TextEscape.Quote(character));
return ParseTree.No;
}
lexer.Read();
state.RuntimeState.Runtime.ParseTrace.Yes(this,
lexer.SourceFrom(start), TextEscape.Quote(character));
if (state.BuildTextNodes)
return new ParseTree(Convert.ToString(character));
else
return ParseTree.Yes;
}
示例2: Parse
public override ParseTree Parse(Lexer lexer, ParserState state)
{
lexer.Whitespace(state.RuntimeState);
int start = lexer.Position;
state.RuntimeState.Runtime.ParseTrace.Enter(this, lexer.CurrentSource(), "[]");
char character = lexer.Peek();
if (character == '\0')
{
state.RuntimeState.Runtime.ParseTrace.No(this, lexer.SourceFrom(start), "End of source");
return ParseTree.No;
}
lexer.Read();
state.RuntimeState.Runtime.ParseTrace.Yes(this, lexer.SourceFrom(start), TextEscape.Quote(character));
if (state.BuildTextNodes)
return new ParseTree(Convert.ToString(character));
else
return ParseTree.Yes;
}
示例3: Parse
public override ParseTree Parse(Lexer lexer, ParserState state)
{
lexer.Whitespace(state.RuntimeState);
int start = lexer.Position;
state.RuntimeState.Runtime.ParseTrace.Enter(
this,
lexer.CurrentSource(),
TextEscape.Quote(text));
for (int n = 0; n < text.Length; n++)
{
char character = lexer.Peek(n);
if (character != text[n])
{
string stoppedString;
if (character == '\0')
stoppedString = "end";
else
stoppedString = TextEscape.Quote(character);
lexer.ErrorStrings[start + n].Add(TextEscape.Quote(text));
if (n > 0)
state.RuntimeState.Runtime.ParseTrace.No(
this,
lexer.SourceFrom(start),
TextEscape.Quote(lexer.Text.Substring(start, n))
+ "..." + stoppedString);
else
state.RuntimeState.Runtime.ParseTrace.No(
this,
lexer.SourceFrom(start),
stoppedString);
return ParseTree.No;
}
}
lexer.Skip(text.Length);
state.RuntimeState.Runtime.ParseTrace.Yes(this,
lexer.SourceFrom(start));
if (state.BuildTextNodes)
return new ParseTree(text);
else
return ParseTree.Yes;
}