当前位置: 首页>>代码示例>>C#>>正文


C# Lexer.Peek方法代码示例

本文整理汇总了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;
 }
开发者ID:KevinKelley,项目名称:katahdin,代码行数:30,代码来源:CharNode.cs

示例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;
 }
开发者ID:KevinKelley,项目名称:katahdin,代码行数:25,代码来源:AnyNode.cs

示例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;
 }
开发者ID:KevinKelley,项目名称:katahdin,代码行数:52,代码来源:TextNode.cs


注:本文中的Lexer.Peek方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。