fix string interpolation
This commit is contained in:
parent
5deab18356
commit
265f867a71
|
@ -236,11 +236,14 @@
|
|||
|
||||
(set stringify stringify*)
|
||||
|
||||
(defn- stringish? [x] (or (string? x) (buffer? x)))
|
||||
|
||||
(defn- interpolated [ast ctx]
|
||||
(def terms (ast :data))
|
||||
(each term terms (pp term))
|
||||
(def interpolations
|
||||
(map (fn [x]
|
||||
(if (string? x) x (stringify (interpret x ctx))))
|
||||
(if (stringish? x) x (stringify (interpret x ctx))))
|
||||
terms))
|
||||
(string/join interpolations))
|
||||
|
||||
|
@ -393,28 +396,16 @@
|
|||
(when (has-errors? parsed) (break (parsed :errors)))
|
||||
(def validated (v/valid parsed))
|
||||
(when (has-errors? validated) (break (validated :errors)))
|
||||
# (interpret (parsed :ast) @{})
|
||||
(try (interpret (parsed :ast) @{})
|
||||
([e] (print "Ludus panicked!: "
|
||||
(if (struct? e) (error (e :msg)) (error e)))))
|
||||
(interpret (parsed :ast) @{})
|
||||
# (try (interpret (parsed :ast) @{})
|
||||
# ([e] (print "Ludus panicked!: "
|
||||
# (if (struct? e) (error (e :msg)) (error e)))))
|
||||
)
|
||||
|
||||
(do
|
||||
(set source `
|
||||
match "foooooo" with {
|
||||
"f{foo}{bar}{baz}" -> (foo, bar, baz)
|
||||
_ -> :nope
|
||||
}
|
||||
let verb = "love"
|
||||
"{verb}"
|
||||
`)
|
||||
(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