private static void CompileFile(Stream fileStream, string fileName, StreamWriter outStream, TypeStorage typeStorage, ILogger logger, ILogger treeLogger, INameConvertor nameConvertor) { logger.Log(String.Format("----Файл {0}----", fileName)); var stream = new ANTLRInputStream(fileStream); var lexer = new PlsqlLexer(stream); var parser = new PlsqlParser(new CommonTokenStream(lexer)); var tree = parser.program().Tree as CommonTree; if (treeLogger != null) { treeLogger.Log(ASTPrinter.Print(tree)); } var semanticAnalyser = new SemanticAnalyser(typeStorage, logger); bool res = semanticAnalyser.Check(tree); if (res) { var optimizer = new Optimizer(); optimizer.Optimize(tree); var codegenerator = new Codegenerator(nameConvertor); string code = codegenerator.Generate(tree, typeStorage); outStream.Write(code); } logger.Log(string.Format("--------", fileName)); }
private List <SourceFile> Parse(List <string> files) { var res = new List <SourceFile>(); foreach (var item in files) { using (var fileStream = new FileStream(item, FileMode.Open)) { var stream = new ANTLRInputStream(fileStream); var lexer = new PlsqlLexer(stream); var parser = new PlsqlParser(new CommonTokenStream(lexer)); var tree = parser.program().Tree as CommonTree; res.Add(new SourceFile(item, tree)); } } return(res); }