This isn't a sensible fhirpath expression that does something useful, however it does check the edges of a fhirpath parser. I've tried to check every single parsing rule, not every function avaialable.
(
(
(( -5.25 * 2 div 3 mod 2 + +3 - 1).toString() & ' units' ) /* polarity + multiplicative + additive + concatenation */
|
( {} | true | %resource | false | 'hello' | 42 | 123L | @2025-08-21
| @2025-08-21T12:34:56.789Z | @T08:00:00 | 5 'mg' | 3 days ) /* union of (null, booleans, string, number, long, date, datetime, time, qty(STRING), qty(keyword-unit) */
| %ext
| %`string-ext`
| %`string-ext`.length() /* functionInvocation (no params) */
| $this.id
| $this.`some-weird` /* delimited member identifier */
| name.select(family & '-' & $index.toString())
| name.aggregate($total + $this.children().count(), 0)
| select( -(2025) as Patient | id as FHIR.id) /* polarity on parenthesized numeric literal + 'as' typeExpression */
.as(Patient) /* keyword used as identifier (function) */
.contains('x') /* keyword used as identifier (function with param) */
)
.trace('stuff')
[
(1 + 1)
] /* indexerExpression (additive inside) */
is Patient /* 'is' typeExpression (simple typeSpecifier) */
and ( (5 'mg' < 10 'mg') or (3 days >= 2 days) ) /* inequalityExpression + orExpression */
and (42 = 42 and 42 != 43 and 'abc' ~ 'abc' and 'abc' !~ 'def') /* equalityExpression variants */
and ('a' in ('a' | 'b') and ('a' | 'b') contains 'a') /* membershipExpression + unionExpression */
and (id is FHIR.string) /* qualifiedIdentifier typeSpecifier w/ dot + both 'is' and 'as' */
xor (false implies true) /* xorExpression + impliesExpression */
)