MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / parse

Method parse

pkg/util/jsonpath/parser/parse.go:65–84  ·  view source on GitHub ↗

parse parses a statement from the given scanned tokens.

(
	query string, tokens []jsonpathSymType,
)

Source from the content-addressed store, hash-verified

63
64// parse parses a statement from the given scanned tokens.
65func (p *Parser) parse(
66 query string, tokens []jsonpathSymType,
67) (statements.JsonpathStatement, error) {
68 p.lexer.init(query, tokens, &p.parserImpl)
69 defer p.lexer.cleanup()
70 if p.parserImpl.Parse(&p.lexer) != 0 {
71 if p.lexer.lastError == nil {
72 // This should never happen -- there should be an error object
73 // every time Parse() returns nonzero. We're just playing safe
74 // here.
75 p.lexer.Error("syntax error")
76 }
77 err := p.lexer.lastError
78 return statements.JsonpathStatement{}, err
79 }
80 return statements.JsonpathStatement{
81 AST: p.lexer.expr,
82 SQL: query,
83 }, nil
84}
85
86func (p *Parser) Parse(jsonpath string) (statements.JsonpathStatement, error) {
87 p.scanner.Init(jsonpath)

Callers 1

ParseMethod · 0.95

Calls 4

initMethod · 0.65
ParseMethod · 0.65
ErrorMethod · 0.65
cleanupMethod · 0.45

Tested by

no test coverage detected