Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ cycleClause
* A toplevel query of subquery, which may be a union or intersection of subqueries
*/
queryExpression
: withClause? orderedQuery # SimpleQueryGroup
| withClause? orderedQuery (setOperator orderedQuery)+ # SetQueryGroup
: withClause? orderedQuery (setOperator orderedQuery)*
;

/**
Expand Down Expand Up @@ -427,19 +426,13 @@ pathContinuation
* * VALUE( path )
* * KEY( path )
* * path[ selector ]
* * ARRAY_GET( embeddableArrayPath, index ).path
* * COALESCE( array1, array2 )[ selector ].path
*/
syntacticDomainPath
: treatedNavigablePath
| collectionValueNavigablePath
| mapKeyNavigablePath
| simplePath indexedPathAccessFragment
| simplePath slicedPathAccessFragment
| toOneFkReference
| function pathContinuation
| function indexedPathAccessFragment pathContinuation?
| function slicedPathAccessFragment
;

/**
Expand Down Expand Up @@ -661,19 +654,21 @@ whereClause
predicate
//highest to lowest precedence
: LEFT_PAREN predicate RIGHT_PAREN # GroupedPredicate
| expression IS NOT? NULL # IsNullPredicate
| expression IS NOT? EMPTY # IsEmptyPredicate
| expression IS NOT? TRUE # IsTruePredicate
| expression IS NOT? FALSE # IsFalsePredicate
| expression IS NOT? DISTINCT FROM expression # IsDistinctFromPredicate
| expression IS NOT? (NULL|EMPTY|TRUE|FALSE) # UnaryIsPredicate
| expression NOT? MEMBER OF? path # MemberOfPredicate
| expression NOT? IN inList # InPredicate
| expression NOT? BETWEEN expression AND expression # BetweenPredicate
| expression NOT? (LIKE | ILIKE) REGEXP? expression likeEscape? # LikePredicate
| expression NOT? CONTAINS expression # ContainsPredicate
| expression NOT? INCLUDES expression # IncludesPredicate
| expression NOT? INTERSECTS expression # IntersectsPredicate
| expression comparisonOperator expression # ComparisonPredicate
| expression
( NOT? (CONTAINS | INCLUDES | INTERSECTS)
| IS NOT? DISTINCT FROM
| EQUAL
| NOT_EQUAL
| GREATER
| GREATER_EQUAL
| LESS
| LESS_EQUAL
) expression # BinaryExpressionPredicate
| EXISTS collectionQuantifier LEFT_PAREN simplePath RIGHT_PAREN # ExistsCollectionPartPredicate
| EXISTS expression # ExistsPredicate
| NOT predicate # NegatedPredicate
Expand All @@ -682,18 +677,6 @@ predicate
| expression # BooleanExpressionPredicate
;

/**
* An operator which compares values for equality or order
*/
comparisonOperator
: EQUAL
| NOT_EQUAL
| GREATER
| GREATER_EQUAL
| LESS
| LESS_EQUAL
;

/**
* Any right operand of the 'in' operator
*
Expand Down Expand Up @@ -748,7 +731,14 @@ primaryExpression
| entityVersionReference # EntityVersionExpression
| entityNaturalIdReference # EntityNaturalIdExpression
| syntacticDomainPath pathContinuation? # SyntacticPathExpression
| function # FunctionExpression
// ARRAY_GET( embeddableArrayPath, index ).path
// COALESCE( array1, array2 )[ selector ].path
// COALESCE( array1, array2 )[ start : end ]
| function (
pathContinuation
| slicedPathAccessFragment
| indexedPathAccessFragment pathContinuation?
)? # FunctionExpression
| generalPathFragment # GeneralPathExpression
;

Expand Down Expand Up @@ -1108,6 +1098,7 @@ function
| columnFunction
| jsonFunction
| xmlFunction
| toOneFkReference
| genericFunction
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,13 @@ private static OrderingParser.OrderByFragmentContext buildParseTree(String fragm
return parser.orderByFragment();
}
catch (ParseCancellationException e) {
// When resetting the parser, its CommonTokenStream will seek(0) i.e. restart emitting buffered tokens.
// This is enough when reusing the lexer and parser, and it would be wrong to also reset the lexer.
// Resetting the lexer causes it to hand out tokens again from the start, which will then append to the
// CommonTokenStream and cause a wrong parse
// lexer.reset();

// reset the input token stream and parser state
lexer.reset();
parser.reset();

// fall back to LL(k)-based parsing
Expand Down
Loading