Merge pull request #11 from superraz375/patch-1

Add properties to enable access to Lexer fields
This commit is contained in:
ericvergnaud 2015-06-21 18:06:50 +08:00
commit 44bee0ed58
1 changed files with 37 additions and 4 deletions

View File

@ -105,7 +105,7 @@ namespace Antlr4.Runtime
/// <summary>The token type for the current token</summary> /// <summary>The token type for the current token</summary>
private int _type; 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; private int _mode = Antlr4.Runtime.Lexer.DefaultMode;
@ -254,7 +254,7 @@ outer_continue: ;
public virtual void PushMode(int m) public virtual void PushMode(int m)
{ {
_modeStack.Add(_mode); _modeStack.Push(_mode);
Mode(m); Mode(m);
} }
@ -265,8 +265,7 @@ outer_continue: ;
throw new InvalidOperationException(); throw new InvalidOperationException();
} }
int mode = _modeStack[_modeStack.Count - 1]; int mode = _modeStack.Pop();
_modeStack.RemoveAt(_modeStack.Count - 1);
Mode(mode); Mode(mode);
return _mode; return _mode;
} }
@ -494,6 +493,40 @@ outer_continue: ;
} }
} }
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 public virtual string[] ModeNames
{ {
get get