[antlr-interest] Filter option

向雅 fyaoxy at gmail.com
Mon May 12 06:50:08 PDT 2008


Hi,

Token.getLine()

Pure Lexer has Token used?

Regards,
Qinxian

2008/5/12 <nilesh.kapile at tcs.com>:

>
> Hi,
>
> I'm using Filter option to generate only Lexer. The problem is, I'm not
> able to get line number for the token.
>
> How can I get the line number? Sample .g below:
>
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> lexer grammar FuzzyQPP;
>
> options {filter=true;}
>
> BLOCK        :
>                 *BEG* WS? ID WS? END
>                 {
>                         int line = 0;
> *                        line = $BEG.line;        /* $BEG.text works but
> $BEG.line doesn't */*
>                         System.out.println(line);
>                 }
>         ;
>
> SL_COMMENT
> : '//' .* '\n'
> ;
>
> WS : (' ' |'\t' |'\r' |'\n' )+
> ;
>
> *BEG        :'{'*
> *        ;*
>
> END        :'}'
>         ;
>
> fragment
> ID : ('a'..'z' |'A'..'Z' |'_' ) ('a'..'z' |'A'..'Z' |'_' |'0'..'9' )*
> ;
>
> Any help will be highly appreciated!
>
>
> Thanks,
> Nilesh Sudhakar Kapile
> Tata Consultancy Services
> Mailto: nilesh.kapile at tcs.com
> Website: http://www.tcs.com
> ____________________________________________
> Experience certainty.        IT Services
>                        Business Solutions
>                        Outsourcing
> ____________________________________________
>
> =====-----=====-----=====
> Notice: The information contained in this e-mail
> message and/or attachments to it may contain
> confidential or privileged information. If you are
> not the intended recipient, any dissemination, use,
> review, distribution, printing or copying of the
> information contained in this e-mail message
> and/or attachments to it are strictly prohibited. If
> you have received this communication in error,
> please notify us by reply e-mail or telephone and
> immediately and permanently delete the message
> and any attachments. Thank you
>
>
>
>


-- 
致敬
向雅
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080512/14d1b859/attachment.html 


More information about the antlr-interest mailing list