RFC: a closed, testable HCON grammar (no regex, hosts interpret maps) #4046
manwithacat
started this conversation in
Ideas
Replies: 1 comment
|
Draft PR (not for merge until this discussion lands): #4047 |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
HCON is the right kind of thing for a server-rendered attribute language: JSON semantics, less punctuation, lives in HTML attributes. It is not yet a language. Shipping 4.0.0 HCON is a global regex plus a peeler per attribute (
hx-swapfirst token,hx-triggerevent[filter],hx-swap-oobstyle:selector). That last peeler is #4029.This is an RFC for one LL(1) grammar, a recursive-descent parser, and a Node CI job that does not need Playwright. Shipping
src/htmx.jsis unchanged.Claim
evalstay outside the grammar.Two start symbols (comma cannot mean two things)
hx-swapmodifiers,hx-vals,hx-config,hx-headers,hx-swap-oobhx-triggerdelay:100ms throttle:200msis one map.click delay:500ms, keyupis a list of two.delay:100ms, throttle:200msas a Map is a syntax error (today it is one map).#4029 is an interpret error, not a parse error
beforeend:#table tbodyis a well-formed Map{beforeend:"#table", tbody:true}. A grammar of maps cannot reject it without a swap-style vocabulary.interpretOobrejects a swap-style key whose value is nottrueand asks forbeforeend target:'#table tbody'. Colon form is a second language; HCON should not grow a smarter space heuristic to host it.Evidence
hcon/GRAMMAR.mdhcon/src/hcon.js(no regex)hcon/test/corpus.jsonhcon_grammar:node --test hcon/test/*.test.js(Node 20, no Chromium). 40 tests, ~60ms locally.Quoted values are always strings (
count:"42"stays"42"). Leftover input that is not a pair is an error. JSON remains the{...}escape hatch and is not mixed with HCON.Happy to change any of this. The point is: specify the microlanguage, test it without a browser, then decide whether 4.x adopts it behind
upgrade-check.All reactions