Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Options options = new Options();
            if (args.Length < 3)
            {
                Console.Write(options.GetUsage());
                return;
            }
            if (Parser.Default.ParseArguments(args, options))
            {
                string input = File.ReadAllText(options.InFile);
                Compiler comp = new Compiler();
                try
                {
                    string output = comp.Compile(input);
                    File.WriteAllText(options.OutFile, output);
                    File.WriteAllText(options.ErrorFile, "");
                }
                catch (Exception ex)
                {
                    try
                    {
                        File.WriteAllText(options.ErrorFile, ex.Message);
                    }
                    catch { }
                }

                
            }
        }
Ejemplo n.º 2
0
        public void TestCompiler1()
        {
            Compiler com = new Compiler();
            string output = com.Compile("a = b + c");
            string expected =
@"0, ""b""
0, ""c""
2, ""0""
1, ""a""";
            Assert.AreEqual(output, expected);
 
 
        }
Ejemplo n.º 3
0
        public void TestCompiler3()
        {
            Compiler com = new Compiler();
            string output = com.Compile("a = b and c OR d XoR e");
            string expected =
@"0, ""b""
0, ""c""
18, ""0""
0, ""d""
0, ""e""
19, ""0""
17, ""0""
1, ""a""";

            Assert.AreEqual(output, expected);
        }