Skip to content

rfc: strict HCON grammar (not wired in) - #4047

Draft
manwithacat wants to merge 1 commit into
bigskysoftware:four-devfrom
manwithacat:rfc/hcon-grammar
Draft

rfc: strict HCON grammar (not wired in)#4047
manwithacat wants to merge 1 commit into
bigskysoftware:four-devfrom
manwithacat:rfc/hcon-grammar

Conversation

@manwithacat

Copy link
Copy Markdown
Contributor

Description

RFC for a closed HCON grammar. Not wired into src/htmx.js. Shipping HCON is unchanged.

Discussion: #4046
Related: #4029 (colon-form hx-swap-oob is a Map the host must reject, not a regex the parser should stretch).

Adds:

  • hcon/GRAMMAR.md — LL(1) EBNF. Two start symbols (Map vs List) so comma is not overloaded.
  • hcon/src/hcon.js — recursive descent, no regex. Quoted values are always strings. Leftover non-pairs error.
  • hcon/src/interpret.jshx-swap / hx-swap-oob / hx-trigger interpret maps. Colon form (beforeend:#table tbody) is a well-formed map that interpretOob rejects in favour of beforeend target:'#table tbody'.
  • hcon/test/ — 40 Node tests, including a corpus against the shipping regex and a no-regex gate on the parser surface.
  • CI job hcon_grammar: node --test hcon/test/*.test.js (no Playwright, ~60ms).

This PR is a demonstration so the discussion has a runnable artefact. Please treat it as draft until the grammar is accepted (or rejected). If the direction is wrong, close it.

Checklist

Adds hcon/ as a proposed LL(1) replacement for the shipping regex
HCON parser. Not wired into src/htmx.js. The new hcon_grammar CI job
runs node --test with no Playwright.

Comma is a List separator only; Maps are whitespace-separated.
Colon-form oob (beforeend:#table tbody) is a well-formed map that
interpretOob rejects. Selectors are quoted values.

Related: bigskysoftware#4029.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant