@@ -284,7 +284,7 @@ makeItemLikeRegex(JsonPathParseItem *expr, string *pattern, string *flags)
284284
285285%type <result> result
286286
287- %type <value> scalar_value path_primary expr pexpr array_accessor
287+ %type <value> scalar_value path_primary expr array_accessor
288288 any_path accessor_op key predicate delimited_predicate
289289 index_elem starts_with_initial opt_datetime_template
290290 expr_or_predicate
@@ -351,21 +351,21 @@ comp_op:
351351 ;
352352
353353delimited_predicate :
354- ' (' predicate ' )' { $$ = $2 ; }
354+ ' (' predicate ' )' { $$ = $2 ; }
355355 | EXISTS_P ' (' expr ' )' { $$ = makeItemUnary(jpiExists, $3 ); }
356356 ;
357357
358358predicate :
359359 delimited_predicate { $$ = $1 ; }
360- | pexpr comp_op pexpr { $$ = makeItemBinary($2 , $1 , $3 ); }
360+ | expr comp_op expr { $$ = makeItemBinary($2 , $1 , $3 ); }
361361 | predicate AND_P predicate { $$ = makeItemBinary(jpiAnd, $1 , $3 ); }
362362 | predicate OR_P predicate { $$ = makeItemBinary(jpiOr, $1 , $3 ); }
363363 | NOT_P delimited_predicate { $$ = makeItemUnary(jpiNot, $2 ); }
364364 | ' (' predicate ' )' IS_P UNKNOWN_P { $$ = makeItemUnary(jpiIsUnknown, $2 ); }
365- | pexpr STARTS_P WITH_P starts_with_initial
365+ | expr STARTS_P WITH_P starts_with_initial
366366 { $$ = makeItemBinary(jpiStartsWith, $1 , $4 ); }
367- | pexpr LIKE_REGEX_P STRING_P { $$ = makeItemLikeRegex($1 , &$3 , NULL ); }
368- | pexpr LIKE_REGEX_P STRING_P FLAG_P STRING_P
367+ | expr LIKE_REGEX_P STRING_P { $$ = makeItemLikeRegex($1 , &$3 , NULL ); }
368+ | expr LIKE_REGEX_P STRING_P FLAG_P STRING_P
369369 { $$ = makeItemLikeRegex($1 , &$3 , &$5 ); }
370370 ;
371371
@@ -385,29 +385,25 @@ accessor_expr:
385385 path_primary { $$ = list_make1($1 ); }
386386 | ' .' key { $$ = list_make2(makeItemType(jpiCurrent), $2 ); }
387387 | ' (' expr ' )' accessor_op { $$ = list_make2($2 , $4 ); }
388- | ' (' predicate ' )' accessor_op { $$ = list_make2($2 , $4 ); }
388+ | ' (' predicate ' )' accessor_op { $$ = list_make2($2 , $4 ); }
389389 | accessor_expr accessor_op { $$ = lappend($1 , $2 ); }
390390 ;
391391
392- pexpr :
393- expr { $$ = $1 ; }
394- | ' (' expr ' )' { $$ = $2 ; }
395- ;
396-
397392expr :
398- accessor_expr { $$ = makeItemList($1 ); }
399- | ' +' pexpr %prec UMINUS { $$ = makeItemUnary(jpiPlus, $2 ); }
400- | ' -' pexpr %prec UMINUS { $$ = makeItemUnary(jpiMinus, $2 ); }
401- | pexpr ' +' pexpr { $$ = makeItemBinary(jpiAdd, $1 , $3 ); }
402- | pexpr ' -' pexpr { $$ = makeItemBinary(jpiSub, $1 , $3 ); }
403- | pexpr ' *' pexpr { $$ = makeItemBinary(jpiMul, $1 , $3 ); }
404- | pexpr ' /' pexpr { $$ = makeItemBinary(jpiDiv, $1 , $3 ); }
405- | pexpr ' %' pexpr { $$ = makeItemBinary(jpiMod, $1 , $3 ); }
393+ accessor_expr { $$ = makeItemList($1 ); }
394+ | ' (' expr ' )' { $$ = $2 ; }
395+ | ' +' expr %prec UMINUS { $$ = makeItemUnary(jpiPlus, $2 ); }
396+ | ' -' expr %prec UMINUS { $$ = makeItemUnary(jpiMinus, $2 ); }
397+ | expr ' +' expr { $$ = makeItemBinary(jpiAdd, $1 , $3 ); }
398+ | expr ' -' expr { $$ = makeItemBinary(jpiSub, $1 , $3 ); }
399+ | expr ' *' expr { $$ = makeItemBinary(jpiMul, $1 , $3 ); }
400+ | expr ' /' expr { $$ = makeItemBinary(jpiDiv, $1 , $3 ); }
401+ | expr ' %' expr { $$ = makeItemBinary(jpiMod, $1 , $3 ); }
406402 ;
407403
408404index_elem :
409- pexpr { $$ = makeItemBinary(jpiSubscript, $1 , NULL ); }
410- | pexpr TO_P pexpr { $$ = makeItemBinary(jpiSubscript, $1 , $3 ); }
405+ expr { $$ = makeItemBinary(jpiSubscript, $1 , NULL ); }
406+ | expr TO_P expr { $$ = makeItemBinary(jpiSubscript, $1 , $3 ); }
411407 ;
412408
413409index_list :
0 commit comments