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


C# ICharStream.Mark方法代码示例

本文整理汇总了C#中ICharStream.Mark方法的典型用法代码示例。如果您正苦于以下问题:C# ICharStream.Mark方法的具体用法?C# ICharStream.Mark怎么用?C# ICharStream.Mark使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICharStream的用法示例。


在下文中一共展示了ICharStream.Mark方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Match

 public virtual int Match(ICharStream input, int mode)
 {
     match_calls++;
     this.mode = mode;
     int mark = input.Mark();
     try
     {
         this.startIndex = input.Index;
         this.prevAccept.Reset();
         DFAState s0 = atn.modeToDFA[mode].s0.Get();
         if (s0 == null)
         {
             return MatchATN(input);
         }
         else
         {
             return ExecATN(input, s0);
         }
     }
     finally
     {
         input.Release(mark);
     }
 }
开发者ID:hustsii,项目名称:antlr4cs,代码行数:24,代码来源:LexerATNSimulator.cs

示例2: EvaluatePredicate

 /// <summary>Evaluate a predicate specified in the lexer.</summary>
 /// <remarks>
 /// Evaluate a predicate specified in the lexer.
 /// <p/>
 /// If
 /// <code>speculative</code>
 /// is
 /// <code>true</code>
 /// , this method was called before
 /// <see cref="Consume(Antlr4.Runtime.ICharStream)">Consume(Antlr4.Runtime.ICharStream)
 ///     </see>
 /// for the matched character. This method should call
 /// <see cref="Consume(Antlr4.Runtime.ICharStream)">Consume(Antlr4.Runtime.ICharStream)
 ///     </see>
 /// before evaluating the predicate to ensure position
 /// sensitive values, including
 /// <see cref="Antlr4.Runtime.Lexer.Text()">Antlr4.Runtime.Lexer.Text()</see>
 /// ,
 /// <see cref="Antlr4.Runtime.Lexer.Line()">Antlr4.Runtime.Lexer.Line()</see>
 /// ,
 /// and
 /// <see cref="Antlr4.Runtime.Lexer.Column()">Antlr4.Runtime.Lexer.Column()</see>
 /// , properly reflect the current
 /// lexer state. This method should restore
 /// <code>input</code>
 /// and the simulator
 /// to the original state before returning (i.e. undo the actions made by the
 /// call to
 /// <see cref="Consume(Antlr4.Runtime.ICharStream)">Consume(Antlr4.Runtime.ICharStream)
 ///     </see>
 /// .
 /// </remarks>
 /// <param name="input">The input stream.</param>
 /// <param name="ruleIndex">The rule containing the predicate.</param>
 /// <param name="predIndex">The index of the predicate within the rule.</param>
 /// <param name="speculative">
 /// 
 /// <code>true</code>
 /// if the current index in
 /// <code>input</code>
 /// is
 /// one character before the predicate's location.
 /// </param>
 /// <returns>
 /// 
 /// <code>true</code>
 /// if the specified predicate evaluates to
 /// <code>true</code>
 /// .
 /// </returns>
 protected internal virtual bool EvaluatePredicate(ICharStream input, int ruleIndex
     , int predIndex, bool speculative)
 {
     // assume true if no recognizer was provided
     if (recog == null)
     {
         return true;
     }
     if (!speculative)
     {
         return recog.Sempred(null, ruleIndex, predIndex);
     }
     int savedCharPositionInLine = charPositionInLine;
     int savedLine = line;
     int index = input.Index;
     int marker = input.Mark();
     try
     {
         Consume(input);
         return recog.Sempred(null, ruleIndex, predIndex);
     }
     finally
     {
         charPositionInLine = savedCharPositionInLine;
         line = savedLine;
         input.Seek(index);
         input.Release(marker);
     }
 }
开发者ID:hustsii,项目名称:antlr4cs,代码行数:79,代码来源:LexerATNSimulator.cs

示例3: Match

 public int Match(ICharStream input, int mode)
 {
     match_calls++;
     this.mode = mode;
     int mark = input.Mark();
     try
     {
         this.startIndex = input.Index;
         this.prevAccept.Reset();
         DFA dfa = decisionToDFA[mode];
         if (dfa.s0 == null)
         {
             return MatchATN(input);
         }
         else
         {
             return ExecATN(input, dfa.s0);
         }
     }
     finally
     {
         input.Release(mark);
     }
 }
开发者ID:antlr,项目名称:antlr4,代码行数:24,代码来源:LexerATNSimulator.cs


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