[erlang-questions] json_to_term EEP

Chris Anderson <>
Fri Aug 1 20:20:19 CEST 2008


On Thu, Jul 31, 2008 at 4:10 PM, Richard A. O'Keefe <> wrote:
> To put it bluntly, there is no way I am ever going to put a SAX-like
> interface in *my* EEP for JSON.  (I am not rejecting the idea that a
> JSON converter might accept or deliver JSON forms incrementally; the
> issues there are rather different.)
>
> Anyone who thinks differently is not only free to write their own
> EEP, they are *welcome* to do so.  It will be *good* for Erlang if
> different ideas about how to do things are clearly written up and
> available for discussion.
>>
>
>> I personally like working with a SAX parser.
>> See the example below - I quite enjoyed writing it.
>

Just checked through the Yecc documentation - it looks like the
example code I posted has both a DVM and a SAX-like API. It's nice
that the same code base can serve both purposes. Now to make it fast!

from the Yecc docs: http://www.erlang.org/doc/man/yecc.html

====

It is also possible to make the parser ask for more input tokens when
needed if the following call format is used:

myparser:parse_and_scan({Function, Args})
myparser:parse_and_scan({Mod, Tokenizer, Args})

The tokenizer Function is either a fun or a tuple {Mod, Tokenizer}.

The call apply(Function, Args) or apply({Mod, Tokenizer}, Args) is
executed whenever a new token is needed. This, for example, makes it
possible to parse from a file, token by token.



-- 
Chris Anderson
http://jchris.mfdz.com



More information about the erlang-questions mailing list