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

Juancarlo Añez apalala at gmail.com
Sat Sep 15 05:18:30 PDT 2012


Use one rule for the versioned comments that succeed, ad let the general
comment one catch those that fail.

CAVEAT, This is off the top of my head:



VERSIONED_COMMENT:
    :
    {nesting==0}?=>
    '/''*!'
    v=INTEGER WS
    {check_version($v)}?=>
    {
        nesting = 1;
        expanding = true;
        $channel = $HIDDEN;
    }
    ;

END_EXPAND
    :
    {nesting == 1 && expanding}?=>
    '*''/'
    {
        nesting = 0;
        expanding = false;
        $channel=HIDDEN;
    }
    ;


COMMENT
    :
    '/''*'
    {nesting+=1;}
    {
    COMMENT_TAIL
    {
        $channel = HIDDEN;
    }
    ;

fragment
COMMENT_TAIL
    :
    (options{greedy=false;} (COMMENT|.))*
    '*/'
    {nesting-=1;}
    ;

ANTLR will probably complain that there's ambiguity, but it can be resolved.


On Sat, Sep 15, 2012 at 5:23 AM, Mike Lischke <mike at lischke-online.de>wrote:

>
> Hi Jim,
>
> > 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.
>
>
> If that were possible I'd be very happy. I have asked the bigger question
> just a few days ago: http://antlr.markmail.org/message/reuws4bz3mi6hb24,
> but got no reply.
>
> In the meantime I came very close to a solution, but am stuck now because
> of the predicates problem I mentioned.
>
> 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
>



-- 
Juancarlo *Añez*


More information about the antlr-interest mailing list