From 87b6f874776b253f77f4a1bf4c1844d99a8e544f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20N=C3=BC=C3=9Flein?= Date: Thu, 2 Jul 2009 21:12:49 +0200 Subject: implement three-address-code objects instead of printf --- src/front/parser.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/front/parser.py') diff --git a/src/front/parser.py b/src/front/parser.py index 511e929..53818bc 100644 --- a/src/front/parser.py +++ b/src/front/parser.py @@ -93,7 +93,11 @@ class Parser: self.move() return Constant(0, self.lexer.line) if self.token.tag == Tag.IDENT: - return Variable(self.match(Tag.IDENT), self.lexer.line) + line = self.lexer.line + name = self.match(Tag.IDENT) + if not self.scope.contains(name): + raise SyntaxError("%s is not declared in line %d" % (name, line)) + return Variable(name, line) return self.function_call() # function_call = "call" ident "[" [ expression_list ] "]". -- cgit v1.2.3