The Mjølner System: Metaprogramming System
A metaprogram is a program that manipulate other programs.
Yggdrasil is a metaprogramming system, that supports creation of
metaprograms. Yggdrasil is grammar based: a metaprogramming
environment may be generated from the grammar of any language
The metaprograms manipulate programs through a common represen
tation called abstract syntax trees (ASTs)
An AST is modelled as an instance of a pattern. There is a pattern
corresponding to each syntactic category (non-terminal) of the
grammar. The grammar hierarchy is modelled by a corresponding
pattern hierarchy, derived automatically from the grammar.
Grammar Based Interface
The grammar for a specific language result in a grammar based
interface-a metaprogramming environment with a set of patterns for
the language. A metaprogram using the grammar based interface will
thus be language specific. Examples of tools that benefit from
using the grammar based interface are: semantic checkers, program
analyzers, interpreters, browsers, and graphical presentation
tools.
Three Levels of Support
The AST may be manipulated at different levels of specialization:
- Tree level: Here the AST is viewed as a tree. Examples of
tools accessing the AST using the tree level are table-driven
parsers and syntax-directed editors
- Context-free level: This is the grammars based interface
generated automatically from the grammar. Graphical
presentation tools and browsers and examples of tools using
the context-free level.
- Semantic level: At this level semantic attributes may be
added to the AST. The compiler is an example of a tool using
the semantic level to access the AST.
Users may develop their own metaprogramming tools.
Yggdrasil supports generation of metaprogramming environments from
a grammar. Users can then use this environment to develop their
own metaprogramming tools-tools that manipulate other programs.
The Fragment System
The fragment system is a part of Yggdrasil, and enables the
management and manipulation of coherent ASTs located in different
files. The functionality of the fragment system allows splitting
of an AST into a number of sub-ASTs (sub-trees) by allowing some
inferior nodes in the original AST to be replaced by special
nodes. The AST, originally positioned at the position of that
node, is called a fragment and may be located in a totally
different file.
More Information
For further information, see
Mjølner System: Yggdrasil: The Meta Programming System.
Yggdrasil is the tree of the world. The ash tree of which the
crown covers the whole world. The tree gets power from the gods,
from the evil giants and from the kingdom of the death. Everything
in the world happens under the mighty crown of Yggdrasil.