コード例 #1
0
ファイル: Form1.cs プロジェクト: nikita-vanyasin/compiler
        private bool BuildSource()
        {
            bool result = false;
            Log("_______________________________________________________________");
            Log("");

            var outStream = new FileStream(outputFileName, FileMode.Create);

            Log("Starting build...");
            var compiler = new Compiler();

            var text = (string)this.Invoke(new Func<string>(() => SourceBox.Text));
            result = compiler.Compile(text, outStream);

            var errorsContainer = compiler.GetErrorsContainer();
            foreach (var ev in errorsContainer)
            {
                text = (string)this.Invoke(new Func<string>(() => SourceBox.Text));
                int id = Log(TextUtils.WriteCompilerError(text, ev));
                m_errorPositions.Add(id, ev.Position);
            }

            if (result)
            {
                Log("Compiled successfully!");
                Log("");
            }
            outStream.Close();
            return result;
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: D-Eijkelenboom/DP2
        static void Main(string[] args)
        {
            string[] lines = File.ReadAllLines(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + "//snippets//example.txt");
            Tokenizer tokenizer = new Tokenizer(lines);
            Compiler compiler = new Compiler();
            compiler.compile(tokenizer.getTokens());
            VirtualMachine vm = new VirtualMachine();
            vm.Run(compiler.Nodes);

            Console.ReadLine();
        }
コード例 #3
0
ファイル: CompiledIf.cs プロジェクト: D-Eijkelenboom/DP2
 public CompileIf(Compiler compiler)
 {
     this.compiler = compiler;
 }
コード例 #4
0
ファイル: CompiledWhile.cs プロジェクト: D-Eijkelenboom/DP2
 public CompileWhile(Compiler compiler)
 {
     this.compiler = compiler;
 }