Open rebcabin opened 1 year ago
Maybe I should do this on the Clojure side with regex search-replace. Is this the only use of colon in ASR? What about namespace syntax like "::" in C++? What about type syntax ":" in Haskell? I'm trying to avoid heavy parsing on the Clojure side, but if regex search-replace is going to be robust, I'll do it on the Clojure side.
I have to make an assumption about the lexemes for ASR "identifier." If they're like C, namely [_a-zA-Z][_a-zA-Z0-9]*
then this isn't too bad. HOWEVER, it locks out Unicode in identifiers. I've been using Greek a lot in identifiers, and this postprocessing of mine is going to kill that.
Here is a better solution that admits Unicode:
I now believe I want to handle all issues like this on the Clojure side. I'll close the issue once one of you responds. IOW, I don't want to change PickleVisitorVisitor!
I want to change our output to be canonical Clojure. The vast majority if all identifier are ascii, so no problem there.
But it can also be Unicode, so we need some solution there. Does Clojure support Unicode symbols?
It can also be special characters that we insert in AST->ASR, such as @
. What is the list of acceptable symbol names in Clojure? We could escape non-conforming names.
Clojure names can be in Unicode. I use Greek to create symbols that won't collide with user symbols by convention.
https://clojure.org/reference/reader https://stackoverflow.com/questions/3902813/is-there-a-language-spec-for-clojure
no other written material. It's an observed fact that Unicode Greek is ok
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java
Consider
I'm writing some back ends in Clojure. something like
_lpython_main_program:
is a syntax error in Clojure. If you move the colon to the front:_lpython_main_program
, then, magically, ASR becomes valid Clojure, no post-processing needed! Otherwise I have to postprocess the output of--show-asr
in non-robust string-hacking in Clojure.Please consider permanently moving the colons to the front of symbols in
--show-asr
. You can change one line of code inPickleVisitorVisitor
to do this forever.