本文整理汇总了C#中Parser.NotifyErrorListeners方法的典型用法代码示例。如果您正苦于以下问题:C# Parser.NotifyErrorListeners方法的具体用法?C# Parser.NotifyErrorListeners怎么用?C# Parser.NotifyErrorListeners使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parser
的用法示例。
在下文中一共展示了Parser.NotifyErrorListeners方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReportContextSensitivity
public override void ReportContextSensitivity(Parser recognizer, DFA dfa, int startIndex
, int stopIndex, SimulatorState acceptState)
{
string format = "reportContextSensitivity d={0}, input='{1}'";
recognizer.NotifyErrorListeners(string.Format(format, GetDecisionDescription(recognizer
, dfa.decision), ((ITokenStream)recognizer.InputStream).GetText(Interval.Of(startIndex
, stopIndex))));
}
示例2: ReportAmbiguity
public override void ReportAmbiguity(Parser recognizer, DFA dfa, int startIndex,
int stopIndex, BitSet ambigAlts, ATNConfigSet configs)
{
string format = "reportAmbiguity d={0}: ambigAlts={1}, input='{2}'";
recognizer.NotifyErrorListeners(string.Format(format, GetDecisionDescription(recognizer
, dfa.decision), ambigAlts, ((ITokenStream)recognizer.InputStream).GetText(Interval
.Of(startIndex, stopIndex))));
}
示例3: ReportAmbiguity
public override void ReportAmbiguity(Parser recognizer, DFA dfa, int startIndex, int stopIndex, bool exact, BitSet ambigAlts, ATNConfigSet configs)
{
if (exactOnly && !exact)
{
return;
}
string format = "reportAmbiguity d={0}: ambigAlts={1}, input='{2}'";
string decision = GetDecisionDescription(recognizer, dfa);
BitSet conflictingAlts = GetConflictingAlts(ambigAlts, configs);
string text = ((ITokenStream)recognizer.InputStream).GetText(Interval.Of(startIndex, stopIndex));
string message = string.Format(format, decision, conflictingAlts, text);
recognizer.NotifyErrorListeners(message);
}
示例4: ReportMissingToken
/// <summary>
/// This method is called to report a syntax error which requires the
/// insertion of a missing token into the input stream.
/// </summary>
/// <remarks>
/// This method is called to report a syntax error which requires the
/// insertion of a missing token into the input stream. At the time this
/// method is called, the missing token has not yet been inserted. When this
/// method returns,
/// <paramref name="recognizer"/>
/// is in error recovery mode.
/// <p>This method is called when
/// <see cref="SingleTokenInsertion(Parser)"/>
/// identifies
/// single-token insertion as a viable recovery strategy for a mismatched
/// input error.</p>
/// <p>The default implementation simply returns if the handler is already in
/// error recovery mode. Otherwise, it calls
/// <see cref="BeginErrorCondition(Parser)"/>
/// to
/// enter error recovery mode, followed by calling
/// <see cref="Parser.NotifyErrorListeners(string)"/>
/// .</p>
/// </remarks>
/// <param name="recognizer">the parser instance</param>
protected internal virtual void ReportMissingToken(Parser recognizer)
{
if (InErrorRecoveryMode(recognizer))
{
return;
}
BeginErrorCondition(recognizer);
IToken t = recognizer.CurrentToken;
IntervalSet expecting = GetExpectedTokens(recognizer);
string msg = "missing " + expecting.ToString(recognizer.Vocabulary) + " at " + GetTokenErrorDisplay(t);
recognizer.NotifyErrorListeners(t, msg, null);
}
示例5: NotifyErrorListeners
protected internal virtual void NotifyErrorListeners(Parser recognizer, string message, RecognitionException e)
{
recognizer.NotifyErrorListeners(e.OffendingToken, message, e);
}
示例6: ReportUnwantedToken
/// <summary>
/// This method is called to report a syntax error which requires the removal
/// of a token from the input stream.
/// </summary>
/// <remarks>
/// This method is called to report a syntax error which requires the removal
/// of a token from the input stream. At the time this method is called, the
/// erroneous symbol is current
/// <code>LT(1)</code>
/// symbol and has not yet been
/// removed from the input stream. When this method returns,
/// <code>recognizer</code>
/// is in error recovery mode.
/// <p>This method is called when
/// <see cref="SingleTokenDeletion(Parser)"/>
/// identifies
/// single-token deletion as a viable recovery strategy for a mismatched
/// input error.</p>
/// <p>The default implementation simply returns if the handler is already in
/// error recovery mode. Otherwise, it calls
/// <see cref="BeginErrorCondition(Parser)"/>
/// to
/// enter error recovery mode, followed by calling
/// <see cref="Parser.NotifyErrorListeners(string)"/>
/// .</p>
/// </remarks>
/// <param name="recognizer">the parser instance</param>
protected internal virtual void ReportUnwantedToken(Parser recognizer)
{
if (InErrorRecoveryMode(recognizer))
{
return;
}
BeginErrorCondition(recognizer);
IToken t = recognizer.CurrentToken;
string tokenName = GetTokenErrorDisplay(t);
IntervalSet expecting = GetExpectedTokens(recognizer);
string msg = "extraneous input " + tokenName + " expecting " + expecting.ToString(recognizer.TokenNames);
recognizer.NotifyErrorListeners(t, msg, null);
}
示例7: ReportAttemptingFullContext
public override void ReportAttemptingFullContext(Parser recognizer, DFA dfa, int
startIndex, int stopIndex, BitSet conflictingAlts, SimulatorState conflictState
)
{
string format = "reportAttemptingFullContext d={0}, input='{1}'";
string decision = GetDecisionDescription(recognizer, dfa);
string text = ((ITokenStream)recognizer.InputStream).GetText(Interval.Of(startIndex
, stopIndex));
string message = string.Format(format, decision, text);
recognizer.NotifyErrorListeners(message);
}
示例8: ReportMissingToken
public virtual void ReportMissingToken(Parser recognizer)
{
if (errorRecoveryMode)
{
return;
}
recognizer._syntaxErrors++;
BeginErrorCondition(recognizer);
IToken t = recognizer.CurrentToken;
IntervalSet expecting = GetExpectedTokens(recognizer);
string msg = "missing " + expecting.ToString(recognizer.TokenNames) + " at " + GetTokenErrorDisplay
(t);
recognizer.NotifyErrorListeners(t, msg, null);
}