Skip to main content

Module expr

Module expr 

Source
Expand description

formatString’s template language: literal text with ${...} interpolations, each a literal, a data binding, or a function call.

The grammar is the one every A2UI SDK parses (the specification’s “The formatString function” and the shared suite core/expressions.yaml):

  • \${ is a literal ${; an unclosed ${ is an error.
  • Inside ${...}: a nested ${...}, a quoted string ('...' or "...", with \n, \t, \r, and \x for any other x), a number ([+-]?(digits[.digits]|.digits)([eE][+-]?digits)?, finite), true, false, null (which reads as ""), a path (characters that are XID_Continue, /, ., or -; relative unless it starts with /), or a call: a name then (name: value, ...), the arguments themselves expressions. @-names (@index) must be calls.
  • At most MAX_DEPTH levels of nesting, MAX_TEMPLATE_LENGTH UTF-16 units (as JavaScript counts them), and MAX_PARTS parts, so every SDK accepts and refuses the same templates.

Structs§

ExpressionError
A template that does not parse.

Enums§

Part
One piece of a parsed template.

Constants§

MAX_DEPTH
The deepest nesting of interpolations and call arguments.
MAX_PARTS
The most parts one template may produce.
MAX_TEMPLATE_LENGTH
The longest template, in UTF-16 code units.

Functions§

number_value
A float as JSON, the way JavaScript would print it: a whole number within i64 is an integer (and -0 is 0), anything else a float.
parse
Parse a template into its parts. Adjacent text stays one literal; empty literals are dropped.