Exemplo n.º 1
0
        public void ParseLine(string value, bool expected)
        {
            var grammer = new AsmStructuralGrammar();
            var p = new ParserState(value);

            Assert.That(grammer.line.Match(p), Is.EqualTo(expected));

            var printer = new CppStructuralOutputAsXml();
            printer.Print(p.GetRoot());
            Console.WriteLine(printer.AsXml());
        }
Exemplo n.º 2
0
        public void Block(string expression, bool expected)
        {
            var grammer = new AndyStructuralGrammar();
            var p = new ParserState(expression);

            Assert.That(grammer.block.Match(p), Is.EqualTo(expected));

            var printer = new CppStructuralOutputAsXml();
            printer.Print(p.GetRoot());
            Console.WriteLine(printer.AsXml());
        }
Exemplo n.º 3
0
        public void OpenFile(string file)
        {
            var grammar = new AsmStructuralGrammar();
            file = string.Concat(_testPaths[Environment.MachineName], file);

            var outputFile = Path.ChangeExtension(file, ".asm");
            using (var stringWriter = File.CreateText(outputFile))
            using (var writer = new InstructionTextWriter(stringWriter))
            {
                string source = File.ReadAllText(file);
                var parser = new ParserState(source);
                var result = grammar.program.Match(parser);
                Assert.That(result, Is.True);

                var printer = new CppStructuralOutputAsXml();
                printer.Print(parser.GetRoot());
                Console.WriteLine(printer.AsXml());

                var assembler = new Assembler(parser);
                assembler.Assemble().ToList().ForEach(writer.Write);
            }
        }
Exemplo n.º 4
0
        public void UnaryInteger(string integer, bool expected)
        {
            var grammer = new AndyStructuralGrammar();
            var p = new ParserState(integer);

            Assert.That(grammer.term.Match(p), Is.EqualTo(expected));

            var printer = new CppStructuralOutputAsXml();
            printer.Print(p.GetRoot());
            Console.WriteLine(printer.AsXml());
        }