[antlr-interest] Re: antlr 3 stuff

mzukowski at yci.com mzukowski at yci.com
Thu Mar 18 10:10:57 PST 2004


Actually there are a few distinctions (but no decisions) I'd like to make.

1.  It's not just refactoring, though the workbench may be the appropriate
place to accommodate this.  We will need exposure to the lookahead analysis,
however.  I want two modes:
  A.  I know what I'm doing, help me fix my ambiguities.
  B.  I have no clue, keep me from introducing ambiguities.

'A' is static.  'B' isn't.  For 'B' there is the before & after.  The
difference is what is important, and we need hooks to analyze that
difference.  From the metamorphic syntactic macro point of view, you
separate the master grammar from the extensions and analyze them
differently.  This also lets you combine multiple extensions from different
files, etc., much like we wish for grammar modularization.  I believe hooks
into the grammar analysis will be necessary or at least desirable to support
this kind of feature.

2.  I believe we have the common goal of being able to write an ANSI C
grammar, write syntax extensions for GCC or MSVC, allow people to write
their own extensions such as safe pointers or programming by contract, write
any number of tree passes for analysis and manipulation, and have the whole
thing modularized for maintainablility.

3.  Modifying the ANTLR syntax could have some benefits.  It could also get
way out of control.  Most of the stuff I care about can be handled through
templates controlling the code generation.  Action syntax is the most
problematic thing for ANTLR, and maybe can be helped.

4.  The other cool thing about syntactic macros is transparency--they
transform the new syntax into the old syntax.  For antlr that would mean
that the tree generated by the syntactic macro would be a tree compatible
with the tree grammar for the master grammar, and hence with all tree
grammars written for C or whatever.  This is not practical for, say, GCC
grammar extensions.  Those would simply be grammar extensions, as they are
now.  It is very practical for domain specific languages, or at least a
large class of them.  I see no reason why the transformation to original
syntax has to be immediate.  I might want to do some analysis passes and
manipulations before it becomes the original syntax, and that would be easy
to support.  Getting it back to the original syntax means you can generate
plain unextended C and compile it with any compiler, etc.  Guaranteeing that
it did get back to the original syntax would make it safe.

5.  I think ANTLR could become a standard in the DSL world if grammars were
easy and safe to extend.  

Monty

-----Original Message-----
From: lgcraymer [mailto:lgc at mail1.jpl.nasa.gov] 
Sent: Wednesday, March 17, 2004 4:39 PM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] Re: antlr 3 stuff

Monty--

I tend to think that this is part of what a language workbench is
about--refactoring support, tree visualization, and all of the other stuff 
that would make it feasible to tweak a translator fast.  It would be nice if
we could figure out how to preserve refactorings when 
regenerating tree grammars.  (On glancing over the paper you mention,
"metamorphism"  == refactoring).

Macros I consider both very useful and very evil.  I think that a reasonable
refactoring editor would be a better approach.  And it might 
be useful if ANTLR inlined rules--that would cover the "syntax macros" and
improve performance.

--Loring


--- In antlr-interest at yahoogroups.com, mzukowski at y... wrote:
> I'd like to explore the 'language extension' space for antlr 3.  To me
> developing a grammar and extending a grammar are very distinct phases of
> antlr coding.  Plenty of people download grammars and just want to tweak
> them with actions or a small bit of new syntax.  In "Growing Languages
with
> Metamorphic Syntax Macros" by Claus Brabrand and Michael I. Schwartzbach
at
> http://www.brics.dk/bigwig/publications/#macro they present a system that
> makes it safe for people to extend languages by not letting them do stupid
> things that have huge side effects.  When the time comes I'll re-read the
> paper again and try and convince Ter & Loring.
> 
> Monty
> www.codetransform.com



 
Yahoo! Groups Links



 


 
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