fix(parser): keep a colon followed by blanks alone as text, not an empty alias #282

Merged
abiwab merged 1 commit from fix/parser-colon-after-bare-ingredient into main 2026-11-26 18:14:07 +01:00
Owner

Fixes #281.

alias = ":" refName accepted an alias made of blanks only: after a bare ingredient or cookware at the end of a line (Add @salt: + line break), the blanks became an empty alias and the colon vanished from the step, while @salt: kept it. gram format strips the trailing blank, so formatting changed the recipe (fuzz format-preserves-meaning).

  • Grammar: alias = ":" ~(sp* (nl | end)) refName. Blanks alone up to a line break (LF, CRLF, lone CR) or the end of the file are no alias; the colon stays text. Real aliases are unchanged (@dry white wine:wine{100ml}, @salt: fleur de sel.), and so is @salt: {1}.
  • Tests: 9 in packages/parser/tests/grammar-edge-cases.test.ts (7 fail on the old grammar), plus the fuzz input in fuzz/regressions/281-colon-blank-alias.gram.
  • patch changeset for @gram-lang/parser.

Checks: 3929 pass / 1 skip / 0 fail, conformance 142/142 and 24/24 with no golden change, typecheck, biome, deprecations:check, audit 126, fuzz 50k (seed 2768684730, 0 signature).

Follow-ups (in #281): tree-sitter-gram sync for the highlighting of the :; @salt: a pinch. reading the rest of the line as an alias is out of scope (syntax change).

Fixes #281. `alias = ":" refName` accepted an alias made of blanks only: after a bare ingredient or cookware at the end of a line (`Add @salt: ` + line break), the blanks became an empty alias and the colon vanished from the step, while `@salt:` kept it. `gram format` strips the trailing blank, so formatting changed the recipe (fuzz `format-preserves-meaning`). - Grammar: `alias = ":" ~(sp* (nl | end)) refName`. Blanks alone up to a line break (LF, CRLF, lone CR) or the end of the file are no alias; the colon stays text. Real aliases are unchanged (`@dry white wine:wine{100ml}`, `@salt: fleur de sel.`), and so is `@salt: {1}`. - Tests: 9 in `packages/parser/tests/grammar-edge-cases.test.ts` (7 fail on the old grammar), plus the fuzz input in `fuzz/regressions/281-colon-blank-alias.gram`. - `patch` changeset for `@gram-lang/parser`. Checks: 3929 pass / 1 skip / 0 fail, conformance 142/142 and 24/24 with no golden change, typecheck, biome, `deprecations:check`, audit 126, fuzz 50k (seed 2768684730, 0 signature). Follow-ups (in #281): `tree-sitter-gram` sync for the highlighting of the `:`; `@salt: a pinch.` reading the rest of the line as an alias is out of scope (syntax change).
fix(parser): keep a colon followed by blanks alone as text, not an empty alias
All checks were successful
CI / Build & Test (pull_request) Successful in 4m56s
daddb567f2
abiwab scheduled this pull request to auto merge when all checks succeed 2026-11-26 18:09:56 +01:00
abiwab merged commit 147d1f377a into main 2026-11-26 18:14:07 +01:00
abiwab deleted branch fix/parser-colon-after-bare-ingredient 2026-11-26 18:14:08 +01:00
Sign in to join this conversation.
No description provided.