Skip to content

Commit

Permalink
Merge pull request #11 from superraz375/patch-1
Browse files Browse the repository at this point in the history
Add properties to enable access to Lexer fields
  • Loading branch information
ericvergnaud committed Jun 21, 2015
2 parents 232d734 + 9cd727b commit 44bee0e
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions runtime/CSharp/Antlr4.Runtime/Lexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public abstract class Lexer : Recognizer<int, LexerATNSimulator>, ITokenSource
/// <summary>The token type for the current token</summary>
private int _type;

private readonly List<int> _modeStack = new List<int>();
private readonly Stack<int> _modeStack = new Stack<int>();

private int _mode = Antlr4.Runtime.Lexer.DefaultMode;

Expand Down Expand Up @@ -254,7 +254,7 @@ public virtual void Mode(int m)

public virtual void PushMode(int m)
{
_modeStack.Add(_mode);
_modeStack.Push(_mode);
Mode(m);
}

Expand All @@ -265,8 +265,7 @@ public virtual int PopMode()
throw new InvalidOperationException();
}

int mode = _modeStack[_modeStack.Count - 1];
_modeStack.RemoveAt(_modeStack.Count - 1);
int mode = _modeStack.Pop();
Mode(mode);
return _mode;
}
Expand Down Expand Up @@ -494,6 +493,40 @@ public virtual int Channel
}
}

public virtual Stack<int> ModeStack
{
get
{
return _modeStack;
}
}

public virtual int CurrentMode
{
get
{
return _mode;
}
set
{
int mode = value;
_mode = mode;
}
}

public virtual bool HitEOF
{
get
{
return _hitEOF;
}
set
{
bool hitEOF = value;
_hitEOF = hitEOF;
}
}

public virtual string[] ModeNames
{
get
Expand Down

0 comments on commit 44bee0e

Please sign in to comment.