Related articles |
---|
Compiler positions available for week ending August 13 compilers@iecc.com (2000-08-13) |
Meta language? mihai@cs.wisc.edu (Mihai Christodorescu) (2000-08-14) |
Re: Meta language? idbaxter@semdesigns.com (Ira D. Baxter) (2000-08-20) |
Re: Meta language? danwang+news@cs.princeton.edu (Daniel C. Wang) (2000-08-20) |
From: | "Ira D. Baxter" <idbaxter@semdesigns.com> |
Newsgroups: | comp.compilers |
Date: | 20 Aug 2000 23:50:08 -0400 |
Organization: | Posted via Supernews, http://www.supernews.com |
References: | 00-08-085 00-08-090 |
Keywords: | optimize |
This is called "source to source" transformation.
You need two notions:
a) Primitive transforms over the source itself.
Here's a rule to decorate the entry of a function with a tracing
call.
rule insert_at_entry
" \result_type \function_name ( \arguments )
{ \body } "
rewrites to
" \result_type \function_name ( \arguments )
{ trace_entry(\make_string(\function_name));
\body } "
These define "concepts" in terms of the language syntax.
While the rule looks like it is some kind of text pattern matcher,
it is actually a specification of an abstract tree match/replace
pair,
where the text inside quotes is in the source language syntax,
and the escaped identifier represent trees or functions producing
trees.
The shape of rule language is one metalanguage.
. Making this work on real languages is a royal pain, because of
parsing troubles, lexical hiccups, lexical mode switches (based on
program points,
column numbers, etc), preprocessors, number formats, comments, ....
This rule can be directly processed by the DMS Reengineering Toolkit
(shameless plug),
http://www.semdesigns.com/Products/DMS/DMSToolkit.html.
Yes, it preserves the program format where no transforms have been
applied.
b) A metaprogram to control the applicaiton of the primitive transforms.
(implicit: "do everywhere",
explicit: "forall \function_name : is_system_call(\function_name)
apply(insert_at_entry)"
Metaprograms decide where and how to apply other transforms.
The shape of the metaprograms is another metalanguage.
(We are actively implementing such a language for DMS,
but you can always code this procedurally).
An accessible book discussing this topic in general
(see the chapter on "Metaprogramming") is
"Generative Programming", Czarnecki/Eisenecker, Addison-Wesley 2000.
See http://www.generative-programming.org/
(I'm not the author, but he is a techical acquaintence of mine).
--
Ira Baxter, Ph.D., CTO idbaxter@semdesigns.com 512-250-1018x140
Semantic Designs, Inc., www.semdesigns.com FAX 512-250-1191
12636 Research Blvd #C214, Austin, Texas 78759
Mihai Christodorescu <mihai@cs.wisc.edu> wrote in message
news:00-08-090@comp.compilers...
> Does anyone know of any language designed specifically for modifying
> source code? It should deal with concepts such as "function", "block",
> "statement", "expression", "type", etc. (of course, only for
> imperative, non-OO languages). It would work on the AST of a program,
> modifying the AST, and generating source in the same language:
>
> C source -> meta language? -> C source
Return to the
comp.compilers page.
Search the
comp.compilers archives again.