[antlr-interest] question about variable assignment in grammars

Olivier Lefevre lefevrol at yahoo.com
Mon Jan 28 13:17:52 PST 2008


I am going through the book and looking at ExprEval.g.
I am puzzled by the use of auxiliary variable names in
the actions, i.e., under the expr and multExpr rules
we have these assignments to 'e' but under the stat
rule expr is "accessed" directly, as in '$expr.value'
Thus why couldn't we write, e.g., $atom.value?

Also, re. the atom rule, something that can correspond
to an entire expression (third option in the rule) does
not match my understanding of the word "atom", atomic
usually meaning "without a fine structure". Is it really
correct to use it here or is it a legerdemain?

Thanks,

-- O.L.



More information about the antlr-interest mailing list