Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Compiler-compiler
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Variants == A typical parser generator associates executable code with each of the rules of the grammar that should be executed when these rules are applied by the parser. These pieces of code are sometimes referred to as semantic action routines since they define the semantics of the syntactic structure that is analyzed by the parser. Depending upon the type of parser that should be generated, these routines may construct a [[parse tree]] (or [[abstract syntax tree]]), or generate executable code directly. One of the earliest (1964), surprisingly powerful, versions of compiler-compilers is [[META II]], which accepted an analytical grammar with output facilities [[Code generation (compiler)|that produce stack machine]] code, and is able to compile its own source code and other languages. Among the earliest programs of the original [[Unix]] versions being built at [[Bell Labs]] was the two-part [[lex (software)|lex]] and [[yacc]] system, which was normally used to output [[C programming language]] code, but had a flexible output system that could be used for everything from programming languages to text file conversion. Their modern [[GNU Project|GNU]] versions are [[Flex (lexical analyser generator)|flex]] and [[GNU Bison|bison]]. Some experimental compiler-compilers take as input a formal description of programming language semantics, typically using [[denotational semantics]]. This approach is often called 'semantics-based compiling', and was pioneered by [[Peter Mosses]]' Semantic Implementation System (SIS) in 1978.<ref>Peter Mosses, "SIS: A Compiler-Generator System Using Denotational Semantics," Report 78-4-3, Dept. of Computer Science, University of Aarhus, Denmark, June 1978</ref> However, both the generated compiler and the code it produced were inefficient in time and space. No production compilers are currently built in this way, but research continues. The Production Quality Compiler-Compiler ([[PQCC]]) project at [[Carnegie Mellon University]] does not formalize semantics, but does have a semi-formal framework for machine description. Compiler-compilers exist in many flavors, including bottom-up rewrite machine generators (see [http://jburg.sourceforge.net/ JBurg]) used to tile syntax trees according to a rewrite grammar for code generation, and [[attribute grammar]] parser generators (e.g. [[ANTLR]] can be used for simultaneous type checking, constant propagation, and more during the parsing stage). ===Metacompilers=== {{blockquote|Metacompilers reduce the task of writing compilers by automating the aspects that are the same regardless of the object language. This makes possible the design of [[domain-specific language]]s which are appropriate to the specification of a particular problem. A metacompiler reduces the cost of producing [[Translator (computing)|translator]]s for such [[domain-specific language|domain-specific]] object languages to a point where it becomes economically feasible to include in the solution of a problem a [[domain-specific language]] design.<ref name="CWIC" />}} As a metacompiler's [[metalanguage]] will usually be a powerful string and symbol processing language, they often have strong applications for general-purpose applications, including generating a wide range of other software engineering and analysis tools.<ref name="CWIC" /><ref name="bayfront" /> Besides being useful for [[domain-specific language]] development, a metacompiler is a prime example of a domain-specific language, designed for the domain of compiler writing. A metacompiler is a [[Metaprogramming|metaprogram]] ''usually written in its own metalanguage'' or an existing computer programming language. The process of a metacompiler, written in its own metalanguage, compiling itself is equivalent to [[History of compiler construction#Self-hosting compilers|self-hosting compiler]]. Most common compilers written today are self-hosting compilers. Self-hosting is a powerful tool, of many metacompilers, allowing the easy extension of their own metaprogramming metalanguage. The feature that separates a metacompiler apart from other compiler compilers is that it takes as input a specialized [[metaprogramming]] language that describes all aspects of the compiler's operation. A metaprogram produced by a metacompiler is as complete a program as a [[Computer program|program]] written in [[C++]], [[BASIC]] or any other general [[programming language]]. The metaprogramming [[metalanguage]] is a powerful attribute allowing easier development of computer programming languages and other computer tools. Command line processors, text string transforming and analysis are easily coded using metaprogramming metalanguages of metacompilers. A full featured development package includes a [[Linker (computing)|linker]] and a [[Run time (program lifecycle phase)|run time]] support [[Library (computing)|library]]. Usually, a machine-oriented [[system programming language]], such as [[C (programming language)|C]] or C++, is needed to write the support library. A library consisting of support functions needed for the compiling process usually completes the full metacompiler package. ====The meaning of metacompiler==== In computer science, the prefix ''[[Meta (prefix)#Epistemology|meta]]'' is commonly used to mean ''about (its own category)''. For example, [[metadata]] are data that describe other data. A language that is used to describe other languages is a [[metalanguage]]. Meta may also mean [[Meta (prefix)|''on a higher level of abstraction'']]. A [[metalanguage]] operates on a higher level of abstraction in order to describe properties of a language. [[Backus–Naur form]] (BNF) is a formal [[metalanguage]] originally used to define [[ALGOL 60]]. BNF is a weak [[metalanguage]], for it describes only the [[syntax]] and says nothing about the [[semantics]] or meaning. Metaprogramming is the writing of [[computer program]]s with the ability to treat [[Computer program|program]]s as their data. A metacompiler takes as input a [[metaprogramming|metaprogram]] written in a [[metalanguage|specialized metalanguages]] (a higher level abstraction) specifically designed for the purpose of metaprogramming.<ref name="CWIC" /><ref name="TMETA" /> The output is an executable object program. An analogy can be drawn: That as a ''C++'' compiler takes as input a ''C++'' programming language program, a ''meta''compiler takes as input a [[metaprogramming|''meta''programming]] [[metalanguage]] program. ===Forth metacompiler=== {{Tone|section|date=August 2015}} Many advocates of the language [[Forth (programming language)|Forth]] call the process of creating a new implementation of Forth a meta-compilation and that it constitutes a metacompiler. The Forth definition of metacompiler is: :"A metacompiler is a compiler which processes its own source code, resulting in an executable version of itself." This Forth use of the term metacompiler is disputed in mainstream computer science. See [[Forth (programming language)#Self-compilation and cross compilation|Forth (programming language)]] and [[History of compiler construction#Forth|History of compiler construction]]. The actual Forth process of compiling itself is a combination of a Forth being a [[History of compiler construction#Self-hosting compilers|self-hosting]] [[extensible programming]] language and sometimes [[History of compiler construction#Cross compilation|cross compilation]], long established terminology in computer science. Metacompilers are a general compiler writing system. Besides the Forth metacompiler concept being indistinguishable from self-hosting and extensible language. The actual process acts at a lower level defining a minimum subset of forth ''words'', that can be used to define additional forth words, A full Forth implementation can then be defined from the base set. This sounds like a bootstrap process. The problem is that almost every general purpose language compiler also fits the Forth metacompiler description. : When (self-hosting compiler) X processes its own source code, resulting in an executable version of itself, X is a metacompiler. Just replace X with any common language, C, C++, [[Java (programming language)|Java]], [[Pascal (programming language)|Pascal]], [[COBOL]], [[Fortran]], [[Ada (programming language)|Ada]], [[Modula-2]], etc. And X would be a metacompiler according to the Forth usage of metacompiler. A metacompiler operates at an abstraction level above the compiler it compiles. It only operates at the same (self-hosting compiler) level when compiling itself. One has to see the problem with this definition of metacompiler. It can be applied to most any language. However, on examining the concept of programming in Forth, adding new words to the dictionary, extending the language in this way is metaprogramming. It is this metaprogramming in Forth that makes it a metacompiler. Programming in Forth is adding new words to the language. Changing the language in this way is [[metaprogramming]]. Forth is a metacompiler, because Forth is a language specifically designed for metaprogramming. Programming in Forth is extending Forth adding words to the Forth vocabulary creates a new Forth [[Dialect (computing)|dialect]]. Forth is a specialized metacompiler for Forth language dialects.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)