From 8d432ae653581815d16febf2af776a1a057660f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt=20B=C3=B6hm?= Date: Sat, 4 Jul 2009 10:44:47 +0200 Subject: adapt parser for backend changes - emit a prologue/epilogue for functions - emit a "JMP main" instruction in the beginning - track the last function label across genrate calls - split scope in params and local variables (they have a different layout on the stack) --- src/front/parser.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/front/parser.py') diff --git a/src/front/parser.py b/src/front/parser.py index 53818bc..8eca7a2 100644 --- a/src/front/parser.py +++ b/src/front/parser.py @@ -144,7 +144,8 @@ class Parser: self.match(Tag.LBRAK) args = [] if self.token.tag == Tag.RBRAK else self.ident_list() self.match(Tag.RBRAK, Tag.NEWLINE) - self.scope.new(name, args) + self.scope.new(name) + self.scope.add_params(args) block = self.statement_list() self.match(Tag.END, Tag.NEWLINE) return Function(name, args, block, line) @@ -198,7 +199,7 @@ class Parser: self.match(Tag.ASSIGNMENT) exp = self.boolean() self.match(Tag.NEWLINE) - self.scope.add(name) + self.scope.add_locals(name) return AssignStatement(name, exp, line) # program = function_list. -- cgit v1.2.3