Compiler
A compiler will typically read a program written in one computer language and translate it into another (computer) language.
The name compiler is primarily used for programs that translate code from a high-level programming language to a lower level language. Examples of this are:
- assembly language
- object code
- machine code
The term compiler was mentioned by an American computer scientist called Grace Hopper, who designed one of the first compilers in the early 1950s.
A compiler executes four major steps:
Scanning: Reads one character at a time from the source code and keeps track of which character is present in which line.
Lexical Analysis: Convert the sequence of characters that appear in the source code into a series of strings of characters (known as tokens), which are associated by a specific rule by a program called a lexical analyzer.
Syntactic Analysis: Preprocessing to determine whether the tokens created during lexical analysis are in proper order as per their usage.
Semantic Analysis: The structure of tokens is checked, along with their order with respect to the grammar in a given language. The meaning of the token structure is interpreted by the parser and analyzer to finally generate an intermediate code, called object code.