parsatron icon indicating copy to clipboard operation
parsatron copied to clipboard

ClojureScript merge

Open quoll opened this issue 5 years ago • 1 comments

I know that you're not a fan of .cljc files, but there are many benefits, and so I'm proposing these changes.

By having the same code for both runtimes, future changes only need to be made in one place, and testing is consistent between both platforms. This also meant that I removed the ClojureScript-only test. It was unnecessarily dependent on being run in a web page (which is awkward to automate). It's not possible to run the ClojureScript tests with:

$ lein cljsbuild test

I've tried to minimize the use of #?(...) macros. The primary difference is in the namespace declarations, due to the differences in referring to macros and importing.

There were also some bugs in the test code. The bf parser did parse correctly (resulting in expected errors or not), but did not return anything. The bencode parser used read-string which is not available in ClojureScript.

Also, I added the position structure to the error continuation object. It's not really needed, but because I moved to using ex-info then the ExceptionInfo structure was asking for some info, and this seemed appropriate.

quoll avatar Jan 10 '20 16:01 quoll

Ah, I missed that PR #37 was doing this as well.

Unfortunately, I pushed to the branch that this PR was based on with a completely separate change that I am hoping for: renaming of char/char? to ch/ch?.

The reason for this change is because it's an annoying pain to have to use refer-clojure/excuse for these functions. It wasn't so bad doing it in Clojure, because the effect of it was restricted to the namespace that needed it (specifically, a language defining file), but ClojureScript can import large blocks of code without namespaces, and it can result in warnings if you require a namespace that in turn requires parsatron.

quoll avatar Jan 13 '20 16:01 quoll