示例#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;

                while(true)
                {
                    Console.Write("ready>");
                    switch(m_parser.GetNextToken())
                    {
                        case TokenCode.Eof:
                            module.Dump();
                            return;

                        case TokenCode.Def:
                            HandleDefinition();
                            break;

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

                        default:
                            HandleTopLevelExpression();
                            break;
                    }
                }

                module.Dump();
            }
        }
示例#2
0
 public Parser(Lexer lexer)
 {
     m_lexer = lexer;
 }