Line 2: | Line 2: | ||
A compiler -- in general, a language processor -- is a program that takes as input a program written in the source language and translates it into another (the target language), typically (although not necessarily) one understandable by a machine. | A compiler -- in general, a language processor -- is a program that takes as input a program written in the source language and translates it into another (the target language), typically (although not necessarily) one understandable by a machine. | ||
− | There are | + | There are several types of language processors: translators (between two high-level languages), compilers (from a high-level language to a low-level language), decompilers (from low- to high-level languages), rewriters (within the same language). |
Modern compilers usually take source code and produce object code, in a form usable by other programs, such as a linker or a virtual machine. Examples: | Modern compilers usually take source code and produce object code, in a form usable by other programs, such as a linker or a virtual machine. Examples: | ||
− | * C/C++ source code is typically compiled to object code for later linking (.o files); | + | * C/C++ source code is typically compiled to object code for later linking ('''.o''' files); |
* Java is typically compiled (Sun compiler) to binary class files (.class), used by the virtual machine. The GCC Java compiler can, besides the class files, also produce object files (like for C/C++). | * Java is typically compiled (Sun compiler) to binary class files (.class), used by the virtual machine. The GCC Java compiler can, besides the class files, also produce object files (like for C/C++). | ||
Line 13: | Line 13: | ||
* [[Introdução ao Desenvolvimento de Compiladores]] - establishes the basic framework for the other sections | * [[Introdução ao Desenvolvimento de Compiladores]] - establishes the basic framework for the other sections | ||
− | * [[Theoretical Aspects of Lexical Analysis]] - presents the basic principles behind lexical analysis and how to build lexical | + | * [[Theoretical Aspects of Lexical Analysis]] - presents the basic principles behind lexical analysis and how to build lexical analyzers |
* [[The Flex Lexical Analyzer]] - presents a concrete lexical analysis tool: flex | * [[The Flex Lexical Analyzer]] - presents a concrete lexical analysis tool: flex | ||
* [[Introduction to Syntax]] - presents a basic introduction to grammar formalisms and basic concepts needed for understanding parsing | * [[Introduction to Syntax]] - presents a basic introduction to grammar formalisms and basic concepts needed for understanding parsing |
A compiler -- in general, a language processor -- is a program that takes as input a program written in the source language and translates it into another (the target language), typically (although not necessarily) one understandable by a machine.
There are several types of language processors: translators (between two high-level languages), compilers (from a high-level language to a low-level language), decompilers (from low- to high-level languages), rewriters (within the same language).
Modern compilers usually take source code and produce object code, in a form usable by other programs, such as a linker or a virtual machine. Examples:
Compiler or interpreter? Although both types of language analysis tools share some properties, they differ in how they handle the analyzed code. Compilers produce an equivalent version of the original language in a target language; interpreters translate the input language, not into a target version, but rather directly into the execution of the actions described in the source language.
The following sections cover the overall development process and contain both theoretical and practical aspects.