[antlr-interest] Suggestion for Parser

Ric Klaren klaren at cs.utwente.nl
Tue Apr 22 08:13:50 PDT 2003


Hi,

On Mon, Apr 21, 2003 at 10:45:48AM -0000, marcschellens wrote:
> It would be convenient, to have a tree parser,
> which doesn't actually check the tree anymore, as this is done
> before with another tree parser.

On Tue, Apr 22, 2003 at 05:41:13AM -0000, marcschellens wrote:
> I mean a tree walker, with no calls to the match(...)

No match would imply that syntactic predicates would not work anymore.
Often match calls look redundant in generated code since just before it the
node is checked in a case. In some situations this will not be the case
thus blowing things up. Also the match code contains the checks for the
null pointer sentries, which is another can of worms altogether.

> function and no case statements (c++ mode) or at least
> (maybe even better) that case statements could be suppressed
> for some functions as the next sibling is determined by its
> predecessor.

It kindoff sounds like you want an unfolding for every possible tree
traversal ? Which would not be practical for the general case. For some
subclass of grammars it might be ok.

> > See the tinybasic.g example for ideas on how to do an interpreter.
> I had a short look at it, but I think it suffers (in terms of
> performance) from the same problem, that in some places it checks
> for the next sibling, even all this information could be delivered
> from a first tree walk.
>
> EG: A switch statement.
> The first node would contain the number N of case entries
> so the type (=function to call) is already known for the next
> N siblings.

> Are there any plans in this direction?

No.

> Where are the crucial lines in the java code?

CppCodegenerator.java and all the lines involving generating 'match' calls.

If you know what you are doing and understand the grammar you have very
well (and it doesn't use syntactic predicates) you may get away by using a
hacked codegenerator. YMMV. 

Cheers,

Ric
--
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
 Why don't we just invite them to dinner and massacre them all when they're
  drunk? You heard the man. There's seven hundred thousand of them. Ah? ..
           So it'd have to be something simple with pasta, then.
                 From: Interesting Times by Terry Pratchet


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list