Exemple #1
0
        public void Ifc_SyntaxAnalysisPass_ShouldParseIfcFile()
        {
            using (var stream = File.Open(@"..\..\..\..\test\ifc4_add2.exp", FileMode.Open, FileAccess.Read))
            {
                var tokens          = Tokenizer.Tokenize(new StreamReader(stream, Encoding.ASCII)).ToArray();
                var builder         = new SyntaxTreeBuilder();
                var declarationPass = new DeclarationPass(tokens);
                declarationPass.Run(builder);

                var errors = new List <ParsingError>();
                var pass   = new SyntaxAnalysisPass(tokens, errors);
                pass.Run(builder);

                foreach (var error in errors)
                {
                    Console.WriteLine(error.ToString());
                }

                Assert.AreEqual(0, errors.Count, errors.FirstOrDefault()?.ToString());
            }
        }
        public void DeclarationCollectingPass_ShouldPassTestCasesWithoutErrors(string fileName)
        {
            var parser = new ExpressParser();

            using (var stream = File.Open($@"..\..\..\..\test\{fileName}.exp", FileMode.Open, FileAccess.Read))
            {
                var errors = new List <ParsingError>();

                var tokens          = Tokenizer.Tokenize(new StreamReader(stream, Encoding.ASCII)).ToArray();
                var declarationPass = new DeclarationPass(tokens, errors);
                var syntaxPass      = new SyntaxAnalysisPass(tokens, errors);
                var builder         = new SyntaxTreeBuilder();
                declarationPass.Run(builder);
                syntaxPass.Run(builder);

                foreach (var error in errors)
                {
                    Console.WriteLine(error.ToString());
                }

                Assert.AreEqual(0, errors.Count);
            }
        }