示例#1
0
        public static Interpreter.Executable Compile(string code, MachineInfo machineInfo = null, Report.Printer printer = null)
        {
            var report = new Report(printer);

            var mi = machineInfo ?? new MachineInfo();

            var pp = new Preprocessor(report);

            pp.AddCode("machine.h", mi.HeaderCode);
            pp.AddCode(DefaultName, code);
            var lexer  = new Lexer(pp);
            var parser = new CParser();
            var tu     = parser.ParseTranslationUnit(lexer);

            var c = new Interpreter.Compiler(mi, report);

            c.Add(tu);
            var exe = c.Compile();

            return(exe);
        }