some unfinished work on string interpolation
This commit is contained in:
parent
3466b075af
commit
c5d04ddd66
|
@ -551,12 +551,12 @@
|
||||||
(import ./scanner :as s)
|
(import ./scanner :as s)
|
||||||
(do
|
(do
|
||||||
#(comment
|
#(comment
|
||||||
(def source `"{foo}"`)
|
(def source `"foo {bar} \{baz"`)
|
||||||
(def scanned (s/scan source))
|
(def scanned (s/scan source))
|
||||||
# (def a-parser (new-parser scanned))
|
# (def a-parser (new-parser scanned))
|
||||||
# (def parsed (whenn a-parser))
|
# (def parsed (whenn a-parser))
|
||||||
# (-> parsed)
|
# (-> parsed)
|
||||||
(map (fn [t] (t :type)) (scanned :tokens))
|
(first (scanned :tokens))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -187,7 +187,6 @@
|
||||||
:else (add-error scanner (string "Unexpected " curr " after number " num ".")))))
|
:else (add-error scanner (string "Unexpected " curr " after number " num ".")))))
|
||||||
(recur scanner (buffer char) false))
|
(recur scanner (buffer char) false))
|
||||||
|
|
||||||
## TODO: activate string interpolation
|
|
||||||
(defn- add-string
|
(defn- add-string
|
||||||
[scanner]
|
[scanner]
|
||||||
(print "Adding string")
|
(print "Adding string")
|
||||||
|
@ -197,9 +196,10 @@
|
||||||
"{" (recur (advance scanner) (buffer/push buff char) true)
|
"{" (recur (advance scanner) (buffer/push buff char) true)
|
||||||
# allow multiline strings
|
# allow multiline strings
|
||||||
"\n" (recur (update (advance scanner) :line inc) (buffer/push buff char) interpolate?)
|
"\n" (recur (update (advance scanner) :line inc) (buffer/push buff char) interpolate?)
|
||||||
### TODO: add interpolated strings
|
"\"" (add-token (advance scanner) (if interpolate? :interpolated :string)(string buff))
|
||||||
### :string -> (if (interpolate? :interpolated :string))
|
### FIXME: Actually add the escaped character to the string;
|
||||||
"\"" (add-token (advance scanner) :string (string buff))
|
### The only weird escapy-thing is actually the lbrace
|
||||||
|
### So only do anything fancy if the next char is "{"
|
||||||
"\\" (let [next (next-char scanner)
|
"\\" (let [next (next-char scanner)
|
||||||
scanner (if (= next "\n")
|
scanner (if (= next "\n")
|
||||||
(update scanner :line inc)
|
(update scanner :line inc)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user