diff options
Diffstat (limited to 'src/front/parser.py')
-rw-r--r-- | src/front/parser.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/front/parser.py b/src/front/parser.py index 72e0051..5029158 100644 --- a/src/front/parser.py +++ b/src/front/parser.py @@ -149,12 +149,13 @@ class Parser: self.match(Tag.END, Tag.NEWLINE) return Function(name, args, block, line) - # statement = ( if_statement | while_statement | assign_statement | return_statement | function_call ) nl. + # statement = ( if_statement | while_statement | assign_statement | return_statement | function_call | print_statement ) nl. def statement(self): res = {Tag.IF: self.if_statement, Tag.WHILE: self.while_statement, Tag.IDENT: self.assignment, Tag.RETURN: self.return_statement, + Tag.PRINT: self.print_statement, Tag.CALL: self.function_call, }[self.token.tag]() self.match(Tag.NEWLINE) @@ -201,6 +202,12 @@ class Parser: self.scope.add_locals(name) return AssignStatement(name, exp, line) + def print_statement(self): + line = self.lexer.line + self.match(Tag.PRINT) + exp = self.boolean() + return PrintStatement(exp, line) + # program = function_list. def program(self): return Program(self.function_list()) |