Skip to content

Commit 51dda4b

Browse files
committed
Fix parser to handle new non-terminating newline NL token in Python 3.12
1 parent 17a9cb8 commit 51dda4b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

scc/parser.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def _tokens_left(self):
136136
def _parse_parameter(self):
137137
""" Parses single parameter """
138138
t = self._next_token()
139-
while t.type == TokenType.NEWLINE or t.value == "\n":
139+
while t.type in (TokenType.NL, TokenType.NEWLINE) or t.value == "\n":
140140
if not self._tokens_left():
141141
raise ParseError("Expected parameter at end of string")
142142
t = self._next_token()
@@ -236,7 +236,7 @@ def _parse_parameters(self):
236236
parameters.append(self._parse_parameter())
237237
# Check if next token is either ')' or ','
238238
t = self._peek_token()
239-
while t.type == TokenType.NEWLINE or t.value == "\n":
239+
while t.type in (TokenType.NL, TokenType.NEWLINE) or t.value == "\n":
240240
self._next_token()
241241
if not self._tokens_left():
242242
raise ParseError("Expected ',' or end of parameter list after parameter '%s'" % (parameters[-1],))
@@ -310,8 +310,8 @@ def _parse_action(self, frm=Action.ALL):
310310
action1 = self._create_action(action_class, *parameters)
311311
action2 = self._parse_action()
312312
return MultiAction(action1, action2)
313-
314-
if t.type == TokenType.NEWLINE or t.value == "\n":
313+
314+
if t.type in (TokenType.NL, TokenType.NEWLINE) or t.value == "\n":
315315
# Newline can be used to join actions instead of 'and'
316316
self._next_token()
317317
if not self._tokens_left():
@@ -324,11 +324,11 @@ def _parse_action(self, frm=Action.ALL):
324324
action1 = self._create_action(action_class, *parameters)
325325
action2 = self._parse_action()
326326
return MultiAction(action1, action2)
327-
327+
328328
if t.type == TokenType.OP and t.value == ';':
329329
# Two (or more) actions joined by ';'
330330
self._next_token()
331-
while self._tokens_left() and self._peek_token().type == TokenType.NEWLINE:
331+
while self._tokens_left() and self._peek_token().type in (TokenType.NL, TokenType.NEWLINE):
332332
self._next_token()
333333
if not self._tokens_left():
334334
# Having ';' at end of string is not actually error

0 commit comments

Comments
 (0)