Fixed #87. First, the if comparison in read-keyword was never true because a Character and an int were compared. Second, the call to readToken was passing in an int instead of a char and causing an IllegalArgExc
This commit is contained in:
parent
bb036ffc91
commit
bb2cb58bae
3 changed files with 42 additions and 20 deletions
|
@ -11,7 +11,8 @@
|
|||
[[lein-clojars "0.6.0"]
|
||||
[jline "0.9.94"]
|
||||
;; lein vimclojure& #starts the nailgun server
|
||||
[org.clojars.autre/lein-vimclojure "1.0.0"]]
|
||||
[org.clojars.autre/lein-vimclojure "1.0.0"]
|
||||
[lein-marginalia "0.7.0-SNAPSHOT"]]
|
||||
;;Needed for testing Latex equation formatting. You must download
|
||||
;;and install MathJax in you doc directory.
|
||||
:marginalia {:javascript ["mathjax/MathJax.js"]})
|
||||
|
|
|
@ -69,23 +69,28 @@
|
|||
(defmethod print-method DoubleColonKeyword [dck ^java.io.Writer out]
|
||||
(.write out (str \: (.content dck))))
|
||||
|
||||
(letfn [(read-token [reader c]
|
||||
(defmethod print-dup DoubleColonKeyword [dck ^java.io.Writer out]
|
||||
(print-method dck out))
|
||||
|
||||
(defn ^:private read-token [reader c]
|
||||
(call-method clojure.lang.LispReader :readToken
|
||||
[java.io.PushbackReader Character/TYPE]
|
||||
nil reader c))
|
||||
(match-symbol [s]
|
||||
|
||||
(defn ^:private match-symbol [s]
|
||||
(call-method clojure.lang.LispReader :matchSymbol
|
||||
[String]
|
||||
nil s))]
|
||||
nil s))
|
||||
|
||||
(defn read-keyword [reader colon]
|
||||
(let [c (.read reader)]
|
||||
(if (= \: c)
|
||||
(-> (read-token reader c)
|
||||
(if (= (int \:) c)
|
||||
(-> (read-token reader (char c))
|
||||
match-symbol
|
||||
DoubleColonKeyword.)
|
||||
(do (.unread reader c)
|
||||
(-> (read-token reader colon)
|
||||
match-symbol))))))
|
||||
match-symbol)))))
|
||||
|
||||
(defn set-keyword-reader [reader]
|
||||
(aset (get-field clojure.lang.LispReader :macros nil)
|
||||
|
@ -115,7 +120,14 @@
|
|||
(try (. clojure.lang.LispReader
|
||||
(read reader false nil false))
|
||||
(catch Exception ex
|
||||
(throw (Exception. (str "Problem parsing near line " start))))))
|
||||
(let [msg (str "Problem parsing near line " start
|
||||
" <" (.readLine reader) ">"
|
||||
" original reported cause is "
|
||||
(.getCause ex) " -- "
|
||||
(.getMessage ex))
|
||||
e (RuntimeException. msg)]
|
||||
(.setStackTrace e (.getStackTrace ex))
|
||||
(throw e)))))
|
||||
end (.getLineNumber reader)
|
||||
code {:form form :start start :end end}
|
||||
comments @top-level-comments]
|
||||
|
|
|
@ -1,7 +1,16 @@
|
|||
(ns problem-cases.general
|
||||
"A place to examine poor parser behavior. These should go in tests when they get written.")
|
||||
|
||||
::foo
|
||||
[::foo]
|
||||
|
||||
{:foo 43}
|
||||
{::foo 42}
|
||||
|
||||
(defn ^:private private-fn "private docstring" [])
|
||||
|
||||
(defn public-fn "docstring" []
|
||||
(let [x (private-fn)]
|
||||
(count x)))
|
||||
|
||||
;; Should have only this comment in the left margin.
|
||||
;; See [https://github.com/fogus/marginalia/issues/#issue/4](https://github.com/fogus/marginalia/issues/#issue/4)
|
||||
|
|
Loading…
Reference in a new issue