Sep 08, 2003 ------------- - Move onto Chap 4 - a sneak peek into compiler world - Lexical analysis - recognizing tokens, lexemes - model based on finite state machines - Example of coding up a lexical analyzer - distinguishing between numbers and identifiers - Syntax analysis - building up a parse tree - or just simply checking for validity - Main types of parsers - top-down: easy to code up - bottom-up: safe - Design of a top-down parser - for grammar - assumes Token global variable has the next token to be analyzed - every procedure/function that consumes this token must return the favor, by calling getNextToken() - Caveats to watch out for - left recursion - -> + - get rid of it! - optional arguments - -> if .. then .. | if .. then .. else - left factor the grammar! - right recursion causes no problem - why?