예제 #1
0
        public void load_string(string str)
        {
            var inputStream       = new AntlrInputStream(str);
            var lexer             = new TSqlLexer(inputStream);
            var commonTokenStream = new CommonTokenStream(lexer);
            var parser            = new TSqlParser(commonTokenStream);

            if (!noerrorlistener)
            {
                parser.RemoveErrorListeners();
                parser.AddErrorListener(new ParserErrorListener());
            }
            Type       t  = parser.GetType();
            MethodInfo mi = t.GetMethod(start_rulename);

            if (mi == null)
            {
                throw new ArgumentException("rulename " + start_rulename + " not found.");
            }
            ParserRuleContext graphContext = (ParserRuleContext)mi.Invoke(parser, new object[] { });

            //ParserRuleContext graphContext = parser.tsql_file();
            var token_names = parser.TokenNames;
            var rule_names  = parser.RuleNames;
            var tree_parser = new TreeParser(token_names, rule_names);

            root = tree_parser.parse(graphContext);
        }