comparison python/c3/semantics.py @ 163:8104fc8b5e90

Added visitor to c3
author Windel Bouwman
date Mon, 18 Mar 2013 20:13:57 +0100
parents b73bc14a3aa3
children e023d3ce1d63
comparison
equal deleted inserted replaced
162:d8c735dc31f9 163:8104fc8b5e90
15 self.mod = astnodes.Package(name) 15 self.mod = astnodes.Package(name)
16 self.mod.loc = loc 16 self.mod.loc = loc
17 self.mod.scope = self.curScope = Scope(topScope) 17 self.mod.scope = self.curScope = Scope(topScope)
18 def actOnVarDef(self, name, loc, t, ival): 18 def actOnVarDef(self, name, loc, t, ival):
19 s = astnodes.Variable(name, t) 19 s = astnodes.Variable(name, t)
20 s.loc = loc
21 self.addSymbol(s)
22 def actOnConstDef(self, name, loc, t, val):
23 s = astnodes.Constant(name, t, val)
20 s.loc = loc 24 s.loc = loc
21 self.addSymbol(s) 25 self.addSymbol(s)
22 def actOnFuncDef1(self, name, loc): 26 def actOnFuncDef1(self, name, loc):
23 self.curFunc = astnodes.Function(name) 27 self.curFunc = astnodes.Function(name)
24 self.curFunc.loc = loc 28 self.curFunc.loc = loc
46 def actOnBinop(self, lhs, op, rhs, loc): 50 def actOnBinop(self, lhs, op, rhs, loc):
47 bo = astnodes.Binop(lhs, op, rhs) 51 bo = astnodes.Binop(lhs, op, rhs)
48 bo.loc = loc 52 bo.loc = loc
49 return bo 53 return bo
50 def actOnNumber(self, num, loc): 54 def actOnNumber(self, num, loc):
51 n = astnodes.Constant(num) 55 n = astnodes.Literal(num)
52 n.loc = loc 56 n.loc = loc
53 return n 57 return n
54 def actOnVariableUse(self, d): 58 def actOnVariableUse(self, d):
55 return astnodes.VariableUse(d) 59 return astnodes.VariableUse(d)
56 60