Funcscript fromal syntax
- A naked key/value block (no braces) is only recognized at the root. Everywhere else
<KeyValueCollection>must be wrapped in{ ... }. return/evalmay appear at most once per block; duplicates raise a syntax error.- Separators may be commas or semicolons and can trail the final entry.
Identifierin<DualFunctionTail>must resolve to a dual-call (CallType.Dual) function. Otherwise the parser falls back to the<CallChain>that preceded it. When a matching dual function is found,expr1 op expr2desugars toop(expr1, expr2), and each~ exprNappends another argument.- All symbolic operators and keywords above are case-insensitive.
- Parentheses and brackets invoke the preceding expression as a function; parameter lists may be empty.
.memberand?.memberturn into function calls backed by the provider entries for.and?..<SelectorBlock>pipes the preceding value into a{ ... }object definition. When the source evaluates to a list, the block is mapped over every element; otherwise it is evaluated once with the source bound inside the selector context. Multiple selectors can be chained:data { a:1 } { b:2 }.
<IdentifierList>may be empty, so() => bodyis valid.case condition: valueaccepts multiple branches separated by,or;.switch selectorrequires at least one branch and uses the same separators.- Prefix operators currently resolve to the built-in logical NOT (
!) and numeric negation (-). Both bind tighter than member access or calls because the operand is parsed as a full<CallChain>.
- Simple strings support the escapes
\n,\t,\\,\uXXXX, and escaping the active delimiter via\',\", or\""". Triple-quoted strings (""" ... """) optionally swallow a single leading newline right after the opener and otherwise preserve whitespace verbatim. - String templates must start with
ffollowed by a valid string delimiter (f"...",f'...', orf"""..."""). Literal segments share the same escape rules as<StringLiteral>. Any{ <Expression> }inside the template is evaluated and interpolated;\{injects a literal brace. - Number literals allow an optional leading
-, optional fractional part, optional exponent (E/eplus optional sign), and an optionallsuffix for 64-bit integers when no decimal/exponent is present. <Identifier>characters are restricted toA-Z,a-z,_for the first position, andA-Z,a-z,0-9,_thereafter.
Operator precedence (highest to lowest):
1. ^
2. *, div, /, %
3. +, -
4. >=, <=, !=, >, <, in
5. ==, =, ??, ?!, ?.
6. or, and
7. |
8. >>
Repeated operators of the same symbol associate to the left (e.g., a - b - c parses as (a - b) - c). Each precedence band may mix the listed operators; evaluation proceeds from the tighter band to the looser one.
Lexical notes:
- Keywords are case-insensitive and reserved: return, eval, fault, case, switch, then, else.
- Keywords and symbolic operators are matched case-insensitively (OR, Div, etc. are accepted).
- Whitespace (space, tab, CR, LF) is insignificant between tokens. // starts a line comment, /* ... */ forms a block comment; both count as whitespace.
- <KeyValueCollection> literals may be appended to any expression as selectors; when the selector appears immediately after the root it becomes the root expression; when it follows another expression it executes in the context of that expression.
- Only one return/eval clause is allowed per key/value block or selector. The parser reports "Duplicate return statement" on violation.