js-on-sx: regex literal lex+parse+transpile+runtime stub

Lexer: js-regex-context? disambiguates / based on prior token;
read-regex handles [...] classes and \ escapes. Emits
{:type "regex" :value {:pattern :flags}}.

Parser: new primary branch → (js-regex pat flags).

Transpile: (js-regex-new pat flags).

Runtime: js-regex? predicate, js-regex-new builds tagged dict with
source/flags/global/ignoreCase/multiline/sticky/unicode/dotAll/
hasIndices/lastIndex. js-regex-invoke-method dispatches .test/.exec/
.toString. js-invoke-method detects regex receivers. Stub engine
uses js-string-index-of; __js_regex_platform__ + override! let a
real engine plug in later.

Runner: repeatable --filter flags (OR'd).

308/310 unit (+30 regex tests), 148/148 slice unchanged.
This commit is contained in:
2026-04-23 20:27:19 +00:00
parent 6b0334affe
commit ce46420c2e
7 changed files with 337 additions and 4 deletions

View File

@@ -314,6 +314,13 @@
(list? val)
(jp-build-template-ast val)
(list (quote js-str) val)))))
((= (get t :type) "regex")
(do
(jp-advance! st)
(list
(quote js-regex)
(get (get t :value) :pattern)
(get (get t :value) :flags))))
((and (= (get t :type) "keyword") (= (get t :value) "true"))
(do (jp-advance! st) (list (quote js-bool) true)))
((and (= (get t :type) "keyword") (= (get t :value) "false"))