[antlr-interest] Re: lexer "modes" for XML parsing etc...

Stephen Quattlebaum stephen at covidimus.net
Sun Nov 20 12:28:25 PST 2005


> Your wish is my command.  ;)  Do we need something like
>
> lexer grammar L;
>
> ID : ... ;
> SQLSTART : "sql(" {pushContext(SQL);} ;
> WS : ... ;
>
> context SQL {
> ID : ... ;
> ACTION : ...;
> STRING : ... ;
> ENDSQL : ')' {popContext();}
> }
>
> context island2 {
> ...
>}

Have been following this conversation.  Something like what you describe
above would very nicely replace an ugly hack I've had to use to switch
between lexers for the primary language and embedded languages in one of my
projects.  Now, if the contexts could be defined independently (in different
files) and then included as separate contexts in other grammars, that'd
_really_ be nice. :-)




More information about the antlr-interest mailing list