[antlr-interest] Island grammar in AntlrV3

Terence Parr parrt at cs.usfca.edu
Sat Sep 2 16:40:04 PDT 2006


Hi.

have you seen the island grammar example in the examples-v3 tarball?

Ter

On Sep 2, 2006, at 4:01 PM, David Holroyd wrote:

> On Sat, Sep 02, 2006 at 11:09:32PM +0400, Ilia Kantor wrote:
>> I have island grammar, that becomes known on parsing stage.
>>
>> How can I parse it with separate lexer/parser,
>>   adding result to common tree ?
>
> I've also been wondering about this, but I don't have an answer yet.
>
> I'm worried that by the time the parser has the chance to try and  
> fiddle
> with the lexer, lookahead has consumed the input anyway.  Maybe the
> standard infrastructure can let the input character stream  
> 'backtrack'?
>
> My specific use case is regular expression literals, e.g. I'd like  
> to be
> able to handle,
>
>   r =   / b; f = r/m;  // regexp literal with 'm' flag
>   r = a / b; f = r/m;  // two expr-statements involving division
>
> It seems that the lexer needs context from the grammar in order to  
> tell
> what to do on seeing '/'.
>
> I've seen that the ECMAscript grammar on antlr.org sidesteps this
> difficulty by dispensing with a lexer per se, and doing everything  
> in the
> parser.  This makes my brain itch.  :)
>
>
> Any clues?
> ta,
> dave
>
> -- 
> http://david.holroyd.me.uk/



More information about the antlr-interest mailing list