[antlr-interest] V3: Clarification parser vs tree grammer, and a question

Mark Mandel mark.mandel at gmail.com
Wed Dec 27 19:43:48 PST 2006


Heya,

Still on my learning trail, and I think I may finaly have had my 'aha'
moment, but I figured I would double check.

Looking at the XML Parser tutorial, because that is a good example,
and looking at the parser grammer vs the tree grammer.

The way I'm seeing it at the moment is that the job of the Parser is
to build the AST tree.  It defines the tokens, explains where the root
of the tree should be, and defines the structure of the children.

The tree grammer is how to DO something with that tree (I believe in
v2, it was a tree walker?).  Basically it parses the AST Tree that is
built in the Parser grammer.

It's almost like it is the parser's parser ... if that remotely makes any sense.

So that means that the rule structure of the tree grammer should match
the tree structure that is generated by the parser grammer.

Is this correct? it seems to be that way to me, so I just want to make
sure I've got it right.

Onto a second question -

If my treeParser requires other Java objects to evaluate the tree it
has been passed, is there some way to add that to the Constructor of
the generated TreeParser, OR is the best way simply to make a
setMyLib(myLib) function via the @members section, and call that prior
to evaluating the tree?

Hope that was clear,

Mark

-- 
E: mark.mandel at gmail.com
W: www.compoundtheory.com


More information about the antlr-interest mailing list