Chez Phase 1 (increment 3i): regex via vendored irregex
Closes the last clojure.core prelude emit gap (parse-uuid): the whole non-macro core now lowers to Scheme (prelude reach 355/355). A #"..." literal analyzes to a :regex IR node. The Chez back end emits a jolt-regex value over irregex (Alex Shinn, BSD), vendored as the vendor/irregex submodule -- a portable Scheme regex with PCRE/Java-style string patterns and first-class Chez support. host/chez/regex.ss wraps jolt's re-* surface over it: irregex-match -> re-matches (anchored), irregex-search -> re-find, groups as Clojure [whole g1 ...] vectors, re-seq as a jolt seq. re-pattern/re-matches/re-find/re-seq/regex? are def-var!'d into clojure.core so prelude / -e code resolves them. They stay OUT of the subset native-ops on purpose: irregex's Unicode/property-class semantics differ from the seed's byte-PEG approximation, so keeping them prelude-only avoids dragging engine-difference divergences into the subset-parity corpus. The Janet back end punts :regex to the interpreter (the seed compiles #"..." to a Janet PEG), so the main language is unchanged. Only two adaptations for Chez's top level: a cond-expand shim (Chez's is library-only) and a normalizing error wrapper (silences irregex's 1-arg error warnings). rt.ss load is ~0.18s. emit-test 131/131 (regex literal + re-* parity vs the CLI oracle); prelude reach 355/355; Chez subset 672/672, 0 divergences; full gate green.
This commit is contained in:
parent
b1cdfd1c9b
commit
37c433bd4a
11 changed files with 164 additions and 14 deletions
|
|
@ -781,6 +781,9 @@
|
|||
# punt to the interpreter, exactly as the analyzer used to before producing
|
||||
# a :host-call node (the Chez back end lowers it instead).
|
||||
:host-call (error "jolt/uncompilable: host method call")
|
||||
# regex literal: the back end doesn't compile patterns — punt to the
|
||||
# interpreter (the seed compiles #"…" to a Janet PEG). Chez emits jolt-regex.
|
||||
:regex (error "jolt/uncompilable: regex literal")
|
||||
(error (string "backend: unhandled op " (node :op))))))
|
||||
|
||||
(defn emit-ir
|
||||
|
|
|
|||
|
|
@ -46,6 +46,13 @@
|
|||
(phm/phm? form)))
|
||||
(defn h-set? [form] (and (struct? form) (= :jolt/set (form :jolt/type))))
|
||||
(defn h-char? [form] (and (struct? form) (= :jolt/char (form :jolt/type))))
|
||||
# A regex literal #"…" reads as a tagged form {:jolt/type :jolt/tagged :tag :regex
|
||||
# :form "source"}. The analyzer lowers it to a :regex IR node (Chez emits a
|
||||
# jolt-regex value; the Janet back end punts to the interpreter, which compiles it
|
||||
# via the seed PEG engine).
|
||||
(defn h-regex? [form]
|
||||
(and (struct? form) (= :jolt/tagged (form :jolt/type)) (= :regex (form :tag))))
|
||||
(defn h-regex-source [form] (form :form))
|
||||
|
||||
(defn h-literal? [form]
|
||||
(or (nil? form) (boolean? form) (number? form) (string? form)
|
||||
|
|
@ -254,6 +261,7 @@
|
|||
"form-sym-meta" h-sym-meta
|
||||
"form-list?" h-list? "form-vec?" h-vector? "form-map?" h-map?
|
||||
"form-set?" h-set? "form-char?" h-char? "form-literal?" h-literal?
|
||||
"form-regex?" h-regex? "form-regex-source" h-regex-source
|
||||
"form-elements" h-elements "form-vec-items" h-vector-items
|
||||
"form-map-pairs" h-map-pairs "form-set-items" h-set-items
|
||||
"form-special?" h-special? "compile-ns" h-current-ns "form-macro?" h-macro?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue