[antlr-interest] antlr vs. javacc+jjtree tree construction
mzukowski at bco.com
mzukowski at bco.com
Wed Mar 27 09:29:46 PST 2002
Boy, I woke up to early this morning...
> -----Original Message-----
> From: mzukowski at bco.com [mailto:mzukowski at bco.com]
> Sent: Wednesday, March 27, 2002 6:13 AM
> To: antlr-interest at yahoogroups.com
> Subject: RE: [antlr-interest] antlr vs. javacc+jjtree tree
> construction
>
>
> If a rule has no tokens, then what would be in the tree?
> What kind of rule
> has no tokens? What does it match?
It matches other rules, of course. What jjtree constructs is basically a
parse tree. Every rule creates a node with children. With expressions this
can get quite nested and is not needed. An AST can represent an expression
with a minimum of nodes. If I have 5*3, my tree would be ("*" 5 3) instead
of (conditionalExpr ( logicalOrExpr ( logicalAndExpr (inclusiveOrExpr
(exclusiveOrExpr (bitAndExpr (equalityExpr (relationalExpr (shiftExpr
(additiveExpr (multExpr 5 3) ) ) ) ) ) ) ) ) ) )
Note that the tree structure will encode the precedence-- (* (+ 5 5) 5)
means something different than (+ (* 5 5) 5) by the way it is nested.
Monty
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list