A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Code Generation
Code generation is the compiler's phase in which the meaning of the source text
(the compiler's input) is unparsed and output in the target language.
Sophisticated compilers may
use several cascaded code generation stages to fully compile code; this is due
to the fact that algorithms for code optimization are more readily applicable
in an intermediate code form, and also facilitates a single compiler that can
target multiple architectures as only the final code generation stage (the backend)
would need to change from target to target.
The input to the code generator stage typically consists of a
parse tree, abstract syntax tree, or intermediate language code. Since the
target machine may be a physical machine such as a microprocessor, or an
abstract machine such as a virtual machine or an intermediate language
(human-readable code), the output of code generator could be machine code,
assembly code, code for an abstract machine (like JVM), or anything between.
In a more general sense, code generation is used to produce programs in some
automatic manner, reducing the need for human programmers to write code
manually. Code generations can be done either at runtime, including load time,
or compiler time. Just-in-time compilers are an example of a code generator
that produce native or nearly native code from byte-code or the like when
programs are loaded onto the compilers. On the other hand, a compiler-compiler,
(yacc, for example) almost always generates code at compiler time. A
preprocessor is an example of the simplest code generator, which produces
target code from the source code by replacing predefined keywords.
Compiler
A compiler is a computer program (or set of
programs) that translates text written in a computer language (the source
language) into another computer language (the target language).
The original sequence is usually called the source coude and the output called
object code. Commonly the output has a form suitable for processing by other
programs (e.g., a linker), but it may be a human readable text file.
The most common reason for wanting to translate source code is
to create an executable program. The name "compiler" is reserved for programs
that translate source code from a high level language to a lower level language
(e.g., assembly language or machine language).
The taskes of a typical language processor, can be represented
like in this diagram: (Imagem Rodrigo)
Context Free Grammar
See: Grammar