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.
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.:5–6
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.:8
Semantic analysis is the final phase of the compiler front end. During this phase, the compiler applies semantic rules to the syntax tree built by the parser. The tasks performed during this phase vary depending on the design of the compiler, but typically include type checking, scope checking and object binding. Symbol tables may also be constructed during semantic analysis in preparation for code generation. In some cases, such as a one-pass compiler, semantic analysis is done at the same time as syntax analysis.
- Functional compiler
- Programming language implementation
- Programming language theory
- A compiler construction book available for download in Wikipedia.
- Alfred V. Aho, Monica S. Lam, Ravi Sethi, Jeffrey D. Ullman. Compilers: Principles, Techniques, and Tools.
- Michael Wolfe. High-Performance Compilers for Parallel Computing. ISBN 978-0-8053-2730-4
- David Gries. Compiler Construction for Digital Computers. John Wiley 1971. ISBN 0-471-32771-9.
- F.R.A.Hopgood. Compiling Techniques. MacDonald/American Elsevier 1969. ISBN 0-356-02474-1.
- 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.<templatestyles src="Module:Citation/CS1/styles.css"></templatestyles>
- Watt, David (2000). Programming Language Processors in Java. Prentice Hall. ISBN 0130257869.<templatestyles src="Module:Citation/CS1/styles.css"></templatestyles>
- Let's Build a Compiler, by Jack Crenshaw, A tutorial on compiler construction.
|This programming-language-related article is a stub. You can help Infogalactic by expanding it.|