@@ -184,7 +184,7 @@ func regexBinaryOp(left jsonpath.Path, regex string) (jsonpath.Operation, error)
184184
185185%token <str> CURRENT
186186
187- %token <str> STRING
187+ %token <str> STR
188188%token <str> NULL
189189
190190%token <str> LIKE_REGEX
@@ -197,6 +197,24 @@ func regexBinaryOp(left jsonpath.Path, regex string) (jsonpath.Operation, error)
197197%token <str> STARTS
198198%token <str> WITH
199199
200+ %token <str> SIZE
201+
202+ %token <str> TYPE
203+
204+ %token <str> KEYVALUE
205+
206+ %token <str> ABS
207+ %token <str> CEILING
208+ %token <str> FLOOR
209+
210+ %token <str> BIGINT
211+ %token <str> BOOLEAN
212+ %token <str> DATE
213+ %token <str> DOUBLE
214+ %token <str> INTEGER
215+ %token <str> NUMBER
216+ %token <str> STRING
217+
200218%type <jsonpath.Jsonpath> jsonpath
201219%type <jsonpath.Path> expr_or_predicate
202220%type <jsonpath.Path> expr
@@ -209,6 +227,7 @@ func regexBinaryOp(left jsonpath.Path, regex string) (jsonpath.Operation, error)
209227%type <jsonpath.Path> predicate
210228%type <jsonpath.Path> delimited_predicate
211229%type <jsonpath.Path> starts_with_initial
230+ %type <jsonpath.Path> method
212231%type <[]jsonpath.Path> accessor_expr
213232%type <[]jsonpath.Path> index_list
214233%type <jsonpath.OperationType> comp_op
@@ -355,6 +374,10 @@ accessor_op:
355374 {
356375 $$ .val = jsonpath.AnyKey{}
357376 }
377+ | ' .' method ' (' ' )'
378+ {
379+ $$ .val = $2 .path()
380+ }
358381;
359382
360383key :
@@ -436,15 +459,15 @@ predicate:
436459 {
437460 $$ .val = binaryOp(jsonpath.OpStartsWith, $1 .path(), $4 .path())
438461 }
439- | expr LIKE_REGEX STRING
462+ | expr LIKE_REGEX STR
440463 {
441464 regex, err := regexBinaryOp($1 .path(), $3 )
442465 if err != nil {
443466 return setErr(jsonpathlex, err)
444467 }
445468 $$ .val = regex
446469 }
447- | expr LIKE_REGEX STRING FLAG STRING
470+ | expr LIKE_REGEX STR FLAG STR
448471 {
449472 return unimplemented(jsonpathlex, " regex with flags" )
450473 }
@@ -462,7 +485,7 @@ delimited_predicate:
462485;
463486
464487starts_with_initial :
465- STRING
488+ STR
466489 {
467490 $$ .val = jsonpath.Scalar{Type: jsonpath.ScalarString, Value: json.FromString($1 )}
468491 }
@@ -499,6 +522,61 @@ comp_op:
499522 }
500523;
501524
525+ method :
526+ SIZE
527+ {
528+ $$ .val = jsonpath.Method{Type: jsonpath.SizeMethod}
529+ }
530+ | TYPE
531+ {
532+ return unimplemented(jsonpathlex, " .type()" )
533+ }
534+ | KEYVALUE
535+ {
536+ return unimplemented(jsonpathlex, " .keyvalue()" )
537+ }
538+ | ABS
539+ {
540+ return unimplemented(jsonpathlex, " .abs()" )
541+ }
542+ | CEILING
543+ {
544+ return unimplemented(jsonpathlex, " .ceiling()" )
545+ }
546+ | FLOOR
547+ {
548+ return unimplemented(jsonpathlex, " .floor()" )
549+ }
550+ | BIGINT
551+ {
552+ return unimplemented(jsonpathlex, " .bigint()" )
553+ }
554+ | BOOLEAN
555+ {
556+ return unimplemented(jsonpathlex, " .boolean()" )
557+ }
558+ | DATE
559+ {
560+ return unimplemented(jsonpathlex, " .date()" )
561+ }
562+ | DOUBLE
563+ {
564+ return unimplemented(jsonpathlex, " .double()" )
565+ }
566+ | INTEGER
567+ {
568+ return unimplemented(jsonpathlex, " .integer()" )
569+ }
570+ | NUMBER
571+ {
572+ return unimplemented(jsonpathlex, " .number()" )
573+ }
574+ | STRING
575+ {
576+ return unimplemented(jsonpathlex, " .string()" )
577+ }
578+ ;
579+
502580scalar_value :
503581 VARIABLE
504582 {
@@ -532,7 +610,7 @@ scalar_value:
532610 {
533611 $$ .val = jsonpath.Scalar{Type: jsonpath.ScalarBool, Value: json.FromBool(false )}
534612 }
535- | STRING
613+ | STR
536614 {
537615 $$ .val = jsonpath.Scalar{Type: jsonpath.ScalarString, Value: json.FromString($1 )}
538616 }
@@ -544,23 +622,36 @@ scalar_value:
544622
545623any_identifier :
546624 IDENT
547- | STRING
625+ | STR
548626| unreserved_keyword
549627;
550628
551629unreserved_keyword :
552- EXISTS
630+ ABS
631+ | BIGINT
632+ | BOOLEAN
633+ | CEILING
634+ | DATE
635+ | DOUBLE
636+ | EXISTS
553637| FALSE
554638| FLAG
639+ | FLOOR
640+ | INTEGER
555641| IS
642+ | KEYVALUE
556643| LAST
557644| LAX
558645| LIKE_REGEX
559646| NULL
647+ | NUMBER
648+ | SIZE
560649| STARTS
561650| STRICT
651+ | STRING
562652| TO
563653| TRUE
654+ | TYPE
564655| UNKNOWN
565656| WITH
566657;
0 commit comments