Abstract
Lexing and parsing will reject many texts as not being correct programs. However, many languages have well-formedness requirements that can not be handled exclusively by the techniques seen so far. These requirements can, for example, be static type correctness or a requirement that pattern-matching or case-statements are exhaustive. These properties are most often not context-free, i.e., they can not be checked by membership of a context-free language. Consequently, they are checked by a phase that (conceptually) comes after syntax analysis (though it may be interleaved with it). These checks may happen in a phase that does nothing else, or they may be combined with the actual execution or translation to another language. Often, the translator may exploit or depend on type information, which makes it natural to combine calculation of types with the actual translation. In Chap. 4, we covered type-checking during execution, which is normally called dynamic typing. We will in this chapter assume that type checking and related checks are done in a phase previous to execution or translation (i.e., static typing), and similarly assume that any information gathered by this phase is available in subsequent phases.
“The most touching epitaph I ever encountered was on the tombstone of the printer of Edinburgh. It said simply:
He kept down the cost and set the type right.”
Gregory Nunn (1955–)
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
Unlike in Chap. 4, where the error function stops execution.
References
Aho, A.V., Lam, M.S., Sethi, R., Ullman, J.D.: Compilers; Principles, Techniques and Tools. Addison-Wesley, Reading (2007)
Milner, R.: A theory of type polymorphism in programming. J. Comput. Syst. Sci. 17(3), 348–375 (1978)
Author information
Authors and Affiliations
Corresponding author
Rights and permissions
Copyright information
© 2011 Springer-Verlag London Limited
About this chapter
Cite this chapter
Mogensen, T.Æ. (2011). Type Checking. In: Introduction to Compiler Design. Undergraduate Topics in Computer Science. Springer, London. https://doi.org/10.1007/978-0-85729-829-4_5
Download citation
DOI: https://doi.org/10.1007/978-0-85729-829-4_5
Publisher Name: Springer, London
Print ISBN: 978-0-85729-828-7
Online ISBN: 978-0-85729-829-4
eBook Packages: Computer ScienceComputer Science (R0)