Skip to content

Expression parsers: accept UAX 31 identifiers in paths, function names and argument names #2838

Description

@gspencergoog

The v1.0 specification requires catalog component, function and argument names to match ^[\p{XID_Start}_][\p{XID_Continue}]*$. See "Catalog Entity Naming Rules" in specification/v1_0/docs/a2ui_protocol.md. The expression parsers do not follow that rule yet:

  • TypeScript, Python and Dart accept only ASCII in paths (a-z, A-Z, 0-9, /, ., _, -) and identifiers. ${café} fails with Unexpected characters, and an expression cannot call a catalog function named größe.
  • Swift uses Character.isLetter and Character.isNumber. It accepts ${café}, but it also accepts characters outside UAX #31, such as ½.

Proposed change (follow-up to #2807):

  • Function and argument names follow UAX #31: XID_Start or _, then XID_Continue.
  • Path segments allow UAX #31 identifier characters and keep /, ., _ and -.
  • After true, false and null, any XID_Continue character counts as part of the word.
  • TypeScript and Dart scan by Unicode code point instead of UTF-16 code unit.
  • Reuse typescript/web_core/src/common/uax31.ts and python/a2ui_core/src/a2ui/core/common/uax31.py. Add UAX #31 helpers for Dart and for Swift (Unicode.Scalar.Properties.isXIDStart and isXIDContinue).
  • Add conformance cases in conformance/core/expressions.yaml for a non-ASCII path, function name, argument name, and rejected non-UAX #31 character.
  • Optionally add a specification paragraph that defines the expression grammar, including number literals.

Related: no parser accepts @ in a function name, so ${@index()} fails. Decide whether expressions can call reserved @ functions.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2The team intends to work on this in the near future, or at a lower priority.status: first-line-handled

    Type

    No type

    Projects

    • Status
      Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions