[antlr-interest] ANTLR 3.0 question about common actions

Ric Klaren klaren at cs.utwente.nl
Tue Aug 3 04:45:47 PDT 2004


Hi,

On Wed, Jul 28, 2004 at 01:48:04PM -0700, Monty Zukowski wrote:
> > So, the main question is: how can we make standard actions in order to
> > avoid retargeting issues and yet allow for free-form actions,
> > especially those that predicate standard actions?
>
> Currently you have an escape mechanism that says "this is all target
> language, but pick out the tree stuff and $ stuff," and offers Ric the
> opportunity to complain how ugly this is :)

Seems I got the point acros ;)

Most of the peave I got with the current implementation is that in the
codegen you have no clue what treebuilding actions are inside the action.
With the current interface you have to kludge a lot around to get an idea
of what stuff to actually generate (I dislike generating too much) also
some cases require additional rudimentary parsing on some of the strings
coming from the action parser making things quite fragile, both from a
maintenance point of view and also as user you sometimes get surprised with
oddities in things happening there.

I can very well live with target language code in the actions it just gives
the biggest amount of flexibility. I have worked for a short while with
tools that have a very limited syntax for actions (basically only function
calls) this really drives you nuts (silly nothing saying naming schemes
etc). I've also used gui's for this kindoff stuff (next gen of the
aforementioned tool) this sucked even worse.

In a sense I'm a bit sceptic with language agnostic stuff. But I've said
that before. Antlr 2 style action parsing is quite acceptable in ANTLR 3 as
far as I'm concerned. As long as a better api between the action parser and
the rest of antlr is possible. Generating code from an AST or something
similar would be ok. One prescan of the action code to see what should be
declared and then another pass to actually write stuff out. The AST code
could just contain tree building constructs interspersed with special
tokens that just collect the target language around the tree building
constructs.

With respect to this if actions in target language are supported it should
be possible to override some syntax per language. The choice of the '#' for
many things is somewhat inconvenient for C++ and C codegen (e.g. it
interferes with the preprocessor in C++ mode or actually the other way
around, we'd have to define a few things as illegal to get around it if we
use '#').

Cheers,

Ric
--
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893755  ----
-----+++++*****************************************************+++++++++-------
  Chaos often breeds life, when order breeds habit.
  --- Henry B. Adams, The Education of Henry Adams



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

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



More information about the antlr-interest mailing list