Files
smnp-py/smnp/ast/tools.py
2019-07-06 21:43:43 +02:00

9 lines
323 B
Python

from smnp.error.syntax import SyntaxException
def assertToken(expected, input):
if not input.hasCurrent():
raise SyntaxException(f"Expected '{expected}'")
if expected != input.current().type:
raise SyntaxException(f"Expected '{expected}', found '{input.current().rawValue}'", input.current().pos)