Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Mirror LispReader when matching missing symbol names

LispReader is very liberal about what characters may appear in a symbol:

    static Pattern symbolPat
        = Pattern.compile("[:]?([\\D&&[^/]].*/)?(/|[\\D&&[^/]][^/]*)");

Therefore non-ASCII Unicode strings are also valid symbols:

    (def unicode-symbols
      '#{스람훈드 Σλαμηονδ ∧ ∨ ∩ ∪ ¬ ∀ ∅ ∴ ∫})

The new sym-pat now covers this set of characters as well.

Also from LispReader.java:

    static boolean isWhitespace(int ch){
        return Character.isWhitespace(ch) || ch == ',';
    }

Happily, the symbol names in error messages are only ever surrounded by
spaces and commas.
  • Loading branch information...
commit e7ac623d967e38d638d3e1df90c5e3226a0ef6b0 1 parent bedcadd
Sung Pae guns authored
2  src/slam/hound/regrow.clj
View
@@ -21,7 +21,7 @@
(Character/isUpperCase ^Character (first (name x))))
(def ^:private missing-sym-patterns
- (let [sym-pat #"([-\+_\w\$\?!\*\>\<=]+'*|/)"
+ (let [sym-pat #"(/|\D[^\p{javaWhitespace},/]*)"
prefixes [#"Unable to resolve \w+: "
"Can't resolve: "
"No such namespace: "
7 test/slam/hound/regrow_test.clj
View
@@ -23,6 +23,9 @@
(def CapitalVar true)
(def Pattern "Not java.util.Pattern")
(def trim (constantly "Conflicts with clojure.string/trim"))
+(def τ (* Math/PI 2))
+(def :intersection)
+(def :star)
;; Explicitly require korma for tests below
(require 'korma.core)
@@ -159,7 +162,9 @@
((keyword? /))])
'{:old {:exclude {clojure.core #{/}}}
:exclude {clojure.core #{/}}
- :refer {slam.hound.regrow-test #{/}}})))
+ :refer {slam.hound.regrow-test #{/}}}))
+ (is (= (regrow '[{} ((def unicode-syms [τ ∩ ★]))])
+ '{:refer {slam.hound.regrow-test #{τ ∩ ★}}})))
(testing "finds consumed references within syntax-quotes"
(is (= (regrow '[{:name slam.hound.regrow-test}
((eval `(instance? Named :foo)))])
2  todo.org
View
@@ -25,6 +25,6 @@
* Minor enhancements
- [X] Sort alias candidates by L̶e̶v̶e̶n̶s̶h̶t̶e̶i̶n̶ "alias" distance, with emphasis on initial letters
- [X] Satisfy all reflection warnings (there are only a handful)
+ - [X] Support Unicode characters in regrow/missing-sym-name
- [ ] Count dashes as word separators when calculating "alias" distance
- - [ ] Support Unicode characters in regrow/missing-sym-name
- [ ] Sort refer candidates by matching arity. e.g. (join []) should prefer clojure.string/join
Please sign in to comment.
Something went wrong with that request. Please try again.