[antlr-interest] abort parsing with special token

Ric Klaren klaren at cs.utwente.nl
Tue Aug 17 08:06:49 PDT 2004


On Tue, Aug 17, 2004 at 02:55:37PM -0000, Oliver Leimig wrote:
> I'm currently creating an ANTLR grammar for target language java.  
> My grammar shall have a command "%cancel" to abort parsing when this  
> command appears in the InputStream.  
>   
> What's probably the best way to tell ANTLR to stopp reading from the 
> InputStream?   
> { doCancel(); } ?  
> Perhaps filtering the Stream in advance? How?  

Throw an exception out of it when you encounter the %cancel token.

Cheers,

Ric
-- 
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893755  ----
-----+++++*****************************************************+++++++++-------
   Words fly like arrows
      as if we knew what was right and wrong. --- Chuang Tsu



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

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



More information about the antlr-interest mailing list