[antlr-interest] error in antlrv3.g? missing suffixes in tree
Terence Parr
parrt at cs.usfca.edu
Thu Jul 3 10:32:54 PDT 2008
Thanks...Fixed in the examples directory.
Ter
On Jul 3, 2008, at 12:02 AM, Jens Boeykens wrote:
> I fixed the error:
>
> elementNoOptionSpec
> : id (labelOp='='|labelOp='+=') atom
> ( ebnfSuffix -> ^( ebnfSuffix ^(BLOCK["BLOCK"]
> ^(ALT["ALT"] ^($labelOp id atom) EOA["EOA"]) EOB["EOB"]))
> | -> ^($labelOp id atom)
> )
> | id (labelOp='='|labelOp='+=') block
> ( ebnfSuffix -> ^( ebnfSuffix ^(BLOCK["BLOCK"]
> ^(ALT["ALT"] ^($labelOp id block) EOA["EOA"]) EOB["EOB"]))
> | -> ^($labelOp id block)
> )
> | atom
> ( ebnfSuffix -> ^(ebnfSuffix ^(BLOCK["BLOCK"]
> ^(ALT["ALT"] atom EOA["EOA"]) EOB["EOB"]))
> | -> atom
> )
> | ebnf
> | ACTION
> | SEMPRED ( '=>' -> GATED_SEMPRED | -> SEMPRED )
> | treeSpec
> ;
>
>
> EbnfSuffix was missing for the alternative beginning with atom.
>
> Greetings,
> Jens
>
> 2008/7/2 Terence Parr <parrt at cs.usfca.edu>:
> thereAre indeed some issues without as I have not done anything but
> an initial work on that. I have some graduate students that are
> looking into this as they build another project.
> Ter
>
> On Jul 2, 2008, at 1:17 AM, Jens Boeykens wrote:
>
> Hi,
>
> I'm on a project where I need to parse grammars. Therefor I use
> antlrv3.g which can be fount here:
> http://www.antlr.org/grammar/ANTLR/
>
> The problem is this:
> consider the example
>
> grammar T;
>
> a : p+;
>
> If I parse this grammar I get the following tree:
>
> (grammar T (RULE a (BLOCK (ALT (BLOCK (ALT p EOA) EOB) EOA) EOB) EOR))
>
> As you can see there is no '+' in the tree. I need the '+' so I can
> regenerate the original grammar.
> When using parentheses it works:
>
> grammar T;
>
> a : (p)+;
>
> (grammar T (RULE a (BLOCK (ALT (+ (BLOCK (ALT p EOA) EOB)) EOA) EOB)
> EOR))
>
> Now the '+' has been added to the tree.
>
> My question is: what is to be changed in antlrv3.g so that it also
> works with the parentheses?
>
> Thanx!
>
>
More information about the antlr-interest
mailing list