Files
smnp-py/smnp/newast/tools.py
2019-07-05 17:00:43 +02:00

9 lines
320 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().value}'", input.current().pos)