Mercurial > lcfOS
view python/c3/semantics.py @ 213:003c8a976fff
Merge of semantics and parser again ..
author | Windel Bouwman |
---|---|
date | Fri, 05 Jul 2013 11:18:48 +0200 |
parents | b01429a5d695 |
children |
line wrap: on
line source
from . import astnodes from .scope import Scope, topScope from ppci import CompilerError class Semantics: """ This class constructs the AST from parser input """ def __init__(self, diag): self.diag = diag def addSymbol(self, s): if self.curScope.hasSymbol(s.name): msg = 'Redefinition of {0}'.format(s.name) raise CompilerError(msg, s.loc) else: self.curScope.addSymbol(s) def actOnFuncDef2(self, parameters, returntype, body): self.curFunc.body = body paramtypes = [p.typ for p in parameters] self.curFunc.typ = astnodes.FunctionType(paramtypes, returntype) self.curFunc = None self.curScope = self.curScope.parent