Updated annotations in RecognitionException

This commit is contained in:
Sam Harwell 2013-02-18 19:34:29 -06:00
parent b12aff16b0
commit c865930973
8 changed files with 57 additions and 40 deletions

View File

@ -129,7 +129,7 @@ namespace Antlr4.Runtime
{
if (recognizer != null)
{
recognizer.NotifyErrorListeners(e.GetOffendingToken(), message, e);
recognizer.NotifyErrorListeners(e.OffendingToken, message, e);
}
}
@ -255,7 +255,7 @@ namespace Antlr4.Runtime
}
else
{
input = tokens.GetText(e.GetStartToken(), e.GetOffendingToken());
input = tokens.GetText(e.GetStartToken(), e.OffendingToken);
}
}
else
@ -270,8 +270,8 @@ namespace Antlr4.Runtime
public virtual void ReportInputMismatch(Parser recognizer, InputMismatchException
e)
{
string msg = "mismatched input " + GetTokenErrorDisplay(e.GetOffendingToken()) +
" expecting " + e.GetExpectedTokens().ToString(recognizer.TokenNames);
string msg = "mismatched input " + GetTokenErrorDisplay(e.OffendingToken) + " expecting "
+ e.GetExpectedTokens().ToString(recognizer.TokenNames);
NotifyErrorListeners(recognizer, msg, e);
}

View File

@ -78,7 +78,7 @@ namespace Antlr4.Runtime
this.predicateIndex = 0;
}
this.predicate = predicate;
this.SetOffendingToken(recognizer.CurrentToken);
this.OffendingToken = recognizer.CurrentToken;
}
public virtual int GetRuleIndex()

View File

@ -48,7 +48,7 @@ namespace Antlr4.Runtime
public InputMismatchException(Parser recognizer) : base(recognizer, ((ITokenStream
)recognizer.InputStream), recognizer._ctx)
{
this.SetOffendingToken(recognizer.CurrentToken);
this.OffendingToken = recognizer.CurrentToken;
}
}
}

View File

@ -65,18 +65,20 @@ namespace Antlr4.Runtime
return deadEndConfigs;
}
public override IIntStream GetInputStream()
public override IIntStream InputStream
{
return (ICharStream)base.GetInputStream();
get
{
return (ICharStream)base.InputStream;
}
}
public override string ToString()
{
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);
}
return string.Format("%s('%s')", typeof(Antlr4.Runtime.LexerNoViableAltException)

View File

@ -80,7 +80,7 @@ namespace Antlr4.Runtime
// LL(1) error
this.deadEndConfigs = deadEndConfigs;
this.startToken = startToken;
this.SetOffendingToken(offendingToken);
this.OffendingToken = offendingToken;
}
public virtual IToken GetStartToken()

View File

@ -47,7 +47,7 @@ namespace Antlr4.Runtime
private const long serialVersionUID = -3861826954750022374L;
/// <summary>Who threw the exception?</summary>
private Recognizer<object, object> recognizer;
private Antlr4.Runtime.Recognizer<object, object> recognizer;
private RuleContext ctx;
@ -72,8 +72,8 @@ namespace Antlr4.Runtime
this.input = input;
}
public RecognitionException(Recognizer<IToken, object> recognizer, IIntStream input
, ParserRuleContext ctx)
public RecognitionException(Antlr4.Runtime.Recognizer<IToken, object> recognizer,
IIntStream input, ParserRuleContext ctx)
{
this.recognizer = recognizer;
this.input = input;
@ -84,8 +84,8 @@ namespace Antlr4.Runtime
}
}
public RecognitionException(string message, Recognizer<IToken, object> recognizer
, IIntStream input, ParserRuleContext ctx) : base(message)
public RecognitionException(string message, Antlr4.Runtime.Recognizer<IToken, object
> recognizer, IIntStream input, ParserRuleContext ctx) : base(message)
{
this.recognizer = recognizer;
this.input = input;
@ -107,14 +107,17 @@ namespace Antlr4.Runtime
/// This will help us tie into the grammar and syntax diagrams in
/// ANTLRWorks v2.
/// </remarks>
public virtual int GetOffendingState()
protected internal int OffendingState
{
return offendingState;
}
protected internal void SetOffendingState(int offendingState)
{
this.offendingState = offendingState;
get
{
return offendingState;
}
set
{
int offendingState = value;
this.offendingState = offendingState;
}
}
public virtual IntervalSet GetExpectedTokens()
@ -127,29 +130,41 @@ namespace Antlr4.Runtime
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;
}
public virtual Recognizer<object, object> GetRecognizer()
{
return recognizer;
get
{
return recognizer;
}
}
}
}

View File

@ -111,8 +111,8 @@ namespace Antlr4.Runtime
/// <summary>What is the error header, normally line/character position information?</summary>
public virtual string GetErrorHeader(RecognitionException e)
{
int line = e.GetOffendingToken().Line;
int charPositionInLine = e.GetOffendingToken().Column;
int line = e.OffendingToken.Line;
int charPositionInLine = e.OffendingToken.Column;
return "line " + line + ":" + charPositionInLine;
}

@ -1 +1 @@
Subproject commit 65817b672a2f47c8c51530eb699295c41fb572ec
Subproject commit e4d1c14c8df3f27105e3bbf935d49f500bc3552e