kanaka / clojurescript

Clojure to JS compiler (patched to allow compiling of compiler to ClojureScript)
189 stars 15 forks source link

Fix for regexps containing / character #1

Closed Gozala closed 11 years ago

Gozala commented 11 years ago

At the moment this fixes reader, such that reading #"/" outputs #"\/" form but there is still something in analyze or comp/emit-str that transform it to #"\\\/". I'll be trying to track it down...

Gozala commented 11 years ago

Now regexp seem to work as expected:

cljs.user=> (set! noderepl/*debug* true)
true
cljs.user=> 
cljs.user=> #"/"
read: #"/"
analyzed: #"/"
emit: /\//
#"\/"
cljs.user=> #"\/"
read: #"\/"
analyzed: #"\/"
emit: /\\\//
#"\\\/"
cljs.user=> (re-find #"hello/world" "hello/world/of/wonders")
read: (re-find #"hello/world" hello/world/of/wonders)
analyzed: (re-find #"hello/world" hello/world/of/wonders)
emit: cljs.core.re_find.call(null,/hello\/world/,"hello/world/of/wonders")
"hello/world"
cljs.user=> 

Only problem is that when you type #"/" in repl it outputs #"\/" instead of actual input. Although emitted js regexp is correct. I suspect that print doing some escaping and causing this. I'll try to fix this, but I think this can land as is.

@kanaka Please comment if you want me to do some further changes before landing this, or if I'm doing something wrong.

Gozala commented 11 years ago

P.S: You see

Failed — The Travis build failed (Details)

because I have enabled travis.ci test integration on my fork, but this branch has no travis config so it fails.

kanaka commented 11 years ago

Looks good. Merged.

Can you open a pull request for the travis change too.

Also, the separate read, analyze, emit debug output is useful, so if it's self-contained open a pull and I'll pull that in too.