Work on datatypes
This commit is contained in:
parent
18e4826960
commit
969c321ffb
|
@ -124,6 +124,13 @@
|
||||||
:token token
|
:token token
|
||||||
:value (get atomic-words (::token/type token))}))))
|
:value (get atomic-words (::token/type token))}))))
|
||||||
|
|
||||||
|
(defn- parse-datatype [parser]
|
||||||
|
(let [token (current parser)]
|
||||||
|
(-> parser (advance)
|
||||||
|
(assoc ::ast {::ast/type ::ast/datatype
|
||||||
|
:token token
|
||||||
|
:value (::token/literal token)}))))
|
||||||
|
|
||||||
(defn- add-member [members member]
|
(defn- add-member [members member]
|
||||||
(if (nil? member)
|
(if (nil? member)
|
||||||
members
|
members
|
||||||
|
@ -1080,6 +1087,9 @@
|
||||||
(::token/lparen ::token/keyword) (parse-synthetic parser)
|
(::token/lparen ::token/keyword) (parse-synthetic parser)
|
||||||
(parse-word parser)))
|
(parse-word parser)))
|
||||||
|
|
||||||
|
::token/datatype
|
||||||
|
(parse-datatype parser)
|
||||||
|
|
||||||
(::token/nil ::token/true ::token/false)
|
(::token/nil ::token/true ::token/false)
|
||||||
(parse-atomic-word parser)
|
(parse-atomic-word parser)
|
||||||
|
|
||||||
|
@ -1148,9 +1158,9 @@
|
||||||
(parser)
|
(parser)
|
||||||
(parse-script)))
|
(parse-script)))
|
||||||
|
|
||||||
(comment
|
(do
|
||||||
(def pp pp/pprint)
|
(def pp pp/pprint)
|
||||||
(def source "let @{a, ...foo, :c d} = :foo")
|
(def source "Word")
|
||||||
|
|
||||||
(println "")
|
(println "")
|
||||||
(println "")
|
(println "")
|
||||||
|
@ -1158,7 +1168,7 @@
|
||||||
(println "")
|
(println "")
|
||||||
(println "*** *** TEST PARSE *** ***")
|
(println "*** *** TEST PARSE *** ***")
|
||||||
|
|
||||||
(pp/pprint (::ast (parse (scanner/scan source)))))
|
(pp (::ast (parse (scanner/scan source)))))
|
||||||
|
|
||||||
(comment "
|
(comment "
|
||||||
Further thoughts/still to do:
|
Further thoughts/still to do:
|
||||||
|
|
|
@ -201,7 +201,7 @@
|
||||||
word (str char)]
|
word (str char)]
|
||||||
(let [curr (current-char scanner)]
|
(let [curr (current-char scanner)]
|
||||||
(cond
|
(cond
|
||||||
(terminates? curr) (add-token scanner ::token/data)
|
(terminates? curr) (add-token scanner ::token/datatype)
|
||||||
(word-char? curr) (recur (advance scanner) (str word curr))
|
(word-char? curr) (recur (advance scanner) (str word curr))
|
||||||
:else (add-error scanner (str "Unexpected " curr " after datatype " word "."))))))
|
:else (add-error scanner (str "Unexpected " curr " after datatype " word "."))))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user