forked from jasder/antlr
Updated annotations in RecognitionException
This commit is contained in:
parent
b12aff16b0
commit
c865930973
|
@ -129,7 +129,7 @@ namespace Antlr4.Runtime
|
||||||
{
|
{
|
||||||
if (recognizer != null)
|
if (recognizer != null)
|
||||||
{
|
{
|
||||||
recognizer.NotifyErrorListeners(e.GetOffendingToken(), message, e);
|
recognizer.NotifyErrorListeners(e.OffendingToken, message, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,7 +255,7 @@ namespace Antlr4.Runtime
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
input = tokens.GetText(e.GetStartToken(), e.GetOffendingToken());
|
input = tokens.GetText(e.GetStartToken(), e.OffendingToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -270,8 +270,8 @@ namespace Antlr4.Runtime
|
||||||
public virtual void ReportInputMismatch(Parser recognizer, InputMismatchException
|
public virtual void ReportInputMismatch(Parser recognizer, InputMismatchException
|
||||||
e)
|
e)
|
||||||
{
|
{
|
||||||
string msg = "mismatched input " + GetTokenErrorDisplay(e.GetOffendingToken()) +
|
string msg = "mismatched input " + GetTokenErrorDisplay(e.OffendingToken) + " expecting "
|
||||||
" expecting " + e.GetExpectedTokens().ToString(recognizer.TokenNames);
|
+ e.GetExpectedTokens().ToString(recognizer.TokenNames);
|
||||||
NotifyErrorListeners(recognizer, msg, e);
|
NotifyErrorListeners(recognizer, msg, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ namespace Antlr4.Runtime
|
||||||
this.predicateIndex = 0;
|
this.predicateIndex = 0;
|
||||||
}
|
}
|
||||||
this.predicate = predicate;
|
this.predicate = predicate;
|
||||||
this.SetOffendingToken(recognizer.CurrentToken);
|
this.OffendingToken = recognizer.CurrentToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual int GetRuleIndex()
|
public virtual int GetRuleIndex()
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace Antlr4.Runtime
|
||||||
public InputMismatchException(Parser recognizer) : base(recognizer, ((ITokenStream
|
public InputMismatchException(Parser recognizer) : base(recognizer, ((ITokenStream
|
||||||
)recognizer.InputStream), recognizer._ctx)
|
)recognizer.InputStream), recognizer._ctx)
|
||||||
{
|
{
|
||||||
this.SetOffendingToken(recognizer.CurrentToken);
|
this.OffendingToken = recognizer.CurrentToken;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,18 +65,20 @@ namespace Antlr4.Runtime
|
||||||
return deadEndConfigs;
|
return deadEndConfigs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IIntStream GetInputStream()
|
public override IIntStream InputStream
|
||||||
{
|
{
|
||||||
return (ICharStream)base.GetInputStream();
|
get
|
||||||
|
{
|
||||||
|
return (ICharStream)base.InputStream;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
string symbol = string.Empty;
|
string symbol = string.Empty;
|
||||||
if (startIndex >= 0 && startIndex < ((ICharStream)GetInputStream()).Size)
|
if (startIndex >= 0 && startIndex < ((ICharStream)InputStream).Size)
|
||||||
{
|
{
|
||||||
symbol = ((ICharStream)GetInputStream()).GetText(Interval.Of(startIndex, startIndex
|
symbol = ((ICharStream)InputStream).GetText(Interval.Of(startIndex, startIndex));
|
||||||
));
|
|
||||||
symbol = Utils.EscapeWhitespace(symbol, false);
|
symbol = Utils.EscapeWhitespace(symbol, false);
|
||||||
}
|
}
|
||||||
return string.Format("%s('%s')", typeof(Antlr4.Runtime.LexerNoViableAltException)
|
return string.Format("%s('%s')", typeof(Antlr4.Runtime.LexerNoViableAltException)
|
||||||
|
|
|
@ -80,7 +80,7 @@ namespace Antlr4.Runtime
|
||||||
// LL(1) error
|
// LL(1) error
|
||||||
this.deadEndConfigs = deadEndConfigs;
|
this.deadEndConfigs = deadEndConfigs;
|
||||||
this.startToken = startToken;
|
this.startToken = startToken;
|
||||||
this.SetOffendingToken(offendingToken);
|
this.OffendingToken = offendingToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual IToken GetStartToken()
|
public virtual IToken GetStartToken()
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace Antlr4.Runtime
|
||||||
private const long serialVersionUID = -3861826954750022374L;
|
private const long serialVersionUID = -3861826954750022374L;
|
||||||
|
|
||||||
/// <summary>Who threw the exception?</summary>
|
/// <summary>Who threw the exception?</summary>
|
||||||
private Recognizer<object, object> recognizer;
|
private Antlr4.Runtime.Recognizer<object, object> recognizer;
|
||||||
|
|
||||||
private RuleContext ctx;
|
private RuleContext ctx;
|
||||||
|
|
||||||
|
@ -72,8 +72,8 @@ namespace Antlr4.Runtime
|
||||||
this.input = input;
|
this.input = input;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecognitionException(Recognizer<IToken, object> recognizer, IIntStream input
|
public RecognitionException(Antlr4.Runtime.Recognizer<IToken, object> recognizer,
|
||||||
, ParserRuleContext ctx)
|
IIntStream input, ParserRuleContext ctx)
|
||||||
{
|
{
|
||||||
this.recognizer = recognizer;
|
this.recognizer = recognizer;
|
||||||
this.input = input;
|
this.input = input;
|
||||||
|
@ -84,8 +84,8 @@ namespace Antlr4.Runtime
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecognitionException(string message, Recognizer<IToken, object> recognizer
|
public RecognitionException(string message, Antlr4.Runtime.Recognizer<IToken, object
|
||||||
, IIntStream input, ParserRuleContext ctx) : base(message)
|
> recognizer, IIntStream input, ParserRuleContext ctx) : base(message)
|
||||||
{
|
{
|
||||||
this.recognizer = recognizer;
|
this.recognizer = recognizer;
|
||||||
this.input = input;
|
this.input = input;
|
||||||
|
@ -107,14 +107,17 @@ namespace Antlr4.Runtime
|
||||||
/// This will help us tie into the grammar and syntax diagrams in
|
/// This will help us tie into the grammar and syntax diagrams in
|
||||||
/// ANTLRWorks v2.
|
/// ANTLRWorks v2.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public virtual int GetOffendingState()
|
protected internal int OffendingState
|
||||||
{
|
{
|
||||||
return offendingState;
|
get
|
||||||
}
|
{
|
||||||
|
return offendingState;
|
||||||
protected internal void SetOffendingState(int offendingState)
|
}
|
||||||
{
|
set
|
||||||
this.offendingState = offendingState;
|
{
|
||||||
|
int offendingState = value;
|
||||||
|
this.offendingState = offendingState;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual IntervalSet GetExpectedTokens()
|
public virtual IntervalSet GetExpectedTokens()
|
||||||
|
@ -127,29 +130,41 @@ namespace Antlr4.Runtime
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual RuleContext GetCtx()
|
public virtual RuleContext Context
|
||||||
{
|
{
|
||||||
return ctx;
|
get
|
||||||
|
{
|
||||||
|
return ctx;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual IIntStream GetInputStream()
|
public virtual IIntStream InputStream
|
||||||
{
|
{
|
||||||
return input;
|
get
|
||||||
|
{
|
||||||
|
return input;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual IToken GetOffendingToken()
|
protected internal IToken OffendingToken
|
||||||
{
|
{
|
||||||
return offendingToken;
|
get
|
||||||
|
{
|
||||||
|
return offendingToken;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
IToken offendingToken = value;
|
||||||
|
this.offendingToken = offendingToken;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected internal void SetOffendingToken(IToken offendingToken)
|
public virtual Antlr4.Runtime.Recognizer<object, object> Recognizer
|
||||||
{
|
{
|
||||||
this.offendingToken = offendingToken;
|
get
|
||||||
}
|
{
|
||||||
|
return recognizer;
|
||||||
public virtual Recognizer<object, object> GetRecognizer()
|
}
|
||||||
{
|
|
||||||
return recognizer;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,8 +111,8 @@ namespace Antlr4.Runtime
|
||||||
/// <summary>What is the error header, normally line/character position information?</summary>
|
/// <summary>What is the error header, normally line/character position information?</summary>
|
||||||
public virtual string GetErrorHeader(RecognitionException e)
|
public virtual string GetErrorHeader(RecognitionException e)
|
||||||
{
|
{
|
||||||
int line = e.GetOffendingToken().Line;
|
int line = e.OffendingToken.Line;
|
||||||
int charPositionInLine = e.GetOffendingToken().Column;
|
int charPositionInLine = e.OffendingToken.Column;
|
||||||
return "line " + line + ":" + charPositionInLine;
|
return "line " + line + ":" + charPositionInLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 65817b672a2f47c8c51530eb699295c41fb572ec
|
Subproject commit e4d1c14c8df3f27105e3bbf935d49f500bc3552e
|
Loading…
Reference in New Issue