Reformat evaluator #1
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from smnp.ast.node.block import BlockNode, CloseBlockNode, BlockItemNode
|
||||
from smnp.ast.parsers.statement import parseStatement
|
||||
from smnp.token.type import TokenType
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from smnp.ast.node.colon import ColonNode
|
||||
from smnp.ast.parsers.expression import parseExpression
|
||||
from smnp.error.syntax import SyntaxException
|
||||
from smnp.token.type import TokenType
|
||||
|
||||
@@ -11,7 +12,7 @@ def parseColon(expr1, input, parent):
|
||||
expr2 = parseExpression(input, parent)
|
||||
|
||||
if expr2 is None:
|
||||
raise SyntaxException(input.current().pos, f"Expected expression '{input.current().value}'")
|
||||
raise SyntaxException(f"Expected expression '{input.current().value}'", input.current().pos)
|
||||
colon = ColonNode(expr1, expr2, parent, token.pos)
|
||||
expr1.parent = colon
|
||||
expr2.parent = colon
|
||||
|
||||
@@ -7,6 +7,6 @@ def parseToken(input, parent):
|
||||
value = combineParsers([ parseStatement ])(input, parent)
|
||||
|
||||
if value is None:
|
||||
raise SyntaxException(None, "Unknown statement") # TODO
|
||||
raise SyntaxException("Unknown statement") # TODO
|
||||
|
||||
return value
|
||||
@@ -15,9 +15,9 @@ def rollup(parser):
|
||||
|
||||
def assertToken(expected, input):
|
||||
if not input.hasCurrent():
|
||||
raise SyntaxException(None, f"Expected '{expected}'")
|
||||
raise SyntaxException(f"Expected '{expected}'")
|
||||
if expected != input.current().type:
|
||||
raise SyntaxException(input.current().pos, f"Expected '{expected}', found '{input.current().value}'")
|
||||
raise SyntaxException(f"Expected '{expected}', found '{input.current().value}'", input.current().pos)
|
||||
|
||||
|
||||
def combineParsers(parsers):
|
||||
|
||||
Reference in New Issue
Block a user