6 The Fragment System Interface

The metaprogramming system also contains an interface to the Fragment System of the Mjølner BETA System. The fragment system enables the management and manipulation of ASTs located on different files. The functionality of the fragment system allows the splitting of an AST into an number of sub-ASTs (sub-trees) by allowing some interior nodes in the original AST to be replaced by special nodes, called slotDesc. The AST, originally positioned at the position of that node, may by located on a totally different file (possibly along with other sub-ASTs). All these ASTs are called fragments. Fragments are named in an hierarchical name space, similar to the UNIX hierarchical file system. The full name of a fragment has the following structure: /name1/name2/.../namen/frag, where /name1/name2/.../namen is called the path of the fragments and frag is called the local name of the fragment. The path of a fragment is the same as the full name of the father of the fragment. Fragments are usually located in files on the file system. Fragments are stored in two different formats: textual representation and binary representation. The binary representation is considered the essential representation of fragments, and the purpose of the textual representation is human reading, printing or parsing into the binary representation. If the fragment is created using tools based on the metaprogramming system, there is no reason for storing the textual representation since the binary representation contains all necessary information.

The fragment system interface of the metaprogramming system is used as the basis for the fragment system for BETA [MIA 90-2].

The fragment system interface consists essentially of four major patterns:

The fragment system interface also influences the AST interface a few places. First of all, an AST has a frag attribute, which refers to the fragment containing this AST. Secondly, unExpanded has the attributes isSlot and theSlot, where isSlot is true if this node in the AST represents a slot, and theSlot contains information (name and syntactic category) on the slot. Slots is inserted in the AST in the following way:

(# aSlot: ^slotDesc; anUnexpanded: ^unExpanded;
do ... -> newUnExpanded -> anUnexpanded[];
   newSlot -> aSlot[];
   'foo' -> aSlot.name;
   aSlot[] -> theUnexpanded.theSlot
#)


The Metaprogramming System - Reference Manual
© 1991-2002 Mjølner Informatics
[Modified: Friday January 4th 2002 at 13:10]