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

Niall Gormley ngormley at hotmail.com
Thu Jun 20 08:34:34 PDT 2002


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/ 



More information about the antlr-interest mailing list