public RootContext GetRootContext(string content, out SqlSyntaxError error) { error = null; MySqlParser parser = this.GetParser(content) as MySqlParser; SqlSyntaxErrorListener errorListener = this.AddParserErrorListener(parser); RootContext context = parser.root(); error = errorListener.Error; return(context); }
public override void Parse(FileInfo file) { Lexer lexer = new MySqlLexer(CharStreams.fromPath(file.FullName)); CommonTokenStream tokens = new CommonTokenStream(lexer); MySqlParser parser = new MySqlParser(tokens); ParserRuleContext context = parser.root(); var children = context.children; foreach (IParseTree child in children) { this.ParseNode(child); } }
private static SqlVisitor?CreateVisitor(string query) { try { var lexer = new MySqlLexer(new CaseChangingCharStream(new AntlrInputStream(query), true)); var tokens = new CommonTokenStream(lexer); var parser = new MySqlParser(tokens); parser.BuildParseTree = true; parser.RemoveErrorListeners(); var visitor = new SqlVisitor(); visitor.Visit(parser.root()); return(visitor); } catch (Exception e) { Console.WriteLine(e); return(null); } }