Enable extending existing types to add custom methods

This commit is contained in:
Bartłomiej Pluta
2019-07-06 00:36:54 +02:00
parent f11b3b67f2
commit bf40c5130c
8 changed files with 86 additions and 6 deletions

View File

@@ -16,7 +16,7 @@ class ArgumentsDeclarationNode(Node):
raise RuntimeError("This class is not supposed to be automatically called")
class FunctionDefinition(StatementNode):
class FunctionDefinitionNode(StatementNode):
def __init__(self, pos):
super().__init__(pos)
self.children = [NoneNode(), NoneNode(), NoneNode()]
@@ -48,7 +48,7 @@ class FunctionDefinition(StatementNode):
@classmethod
def _parse(cls, input):
def createNode(function, name, arguments, body):
node = FunctionDefinition(function.pos)
node = FunctionDefinitionNode(function.pos)
node.name = name
node.arguments = arguments
node.body = body