This site's content was compiled from 1993 to 2006. Beyond that, Google is your friend.

Codegen

Maintainer

Patrick Doyle

Description

Codegen is a compiler tool that takes a description of the semantics of a language, and uses scripts to generate code for manipulating an Abstract Syntax Tree (AST) for that language. Think of it as being the next tool you use after lex and yacc.

Categories

Versions

Links

Details

Codegen is a utility which (surprise!) generates code. Specifically, it reads a "model", which is a description of the types of objects to be manipulated by the generated code; and a set of "scripts", which describe how to traverse the model to generate code.

The model files use a language somewhat like a stripped-down Eiffel, to describe the types of items and their relationships. A typical model for a procedural language might contain something like this:

   ROUTINE
      formal_arg$: VARIABLE  -- '$' means one-to-many relation
      body: BLOCK
   end

   FUNCTION < ROUTINE
      result_variable: VARIABLE
   end

   FUNCTION_CALL < EXPRESSION
      target: FUNCTION
      actual_arg$: EXPRESSION
   end

The UPPERCASE names are type names; each describes a type of entity found in programs written in this fictitious procedural language. The lowercase names are "relations" (similar to Eiffel features). A dollar-sign ("$") at the end of a relation name makes it a "plural" (ie. one-to-many) relation. (It's supposed to be reminiscient of the 's' at the end of a plural noun.)

Once Codegen has read a model, it runs one or more scripts. Each script describes how to traverse the model, and what code should be generated for each part of it. As a matter of fact, Codegen is used to generate some of its own code; the classes involved in the model and script structures are all generated by Codegen itself.

Supported compilers

Platforms

Licensing

Dependencies

Google
 
Web eiffelzone.com