A number of tools in the Mjølner programming environment are metaprograms, i.e. programs that manipulate other programs. The metaprogramming system is grammar based in the sense that a metaprogramming tool may be generated from the grammar of any language. For each syntactic category of the language, a corresponding class is generated. The syntactic hierarchy of the grammar is mapped into a corresponding class hierarchy. This object-oriented representation of programs is further exploited by including a set of more general classes that view a program as an abstract syntax tree and by allowing the user to add semantic attributes in sub-classes