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