[antlr-interest] Re: lexer "modes" for XML parsing etc...
Terence Parr
parrt at cs.usfca.edu
Sun Nov 20 12:30:22 PST 2005
On Nov 20, 2005, at 12:28 PM, Stephen Quattlebaum wrote:
>> 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. :-)
Hi. Well we can do separate files right now and you can use a
selector to switch between different lexers, just have the ctor to
the lexer share the same input stream. The reason to have them in
the same file I think is probably convenience. Perhaps I'm wrong...
Ter
More information about the antlr-interest
mailing list