Skip to content

Commit 82b602a

Browse files
committed
feat: add check_class method
Will return if classes matches, and output a syntax error if not.
1 parent c150ba2 commit 82b602a

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/api/check.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,3 +428,14 @@ def is_ender(node) -> bool:
428428
'CONTINUE_DO', 'CONTINUE_FOR', 'CONTINUE_WHILE',
429429
'EXIT_DO', 'EXIT_FOR', 'EXIT_WHILE',
430430
'GOTO', 'RETURN', 'STOP'}
431+
432+
433+
def check_class(node, class_: CLASS, lineno: int) -> bool:
434+
""" Returns whether the given node has CLASS.unknown or the given class_.
435+
It False, it will emit a syntax error
436+
"""
437+
if node.class_ == CLASS.unknown or node.class_ == class_:
438+
return True
439+
440+
errmsg.syntax_error_unexpected_class(lineno, node.name, node.class_, class_)
441+
return False

0 commit comments

Comments
 (0)