Mercurial > lcfOS
comparison python/c3/semantics.py @ 169:ee0d30533dae
Added more tests and improved the diagnostic update
author | Windel Bouwman |
---|---|
date | Sat, 23 Mar 2013 18:34:41 +0100 |
parents | 0b5b2ee6b435 |
children | a51b3c956386 |
comparison
equal
deleted
inserted
replaced
168:49f1ab80d040 | 169:ee0d30533dae |
---|---|
3 | 3 |
4 class Semantics: | 4 class Semantics: |
5 """ This class constructs the AST from parser input """ | 5 """ This class constructs the AST from parser input """ |
6 def __init__(self, diag): | 6 def __init__(self, diag): |
7 self.diag = diag | 7 self.diag = diag |
8 def reinit(self): | |
9 # Set mod to empty package: | |
10 self.mod = astnodes.Package('unnamed') | |
11 self.mod.scope = Scope(topScope) | |
8 def addSymbol(self, s): | 12 def addSymbol(self, s): |
9 if self.curScope.hasSymbol(s.name): | 13 if self.curScope.hasSymbol(s.name): |
10 msg = 'Redefinition of {0}'.format(s.name) | 14 msg = 'Redefinition of {0}'.format(s.name) |
11 self.diag.error(msg, s.loc) | 15 self.diag.error(msg, s.loc) |
12 else: | 16 else: |