From a4f2a248273064ec464e7d376f8f5778ac808bd6 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Sun, 28 Jun 2009 15:10:57 +0200 Subject: fixed error with not newline at file end moved __init__.py with testcode from src/front to src/ added in lexer "\n\n" at source end to have a newline at file end added unexpected end of file message, if matched token is None --- src/front/parser.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/front/parser.py') diff --git a/src/front/parser.py b/src/front/parser.py index 9e738d3..29e300d 100644 --- a/src/front/parser.py +++ b/src/front/parser.py @@ -23,6 +23,9 @@ class Parser: raise Exception(msg) def match(self, tag): + if self.token == None: + self.error("Unexpected end of file.") + if self.token.tag != tag: self.error("match: expected %s got %s\n" %(tag, self.token.tag)) val = self.token.value @@ -155,7 +158,7 @@ class Parser: # function_list = function { function }. def function_list(self): funcs = [self.function()] - while self.token != None: + while self.token: funcs.append(self.function()) return funcs -- cgit v1.2.3