Remove expect fns; declare parse-word.

This commit is contained in:
Scott Richmond 2022-02-15 18:27:22 -05:00
parent 531c85054c
commit a35da1498e

View File

@ -24,29 +24,9 @@
(defn- token-type [parser] (defn- token-type [parser]
(::token/type (current parser))) (::token/type (current parser)))
(defn- expect [message tokens parser] ;; some forward declarations
(let [curr (current parser)] (declare parse-expr)
(if (contains? tokens (::token/type curr)) (declare parse-word)
parser
(assoc parser ::ast {
::ast/type ::ast/poison
:message (str "Expected " message)
:token curr}))))
(defn- expect+ [message tokens parser]
(print "Epxecting ")
(pp/pprint tokens)
(let [curr (current parser)
next (next parser)]
(println "Current: " curr " Next: " next)
(if (contains? tokens (::token/type curr))
(if (contains? tokens (::token/type next))
(recur message tokens (advance parser))
parser)
(assoc parser ::ast {
::ast/type ::ast/poison
:message (str "Expected " message)
:token curr}))))
(defn- parse-atom [parser token] (defn- parse-atom [parser token]
(-> parser (-> parser
@ -68,7 +48,6 @@
::ast/type ::ast/atom ::ast/type ::ast/atom
:value (get atomic-words (::token/type token))}))) :value (get atomic-words (::token/type token))})))
(declare parse-expr)
(defn- add-member [members member] (defn- add-member [members member]
(if (nil? member) (if (nil? member)