comparison python/c3/semantics.py @ 152:b73bc14a3aa3

Light coupling ide and c3 frontend
author Windel Bouwman
date Sat, 02 Mar 2013 09:56:12 +0100
parents 4ae0e02599de
children 8104fc8b5e90
comparison
equal deleted inserted replaced
151:afc8c0207984 152:b73bc14a3aa3
1 from . import astnodes 1 from . import astnodes
2 from .scope import Scope, topScope 2 from .scope import Scope, topScope
3 from ppci.errors import CompilerException
4 3
5 class Semantics: 4 class Semantics:
6 """ This class constructs the AST from parser input """ 5 """ This class constructs the AST from parser input """
7 def __init__(self, diag): 6 def __init__(self, diag):
8 self.diag = diag 7 self.diag = diag
9 def addSymbol(self, s): 8 def addSymbol(self, s):
10 if self.curScope.hasSymbol(s.name): 9 if self.curScope.hasSymbol(s.name):
11 msg = 'Redefinition of {0}'.format(s.name) 10 msg = 'Redefinition of {0}'.format(s.name)
12 self.diag.diag(CompilerException(msg, s.loc)) 11 self.diag.error(msg, s.loc)
13 else: 12 else:
14 self.curScope.addSymbol(s) 13 self.curScope.addSymbol(s)
15 def handlePackage(self, name, loc): 14 def handlePackage(self, name, loc):
16 self.mod = astnodes.Package(name) 15 self.mod = astnodes.Package(name)
17 self.mod.loc = loc 16 self.mod.loc = loc