TREE-META is a translator writing system. Consequently, it is capable of defining itself. The original system, of course, had to be defined in some other way. However, once a version of TREE-META was in existence, it was possible to redefine the translator in terms of itself. This definition is given in the file :SUBLIB.TREEDEF. A print-out of this file is given in Appendix 3. TREE-META can, itself, be compiled in the same way as any other translator:
TASK PLASYD,*CR :SUBLIB.TREEMETA,#CR1 :SUBLIB.TREEDEF,#CP0O :SUBLIB.TREEPROG
The TREE-META translator itself, uses the same standard set of library routines contained in :SUBLIB.TREELIB. Thus a new version of the system would be the two files :SUBLIB.TREELIB and :SUBLIB.TREEPROG. Assuming no changes have been made to the definition of the system since it was last compiled, the file :SUBLIB.TREEMETA ~ill consist of :SUBLIB.TREELIB with :SUBLIB.TREEPROG appended to it.
TREE-META is a basic system which can easily be modified to suit a particular need. A sophisticated user can improve the system by adding to the library or by changing the syntactic form of the language. The more complex changes will require a complete understanding of the existing system. However, useful changes can be made with only an outline of the system.
Simple syntactic changes are straightforward. Consider, for example, an amendment which would allow assignment statements to be written in the form:
< A:=6 >
as well as the standard form:
< A<-6 >
The original form is defined by the Syntax Rule:
STHT = <- .ID '<-' EXPR :STOR[2] / UNION ;
Replacing this with:
STMT <- .ID ( '<-' / ':=' ) EXPR :STOR[2] / UNION ;
will produce the desired effect. If this new definition is stored in the file TREEDEF2 then the updated system can be generated by:
TASK PLASYD *CR :SUBLIB.TREEMETA,#CR1 TREEDEF2,#CP0 TREEPROG2
The revised system then consists of the two files :SUBLIB.TREELIB and TREEPROG2. It would now be possible to redefine the language TREEMETA2 making use of this additional facility by rewriting the file TREEDEF2 in terms of the symbol := rather than <-.
The standard TREE-META input routine, %INCHR, reads 80 character lines from card reader stream 1 and passes them on one at a time. If a listing is required, the lines are printed as they are read.
Before each line, the character, whose internal code number is 63, is passed on to represent a newline character. Each line, therefore, generates 81 characters.
This input routine tends to be of use only if the language involved is free format. To generate a translator for a language which is field dependent, it is worthwhile modifying the standard input routine so that delimiters are inserted at the field boundaries.
The basic set of library routines used by TREE-META and the compilers that it generates make use of a number of internal storage structures. In order to understand the system, a rudimentary knowledge of these is essential. The major items are:
= 0 string added to stack by ↑ facility = 1 .ID string = 2 .NUM, .OCT, .HEX string = 3 .SR string
= 0 .CHR, .LET, .DIG = 2 label = 4 .ID,.NUM,.OCT,.HEX pointer = 8 pointer to string = 16 pointer to tree node
The internal names for these main structures are:
During both the processing of Syntax Rules and Code Rules, a single Boolean variable, %MFLAG, will be set equal to the value true or false depending on the result of some test. This truth value is interrogated by a number of routines.
During the execution of Code Rules, a particular variable %CNODE always contains the name of the rule being obeyed. The system also makes use of the index register, X2, as an accumulator which either contains the result of some arithmetic operation or contains a pointer to a node being examined.
The TREE-META user only needs to know about the library routines if modifications are to be made to the basic system. Appendix 4 gives a brief indication of the action of each routine. This should be sufficient for a user to understand the definition of TREE-META given in Appendix 3. A full description of these routines can be obtained by looking at the source listing of :SUBLIB.TREELIB.
Code Rules tend to be more difficult to debug in TREE-META than Syntax Rules. It is possible to insert code into the middle of the translated Code Rule to aid debugging or to provide any non-standard code required by the user. A Code Rule of the form:
OER[-,-] => 'ABC' 'DEFGH' % ;
would generate code:
OER: %BEGN; %CNTCK;DATA(2); checks node has two branches %BF;DATA(@%Ll); %OUTSR;DATA(3,"ABC"); %OUTSR;DATA(5,"DEFHG"); %OCR; %Ll: %END ;
Any PLASYD text can be added to this generated code by inserting it in the rule as a string preceded by the! symbol. For example:
OER[-,-] => 'ABC' ! 'DEBUG;' 'DEFGH' %
would separate the calls of OUTSR as follows:
%OUTSR;DATA(3,"ABC"); DEBUG; 7,OUTSR;DATA(5,"DEFGH");
The routine, DEBUG, has to be added to the TREE-META library. Whenever this rule is called, the routine DEBUG will be entered between the output of the two strings.