Skip to content

Commit e5935b9

Browse files
committed
Update PythonLexerBase.java
1 parent 45b2e72 commit e5935b9

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

port_Java/PythonLexerBase.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ of this software and associated documentation files (the "Software"), to deal
3333

3434
public abstract class PythonLexerBase extends Lexer {
3535
// A stack that keeps track of the indentation lengths
36-
private final Deque<Integer> _indentLengthStack = new ArrayDeque<>();
36+
private Deque<Integer> _indentLengthStack = new ArrayDeque<>();
3737
// A linked where tokens are waiting to be loaded into the token stream
3838
private LinkedList<Token> _pendingTokens = new LinkedList<>();
3939

@@ -49,15 +49,30 @@ public abstract class PythonLexerBase extends Lexer {
4949
private boolean _wasIndentationMixedWithSpacesAndTabs = false;
5050
private final int _INVALID_LENGTH = -1;
5151

52-
private CommonToken _curToken; // current (under processing) token
53-
private Token _ffgToken; // following (look ahead) token
52+
private CommonToken _curToken = null; // current (under processing) token
53+
private Token _ffgToken = null; // following (look ahead) token
5454

5555
private final String _ERR_TXT = " ERROR: ";
5656

5757
protected PythonLexerBase(CharStream input) {
5858
super(input);
5959
}
6060

61+
@Override
62+
public void reset() {
63+
_indentLengthStack = new ArrayDeque<>();
64+
_pendingTokens = new LinkedList<>();
65+
_previousPendingTokenType = 0;
66+
_lastPendingTokenTypeFromDefaultChannel = 0;
67+
_opened = 0;
68+
_wasSpaceIndentation = false;
69+
_wasTabIndentation = false;
70+
_wasIndentationMixedWithSpacesAndTabs = false;
71+
_curToken = null;
72+
_ffgToken = null;
73+
super.reset();
74+
}
75+
6176
@Override
6277
public Token nextToken() { // reading the input stream until a return EOF
6378
checkNextToken();

0 commit comments

Comments
 (0)