Ejemplo n.º 1
0
        private Ast.Expr ParseExpr(TokenQueue q)
        {
            var start = q.GetLocation();
            var tok   = q.SourceToken;

            Ast.SqliteSyntaxProduction syntaxNode;
            var result = SqliteParser.ReadExpr(q, out syntaxNode);

            if (result.IsValid)
            {
                return(new Ast.Expr {
                    Sql = q.Substring(start, result.NumValidTokens),
                    SourceToken = tok,
                    SqliteSyntax = syntaxNode
                });
            }
            else if (result.InvalidMessage != null)
            {
                throw new SyntaxException(result.InvalidMessage);
            }
            else
            {
                throw new SyntaxException(q);
            }
        }
Ejemplo n.º 2
0
        private Ast.SqlStmt ParseSqlStmt(TokenQueue q, string rootProdName = "sql-stmt")
        {
            var start = q.GetLocation();
            var tok   = q.SourceToken;

            Ast.SqliteSyntaxProduction syntaxNode;
            var result = SqliteParser.ReadStmt(q, out syntaxNode, rootProdName);

            if (result.IsValid)
            {
                var stmt = new Ast.SqlStmt {
                    Sql          = q.Substring(start, result.NumValidTokens),
                    SourceToken  = tok,
                    SqliteSyntax = syntaxNode
                };
                _preprocessor.PreprocessStmt(stmt);
                return(stmt);
            }
            else if (result.InvalidMessage != null)
            {
                throw new SyntaxException(result.InvalidMessage);
            }
            else
            {
                throw new SyntaxException(q);
            }
        }
Ejemplo n.º 3
0
        private bool PeekExpr(TokenQueue q)
        {
            var start = q.GetLocation();
            var tok   = q.SourceToken;

            Ast.SqliteSyntaxProduction ast;
            var result = SqliteParser.ReadExpr(q, out ast);

            q.Jump(start);
            return(result.IsValid);
        }