fix string interpolation
This commit is contained in:
parent
5deab18356
commit
265f867a71
|
@ -236,11 +236,14 @@
|
||||||
|
|
||||||
(set stringify stringify*)
|
(set stringify stringify*)
|
||||||
|
|
||||||
|
(defn- stringish? [x] (or (string? x) (buffer? x)))
|
||||||
|
|
||||||
(defn- interpolated [ast ctx]
|
(defn- interpolated [ast ctx]
|
||||||
(def terms (ast :data))
|
(def terms (ast :data))
|
||||||
|
(each term terms (pp term))
|
||||||
(def interpolations
|
(def interpolations
|
||||||
(map (fn [x]
|
(map (fn [x]
|
||||||
(if (string? x) x (stringify (interpret x ctx))))
|
(if (stringish? x) x (stringify (interpret x ctx))))
|
||||||
terms))
|
terms))
|
||||||
(string/join interpolations))
|
(string/join interpolations))
|
||||||
|
|
||||||
|
@ -393,28 +396,16 @@
|
||||||
(when (has-errors? parsed) (break (parsed :errors)))
|
(when (has-errors? parsed) (break (parsed :errors)))
|
||||||
(def validated (v/valid parsed))
|
(def validated (v/valid parsed))
|
||||||
(when (has-errors? validated) (break (validated :errors)))
|
(when (has-errors? validated) (break (validated :errors)))
|
||||||
# (interpret (parsed :ast) @{})
|
(interpret (parsed :ast) @{})
|
||||||
(try (interpret (parsed :ast) @{})
|
# (try (interpret (parsed :ast) @{})
|
||||||
([e] (print "Ludus panicked!: "
|
# ([e] (print "Ludus panicked!: "
|
||||||
(if (struct? e) (error (e :msg)) (error e)))))
|
# (if (struct? e) (error (e :msg)) (error e)))))
|
||||||
)
|
)
|
||||||
|
|
||||||
(do
|
(do
|
||||||
(set source `
|
(set source `
|
||||||
match "foooooo" with {
|
let verb = "love"
|
||||||
"f{foo}{bar}{baz}" -> (foo, bar, baz)
|
"{verb}"
|
||||||
_ -> :nope
|
|
||||||
}
|
|
||||||
`)
|
`)
|
||||||
(run)
|
(run)
|
||||||
)
|
)
|
||||||
|
|
||||||
(def g @{:0 "f" :1 '(<- (to :2)) :2 "o" :3 -1
|
|
||||||
:main '(* :0 :1 :2 :3)})
|
|
||||||
|
|
||||||
(def f '{:0 "b" :1 (<- (to :2)) :2 (* "" -1)
|
|
||||||
:main (* :0 :1 :2)})
|
|
||||||
|
|
||||||
(def h ~(* (<- (to "a")) "a" -1))
|
|
||||||
|
|
||||||
(peg/match f "barrr")
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user