[antlr-interest] Follow up to hoisted predicates and local variables

Jim Idle jimi at temporal-wave.com
Fri Sep 14 09:59:47 PDT 2012


I think that you may need to step back on your approach here. You may have
showed this before, but what (clearly horrible) language are you trying to
parse, and what is the context? We seem to be solving small issues for
you, when perhaps your bigger question can be addressed in a more correct
fashion.

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Mike Lischke
> Sent: Friday, September 14, 2012 9:31 AM
> To: ANTLR Mailing List
> Subject: [antlr-interest] Follow up to hoisted predicates and local
> variables
>
> Hi,
>
> I'm bitten by this problem as well:
> http://antlr.markmail.org/message/eliyhfji5hsrbyoz?q=hoisted+predicates
> +and+local+variables
>
> but with lexer rules and wonder what would be a good approach to solve
> this case? I couldn't get global scopes to work because I cannot use
> them in a lexer rule. Lexer member vars seem to be a good solution, but
> they are evaluated in the dfa15_sst helper before they are actually
> set.
>
> Here's the relevant code:
>
> fragment BLOCK_COMMENT options{ greedy = false; }:
> 	VERSION_COMMENT
> 	| MULTILINE_COMMENT
> ;
>
> fragment VERSION_COMMENT:
> 	LOGICAL_NOT_OPERATOR (v = INTEGER WS { matched_version =
> check_version($v); })? VERSION_COMMENT_TAIL ;
>
> fragment VERSION_COMMENT_TAIL:
> 	{ !matched_version }? => ( options { greedy = false; }: . )* '*'
> '/' { $type = MULTILINE_COMMENT; $channel = 98; }
> 	| { $type = VERSION_COMMENT; $channel = 98; in_version_comment =
> true; }
>
>
> (the initial /* is consumed by a higher level rule).
>
> Mike
> --
> www.soft-gems.net
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address


More information about the antlr-interest mailing list