[antlr-interest] lexer mode controlled in grammar rules ?

Eric researcher0x00 at gmail.com
Tue Oct 18 08:04:20 PDT 2011


On Tue, Oct 18, 2011 at 9:08 AM, Rampon Jerome <ramponjerome at yahoo.fr>wrote:

>
>
>
> Hi,
>
>
> I noticed in the following link
>
> http://www.antlr.org/wiki/display/ANTLR3/1.+Lexer
> the possibility to use lexer modes (controlled in the example via the
> boolean tagMode settings in lexer rules)
>
> Is there one way to switch the lexer mode at grammar rule level or is it
> only possible at lexer level ?
>

The parser also supports gated semantic predicates.While you may find more
info about gated semantic predicates by using http://antlr.markmail.org/ and
searching on "gated semantic predicate", if you are serious about using
ANTLR, I would strongly suggest you buy
http://pragprog.com/book/tpantlr/the-definitive-antlr-reference The book has
the most accurate info on the subject less reading the source code.



> Apparently @members declarations are not shared in both lexer and parser
> and  lexer::members, parser::members declaration are dedicated to the lexer
> for the 1st one,
>
> and the parser for 2nd one
>

See: http://www.antlr.org/wiki/pages/viewpage.action?pageId=4882470

The lexer runs first and creates a list of tokens. Then the parser is feed
the list of tokens created by the lexer. The parser does not communicate
with the lexer.



>
>
> One way to do it if not via @members ?
>
> Thanks
>
> Jerome
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>
>
Hope this helps, Eric


More information about the antlr-interest mailing list