Skip to content

Commit 11b298a

Browse files
authored
Merge pull request kozec#4 from chewi/py3.12
Python 3.12 fixes and 3.14 deprecation fixes
2 parents 023d43e + e8cc68c commit 11b298a

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

scc/cheader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ def eval_expr(expr):
5959
""" Eval and expression inside a #define using a suppart of python grammar """
6060

6161
def _eval(node):
62-
if isinstance(node, ast.Num):
63-
return node.n
62+
if isinstance(node, ast.Constant):
63+
return node.value
6464
elif isinstance(node, ast.BinOp):
6565
return OPERATORS[type(node.op)](_eval(node.left), _eval(node.right))
6666
elif isinstance(node, ast.UnaryOp):

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)