Lecture 05: LR Parsing
Continuing Lecture 04, Lecture 03
Announcement: projects updated, include Earley parser
Introduction
LR Parser without Lookahead
LR Parser with Lookahead
Precedence
Tools
Traditional, widely used, tool is called yacc (for Yet Another Compiler Compiler) developed for C.
- Dragon book, Section 4.9
Its versions are available for Java (called 'CUP'), OCaml (ocamlyacc), and other languages.
Reference
- Theory of Parsing, Chapter 5 (One-Pass No Backtrack Parsing)
Discussion of Semantic Analysis
Examples of semantic analysis:
- undeclared identifiers
- duplicate identifiers in same scope
- variables read but not written / written but not read / not used
- type mismatch for built-in operators (if (7) …)
- calling unknown methods, accessing unknown fields
- variables read before being written
- unreachable code
- accessing variable out of bounds