Re: Meta language?

"Ira D. Baxter" <>
20 Aug 2000 23:50:08 -0400

          From comp.compilers

Related articles
Compiler positions available for week ending August 13 (2000-08-13)
Meta language? (Mihai Christodorescu) (2000-08-14)
Re: Meta language? (Ira D. Baxter) (2000-08-20)
Re: Meta language? (Daniel C. Wang) (2000-08-20)
| List of all articles for this month |

From: "Ira D. Baxter" <>
Newsgroups: comp.compilers
Date: 20 Aug 2000 23:50:08 -0400
Organization: Posted via Supernews,
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
                          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
                where the text inside quotes is in the source language syntax,
                and the escaped identifier represent trees or functions producing
                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),
                  Yes, it preserves the program format where no transforms have been

      b) A metaprogram to control the applicaiton of the primitive transforms.
                (implicit: "do everywhere",
                  explicit: "forall \function_name : is_system_call(\function_name)
              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.
(I'm not the author, but he is a techical acquaintence of mine).

Ira Baxter, Ph.D., CTO 512-250-1018x140
Semantic Designs, Inc., FAX 512-250-1191
12636 Research Blvd #C214, Austin, Texas 78759

Mihai Christodorescu <> wrote in message
> 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

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.