Ejemplo n.º 1
0
def semanticProgram(program, assemblies=[]):
    from ast.namespace import Namespace
    from ast.vartypes import Type

    driver = Driver()
    globalNs = Namespace('')
    for asm in assemblies:
        driver._scanAssembly(globalNs, asm)

    driver.fixPrimitives()

    globalScope = semantic.makeGlobalScope(globalNs.symbols)

    return semantic.semantic(parse(lex(program)), globalScope)
Ejemplo n.º 2
0
    def compileProgram(self, ast, outputName):
        globalNs = self.scanAssemblies(self.references)

        self.fixPrimitives()

        # Fill globalNs with declared symbols
        for decl in ast:
            if hasattr(decl, 'name'):
                globalNs.symbols[decl.name] = decl

        globalScope = semantic.makeGlobalScope(globalNs.symbols)
        st = semantic.semantic(ast, globalScope)

        gen = CodeGenerator()
        gen.createProgram(outputName, st)