Esempio n. 1
0
        public void Run()
        {
            Lexer lexer = new Lexer(Console.In);
            m_parser = new Parser(lexer);
            using(LLVM.Module module = new LLVM.Module("my cool jit"))
            using(m_builder = new LLVM.IRBuilder())
            {
                CodeGenManager.Module = module;
                m_engine = new LLVM.ExecutionEngine(module);
                m_passMgr = new LLVM.PassManager(module);
                m_passMgr.AddTargetData(m_engine.GetTargetData());
                m_passMgr.AddBasicAliasAnalysisPass();
                m_passMgr.AddPromoteMemoryToRegisterPass();
                m_passMgr.AddInstructionCombiningPass();
                m_passMgr.AddReassociatePass();
                m_passMgr.AddGVNPass();
                m_passMgr.AddCFGSimplificationPass();
                m_passMgr.Initialize();

                while(true)
                {
                    Console.Write("ready>");
                    switch(m_parser.GetNextToken())
                    {
                        case TokenCode.Eof:
                            // Continnue and consume new commands
                            // module.Dump();
                            break;

                        case TokenCode.Def:
                            HandleDefinition();
                            break;

                        case TokenCode.Symbol:
                            if(m_parser.Token.IdentiferText == ";")
                                m_parser.GetNextToken();
                            else
                                HandleTopLevelExpression();
                            break;

                        default:
                            HandleTopLevelExpression();
                            break;
                    }
                }
            }
        }
Esempio n. 2
0
 public Parser(Lexer lexer)
 {
     m_lexer = lexer;
 }