[antlr-interest] Possible bug in swapping intermediary terminal?

Mark Volkmann r.mark.volkmann at gmail.com
Fri Feb 1 13:24:22 PST 2008


On Feb 1, 2008 2:47 PM, Dejas Ninethousand <dejas9000 at gmail.com> wrote:
> Can you send me your grammar file?

It's attached.

> Also I'm using ANTLRWorks 1.5  Is that the same version for you as well?

I think you mean 1.1.5. Yes, that's what I tested with. I just
downloaded 1.1.7 and tried that. That works too. A screenshot is
attached.

> On Feb 1, 2008 2:38 PM, Mark Volkmann <r.mark.volkmann at gmail.com> wrote:
>
> >
> >
> >
> > On Feb 1, 2008 2:29 PM, Dejas Ninethousand <dejas9000 at gmail.com> wrote:
> > > Hi,
> > >
> > > I'm having a problem getting a grammar to to accept "foo.bar.Dec" and
> I'm
> > > not sure why.  I think it may be a bug.  Consider my initial grammar:
> > >
> > > type_identifier
> > >      : IDENTIFIER
> > >     |
> > >     TYPE_IDENTIFIER_FULL
> > >     ;
> > >
> > > IDENTIFIER
> > >     : ('a'..'z'|'A'..'Z')('a'..'z'|'A'..'Z'|'0'..'9')*
> > >      ;
> > >
> > > PACKAGE_SEPARATOR
> > >     :    '.'
> > >     ;
> > >
> > > TYPE_IDENTIFIER_FULL
> > >     : IDENTIFIER (PACKAGE_SEPARATOR IDENTIFIER)+
> > >     ;
> > >
> > > This grammar accepts the "foo.bar.Dec" input no problems.  However, I
> wanted
> > > to modify the grammar to eliminate the the intermediary
> TYPE_IDENTIFIER_FULL
> > > terminal by taking its rhs and allowing it to directly derive from
> > > type_identifier:
> > >
> > > type_identifier
> > >     : IDENTIFIER
> > >     |
> > >     IDENTIFIER (PACKAGE_SEPARATOR IDENTIFIER)+
> > >     ;
> > >
> > > IDENTIFIER
> > >     : ('a'..'z'|'A'..'Z')('a'..'z'|'A'..'Z'|'0'..'9')*
> > >      ;
> > >
> > > PACKAGE_SEPARATOR
> > >     :    '.'
> > >     ;
> > >
> > > Now when I give ANTLRWorks the same "foo.bar.Dec" to interpret, it
> builds
> > > the tree :
> > >
> > > <grammar XXX>
> > >  type_identifier
> > > foo
> > > .
> > > bar
> > > .
> > > Dec
> > > NoViableAltException
> > >
> > >
> > > ... and I don't understand why.  These grammars seem equivalent to me.
> Is
> > > there something I'm not seeing or is this a bug?
> >
> > I hate it when people say "Works for me!"  ;-)
> > Unfortunately that's what I have to say here. I ran the ANTLRWorks
> > debugger on the following grammar and gave it your input of
> > "foo.bar.Dec" and it created the correct parse tree.
> >
> > grammar package;
> >
> >
> >
> >
> > type_identifier
> >  : IDENTIFIER
> >  | IDENTIFIER (PACKAGE_SEPARATOR IDENTIFIER)+
> >  ;
> >
> > IDENTIFIER
> >  : ('a'..'z'|'A'..'Z')('a'..'z'|'A'..'Z'|'0'..'9')*
> >  ;
> >
> > PACKAGE_SEPARATOR: '.';
> >
> > --
> > R. Mark Volkmann
> > Object Computing, Inc.
> >
>
>



-- 
R. Mark Volkmann
Object Computing, Inc.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: package.g
Type: application/octet-stream
Size: 197 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20080201/a52ae0f0/attachment-0001.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Picture 1.png
Type: image/png
Size: 23242 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20080201/a52ae0f0/attachment-0001.png 


More information about the antlr-interest mailing list