Carter Cheng wrote:
I apologize for the potential double post. But I meant something like this where I am trying to throw an error when a condition is met.

LPAREN LBRACE { $LPAREN.index == $LBRACE.index - 1 }? arrayElementList? RBRACE RPAREN { $RBRACE.index == $RPAREN.index - 1 }?
  

Basically, don't use constructs like that for raising error messages. You should be overriding the built in report mechanism anyway (just copy it and then make it do what you need, such as collect a list of errors, or use your own messages and strings for particular symbols etc. Make sure that you can call that error handler from anywhere, then just do this:

LPAREN LBRACE { $LPAREN.index == $LBRACE.index - 1 }? arrayElementList? RBRACE RPAREN 
  { 
	if ($RBRACE.index != $RPAREN.index)
        { 
           myErrorHandler(xxxxxx);
        }
  }

You don't want to try and hijack the failed predicate code as it is really telling you that you have not covered all possibilities. Always take control yourself ;-)

Jim


Regards,

Carter.


--- On Fri, 1/23/09, Jim Idle <[email protected]> wrote:

  
From: Jim Idle <[email protected]>
Subject: Re: [antlr-interest] customizing error messages for syntactic predicates
To: 
Cc: [email protected]
Date: Friday, January 23, 2009, 10:31 AM
Carter Cheng wrote:
    
Hello,

This is probably something that is quite easy- but how
      
does one go about customizing error messages resulting from
a predicate type check? The standard error messages can be
rather cryptic.
    
  
      
Do you mean things like "predicate failed."? If
you get that it means 
you have not covered all the alts and need to supply more
options to the 
grammar :-)

Jim



List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
    


      

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
  


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

Reply via email to