correctly parse pkg-name and pkg-kw
This commit is contained in:
parent
23128902bc
commit
70b6a1dcd7
|
@ -163,6 +163,12 @@
|
||||||
(advance parser)
|
(advance parser)
|
||||||
{:type :keyword :data (curr :literal) :token curr})
|
{:type :keyword :data (curr :literal) :token curr})
|
||||||
|
|
||||||
|
(defn- pkg-kw [parser]
|
||||||
|
(expect parser :pkg-kw)
|
||||||
|
(def curr (-> parser current))
|
||||||
|
(advance parser)
|
||||||
|
{:type :pkg-kw :data (curr :literal) :token curr})
|
||||||
|
|
||||||
(defn- nill [parser]
|
(defn- nill [parser]
|
||||||
(expect parser :nil)
|
(expect parser :nil)
|
||||||
(def curr (current parser))
|
(def curr (current parser))
|
||||||
|
@ -255,7 +261,7 @@
|
||||||
(panic parser (string "expected separator, got " (-> parser current type))))
|
(panic parser (string "expected separator, got " (-> parser current type))))
|
||||||
(while (separates? parser) (advance parser)))
|
(while (separates? parser) (advance parser)))
|
||||||
|
|
||||||
(def sequels [:lparen :keyword])
|
(def sequels [:lparen :keyword :pkg-kw])
|
||||||
|
|
||||||
(defn- word-expr [parser]
|
(defn- word-expr [parser]
|
||||||
(expect parser :word)
|
(expect parser :word)
|
||||||
|
@ -321,6 +327,7 @@
|
||||||
(case (-> parser current type)
|
(case (-> parser current type)
|
||||||
:lparen (args parser)
|
:lparen (args parser)
|
||||||
:keyword (kw-only parser)
|
:keyword (kw-only parser)
|
||||||
|
:pkg-kw (pkg-kw parser)
|
||||||
))
|
))
|
||||||
(array/push terms term)
|
(array/push terms term)
|
||||||
)
|
)
|
||||||
|
@ -830,7 +837,9 @@
|
||||||
(defn- pkg-name [parser]
|
(defn- pkg-name [parser]
|
||||||
(expect parser :pkg-name)
|
(expect parser :pkg-name)
|
||||||
(def origin (current parser))
|
(def origin (current parser))
|
||||||
(if (= :keyword (-> parser peek type)) (break (synthetic parser)))
|
(def next-type (-> parser peek type))
|
||||||
|
(when (or (= :keyword next-type) (= :pkg-kw next-type))
|
||||||
|
(break (synthetic parser)))
|
||||||
(advance parser)
|
(advance parser)
|
||||||
{:type :pkg-name :data (origin :lexeme) :token origin})
|
{:type :pkg-name :data (origin :lexeme) :token origin})
|
||||||
|
|
||||||
|
@ -1106,7 +1115,8 @@
|
||||||
|
|
||||||
# (do
|
# (do
|
||||||
(comment
|
(comment
|
||||||
(def source `a :b :c
|
(def source `
|
||||||
|
Foo :bar :Baz
|
||||||
`)
|
`)
|
||||||
(def scanned (s/scan source))
|
(def scanned (s/scan source))
|
||||||
(print "\n***NEW PARSE***\n")
|
(print "\n***NEW PARSE***\n")
|
||||||
|
@ -1115,9 +1125,9 @@
|
||||||
|
|
||||||
# (print (pp-ast parsed))
|
# (print (pp-ast parsed))
|
||||||
# (pp scanned)
|
# (pp scanned)
|
||||||
# (pp parsed)
|
(pp parsed)
|
||||||
(def cleaned (get-in parsed [:data 2]))
|
# (def cleaned (get-in parsed [:data 2]))
|
||||||
(pp cleaned)
|
# (pp cleaned)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user