Add 'throw' statement

This commit is contained in:
Bartłomiej Pluta
2019-07-13 14:48:58 +02:00
parent a07b226edb
commit 86cf5d01f3
7 changed files with 52 additions and 2 deletions

17
smnp/ast/node/throw.py Normal file
View File

@@ -0,0 +1,17 @@
from smnp.ast.node.expression import ExpressionParser
from smnp.ast.node.valuable import Valuable
from smnp.ast.parser import Parser
from smnp.token.type import TokenType
class Throw(Valuable):
pass
def ThrowParser(input):
return Parser.allOf(
Parser.terminal(TokenType.THROW),
Parser.doAssert(ExpressionParser, "error message as string"),
createNode=lambda throw, message: Throw.withValue(message, throw.pos),
name="throw"
)(input)