Exemplo 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
Exemplo 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
Exemplo n.º 3
0
class ParserTest(unittest.TestCase):
    
    def setUp(self):
        
        self._preprocessor = PreProcessor()
            
    def tearDown(self):
        
        self._preprocessor = None
        
    def testParsing(self):
        
        ast = self._preprocessor.get_expanded_ast(_CURDIR + os.sep + "test.goc3")
        self.assertIsNotNone(ast)
        print(ast.toXml())
            
        interpreter = Interpreter()
        interpreter.eval_grammar(ast, TestVisitor())
Exemplo n.º 4
0
    def __init__(self):

        self._preprocessor = PreProcessor()
        self._interpreter = Interpreter()
Exemplo n.º 5
0
 def __init__(self):
     
     self._preprocessor = PreProcessor()
     self._interpreter = Interpreter()
Exemplo n.º 6
0
 def setUp(self):
     
     self._preprocessor = PreProcessor()