private void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (messages != null)
                {
                    messages.Clear();
                }

                if (lexer != null)
                {
                    lexer.Interpreter.ClearDFA();
                    lexer.Reset();
                    lexer.Interpreter = new LexerATNSimulator(new ATN(ATNType.Lexer, 2));
                }

                if (plSqlParser != null)
                {
                    plSqlParser.Interpreter.ClearDFA();
                    plSqlParser.Reset();
                    plSqlParser.Interpreter = new ParserATNSimulator(new ATN(ATNType.Parser, 2));
                }
            }

            lexer       = null;
            plSqlParser = null;
            messages    = null;
        }
Esempio n. 2
0
 public static void analyze(TextReader file)
 {
     var input  = new AntlrInputStream(file);
     var lexer  = new PlSqlLexer(input);
     var tokens = new CommonTokenStream(lexer);
     var parser = new PlSqlParser(tokens);
     var tree   = parser.sql_script();
 }
Esempio n. 3
0
        public void processPackage(string inputFilePath)
        {
            #region ANTLR4 necessary stuff



            var input = new AntlrInputStream(new StreamReader(inputFilePath));


            var lexer = new PlSqlLexer(input);

            var tokens = new CommonTokenStream(lexer);

            var parser = new PlSqlParser(tokens);

            PlSqlParser.Create_package_bodyContext context1 = parser.create_package_body();

            ParseTreeWalker walker = new ParseTreeWalker();

            var bListener = new BODYlistener();

            walker.Walk(bListener, context1);
            #endregion

            //you can start making changes from this point

            var converter   = new JoinLinksConverter(bListener.joinsList);
            var uniqueLinks = converter.MakeUniqueLinksList();



            using (var storage = new StorageContext(StorageContext.constr))
            {
                Dictionary <string, string> linkToText = new Dictionary <string, string>();

                foreach (var link in storage.links.ToList())
                {
                    linkToText.Add(link.toText, "");
                }



                List <Link> linkListToConvert = new List <Link>();

                linkListToConvert.AddRange(uniqueLinks.Where(link => dbObjectNames.ContainsKey(link.firstTable) && dbObjectNames.ContainsKey(link.secondTable) && !linkToText.ContainsKey(link.ToText())));

                LinkDBFormatConverter linkConverter = new LinkDBFormatConverter(linkListToConvert);

                foreach (var link in linkConverter.Result)
                {
                    storage.links.Add(link);
                }


                storage.SaveChanges();
            }
        }
        private void MakeParser(string input, Action <SqlCompileMessage> messageReceiver)
        {
            using (var reader = new StringReader(input)) {
                var inputStream = new AntlrInputStream(reader);
                lexer = new PlSqlLexer(inputStream);

                var commonTokenStream = new CommonTokenStream(lexer);

                plSqlParser = new PlSqlParser(commonTokenStream);
                plSqlParser.RemoveErrorListeners();
                plSqlParser.AddErrorListener(new ErrorHandler(messageReceiver));
            }
        }
Esempio n. 5
0
        private void MakeParser(string input, Action<SqlCompileMessage> messageReceiver)
        {
            using (var reader = new StringReader(input)) {
                var inputStream = new AntlrInputStream(reader);
                lexer = new PlSqlLexer(inputStream);

                var commonTokenStream = new CommonTokenStream(lexer);

                plSqlParser = new PlSqlParser(commonTokenStream);
                plSqlParser.RemoveErrorListeners();
                plSqlParser.AddErrorListener(new ErrorHandler(messageReceiver));
            }
        }
Esempio n. 6
0
        private void Dispose(bool disposing)
        {
            if (disposing) {
                if (messages != null)
                    messages.Clear();

                if (lexer != null) {
                    lexer.Interpreter.ClearDFA();
                    lexer.Reset();
                    lexer.Interpreter = new LexerATNSimulator(new ATN(ATNType.Lexer, 2));
                }

                if (plSqlParser != null) {
                    plSqlParser.Interpreter.ClearDFA();
                    plSqlParser.Reset();
                    plSqlParser.Interpreter = new ParserATNSimulator(new ATN(ATNType.Parser, 2));
                }
            }

            lexer = null;
            plSqlParser = null;
            messages = null;
        }