Fix issue where position was retained across Lexer instances
This commit is contained in:
parent
4098c0e25a
commit
fbd62512d1
@ -15,10 +15,9 @@ class Block(dict):
|
||||
self.labels = labels
|
||||
super().__init__()
|
||||
|
||||
class Interp:
|
||||
vars: dict[str, typing.Any] = {}
|
||||
|
||||
class Interp:
|
||||
def __init__(self, stream: typing.TextIO, name: str):
|
||||
self.vars: dict[str, typing.Any] = {}
|
||||
self.parser = parser.Parser(stream, name)
|
||||
|
||||
def __setitem__(self, key, val):
|
||||
|
@ -34,11 +34,10 @@ class ExpectedError(Exception):
|
||||
self.expected = expected
|
||||
|
||||
class Lexer:
|
||||
pos = ast.Position()
|
||||
prev_pos = ast.Position()
|
||||
unread = ''
|
||||
|
||||
def __init__(self, stream: typing.TextIO, name: str):
|
||||
self.pos = pos = ast.Position()
|
||||
self.prev_pos = ast.Position()
|
||||
self.unread = ''
|
||||
self.stream = stream
|
||||
self.pos.name = name
|
||||
|
||||
|
@ -15,10 +15,9 @@ class ExpectedError(Exception):
|
||||
self.expected = expected
|
||||
|
||||
class Parser:
|
||||
_prev: tuple[lexer.Token, ast.Position, str] | None = None
|
||||
|
||||
def __init__(self, stream: TextIO, name: str):
|
||||
self.lexer = lexer.Lexer(stream, name)
|
||||
self._prev: tuple[lexer.Token, ast.Position, str] | None = None
|
||||
|
||||
def _scan(self) -> tuple[lexer.Token, ast.Position, str]:
|
||||
if self._prev is not None:
|
||||
|
Loading…
Reference in New Issue
Block a user