Compare commits
No commits in common. "70b6a1dcd73bfe7d2dbe5ebd090b25bc132b439f" and "94adf5e9d56b9e060bff6f97488e1535ca3f5d5d" have entirely different histories.
70b6a1dcd7
...
94adf5e9d5
|
@ -163,12 +163,6 @@
|
||||||
(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))
|
||||||
|
@ -261,7 +255,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 :pkg-kw])
|
(def sequels [:lparen :keyword])
|
||||||
|
|
||||||
(defn- word-expr [parser]
|
(defn- word-expr [parser]
|
||||||
(expect parser :word)
|
(expect parser :word)
|
||||||
|
@ -327,7 +321,6 @@
|
||||||
(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)
|
||||||
)
|
)
|
||||||
|
@ -837,9 +830,7 @@
|
||||||
(defn- pkg-name [parser]
|
(defn- pkg-name [parser]
|
||||||
(expect parser :pkg-name)
|
(expect parser :pkg-name)
|
||||||
(def origin (current parser))
|
(def origin (current parser))
|
||||||
(def next-type (-> parser peek type))
|
(if (= :keyword (-> parser peek type)) (break (synthetic parser)))
|
||||||
(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})
|
||||||
|
|
||||||
|
@ -1115,8 +1106,7 @@
|
||||||
|
|
||||||
# (do
|
# (do
|
||||||
(comment
|
(comment
|
||||||
(def source `
|
(def source `a :b :c
|
||||||
Foo :bar :Baz
|
|
||||||
`)
|
`)
|
||||||
(def scanned (s/scan source))
|
(def scanned (s/scan source))
|
||||||
(print "\n***NEW PARSE***\n")
|
(print "\n***NEW PARSE***\n")
|
||||||
|
@ -1125,9 +1115,9 @@ Foo :bar :Baz
|
||||||
|
|
||||||
# (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)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -169,15 +169,6 @@
|
||||||
:else (add-error scanner (string "Unexpected " char "after keyword :" key)))))
|
:else (add-error scanner (string "Unexpected " char "after keyword :" key)))))
|
||||||
(recur scanner ""))
|
(recur scanner ""))
|
||||||
|
|
||||||
(defn- add-pkg-kw [scanner]
|
|
||||||
(defn recur [scanner key]
|
|
||||||
(let [char (current-char scanner)]
|
|
||||||
(cond
|
|
||||||
(terminates? char) (add-token scanner :pkg-kw (keyword key))
|
|
||||||
(word-char? char) (recur (advance scanner) (string key char))
|
|
||||||
:else (add-error scanner (string "Unexpected " char " after pkg keyword :" key)))))
|
|
||||||
(recur scanner ""))
|
|
||||||
|
|
||||||
(defn- read-literal [lit] (-> lit parse-all first))
|
(defn- read-literal [lit] (-> lit parse-all first))
|
||||||
|
|
||||||
### TODO: consider whether Janet's number rules are right for Ludus
|
### TODO: consider whether Janet's number rules are right for Ludus
|
||||||
|
@ -308,8 +299,7 @@
|
||||||
# XXX: make sure we want only lower-only keywords
|
# XXX: make sure we want only lower-only keywords
|
||||||
":" (cond
|
":" (cond
|
||||||
(lower? next) (add-keyword scanner)
|
(lower? next) (add-keyword scanner)
|
||||||
(upper? next) (add-pkg-kw scanner)
|
:else (add-error scanner (string "Expected keyword. Got " char next)))
|
||||||
:else (add-error scanner (string "Expected keyword or pkg keyword. Got " char next)))
|
|
||||||
|
|
||||||
## splats
|
## splats
|
||||||
"." (let [after_next (current-char (advance scanner))]
|
"." (let [after_next (current-char (advance scanner))]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user