[antlr-interest] ANTLR Optional statements
mzukowski at bco.com
mzukowski at bco.com
Fri Apr 5 07:37:15 PST 2002
What version of antlr? Have you tried 2.7.2a2?
Monty
> -----Original Message-----
> From: jg z [mailto:zjg1964 at yahoo.com]
> Sent: Friday, April 05, 2002 7:31 AM
> To: antlr-interest at yahoogroups.com
> Subject: RE: [antlr-interest] ANTLR Optional statements
>
>
> The generated code is like this,
>
> switch ( LA(1)) {
> case ID:
> {
> match(ID);
> {
> switch ( LA(1)) {
> case COLON:
> {
> base_clause();
> break;
> }
> case ANTLR_USE_NAMESPACE(antlr)Token::EOF_TYPE:
> {
> break;
> }
> default:
> {
> throw
> ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1),
> getFilename());
> }
> }
> }
> break;
> }
> case ANTLR_USE_NAMESPACE(antlr)Token::EOF_TYPE:
> {
> break;
> }
> default:
> {
> throw
> ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1),
> getFilename());
> }
> }
>
> The problem is, if there is no "ID", it would go into
> default and throw an Exception. It shouldn't do like
> this as an optional statement, should it?
> --- mzukowski at bco.com wrote:
> > What does it produce that's not right?
> >
> > > -----Original Message-----
> > > From: jg z [mailto:zjg1964 at yahoo.com]
> > > Sent: Friday, April 05, 2002 6:44 AM
> > > To: antlr-interest at yahoogroups.com
> > > Subject: [antlr-interest] ANTLR Optional
> > statements
> > >
> > >
> > > We are trying to convert a C++ Parser from PCCTS
> > to
> > > ANTLR, and becoming increasingly frustrated by the
> > > differences between the two systems.
> > >
> > > For instance;
> > >
> > > In cplusplus.g we have,
> > >
> > > class_head
> > > : ( STRUCT
> > > | UNION
> > > | CLASS
> > > )
> > > {ID { base_clause } }
> > > ;
> > >
> > > which works fine in PCCTS.
> > >
> > > For ANTLR we have converted this to,
> > >
> > > class_head
> > > :
> > > ( STRUCT
> > > | UNION
> > > | CLASS
> > > )
> > > (ID ( base_clause)? )?
> > > ;
> > >
> > > However, the optional statements shown at the end
> > of
> > > this production no longer produces a properly
> > optional
> > > construction in the generated .cpp file.
> > >
> > > What are we supposed to do?
> > >
> > > David.
> > >
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Yahoo! Tax Center - online filing with TurboTax
> > > http://taxes.yahoo.com/
> > >
> > >
> > >
> > > Your use of Yahoo! Groups is subject to
> > http://docs.yahoo.com/info/terms/
> >
> >
> >
> >
> >
> > Your use of Yahoo! Groups is subject to
> > http://docs.yahoo.com/info/terms/
> >
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Tax Center - online filing with TurboTax
> http://taxes.yahoo.com/
>
>
>
> Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list