If what you want is a parser not a reader, I reworked this [1] recently and to the limits of my testing it's "correct" in that it parses every reader construct I thought of to throw at it. You could improve it, I believe that #() nesting is supported by this grammar, but I was trying not to complicate evaluation semantics with the parser grammar too much. Debugging ANTLR grammars is not what I'd call friendly.

A "useful" subset of this grammar with nicer evaluation semantics is used, a reader implemented and tested here [2]

[1] https://github.com/antlr/grammars-v4/blob/master/clojure/Clojure.g4
[2] https://github.com/oxlang/oxlang/blob/master/resources/grammar/Oxlang.g4

Reid

On 01/15/15 17:21, Thomas Heller wrote:
https://github.com/clojure/tools.reader is probably your best bet.

On Friday, January 16, 2015 at 12:13:22 AM UTC+1, zirkonit wrote:

    I'm thoroughly confused. If I want to parse clojure code from string
    without evaluating or caring a lot about its context, I'm out of luck.

    EDN tools choke on reader macros ( #(blah % blah) is not valid EDN
    ), yet more context-aware tools like read-string with *read-eval*
    set to false choke on namespace-specific tokens like ::om/pass.

    What would be a best choice to parse Clojure code into analyzable
    data structure while both parsing all of it (so, not just
    clojure.edn/read), _and_ not going the entire
    namespaces/shadowing/etc dance?

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with
your first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to clojure+unsubscr...@googlegroups.com
<mailto:clojure+unsubscr...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to