add easy patterns, start work on string interpolation

This commit is contained in:
Scott Richmond 2024-05-08 17:31:47 -04:00
parent 736f1024c3
commit 3466b075af

View File

@ -324,6 +324,14 @@
(advance parser)
{:type :word :data (origin :lexeme) :token origin})
(defn- tuple-pattern [parser])
(defn- list-pattern [parser])
(defn- dict-pattern [parser])
(defn- string-pattern [parser])
(defrec pattern [parser]
(case (-> parser current type)
:nil (nill parser)
@ -331,11 +339,15 @@
:false (bool parser)
:keyword (kw parser)
:number (number parser)
:string (str parser)
:word (word-pattern parser)
:placeholder (placeholder parser)
)
)
:lparen (tuple-pattern parser)
:lbracket (list-pattern parser)
:startdict (dict-pattern parser)
:interpolated (string-pattern parser)
(panic parser "expected pattern")
))
### conditional forms
# if {simple} then {nonbinding} else {nonbinding}
@ -539,18 +551,12 @@
(import ./scanner :as s)
(do
#(comment
(def source `when {
a -> b
foo -> bar quux
-> baz
c -> d
}
`)
(def source `"{foo}"`)
(def scanned (s/scan source))
(def a-parser (new-parser scanned))
(def parsed (whenn a-parser))
(-> parsed)
# (map (fn [t] (t :type)) (scanned :tokens))
# (def a-parser (new-parser scanned))
# (def parsed (whenn a-parser))
# (-> parsed)
(map (fn [t] (t :type)) (scanned :tokens))
)