rm-hull / infix

A Clojure library for expressing LISP expressions as infix rather than prefix notation
https://www.destructuring-bind.org/infix/
MIT License
106 stars 11 forks source link

Dot-namespacing? #42

Closed dsbw closed 7 months ago

dsbw commented 10 months ago

Hello,

I've got code I've been running for a while where the variables are namespaced.

{:x.y.z 4} And formulae that are composed like:

((from-string [] (merge all-fns {:x.y.z 4}) "1+2+x.y.z"))

And it does not work now. I get a

Execution error (ParseException) at jasentaa.position/parse-exception-interop (position.cljc:45).
Failed to parse text at line: 1, col: 6
1+2+x.y.z

I was using 0.40 when I noticed this and just switched to 0.41. Then I tried flipping back to 0.33, and it all got the same error.

So did something change or did I just hallucinate that the dot-notation for variables are usable?

rm-hull commented 9 months ago

It's not something I tried or considered. Pretty sure it was never supported. You can have variables like x_y_z - the parser for variables is encoded as

envref ::= letter | "_" { letter | digit | "_" }.

in this function: https://github.com/rm-hull/infix/blob/master/src/infix/grammar.clj#L66-L75

In theory it could be extended quite easily to enable dots, where the BNF expression would just be:

envref ::= letter | "_" { letter | digit | "_" | "." }.

If it's something you need, I can add look to add it, else a PR would be welcome

dsbw commented 7 months ago

OK, finally able to get back to this. Made the changes, added some tests... Should I fork or... (It's been a long time since I submitted a PR to someone else's code on GH, so I'm not sure of the next steps.)

rm-hull commented 7 months ago

Hi, yes fork, make changes and then create a PR .. it should set the base to be this repo - I can then merge the changes and publish a new version on clojars

dsbw commented 7 months ago

Done.

rm-hull commented 7 months ago

PR merged & 0.4.3 deployed to clojars: https://clojars.org/rm-hull/infix/versions/0.4.3