[antlr-interest] Antlr 3 syntax question
Terence Parr
parrt at cs.usfca.edu
Thu Apr 27 09:55:45 PDT 2006
On Apr 27, 2006, at 4:01 AM, shmuel siegel wrote:
> I would also like to understand the usage of alternatives and
> parenthesis. According to AntlrWorks, the following rule has 4
> alternatives consistent with the visual layout of this rule. The
> second and third alternatives are identical. My question is "Why is
> there an implied parenthesis around the second alternative?". In
> other words, does sequencing of tokens always take precedence to
> alternatives?
>
> levelExpr : # one
> INT
> | # two
> '@level' '(' 'offset' '=' INT ')'
> | # three
> ('@level' '(' 'offset' '=' INT ')' )
> | # four
> ;
See annotations. 4 alts. #alts = #pipes + 1.
The '|' binds most loosely. Every grammar tool I've seen does this I
think...does it seem weird or different from v2?
Ter
More information about the antlr-interest
mailing list