[antlr-interest] Throwing an excption in a Tree Action

Niall Gormley ngormley at hotmail.com
Sat Jun 22 04:45:10 PDT 2002


Thanks Monty,

I will need this.

Thanks,
Niall


>From: mzukowski at yci.com
>Reply-To: antlr-interest at yahoogroups.com
>To: antlr-interest at yahoogroups.com
>Subject: RE: [antlr-interest] Throwing an excption in a Tree Action
>Date: Fri, 21 Jun 2002 12:53:52 -0700
>
>It looks like I am wrong about this.  You can specify other exceptions to
>throw with the throws clause:
>
>a throws MyException
>   : A
>   ;
>
>Monty
>
> > -----Original Message-----
> > From: mzukowski at yci.com [mailto:mzukowski at yci.com]
> > Sent: Thursday, June 20, 2002 8:37 AM
> > To: antlr-interest at yahoogroups.com
> > Subject: RE: [antlr-interest] Throwing an excption in a Tree Action
> >
> >
> > No, you currently can't specify specific Exceptions that a
> > rule can throw.
> > You have to make sure that the exceptions you throw are subclasses of
> > RecognitionException.
> >
> > Monty
> >
> > > -----Original Message-----
> > > From: Niall Gormley [mailto:ngormley at hotmail.com]
> > > Sent: Thursday, June 20, 2002 8:35 AM
> > > To: antlr-interest at yahoogroups.com
> > > Subject: [antlr-interest] Throwing an excption in a Tree Action
> > >
> > >
> > > Hi,
> > >
> > > I would like to throw an exception in an action as per the
> > > grammar below. Is
> > > it possible to specify that it should throw my
> > > InvalidAssignmentException
> > > exception in the tree grammar?
> > >
> > > Thanks Again,
> > > Niall
> > >
> > > assignmentExpression
> > >   : #( ASSIGN i:IDENT p:primaryExpression)
> > >     {
> > >       System.out.println("Checking Assignment Statement:
> > > "+#i.getText()
> > >                                                  +" "+#p.getText());
> > >       if(#i.getType()!=#p.getType())
> > >       {
> > >         throw new InvalidAssignmentException("Cannot assign"
> > >            + #i.getType() + " to " +  #p.getType());
> > >       }
> > >       else
> > >       {
> > >         System.out.println("Assingment OK");
> > >       }
> > >     }
> > >   ;
> > >
> > > _________________________________________________________________
> > > Send and receive Hotmail on your mobile device:
>http://mobile.msn.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/
>
>
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>


_________________________________________________________________
Join the world’s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list