[antlr-interest] Skipping sections of the input stream

Burton Samograd burton.samograd at markit.com
Thu Jun 28 09:34:15 PDT 2012

I simplified my example and we actually have two top level section types which I think would greatly
Increase the complexity of a splitter and require making a baby parser to parse quite a bit of the input
structure before passing it to the actual parser.

Not an impossible task, but I think if it could be done completely in the grammar using the standard input
stream it wouldn't create such a dependency between the baby parser and the actual parser unless you
can suggest a better way to do the splitting.

Burton Samograd

-----Original Message-----
From: Mike Lischke [mailto:mike at lischke-online.de]
Sent: Thursday, June 28, 2012 10:27 AM
To: Burton Samograd
Subject: Re: [antlr-interest] Skipping sections of the input stream


> It has been requested that we only parse the section that has been
> specified by the user.  I am thinking that a strategy where we have a rule like:
> section: SECTION quoted_string {
>    // if quoted_string != requested_section
>    // skip entire section by matching { and } parens
>    }
>    | SECTION quoted_string LCURLY subsection* RCURLY -> ...
>    ;
> First off, is what I would like to do possible and is my approach
> reasonable using anltr?  If it is, can I skip over and discard large sections of the input stream like I have outlined above?

It might simplify things a lot (and make it much faster) if you would run your input through a splitter, which takes out anything unwanted and only feed the relevant text to the parser. Skipping over some text considering quotes etc. is simple stuff and can be extremely fast in a (relatively) simple loop.


This e-mail, including accompanying communications and attachments, is strictly confidential and only for the intended recipient. Any retention, use or disclosure not expressly authorised by Markit is prohibited. This email is subject to all waivers and other terms at the following link: http://www.markit.com/en/about/legal/email-disclaimer.page

Please visit http://www.markit.com/en/about/contact/contact-us.page? for contact information on our offices worldwide.

More information about the antlr-interest mailing list