[antlr-interest] Annotation tool best practices
Monty Zukowski
monty at codetransform.com
Tue Apr 27 14:58:36 PDT 2004
On Apr 27, 2004, at 9:52 AM, John D. Mitchell wrote:
> For a concrete and available example, check out what Monty did with the
> GnuC project with "literate programming" (ala Knuth via noweb). That
> allows for nice, cross-phase locality (i.e., all of those versions of
> expression right next to each other). One of my dislikes for that
> approach
> is that the intermingling makes in more difficult to just look at all
> of
> the rules for a single phase (in the editor). On my play-with to-do
> list
> is to investigate using a "literate" approach with a good outline
> editor so
> that I could fold out all of the stuff that I didn't want to deal with
> at
> any given point in time (think: different, editable views of a single
> master source file).
Note that the noweb source is available by request. In the
distribution I didn't want people to deal with noweb so I put in the
files after noweb was run.
On my latest project, instead of going through the noweb stuff I wrote
a small python program to extract /*tree */ comments. Example from my
select.g:
orderByClause
: ORDER^ BY! expression (ASC | DESC)? (COMMA! expression (ASC | DESC)?
)*
;
/*tree
orderByClause
: #(ORDER (expression (ASC | DESC)? )+)
;
*/
Here's the regex to grab all those tree comments:
p=re.compile(r'/\*tree(.*?)\*/',re.DOTALL). My python program writes
out a header and then all the tree rules into selectTreeParser.g. Only
major drawback is that I have to look at selectTreeParser.g when I have
a line number for a problem with the tree grammar. No big deal for me.
I really can't work on building trees separate from tree parsing.
Loring's tree stuff automatically generates a tree parser from your
grammar tree actions. It's gonna be so cool when it can be released!
Monty Zukowski
ANTLR & Java Consultant -- http://www.codetransform.com
ANSI C/GCC transformation toolkit --
http://www.codetransform.com/gcc.html
Embrace the Decay -- http://www.codetransform.com/EmbraceDecay.html
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