[antlr-interest] Fwd: Pruning the Parse Tree

Aaron Armstrong ae.armstrong at gmail.com
Mon Mar 10 17:34:51 PDT 2008


---------- Forwarded message ----------
From: Aaron Armstrong <ae.armstrong at gmail.com>
Date: Mon, Mar 10, 2008 at 11:35 AM
Subject: Re: [antlr-interest] Pruning the Parse Tree
To: Guntis Ozols <guntiso at latnet.lv>


The simple reason for using a parse tree is that I don't have time to muck
around with writing an AST grammar.

Here is the full list of reasons:
1.  I'm trying to make my tool as language-agnostic as possible.  Any work I
put into an ANTLR grammar will be specific for one language.  If I can
decouple parts of the process, it can hopefully make for less work when I
port to other languages.
2. The default AST is flat.  Basically, I get no more information than
what the lexer would give me.  (I don't know why this is, but ANTLR is not
my design).
3.  I'm more interested in the overall code orgainzation.  I don't need a
letter-perfect grammar; I just need ANTLR to properly identify the parts of
code.  There are only specific nodes I am interested in.  My thinking is if
I identify those nodes for one language I can use some kind of mapping
mechanism to generalize for other languages.

This is why I'm using a parse tree.  It gets me the information I need
without having to pour a lot of work into a language-specific AST.  I was
hoping there would be some kind of information in each node that would state
what rules were actually used vs. what rules were looked at.
  On Fri, Mar 7, 2008 at 1:47 PM, Guntis Ozols <guntiso at latnet.lv> wrote:

> > Both are found in the final parse tree, and I need to
> > get rid of the superfluous nodes.  I don't know if this
> > is default antlr behavior or if this is a bug.
>
> Why do you need parse tree?
> How about using syntax tree?
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080310/91e4c917/attachment.html 


More information about the antlr-interest mailing list