blob: 43606a20776a5ad4575142440903f204b14e5467 (
plain) (
tree)
|
|
class Parser:
lexer = None
def __init__(self, lexer):
return
def parse(self):
return self.program()
def move(self):
return
def error(self, msg):
return
def match(tag):
return
# bool = bool "||" join | join.
def bool(self):
return
# join = join "&&" equality | equality.
def join(self):
return
# equality = equality "==" relation | equality "!=" relation | relation.
def equality(self):
return
# relation = expression "<" expression | expression "<=" expression | expression ">=" expression | expression ">" expression | expression.
def relation(self):
return
# expression = expression "+" term | expression "-" term | term.
def expression(self):
return
# term = term "*" unary | term "/" unary | unary.
def term(self):
return
# unary = "!" unary | "-" unary | factor.
def unary(self):
return
# factor = "(" bool ")" | ident | integer | "true" | "false".
def factor(self):
return
# ident_list = ident { "," ident }.
def ident_list(self):
return
# expression_list = expression { "," expression }.
def expression_list(self):
return
# program = function { function }.
def program(self):
return
# function = "fun" ident "[" [ ident_list ] "]" statements "end".
def function(self):
return
# statements = statement { nl statement }.
def statements(self):
return
# statement = [ if_statement | while_statement | assignment | function_call | return_statement ].
def statement(self):
return
# if_statement = "if" expression statements [ "else" statements ] "end".
def if_statement(self):
return
# while_statement = "while" expression statements "end".
def while_statement(self):
return
# assignment = ident "=" expression.
def assignment(self):
return
# function_call = ident "[" [ expression_list ] "]".
def function_call(self):
return
# return_statement = "@" expression.
def return_statement(self):
return
|