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