Chapter 7: Checking Base Types
This is the first of two chapters about type checking. In most mainstream programming languages, type checking is a key aspect of semantic analysis that must be performed before you can generate code.
This chapter will show you how to do simple type checks for the base types included in the Jzero subset of Java. A byproduct of checking the types is to add type information to the syntax tree. Knowing the types of operands in the syntax tree enables you to generate correct instructions for various operations.
This chapter covers the following main topics:
- Type representation in the compiler
- Assigning type information to declared variables
- Determining the type at each syntax tree node
- Runtime type checks and type ...
Get Build Your Own Programming Language now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.