Skip to content

Commit b761683

Browse files
author
Yannick Scherer
committed
parse aliased keywords. (see #21)
Expansion to s-expression will return a namespaced keyword without resolving the alias. This is in accordance with the expectation that a `:token` node returns a token, not a nested structure. (An alternative approach would have been to generate the form `(read-string "::ns/x")`.)
1 parent 6179c0b commit b761683

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

src/rewrite_clj/node/keyword.clj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@
3535

3636
(defn keyword-node
3737
"Create node representing a keyword. If `namespaced?` is given as `true`
38-
a keyword à la `::x` (i.e. namespaced to the current namespace) is
39-
generated."
38+
a keyword à la `::x` or `::ns/x` (i.e. namespaced/aliased) is generated."
4039
[k & [namespaced?]]
4140
{:pre [(keyword? k)]}
42-
(assert (or (not namespaced?) (not (namespace k)))
43-
(str "invalid namespaced keyword: :" (pr-str k)))
4441
(->KeywordNode k namespaced?))

test/rewrite_clj/parser_test.clj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
":ns/key" :ns/key
5151
"::1.5.1" ::1.5.1
5252
"::key" ::key
53+
"::xyz/key" :xyz/key
5354
"sym" 'sym
5455
"sym#" 'sym#
5556
"\"string\"" "string")

0 commit comments

Comments
 (0)