Fix scanning of multiline operators with '<' or '/'
This commit is contained in:
parent
58b45e6cac
commit
4098c0e25a
@ -175,7 +175,6 @@ class Lexer:
|
||||
|
||||
return Token.HEREDOC, pos, out.getvalue()
|
||||
|
||||
# TODO: scan multi-char operators like ==
|
||||
def _scan_operator(self, char) -> tuple[Token, ast.Position, str]:
|
||||
pos = dataclasses.replace(self.pos)
|
||||
with io.StringIO() as out:
|
||||
@ -183,7 +182,6 @@ class Lexer:
|
||||
out.write(char)
|
||||
char = self._read()
|
||||
self._unread(char)
|
||||
val = out.getvalue()
|
||||
return Token.OPERATOR, pos, out.getvalue()
|
||||
|
||||
def scan(self) -> tuple[Token, ast.Position, str]:
|
||||
@ -208,7 +206,7 @@ class Lexer:
|
||||
# If the next character is not another less than symbol,
|
||||
# this is probably a less than operator.
|
||||
if self._peek(1) != '<':
|
||||
return Token.OPERATOR, self.pos, char
|
||||
return self._scan_operator(char)
|
||||
return self._scan_heredoc(char)
|
||||
case '/':
|
||||
next = self._peek(1)
|
||||
@ -224,7 +222,7 @@ class Lexer:
|
||||
# If the next character is not another slash
|
||||
# or an asterisk, this is probably a division
|
||||
# operator.
|
||||
return Token.OPERATOR, self.pos, char
|
||||
return self._scan_operator(char)
|
||||
case '#':
|
||||
# Ignore comments and return next token
|
||||
self._scan_comment(char)
|
||||
|
Loading…
Reference in New Issue
Block a user