Clean code

This commit is contained in:
Bartłomiej Pluta
2019-07-11 19:51:47 +02:00
parent 5a1d568e8e
commit 261530eb10
8 changed files with 53 additions and 92 deletions

View File

@@ -8,22 +8,23 @@ class Program(Node):
def __init__(self):
super().__init__((-1, -1))
def parse(input):
root = Program()
while input.hasCurrent():
result = Parser.oneOf(
# Start Symbol
ImportParser,
StatementParser,
exception=RuntimeError("Nie znam tego wyrazenia")
)(input)
def ProgramParser(input):
def parse(input):
root = Program()
while input.hasCurrent():
result = Parser.oneOf(
# Start Symbol
ImportParser,
StatementParser,
exception=RuntimeError("Nie znam tego wyrazenia")
)(input)
if result.result:
root.append(result.node)
if result.result:
root.append(result.node)
return ParseResult.OK(root)
return ParseResult.OK(root)
ProgramParser = Parser(parse, name="program")
return Parser(parse, name="program")(input)
# @classmethod
# def _parse(cls, input):
# def parseToken(input):