@@ -33,35 +33,37 @@ THE SOFTWARE.
3333public abstract class PythonLexerBase : Lexer
3434{
3535 // A stack that keeps track of the indentation lengths
36- private Stack < int > _indentLengthStack = new Stack < int > ( ) ;
36+ private Stack < int > _indentLengthStack ;
3737 // A list where tokens are waiting to be loaded into the token stream
38- private LinkedList < IToken > _pendingTokens = new LinkedList < IToken > ( ) ;
38+ private LinkedList < IToken > _pendingTokens ;
3939 // last pending token types
40- private int _previousPendingTokenType = 0 ;
41- private int _lastPendingTokenTypeFromDefaultChannel = 0 ;
40+ private int _previousPendingTokenType ;
41+ private int _lastPendingTokenTypeFromDefaultChannel ;
4242
4343 // The amount of opened parentheses, square brackets, or curly braces
44- private int _opened = 0 ;
44+ private int _opened ;
4545
46- private bool _wasSpaceIndentation = false ;
47- private bool _wasTabIndentation = false ;
48- private bool _wasIndentationMixedWithSpacesAndTabs = false ;
46+ private bool _wasSpaceIndentation ;
47+ private bool _wasTabIndentation ;
48+ private bool _wasIndentationMixedWithSpacesAndTabs ;
4949 private const int INVALID_LENGTH = - 1 ;
5050
51- private CommonToken _curToken = null ! ; // current (under processing) token
52- private IToken _ffgToken = null ! ; // following (look ahead) token
51+ private CommonToken _curToken ; // current (under processing) token
52+ private IToken _ffgToken ; // following (look ahead) token
5353
5454 private const string _ERR_TXT = " ERROR: " ;
5555
5656 protected PythonLexerBase ( ICharStream input ) : base ( input )
5757 {
58+ Init ( ) ;
5859 }
5960
6061 protected PythonLexerBase ( ICharStream input , TextWriter output , TextWriter errorOutput ) : base ( input , output , errorOutput )
6162 {
63+ Init ( ) ;
6264 }
6365
64- public override void Reset ( )
66+ private void Init ( )
6567 {
6668 _indentLengthStack = new Stack < int > ( ) ;
6769 _pendingTokens = new LinkedList < IToken > ( ) ;
@@ -73,7 +75,6 @@ public override void Reset()
7375 _wasIndentationMixedWithSpacesAndTabs = false ;
7476 _curToken = null ! ;
7577 _ffgToken = null ! ;
76- base . Reset ( ) ;
7778 }
7879
7980 public override IToken NextToken ( ) // reading the input stream until a return EOF
@@ -385,4 +386,10 @@ private void ReportError(string errMsg)
385386 // the ERROR_TOKEN will raise an error in the parser
386387 CreateAndAddPendingToken ( PythonLexer . ERROR_TOKEN , TokenConstants . DefaultChannel , _ERR_TXT + errMsg , _ffgToken ) ;
387388 }
389+
390+ public override void Reset ( )
391+ {
392+ Init ( ) ;
393+ base . Reset ( ) ;
394+ }
388395}
0 commit comments