[antlr-interest] token query

Paul Keir paul at paulkeir.com
Fri May 11 11:35:48 PDT 2007


Oops. I had meant to use the tokens in the rule (instead of single 
quoted strings).

I think I know the answer now though. Instead of 'name=null', I can use 
'name=input.LT(1).getText()'

Cheers,
Paul


antlr-interest-request at antlr.org wrote:
> Send antlr-interest mailing list submissions to
> 	antlr-interest at antlr.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://www.antlr.org/mailman/listinfo/antlr-interest
> or, via email, send a message with subject or body 'help' to
> 	antlr-interest-request at antlr.org
>
> You can reach the person managing the list at
> 	antlr-interest-owner at antlr.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of antlr-interest digest..."
>
>
> Today's Topics:
>
>    1. Dealing with issues in non-greedy (.)* rules
>       (Marc-Andr? Laverdi?re)
>    2. Nondeterminism (Vijai Kalyan)
>    3. Re: C-target (Marc)
>    4. Re: Dealing with issues in non-greedy (.)* rules (Terence Parr)
>    5. Re: Lots of memory leak with	TokenStreamHiddenTokenFilter of
>       C++ Target in Antlr 2.7x? (Ric Klaren)
>    6. How to redirect the input stream? (Frank Yue)
>    7. Re: How to redirect the input stream? (Ric Klaren)
>    8. token query (Paul Keir)
>    9. Choosing token (Stefan Chrobot)
>   10. Re: Choosing token (Johannes Luber)
>   11. Re: Some Problem with antlrv3 (femto gary)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 10 May 2007 15:08:35 -0400
> From: Marc-Andr? Laverdi?re 	<ma_laver at ciise.concordia.ca>
> Subject: [antlr-interest] Dealing with issues in non-greedy (.)* rules
> To: ANTLR Interest <antlr-interest at antlr.org>
> Message-ID: <46436DB3.4040806 at ciise.concordia.ca>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> Hello,
>
> I just wanted to a) share a hack and b) ask for some help dealing with 
> blob-matching rules.
>
> I have the following rule:
> sh_code_blob
> 	:	( options {greedy=false;} : . )*
>             {if (false) throw new RecognitionException();};
>
> a) you will notice the "if (false) throw new RecognitionException();"
> This hack takes care of the compilation exception in the generated 
> parser for this rule, since the generated code tries to catch an 
> exception that won't ever be thrown.
>
> I'm not impressed by Sun's compiler for not figuring out that invariant, 
> but it works!
>
> Ter, should we update the StringTemplate to include this by default? 
> This would probably save you from having to have a different template 
> just for this one case.
>
> b) this rule will however emit error messages. These error messages will
> refer to the last character match. The call reportError() is not called 
> however. (I validated this)
>
> Do we have a "quiet" option that we can set for this rule? I don't see 
> anything in the documentation nor in the BaseRecognizer class.
>
> Thanks in advance for the help. I hope that my hack will help someone.
>
> Regards,
>
>   

-- 
512k Broadband £14.99 per month
Unlimited Downloads - No extra Costs
£14.99 per month (inc. VAT)
Order Now www.adsl4less.com


More information about the antlr-interest mailing list