Compiler: Difference between revisions

From Rosetta Code
Content added Content deleted
(improve the description)
(Add Preprocessor to sequence)
 
(8 intermediate revisions by 6 users not shown)
Line 1: Line 1:
[[Category:Encyclopedia]]
[[Category:Encyclopedia]]A compiler reads the source code of a program, and produces machine code, [[bytecode]], or a transformation of the source into another form (e.g., into a language like [[C]]).
A compiler reads the source code of a program, and produces either [[wp:Machine code|machine code]] (instructions in a suitable format for the [[wp:Central processing unit|CPU]] to execute), [[bytecode]], or a translation of the source into some other form (often into a different language, i.e. [[:Category:C|C]] to [[:Category:Assembly|assembly]]).


When generating object code, it is often the case that the resulting code must be then passed to a linking stage for conversion into an executable form. The linking stage is necessary for resolving references to libraries of code and adding any extra executable runtime that is required. (Some compilers will automatically link the code for you, so this step is not always visible.)
When generating [[wp:Object file|object code]], it is often the case that the resulting code must be then passed to a [[wp:Linker (computing)|linking stage]] for conversion into an executable form. The linking stage is necessary for resolving references to libraries of code and adding any extra executable runtime that is required. Depending on the compiler in use, sometimes the linker is a separate program from the compiler; other times, the compiler handles the linking itself.


==See also==
==See also==
Line 7: Line 8:
* [[:Category:Compilers and Interpreters|List of compilers and interpreters]]
* [[:Category:Compilers and Interpreters|List of compilers and interpreters]]
* [[wp:Compiler|Wikipedia page about compilers]]
* [[wp:Compiler|Wikipedia page about compilers]]
* [http://www-old.oberon.ethz.ch/WirthPubl/CBEAll.pdf Free PDF of Niklaus Wirth's "Compiler Construction"]
* [https://people.inf.ethz.ch/wirth/CompilerConstruction/CompilerConstruction1.pdf Free PDF of Niklaus Wirth's "Compiler Construction" (chapters 1-8)]
* [https://people.inf.ethz.ch/wirth/CompilerConstruction/CompilerConstruction2.pdf Free PDF of Niklaus Wirth's "Compiler Construction" (chapters 9-16)]
* [[Compiler/Preprocessor|Preprocessor task]]
* [[Compiler/lexical_analyzer|Lexical Analyzer task]]
* [[Compiler/syntax_analyzer|Syntax Analyzer task]]
* [[Compiler/code_generator|Code Generator task]]
* [[Compiler/virtual_machine_interpreter|Virtual Machine Interpreter task]]
* [[Compiler/AST_interpreter|AST Interpreter task]]
* [[Compiler/Verifying_syntax|Verify syntax task]]
* [[Compiler/Simple file inclusion pre processor]]

Latest revision as of 22:39, 23 May 2022

A compiler reads the source code of a program, and produces either machine code (instructions in a suitable format for the CPU to execute), bytecode, or a translation of the source into some other form (often into a different language, i.e. C to assembly).

When generating object code, it is often the case that the resulting code must be then passed to a linking stage for conversion into an executable form. The linking stage is necessary for resolving references to libraries of code and adding any extra executable runtime that is required. Depending on the compiler in use, sometimes the linker is a separate program from the compiler; other times, the compiler handles the linking itself.

See also