ADR 0028 - Literal syntax constraints + unsupported-syntax detection
- Status: accepted
- Date: 2026-05-09
- Spec target: XTL 0.1
- Affects: language.md, grammar.ebnf, ADR-0023
Context
A spec audit found three under-specified shapes in expression literals and unary-operator handling:
#1 — String literal escape
The grammar says "no escape sequences in XTL 0.1" but the impl
silently accepts unbalanced quotes. "hello"world" parses as
hello"world (the trailing quote is consumed somewhere), and
"hello \"world\"" outputs literal hello \"world\" because
backslashes pass through. There is no normative way to embed a "
inside a string literal.
#2 — Unary operators on non-literal expressions
-5 works (sign-prefixed number literal). -[X], +5, --5,
-(expr) all silently fall through to bare-string return,
producing "-[X]", "+5", etc. as cell values. Excel handles all
of these (=-A1, =+A1, =--A1); xl3 does not.
#3 — + as a unary prefix
Excel accepts =+A1 (no-op identity). xl3 silently treats it as
the literal string +A1.
Considered Options
A. Fix all three properly (parser change). Add unary +/- as
proper expression prefixes; add Excel-style "" escape inside
string literals. Pro: feature-complete. Con: parser change, tricky
to get right, expands surface for 1.0.
B. Document constraints; throw on detected silent garbage. Spec
says: number literal -N valid; unary on expressions / column refs
NOT supported in 0.x; string "..." is matched-pair only with no
escape. Impl detects the unsupported patterns at the bare-string
fallthrough and throws xl3/eval/unsupported-syntax. Pro: small
change, fail-loud. Con: authors who want =-A1 shape have to write
(0 - [A]).
C. Document; do not detect. Pro: zero impl change. Con: silent garbage continues; users debug for hours.
Decision
Adopt B.