Working string interpolation!
This commit is contained in:
@@ -56,18 +56,16 @@
|
||||
|_ _ name _ _ _ params _ _ body| `(fun ~name (,(map |x| (idx x 0) params)) ~body))
|
||||
|
||||
; string interpolation
|
||||
fun remove_dollar(done to_do i j) (do (println "remove_dollar" done to_do i j) (cond (>= j (- (len to_do) 2)) done
|
||||
(= "\\$" (slice to_do j (+ j 2))) (remove_dollar (concat done (slice to_do i j)) to_do (+ j 2) (+ j 2))
|
||||
true (remove_dollar done to_do i (+ j 1))))
|
||||
fun remove_dollar(done to_do i j) (cond (>= j (- (len to_do) 2)) (str done (slice to_do i -1))
|
||||
(= "\\$" (slice to_do j (+ j 2))) (remove_dollar (str done (slice to_do i j) "$") to_do (+ j 2) (+ j 2))
|
||||
true (remove_dollar done to_do i (+ j 1)))
|
||||
fun fixup_str_parts(s) (remove_dollar "" (slice s 0 -2) 0 0)
|
||||
(add_grammar_rule 'form [ "$\"" [ "(#|[%-[]| |[]-~]|(\\\\)|(\\n)|(\\t)|(\\*)|(\\\\$)|
|
||||
|[ -!]|(\\\\\"))*$" 'form ] * "(#|[%-[]| |[]-~]|(\\\\)|(\\n)|(\\t)|(\\*)|(\\\\$)|
|
||||
|[ -!]|(\\\\\"))*\"" ]
|
||||
|_ string_form_pairs end| `(str ,( flat_map |x| [ (fixup_str_parts (idx x 0)) (idx x 1) ] string_form_pairs) ~(fixup_str_parts end)))
|
||||
|
||||
(println "HAY")
|
||||
(println $"unu |\$| $$"inner $(+ 1 2) post-inner" sual")
|
||||
(println "YAAAA")
|
||||
|
||||
obj Point( x y ) {
|
||||
add |self other| { Point((+ self.x other.x) (+ self.y other.y)) }
|
||||
|
||||
Reference in New Issue
Block a user