META II is a
domain-specific
Domain specificity is a theoretical position in cognitive science (especially modern cognitive development) that argues that many aspects of cognition are supported by specialized, presumably evolutionarily specified, learning devices. The posit ...
programming language
A programming language is a system of notation for writing computer programs.
Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
for writing
compiler
In computing, a compiler is a computer program that Translator (computing), translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primaril ...
s. It was created in 1963–1964 by Dewey Val Schorre at
University of California, Los Angeles
The University of California, Los Angeles (UCLA) is a public university, public Land-grant university, land-grant research university in Los Angeles, California, United States. Its academic roots were established in 1881 as a normal school the ...
(UCLA). META II uses what Schorre called ''
syntax
In linguistics, syntax ( ) is the study of how words and morphemes combine to form larger units such as phrases and sentences. Central concerns of syntax include word order, grammatical relations, hierarchical sentence structure (constituenc ...
equations''. Its operation is simply explained as:
Each ''syntax equation'' is translated into a recursive subroutine
In computer programming, a function (also procedure, method, subroutine, routine, or subprogram) is a callable unit of software logic that has a well-defined interface and behavior and can be invoked multiple times.
Callable units provide a ...
which tests the input string for a particular phrase structure, and deletes it if found.
Meta II programs are compiled into an
interpreted byte code
Bytecode (also called portable code or p-code) is a form of instruction set designed for efficient execution by a software interpreter. Unlike human-readable source code, bytecodes are compact numeric codes, constants, and references (normally ...
language. VALGOL and SMALGOL compilers illustrating its capabilities were written in the META II language,
VALGOL is a simple algebraic language designed for the purpose of illustrating META II. SMALGOL was a fairly large subset of ALGOL 60
ALGOL 60 (short for ''Algorithmic Language 1960'') is a member of the ALGOL family of computer programming languages. It followed on from ALGOL 58 which had introduced code blocks and the begin and end pairs for delimiting them, representing a ...
.
Notation
META II was first written in META I, a hand-compiled version of META II. The history is unclear as to whether META I was a full implementation of META II or a required subset of the META II language required to compile the full META II compiler.
In its documentation, META II is described as resembling Backus–Naur form
In computer science, Backus–Naur form (BNF, pronounced ), also known as Backus normal form, is a notation system for defining the Syntax (programming languages), syntax of Programming language, programming languages and other Formal language, for ...
(BNF), which today is explained as a production grammar. META II is an analytical grammar. In the 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. Parsing statements of the metalanguage resemble augmented Backus–Naur form with embedd ...
document, these languages were described as reductive grammars.
For example, in BNF, an arithmetic expression may be defined as:
:= ,
BNF rules are today production rules describing how constituent parts may be assembled to form only valid language constructs. A parser does the opposite taking language constructs apart. META II is a stack-based
Stack-oriented programming is a programming paradigm that relies on one or more stacks to manipulate data and/or pass parameters. Programming constructs in other programming languages need to be modified for use in a stack-oriented system. Most ...
functional parser
Parsing, syntax analysis, or syntactic analysis is a process of analyzing a string of symbols, either in natural language, computer languages or data structures, conforming to the rules of a formal grammar by breaking it into parts. The term '' ...
programming language
A programming language is a system of notation for writing computer programs.
Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
that includes output directive. In META II, the order of testing is specified by the equation. META II like other programming languages would overflow its stack attempting left recursion. META II uses a $ (zero or more) sequence operator. The expr parsing equation written in META II is a conditional expression evaluated left to right:
expr = term
$( '+' term .OUT('ADD')
/ '-' term .OUT('SUB'));
Above the expr equation is defined by the expression to the right of the '='. Evaluating left to right from the '=', term is the first thing that must be tested. If term returns failure expr fails. If successful a term was recognized we then enter the indefinite $ zero or more loop were we first test for a '+' if that fails the alternative '-' is attempted and finally if a '-' were not recognized the loop terminates with expr returning success having recognized a single term. If a '+' or '-' were successful then term would be called. And if successful the loop would repeat. The expr equation can also be expressed using nested grouping as:
expr = term $(('+' / '-') term);
The code production elements were left out to simplify the example. Due to the limited character set of early computers the character /
was used as the alternative, or, operator. The $
, loop operator, is used to match zero or more of something:
expr = term $( '+' term .OUT('ADD')
/ '-' term .OUT('SUB')
);
The above can be expressed in English: An expr is a term followed by zero or more of (plus term or minus term). Schorre describes this as being an aid to efficiency, but unlike a naive recursive descent parser
In computer science, a recursive descent parser is a kind of top-down parser built from a set of mutually recursive procedures (or a non-recursive equivalent) where each such procedure implements one of the nonterminals of the grammar. Thus t ...
compiler it will also ensure that the associativity
In mathematics, the associative property is a property of some binary operations that rearranging the parentheses in an expression will not change the result. In propositional logic, associativity is a Validity (logic), valid rule of replaceme ...
of arithmetic operations is correct:
expr = term $('+' term .OUT('ADD')
/ '-' term .OUT('SUB')
);
term = factor $( '*' factor .OUT('MPY')
/ '/' factor .OUT('DIV')
);
factor = ( .ID
/ .NUMBER
/ '(' expr ')')
( '^' factor .OUT('EXP')
/ .EMPTY);
With the ability to express a sequence with a loop or right ("tail") recursion, the order of evaluation can be controlled.
Syntax rules appear declarative, but are actually made imperative by their semantic specifications.
Operation
META II outputs assembly code for a stack machine. Evaluating this is like using an Reverse Polish notation
Reverse Polish notation (RPN), also known as reverse Łukasiewicz notation, Polish postfix notation or simply postfix notation, is a mathematical notation in which operators ''follow'' their operands, in contrast to prefix or Polish notation ...
(RPN) calculator.
expr = term
$('+' term .OUT('ADD')
/'-' term .OUT('SUB'));
term = factor
$('*' factor .OUT('MPY')
/ '/' factor .OUT('DIV'));
factor = (.ID .OUT('LD ' *)
/ .NUM .OUT('LDL ' *)
/ '(' expr ')')
( '^' factor .OUT('XPN') / .EMPTY);
In the above .ID and .NUM are built-in token recognizers. * in the .OUT code production references the last token recognized. On recognizing a number with .NUM .OUT('LDL' *) outputs the load literal instruction followed the number. An expression:
:(3*a^2+5)/b
will generate:
LDL 3
LD a
LDL 2
XPN
MPY
LDL 5
ADD
LD b
DIV
META II is the first documented version of a metacompiler
In computer science, a compiler-compiler or compiler generator is a programming tool that creates a parser, interpreter, or compiler from some form of formal description of a programming language and machine.
The most common type of compiler- ...
,[Ignoring META I which is only mentioned in passing in the META II document.] as it compiles to machine code for one of the earliest instances of a virtual machine
In computing, a virtual machine (VM) is the virtualization or emulator, emulation of a computer system. Virtual machines are based on computer architectures and provide the functionality of a physical computer. Their implementations may involve ...
.
The paper itself is a wonderful gem which includes a number of excellent examples, including the bootstrapping
In general, bootstrapping usually refers to a self-starting process that is supposed to continue or grow without external input. Many analytical techniques are often called bootstrap methods in reference to their self-starting or self-supporting ...
of Meta II in itself (all this was done on an 8K (six bit byte) 1401
Year 1401 ( MCDI) was a common year starting on Saturday of the Julian calendar.
Events
January–March
* January 6 – Rupert, King of Germany, is crowned King of the Romans at Cologne.
* January 12 – Emperor Hồ Quý Ly ...
!)." – Alan Kay
Alan Curtis Kay (born May 17, 1940) published by the Association for Computing Machinery 2012 is an American computer scientist who pioneered work on object-oriented programming and windowing graphical user interface (GUI) design. At Xerox ...
The original paper is not freely available, but was reprinted in ''Dr. Dobb's Journal
''Dr. Dobb's Journal'' (often shortened to ''Dr. Dobb's'' or DDJ) was a monthly magazine published in the United States by UBM Technology Group, part of UBM. It covered topics aimed at computer programmers. When launched in 1976, DDJ was the fi ...
'', April 1980. Transcribed source code has at various times been made available (possibly by the CP/M
CP/M, originally standing for Control Program/Monitor and later Control Program for Microcomputers, is a mass-market operating system created in 1974 for Intel 8080/Intel 8085, 85-based microcomputers by Gary Kildall of Digital Research, Dig ...
User Group
A users' group (also user's group or user group) is a type of Club (organization), club focused on the use of a particular technology, usually (but not always) computer-related.
Overview
Users' groups started in the early days of Mainframe compu ...
). The paper included a listing of the description of Meta II, this could in principle be processed manually to yield an interpretable program in virtual machine opcodes; if this ran and produced identical output then the implementation was correct.
META II was basically a proof of concept. A base from which to work.
META II is not presented as a ''standard language'', but as a point of departure from which a user may develop his own ''META'' "''language''".
Many META "languages" followed. Schorre went to work for System Development Corporation
System Development Corporation (SDC) was a computer software company based in Santa Monica, California. Initially created as a division of the RAND Corporation in December 1955 (under the name System Development Division) and established as an ind ...
where he was a member of the Compiler for Writing and Implementing Compilers (CWIC) project. CWIC's SYNTAX language built on META II adding a backtrack alternative operator positive and negative look ahead operators and programmed token equations. The .OUT
and .LABEL
operations removed and stack transforming operations :
and !
added. The GENERATOR language based on LISP 2
LISP 2 is a programming language proposed in the 1960s as the successor to Lisp. It had largely Lisp-like semantics and ALGOL 60-like syntax. It is remembered mostly for its syntax, yet it had many features beyond those of early Lisps.
Early Li ...
processed the trees produced by the SYNTAX parsing language. To generate code a call to a generator function was placed in a SYNTAX equation. These languages were developed by members of the L.A. ACM SIGPLAN sub-group on Syntax Directed Compilers. Schorre viewed the META II language in a general way:
The term ''META'' "language" with ''META'' in capital letters is used to denote any compiler-writing ''language'' so developed.
Schorre explains META II as a base from which other META "languages" may be developed.
See also
* OMeta
*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. Parsing statements of the metalanguage resemble augmented Backus–Naur form with embedd ...
Notes
References
{{Reflist
External links
ACM - Paper on META II
1960s software
Computer languages
Parser generators
Articles with example code