TREE-META
The TREE-META (or Tree Meta, TREEMETA) Translator Writing System is a compiler-compiler system for context-free languages originally developed in the 1960s.[src] Parsing statements of the metalanguage resemble augmented Backus–Naur form with embedded tree-building directives.[src] Unparsing rules include extensive tree-scanning and code-generation constructs.[src]
The TREE-META (or Tree Meta, TREEMETA) Translator Writing System is a compiler-compiler system for context-free languages originally developed in the 1960s.[src] Parsing statements of the metalanguage resemble augmented Backus–Naur form with embedded tree-building directives.[src] Unparsing rules include extensive tree-scanning and code-generation constructs.[src] ==History== TREE-META was instrumental in the development of NLS (oN-Line System) and was ported to many systems including the UNIVAC 1108, GE 645, SDS 940, ICL 1906A, PERQ, and UCSD p-System.[src] ==Example== This is a complete example of a TREE-META program extracted (and untested) from the more complete (declarations, conditionals, and blocks) example in Appendix 6 of the ICL 1900 TREE-META manual.[src] That document also has a definition of TREE-META in TREE-META in Appendix 3.[src] This program is not only a recognizer, but also outputs the assembly language for the input.[src] It demonstrates one of the key features of TREE-META, which is tree pattern matching.[src] It is used on both the LHS (GET and VAL for example) and the RHS (ADD and SUB).[src] % This is an ALGOL-style comment delimited by % % ====================== INPUT PARSE RULES ======================= % .META PROG % A program defining driving rule is required.[src] % % This PROG rule is the driver of the complete program.[src] % PROG = $STMT ; % $ is the zero or more operator.[src] % % PROG (the program) is defined as zero or more STMT (statements).[src] % STMT = .ID ':=' AEXP :STORE[2]*; % Parse an assignment statement from the source to the tree.[src] % % ':=' is a string constant, :STORE creates a STORE node, % % [2] defines this as having two branches i.e.[src] STORE[ID,AEXP].[src] % % * triggers a unparse of the tree, Starting with the last created % % tree i.e.[src] the STORE[ID,AEXP] which is emitted as output and % % removed from the tree.[src] % AEXP = FACTOR $('+' FACTOR :ADD[2] / '-' FACTOR :SUB[2]); % Here we have the recognizer for arithmetic '+' :ADD and '-' :SUB % % tree building.[src] Again the [2] creates a 2-branch ADD or SUB tree.[src] % % Unparsing is deferred until an entire statement has been parsed.[src] % % ADD[FACTOR,FACTOR] or SUB[FACTOR,FACTOR] % FACTOR = '-' PRIME :MINUSS[1] / PRIME ; PRIME = .ID / .NUM / '(' AEXP ')' ?3?[src] ; % ?3?[src] is a hint for error messages.[src] % % ===================== OUTPUT UNPARSE RULES ===================== % STORE[-,-] => GET[*2] 'STORE ' *1 ; % *1 is the left tree branch.[src] *2 is the right % % GET[*2] will generate code to load *2.[src] % % The 'STORE' string will be output % % followed by left branch *1 a symbol % % Whatever *2, it will be loaded by GET[*2].[src] % GET[.ID] => 'LOAD ' *1 / [.NUM] => ' LOADI ' *1 / [MINUSS[.NUM]] => 'LOADN ' *1:*1 / [-] => *1 ; % Here an .ID or a .NUM will simply be loaded.[src] A MINUSS node % % containing a .NUM will have this used, the notation *1:*1 means % % the first branch (a .NUM) of the first branch (MINUSS).[src] % % Anything else will be passed on for node recognition % % The unparse rules deconstruct a tree outputing code.[src] % ADD[-,-] => SIMP[*2] GET[*1] 'ADD' VAL[*2] / SIMP[*1] GET[*2] 'ADD' VAL[*1] / GET[*1] 'STORE T+' / GET[*2] 'ADD T+' ; % Chevrons indicate an arithmetic operation, for example to % % generate an offset A relative to a base address T.[src] % SUB[-,-] => SIMP[*2] GET[*1] 'SUB' VAL[*2] / SIMP[*1] GET[*2] 'NEGATE' % 'ADD' VAL[*1] / GET[*2] 'STORE T+' / GET[*1] 'SUB T+' ; % A percent character in an unparse rule indicates a newline.[src] % SIMP[.ID] => .EMPTY / [.NUM] => .EMPTY / [MINUSS[.NUM]] => .EMPTY; VAL[.ID] => ' ' *1 / [.NUM] => 'I ' *1 / [MINUSS[.NUM]] => 'N ' *1:*1 ; MINUSS[-] => GET[*1] 'NEGATE' ; .END ==See also== NLS (computer system) META II Basic/Four[src]
36 sentences · 36 cited inline · 0 references stored
References
No reference rows published for this article.
Cite this article
MLA
"TREE-META." encyclopegia.org, 2025, https://encyclopegia.org/wiki/tree-meta. Accessed 26 November 2026.
Chicago
"TREE-META." encyclopegia.org. Accessed November 26, 2026. https://encyclopegia.org/wiki/tree-meta.
APA
encyclopegia.org. (2025). TREE-META. Retrieved November 26, 2026, from https://encyclopegia.org/wiki/tree-meta
Accessed November 26, 2026 · CC BY-SA 4.0 · citation page · JSON