Ejemplo n.º 1
0
class Compiler(object):
    def __init__(self):

        self._preprocessor = PreProcessor()
        self._interpreter = Interpreter()

    def add_include_dir(self, dirpath):

        self._preprocessor.add_include_dir(dirpath)

    def add_std_include_dir(self, dirpath):

        self._preprocessor.add_std_include_dir(dirpath)

    def compile(self, filepath):

        expanded_ast = self._preprocessor.get_expanded_ast(filepath)

        step0 = CompileStep0()
        self._interpreter.eval_grammar(expanded_ast, step0)
        root_module = step0.get_root_module()

        step1 = CompileStep1(root_module)
        self._interpreter.eval_grammar(expanded_ast, step1)

        step2 = CompileStep2(root_module)
        self._interpreter.eval_grammar(expanded_ast, step2)

        return root_module
Ejemplo n.º 2
0
class Compiler(object):
    
    def __init__(self):
        
        self._preprocessor = PreProcessor()
        self._interpreter = Interpreter()

    def add_include_dir(self, dirpath):
        
        self._preprocessor.add_include_dir(dirpath)

    def add_std_include_dir(self, dirpath):
        
        self._preprocessor.add_std_include_dir(dirpath)
        
    def compile(self, filepath):
        
        expanded_ast = self._preprocessor.get_expanded_ast(filepath)
        
        step0 = CompileStep0()
        self._interpreter.eval_grammar(expanded_ast, step0)
        root_module = step0.get_root_module()
        
        step1 = CompileStep1(root_module)
        self._interpreter.eval_grammar(expanded_ast, step1)

        step2 = CompileStep2(root_module)
        self._interpreter.eval_grammar(expanded_ast, step2)
                
        return root_module