コード例 #1
0
ファイル: ICompiler.cs プロジェクト: ziachap/Quack
        public void Compile(string filePath)
        {
            //var input = "declare a; a = 5; print a;";

            var sourceLines    = _reader.LoadFromFile(filePath);
            var sanitizedLines = _sanitizer.Sanitize(sourceLines).ToArray();

            Console.WriteLine("Loaded from " + filePath);

            var tokens = _lexer.Tokenise(sanitizedLines, sourceLines);

            foreach (var token in tokens)
            {
                Console.WriteLine($"    {token}");
            }

            var ast = _parser.Parse(tokens);

            PrintAstTree(ast);

            var analyzedAst = _semanticValidator.Analyze(ast);

            var transpiledCode = _transpiler.Transpile(analyzedAst);

            Console.WriteLine(transpiledCode);

            var outputPath     = "C:/working.git/Quack/TestScripts";
            var outputFilename = "Output.js";

            _writer.WriteToFile(transpiledCode, outputPath, outputFilename);

            Console.WriteLine($"Written to {outputPath}/{outputFilename}");
            Console.WriteLine($"\nPress any key to exit..");
        }
コード例 #2
0
 public void FileNotFoundFailTest()
 {
     //Arrange at Initialize
     //Act
     _transpiler.Transpile(@"C:\NonExistent.vm");
 }