bpsm / edn-java

a reader for extensible data notation
Eclipse Public License 1.0
100 stars 24 forks source link

it should be possible to configure the parser with data #20

Closed bpsm closed 8 years ago

bpsm commented 11 years ago

I'm thinking of something like:

Parser p = Parsers.newParser(…);
Parseable r = Parsers.newParseable( … );
Parser.Config cfg = (Parser.Config) p.nextValue(r);

Where the Parseable r reads edn that's something like this:

#bpsm.edn-java/parser-config {
    :listFactory #bpsm.edn-java/class "fully.qualifed.class.Name"
    ;; new fully.qualified.class.Name() returns a CollectionBuilder.Factory
    …
    :handlers {
        :my/base64 #bpsm.edn-java/method {
            :class #bpsm.edn-java/class "fully.qualified.class.Name"
            :name "staticFactoryMethod"
        }
        ;; fully.qualified.class.Name.staticFactoryMethod() 
        ;;     returns a TagHandler.
        …
}

Open design questions:

mikera commented 11 years ago

Nice idea!

I'm wondering if there is / should be an edn-wide standard for how these kind of tags are named? The edn spec isn't particularly specific - only says that the prefix should "must be owned by the user (e.g. trademark or domain) or known unique in the communication context".

In this case, since the domain is controlled, you can safely use any prefix you like if the spec is to be believed - e.g. just #edn-java/method would be fine I think.....

bpsm commented 8 years ago

don't intend to implement