Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
 public CompileIf(Compiler compiler)
 {
     this.compiler = compiler;
 }
Esempio n. 4
0
 public CompileWhile(Compiler compiler)
 {
     this.compiler = compiler;
 }