On 01/11/24 9:19 PM, "Robert Feldt" <feldt / ce.chalmers.se> wrote:

> On Sun, 25 Nov 2001, Bob Hutchison wrote:
> 
>> The same holds for XML stream or event parsers (e.g. SAX, XPP). You have the
>> opportunity to structure your application in a nice OO fashion. The impact
>> of this is most visible in a large application. Of course in a large
>> application you would also, likely, be more concerned with performance and
>> memory requirements, in which case events are the way to go (and you don't
>> need any other arguments).
>> 
> On an indirectly related note:
> 
> (Background) Rockit is a parser generator framework in pure-Ruby I'm
> working on. It allows you to specify the abstract syntax together with the
> grammar. So basically you're describing a tree that the parser will
> output. (BTW, is DOM simply an objectification of an abstract syntax
> tree? I'm not up-to-date with XML...)

I think DOM is supposed to be a representation of the XML infoset -- that
is, the information represented by the XML document (which in XML's case is
a tree, and since XML is supposed to be entirely syntactic, I can see how an
AST might be similar).

> 
> For the next major Rockit release I'm considering building the tree by
> creating a ParseAction object which is called in event-style. If so, you
> can plug in your own ParseAction object and get an event-based parser even
> though the default actions (are auto-generated and) build the tree. Anyone
> care to comment on this design? Are there better ways? Got pointers to
> something similar?

I don't know about better ways, but I do know that a bunch of event based
parsers have been extended to generate ASTs. (And if the careful reader is
wondering if this is a counter example to my GUI argument, I'm not sure I'd
agree :-) and I'd point you to, for example, SableCC and suggest you
consider why they have an extended 'visitor' pattern defined and what an
application might do with that visitor).

You might want to look at Muskox (http://www.mastersys.com/), I think they
do something similar, but I'm not sure I remember correctly.

Cheers,
Bob

> 
> Regards,
> 
> /Robert
>