protected Ast.SqliteSyntaxProduction ParseSqlStmt(string text) { var tokens = Notebook.Tokenize(text); var q = new TokenQueue(tokens, Notebook); Ast.SqliteSyntaxProduction ast; var result = SqliteParser.ReadStmt(q, out ast); if (result.IsValid && q.Eof()) { return(ast); } else { throw new MacroProcessorException($"\"{text}\" is not a valid SQL statement."); } }
private Ast.Script ParseScript(TokenQueue q) { var script = new Ast.Script { SourceToken = q.SourceToken }; script.Block = new Ast.Block { SourceToken = q.SourceToken }; while (!q.Eof()) { var stmt = ParseStmt(q); if (stmt != null) { script.Block.Statements.Add(stmt); } } return(script); }
protected Ast.Expr NewExpr(string text) { var tokens = Notebook.Tokenize(text); var q = new TokenQueue(tokens, Notebook); Ast.SqliteSyntaxProduction ast; var result = SqliteParser.ReadExpr(q, out ast); if (result.IsValid && q.Eof()) { return(new Ast.Expr { Sql = text, SqliteSyntax = ast }); } else { throw new MacroProcessorException($"\"{text}\" is not a valid SQL expression."); } }