Skip to content

Commit

Permalink
parse aliased keywords. (see #21)
Browse files Browse the repository at this point in the history
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")`.)
  • Loading branch information
Yannick Scherer committed Jan 29, 2015
1 parent 6179c0b commit b761683
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/rewrite_clj/node/keyword.clj
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@

(defn keyword-node
"Create node representing a keyword. If `namespaced?` is given as `true`
a keyword à la `::x` (i.e. namespaced to the current namespace) is
generated."
a keyword à la `::x` or `::ns/x` (i.e. namespaced/aliased) is generated."
[k & [namespaced?]]
{:pre [(keyword? k)]}
(assert (or (not namespaced?) (not (namespace k)))
(str "invalid namespaced keyword: :" (pr-str k)))
(->KeywordNode k namespaced?))
1 change: 1 addition & 0 deletions test/rewrite_clj/parser_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
":ns/key" :ns/key
"::1.5.1" ::1.5.1
"::key" ::key
"::xyz/key" :xyz/key
"sym" 'sym
"sym#" 'sym#
"\"string\"" "string")
Expand Down

0 comments on commit b761683

Please sign in to comment.