-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port to cljc #3
Port to cljc #3
Conversation
@PEZ thanks a lot for the effort. I am not very proficient with the Cljs side but I would guess that the StringBuffer implementation that @borkdude proposed would be enough for this use case. See #2 . From what I see both "classes" provide an
Regarding the regular expression. That is a special (multicharacter) unicode regex. It might be that Javascript doesnt support that exact syntax so you would need to check that. I put the link from the regex next to the grammar definition for specific rule: https://github.com/carocad/parcera/blob/master/src/parcera/core.clj#L138 Hope it helps |
Yeah, maybe we can use that StringBuffer instead. Even if the tiny StringBuilder I used makes for fewer changes in the rest of the code. I.e.something like: (let [string-builder (new StringBuilder)]
... Stays the same, no need for the conditional reader there. It's a matter of taste, I think. (Though, I say that without having had a look at goop's implementation.) Will have a look at the unicode regex thing. I've fought that fight before. Seems to vary a bit between node versions what is supported and not... |
It seems that the current regex doesn't work for anything unicode as it is (regardless of CLJ or CLJS). Just sticking a Swedish (testing "backtick"
(as-> "`hellö/world" input (is (= input (parcera/code (parcera/clojure input)))))
(as-> "`hello" input (is (= input (parcera/code (parcera/clojure input)))))
(as-> "`/" input (is (= input (parcera/code (parcera/clojure input)))))) I get this:
|
It seems like you just caught a bug 😅. I was using autogenerated symbols to test the symbol-regex but it seems that it doesnt create symbols with unicode characters in it. However, the regex that I mentioned was only for the character literals not for symbols which is why you just saw this behavior. |
Also add test for character literals
I see. I think I just assumed that the simple characters built up the identifiers. Should have read more carefully. Anyway. I've used http://kourge.net/projects/regexp-unicode-block to cook the character classes for the regex, since JavaScript just does not have the unicode support in its regex engine. Added a test for character literals, including unicode ones, which passes in both Clojure and ClojureScript. What'ya say? |
Right now the test suite as such bails on the |
I guess you can make a macro that puts the result of slurp into a var that can later on be used for the tests. That way the slurp process is at compile time (clojure) not runtime cljs. |
Right, did that now.
The ClojureScript tests run significantly slower. Maybe that is what It is, but also maybe my naive StringBuilder isn't fast enough. (Can't see why it wouldn't be though.) |
I guess one part of it is due to the use of I think another thing that we can check are instaparse tests itself. I would assume that it also has some cljs tests with the same content as those in clj so if those are also significantly slower then there is little we can do :/ |
After checking up the StringBuffer implementation, and confirmed that it has the same performance as my own tiny shim, I decided that it is worth using the goog implementation instead. I'll confirm that I can use this library from Calva (shadow-cljs) and if that works, I'd say this is good to go. it will be easier for more people to obsess on the performance side of things if it gets merged. 😄 |
Document the character literal unicode regex some. Also moved up criterium in global dependencies. I don't like it, but don't know how to otherwise satsify the production build
I am happy to keep merging your changes from upstream! No worries. And the JS tests are ... PASSING! Yay! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for this improvement :)
Hello,
This is work In progress. Wanted to get your feedback on wether you think it is the right way to go or not. For me it is important to be able to use a library like this from ClojureScript, because that's what Calva needs.
Right now do not expect anything to really work. Running the node tests fails like so: