| @@ -298,10 +298,11 @@ |
| 298 | 298 | `xsd:string` value was mis-typed as a number (`string(2) = "2"`), and string |
| 299 | 299 | results were whitespace-stripped (`substring("foob r", -2, 1) = " "`). Unlocked |
| 300 | 300 | 20 `feel-*-function` / list / string TCK dirs (303 → 541 fixture cases). |
| 301 | | -- **Deferred (still out of scope):** space-containing names (`string length`), |
| 302 | | - temporal functions and `abs` on durations (await ADR temporal types), |
| 303 | | - `sort`/`list replace` (need function values), range relations and `is` (need |
| 304 | | - first-class ranges / temporal identity), and a full XPath-regex dialect bridge. |
| 301 | +- **Deferred (still out of scope):** *space-containing names (`string length`) are |
| 302 | + now done — see ADR-17.* Temporal functions and `abs` on durations (await ADR |
| 303 | + temporal types), `sort` and the matching-function form of `list replace` (need |
| 304 | + function values), range relations and `is` (need first-class ranges / temporal |
| 305 | + identity), and a full XPath-regex dialect bridge. |
| 305 | 306 | |
| 306 | 307 | ## ADR-16: Host-environment regex dialect (per-target `FeelRegex` provider) |
| 307 | 308 | |
| @@ -345,6 +346,64 @@ |
| 345 | 346 | invalid pattern produces, so the strict boundary surfaces it (ADR-14). ADR-15's |
| 346 | 347 | `regex-xpath-dialect` deviation is now per-target rather than global. |
| 347 | 348 | |
| 349 | +## ADR-17: Full FEEL names (whitespace) + multi-word built-ins via a two-tier lexer join |
| 350 | + |
| 351 | +- **Context:** FEEL names may contain spaces — both user names (`full name`, |
| 352 | + `year of birth`) and built-ins (`string length`, `list contains`, `date and |
| 353 | + time`). ADR-15 deferred these because the single-`Name`-token lexer cannot form |
| 354 | + them. The spec resolves the ambiguity they create (`a + b` = a name or an |
| 355 | + addition?) with a *name oracle*: the parser must know the names in scope and |
| 356 | + take the longest match. That couples parsing to the evaluation context — a large |
| 357 | + lift we did not want for this increment (temporal *values* stay out, too). |
| 358 | +- **Decision:** Join multi-word names in a second pass over the token stream |
| 359 | + (`lexer::join_names`), so the grammar is **unchanged** — the `Name` terminal just |
| 360 | + carries a space-normalised payload now. No name oracle is needed: soundness |
| 361 | + comes from FEEL having no juxtaposition of two expressions, so two adjacent |
| 362 | + `Name` tokens can only be one name. Two tiers: |
| 363 | + - **Tier 1 (generic):** greedily merge a run of adjacent `Name` tokens. Keywords |
| 364 | + are separate tokens (the `keyword()` remap already ran) and stop the run, so |
| 365 | + `x and y` stays boolean — the join is backward-compatible (it only turns the |
| 366 | + previously-invalid `a b` into a name). Covers user names and every |
| 367 | + keyword-free multi-word built-in. |
| 368 | + - **Tier 2 (the built-in exception):** a fixed, closed dictionary of *keyword- |
| 369 | + containing* built-in phrases (`builtins::KEYWORD_PHRASE_BUILTINS`: `date and |
| 370 | + time`, `years and months duration`) matched only in **call position** |
| 371 | + (immediately followed by `(`). It needs no oracle because the set is finite |
| 372 | + and holds only built-in names, never user variables — this is the bounded |
| 373 | + "exception for built-ins" that lets `date and time(…)` parse without |
| 374 | + scope-aware parsing. |
| 375 | + |
| 376 | + The non-temporal multi-word built-ins are implemented (per spec §10.3.4): string |
| 377 | + `string length`/`upper case`/`lower case`/`substring before`/`substring after`/ |
| 378 | + `starts with`/`ends with`/`string join`; list `list contains`/`index of`/ |
| 379 | + `distinct values`/`insert before`/`list replace` (positional form); context |
| 380 | + `get value`/`get entries`. Dispatch is the same `match name` as ADR-15 (a |
| 381 | + normalised single-space key), so single- and multi-word calls share one path. |
| 382 | + - **Error policy (ADR-14)** is unchanged: wrong arity/type/domain → error-null; |
| 383 | + spec-legitimate empties (`string join([]) = ""`, `index of(l, x) = []`, |
| 384 | + `get entries({}) = []`) → value-null/empty. `string join` skips null items and |
| 385 | + treats a scalar as a one-element list; `get value` returns null for an absent |
| 386 | + *or* present-null entry; `list replace` truncates a fractional position. The |
| 387 | + keyword-phrase temporals parse but dispatch to error-null until temporal types |
| 388 | + land (the *name* machinery is what lands here). |
| 389 | + - **Ingestion** widened in lockstep: multi-word call heads and multi-word free |
| 390 | + names fit the slice predicate, and `parse_expected_node` learns context |
| 391 | + (`<component>`) results so `get entries`' `{key, value}` list is no longer |
| 392 | + degraded to `[null]`. Unlocked 1104-1108/1140 (string), 0011/1155/0012 (list), |
| 393 | + 0080/0081 (context); 541 → 672 fixture cases. |
| 394 | +- **Consequence:** No grammar change and no new lalrpop conflict — the token set is |
| 395 | + identical, only `Name` payloads grew. ADR-1 holds: names are strings and the |
| 396 | + JSON boundary already carries arbitrary keys, so the wrappers are untouched. |
| 397 | +- **Deviations (deliberate, documented):** |
| 398 | + - **Special characters in names** (`+ - * / . '` and the `?` name-part char) are |
| 399 | + out — a name is whitespace-joined words only. These are what reintroduce the |
| 400 | + arithmetic ambiguity, so supporting them would need the oracle. |
| 401 | + - **Keyword-containing *variables*** (`date and time` as a free name) are out; |
| 402 | + only the fixed built-in phrases are recognised, and only in call position. |
| 403 | + - The `date and time(x)` vs `date and (time(x))` collision is resolved toward the |
| 404 | + built-in phrase (the oracle case). Both are temporal-adjacent and yield null |
| 405 | + today, so the choice is observable only once temporal types exist. |
| 406 | + |
| 348 | 407 | ## Revisable design decisions |
| 349 | 408 | |
| 350 | 409 | Softer than the ADRs above: deliberate, **reversible** choices that are not |
| @@ -387,13 +446,15 @@ |
| 387 | 446 | These were considered and deliberately deferred to keep the slice thin. Listed so |
| 388 | 447 | the rationale and entry points survive: |
| 389 | 448 | |
| 390 | | -- **Built-in functions** — *single-word, non-temporal slice done (ADR-15):* a |
| 391 | | - `Name "(" … ")"` production in `Postfix`, a `builtins` dispatch table, and the |
| 392 | | - conversion/string/list/numeric functions listed there (incl. `regex`-backed |
| 393 | | - `replace`/`split`/`matches`). *Still deferred:* FEEL's space-containing names |
| 394 | | - (`string length`, `upper`/`lower case`, `distinct values`); `sort`/`list |
| 395 | | - replace` (need function values); range relations and `is`; the temporal |
| 396 | | - functions (await temporal types). Built-ins would also enable an explicit |
| 449 | +- **Built-in functions** — *single-word slice done (ADR-15); non-temporal |
| 450 | + multi-word slice done (ADR-17):* a `Name "(" … ")"` production in `Postfix`, a |
| 451 | + `builtins` dispatch table, the conversion/string/list/numeric functions (incl. |
| 452 | + `regex`-backed `replace`/`split`/`matches`), and the multi-word string/list/ |
| 453 | + context functions (`string length`, `upper`/`lower case`, `distinct values`, |
| 454 | + `get value`/`get entries`, …) reached via the lexer name-join. *Still deferred:* |
| 455 | + `sort` and the matching-function form of `list replace` (need function values); |
| 456 | + range relations and `is`; the temporal functions (await temporal types). |
| 457 | + Built-ins would also enable an explicit |
| 397 | 458 | `assert non null(x)` tripwire — an in-expression complement to the strict |
| 398 | 459 | boundary policy (ADR-14) for surfacing error-nulls where the author wants them |
| 399 | 460 | loud. |