Compiler-compiler: Difference between revisions

Content deleted Content added
m Some disambiguations resolved
Reverted 1 edit by Solidmiki21 (talk): 'object language' is the correct term here, metalanguage is not
Line 6:
In [[computer science]], a '''compiler-compiler''' or '''compiler generator''' is a programming tool that creates a [[parsing|parser]], [[interpreter (computer software)|interpreter]], or [[compiler]] from some form of formal description of a [[programming language]] and machine.
 
The most common type of compiler-compiler is more precisely called a '''parser generator'''<ref>{{Cite book |url=https://www.worldcat.org/oclc/70775643 |title=Compilers : principles, techniques, & tools |date=2007 |others=Alfred V. Aho, Monica S. Lam, Ravi Sethi, Jeffrey D. Ullman, Alfred V. Aho |isbn=0-321-48681-1 |edition=Second |___location=Boston |page=287 |oclc=70775643}}</ref> and'''.''' It only handles syntactic analysis.
 
The input of a parser generator is a [[formal grammar|grammar]] file, typically written in [[Backus–Naur form]] (BNF) or [[extended Backus–Naur form]] (EBNF) that defines the [[Syntax (programming languages)|syntax]] of a target programming language.
Line 14:
Parser generators do not handle the [[Semantics (computer science)|semantics]] of the AST, or the [[Code generation (compiler)|generation of machine code]] for the target machine.<ref name="name">"A Syntax Directed Compiler for ALGOL 60" Edgar T. Irons, Communications of the ACM Volume 4 Issue 1, Jan. 1961.</ref>
 
A '''metacompiler''' is a software development tool used mainly in the construction of [[compiler]]s, [[Translator (computing)|translators]], and [[interpreter (computing)|interpreters]] for other programming languages.<ref name="McGraw"/> The input to a metacompiler is a [[computer program]] written in a [[Domain-specific language|specialized]] programming [[metalanguage]] designed mainly for the purpose of constructing compilers.<ref name="McGraw"/><ref name="CWIC"/> The language of the compiler produced is called the object language. The minimal input producing a compiler is a [[Metaprogramming|metaprogram]] specifying the [[Metalanguage|object language]]{{dn|date=February 2023}} grammar and [[Semantics (computer science)|semantic]] transformations into an [[object program]].<ref name="CWIC"/><ref name="TMETA"/>
 
== Variants ==
Line 23:
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 are still being researched{{Citation needed|date=Septemberresearch 2023}}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.
Line 30:
 
===Metacompilers===
{{blockquote|Metacompilers reduce the task of writing compilers by automating the aspects that are the same regardless of the [[metalanguageobject language]]{{dn|date=February 2023}}. 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]] [[metalanguageobject language]]{{dn|date=February 2023}}s 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"/>