public void CanWeParseWithoutErrorsTest()
        {
            var queryString       = "CREATE TABLE c15 (x, y, FOREIGN KEY(x,y) REFERENCES p5(b,c))";
            var inputStream       = new AntlrInputStream(queryString);
            var sqliteLexer       = new SQLiteParserSimpleLexer(inputStream);
            var commonTokenStream = new CommonTokenStream(sqliteLexer);
            var sqliteParser      = new SQLiteParserSimpleParser(commonTokenStream);

            var s = sqliteParser.sql_stmt();

            Assert.Equal(0, sqliteParser.NumberOfSyntaxErrors);
        }
Example #2
0
        public static SQLiteParseTreeNode ParseString(string queryString,
                                                      Func <SQLiteParserSimpleParser, IParseTree> startingNode)
        {
            var inputStream       = new AntlrInputStream(queryString);
            var sqliteLexer       = new SQLiteParserSimpleLexer(inputStream);
            var commonTokenStream = new CommonTokenStream(sqliteLexer);
            var sqliteParser      = new SQLiteParserSimpleParser(commonTokenStream);
            var getStartingNode   = startingNode(sqliteParser);

            if (sqliteParser.NumberOfSyntaxErrors != 0)
            {
                throw new ParseException(String.Format("There were {0} parse errors.", sqliteParser.NumberOfSyntaxErrors));
            }

            var visitor = new SQLiteParseVisitor();

            return(visitor.Visit(getStartingNode));
        }