[antlr-interest] Can an Antlr Parser return a TreeNodeStream so as to not have to parse the whole file at once?

Eric researcher0x00 at gmail.com
Mon Apr 16 12:14:38 PDT 2012


I see you use both SO and ANTLR interest list.

It sounds like your problem has more to do with being a large file, than
trying to find out if your purposed solution works. While I have not had
this problem, it is a common one mentioned here.

Try

http://antlr.markmail.org/search/ with large file.


On Mon, Apr 16, 2012 at 3:03 PM, Burton Samograd <burton.samograd at markit.com
> wrote:

> Hello,
> In the following Antlr example, the parser is used to generate an AST
> which is then converted into a CommonTreeNodeStream, which is then passed
> to the checker.
> public static void main(String[] args) {
>
> CalcLexer  lex  = new CalcLexer(
>                        new ANTLRInputStream(System.in));
> CommonTokenStream tokens = new CommonTokenStream(lex);
> CalcParser parser = new CalcParser(tokens);
>
> CalcParser.program_result result = parser.program();
> CommonTree tree = (CommonTree) result.getTree();
>
> CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
> CalcChecker checker = new CalcChecker(nodes);
> checker.program();
>
> CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
> CalcInterpreter interpreter = new CalcInterpreter(nodes);
> interpreter.program();
> }
> Is it possible to get the parser to return a CommonTreeNodeStream that can
> be then passed to the Checker so that the whole file does not have to be
> lexed and parsed at once and rather as a stream of tokens and then tree
> nodes?
> I ask because we are running into a problem with an extremely large file
> being passed into our Antlr parser and it is causing memory exhaustion in
> the parsing phase. I am thinking that using a TreeNodeStream would solve
> this problem if it is even possible.
> --
> Burton Samograd
>
>
> ________________________________
> 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.
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>


More information about the antlr-interest mailing list