[antlr-interest] Throwing an excption in a Tree Action
mzukowski at yci.com
mzukowski at yci.com
Thu Jun 20 08:37:14 PDT 2002
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/
More information about the antlr-interest
mailing list