Look at the examples and find 'island grammars', If your switch over can be
triggered lexically, then it is very easy.

Jim

> -----Original Message-----
> From: [email protected] [mailto:antlr-interest-
> [email protected]] On Behalf Of Luis Pureza
> Sent: Friday, September 10, 2010 2:37 PM
> To: [email protected]
> Subject: [antlr-interest] Parsing portions of the input with different
> grammars.
> 
> Hi,
> 
> Is there any way i can parse a portion of text using a rule from grammar
> A, while parsing the rest of the text with grammar B?
> 
> More concretely, I have an expression grammar which is central to my
> project and used everywhere. But now, I need to parse new kinds of
> inputs which may contain expressions inside. For this, I'm creating a
> new grammar. However, I'd like to reuse the old grammar just to parse
> the expressions. I don't want to modify it because it is a generic
> grammar and the new use-case is too specific. Moreover, I'd prefer not
> to copy the entire grammar verbatim into the new one, because then I'd
> have two expression grammars to maintain.
> 
> What I really want is some mechanism that allows me to express "Parse
> the entire thing with grammar A, except expressions, which are delegated
> to the Expression grammar".
> 
> What is the best way to achieve this?
> 
> Thank you,
> 
> Luís Pureza
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to