Compiler construction

From Wikipedia, the free encyclopedia
Jump to: navigation, search

Compiler construction is an area of computer science that deals with the theory and practice of developing programming languages and their associated compilers.

The theoretical portion is primarily concerned with syntax, grammar and semantics of programming languages. One could say that this gives this particular area of computer science a strong tie with linguistics. Some courses on compiler construction will include a simplified grammar of a spoken language that can be used to form a valid sentence for the purposes of providing students with an analogy to help them understand how grammar works for programming languages.

The practical portion covers actual implementation of compilers for languages. Students will typically end up writing the front end of a compiler for a simplistic teaching language, such as Micro.

Lexical analysis[edit]

Main article: Lexical analysis

The first phase of a compiler is called lexical analysis. This phase involves grouping the characters that make up the source program into meaningful sequences called lexemes. Lexemes belong to token classes such as "integer", "identifier", or "whitespace". A token of the form <token-class, attribute-value> is produced for each lexeme. Lexical analysis is also called scanning.[1]:5-6

Syntax analysis[edit]

Main article: Syntax analysis

The second phase of constructing a compiler is syntax analysis. The output of lexical analyser is used to create a representation which shows the grammatical structure of the tokens. Syntax analysis is also called parsing.[1]:8



See also[edit]

Further reading[edit]


  1. ^ a b Aho, Alfred V.; Lam, Monica S.; Sethi, Ravi; Ullman, Jeffrey D. (1986). Compilers: Principles, Techniques, and Tools (2nd Edition). Pearson. ISBN 0-321-48681-1. 

External links[edit]