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

@@ -53,6 +53,8 @@
((js-tag? ast "js-num") (nth ast 1))
((js-tag? ast "js-str") (nth ast 1))
((js-tag? ast "js-bool") (nth ast 1))
((js-tag? ast "js-regex")
(list (js-sym "js-regex-new") (nth ast 1) (nth ast 2)))
((js-tag? ast "js-null") nil)
((js-tag? ast "js-undef") (list (js-sym "quote") :js-undefined))
((js-tag? ast "js-ident") (js-transpile-ident (nth ast 1)))