-
Notifications
You must be signed in to change notification settings - Fork 19
/
parse_helpers.go
68 lines (57 loc) · 2.28 KB
/
parse_helpers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package memefish
import (
"github.com/cloudspannerecosystem/memefish/ast"
"github.com/cloudspannerecosystem/memefish/token"
)
func newParser(filepath, s string) *Parser {
return &Parser{
Lexer: &Lexer{
File: &token.File{FilePath: filepath, Buffer: s},
},
}
}
// ParseStatement parses an input string containing a statement.
// filepath can be empty, it is only used in error message.
func ParseStatement(filepath, s string) (ast.Statement, error) {
return newParser(filepath, s).ParseStatement()
}
// ParseStatements parses an input string containing statements.
// filepath can be empty, it is only used in error message.
func ParseStatements(filepath, s string) ([]ast.Statement, error) {
return newParser(filepath, s).ParseStatements()
}
// ParseQuery parses an input string containing a query statement.
// filepath can be empty, it is only used in error message.
func ParseQuery(filepath, s string) (*ast.QueryStatement, error) {
return newParser(filepath, s).ParseQuery()
}
// ParseExpr parses an input string containing an expression.
// filepath can be empty, it is only used in error message.
func ParseExpr(filepath, s string) (ast.Expr, error) {
return newParser(filepath, s).ParseExpr()
}
// ParseType parses an input string containing a type.
// filepath can be empty, it is only used in error message.
func ParseType(filepath, s string) (ast.Type, error) {
return newParser(filepath, s).ParseType()
}
// ParseDDL parses an input string containing a DDL statement.
// filepath can be empty, it is only used in error message.
func ParseDDL(filepath, s string) (ast.DDL, error) {
return newParser(filepath, s).ParseDDL()
}
// ParseDDLs parses an input string containing DDL statements.
// filepath can be empty, it is only used in error message.
func ParseDDLs(filepath, s string) ([]ast.DDL, error) {
return newParser(filepath, s).ParseDDLs()
}
// ParseDML parses an input string containing a DML statement.
// filepath can be empty, it is only used in error message.
func ParseDML(filepath, s string) (ast.DML, error) {
return newParser(filepath, s).ParseDML()
}
// ParseDMLs parses an input string containing DML statements.
// filepath can be empty, it is only used in error message.
func ParseDMLs(filepath, s string) ([]ast.DML, error) {
return newParser(filepath, s).ParseDMLs()
}