CSC362 2004S, Class 30: A Pascal Parser Admin: * Parser nearly ready. Released at 4:15 p.m. Extra credit for finding errors. * Today: Some review of parsing (since it's on my mind) * Wednesday: Learn about target code. * Cool talk Friday at noon. Free pizza. Overview: * Your problems in parsing. * My problems in parsing. * Solving those problems. * On type checking. Common problems * Structural * Compiling Java: You have to learn it some time. * Sam's design of Node.java sucks: * No standard grammar to use * Dealing with separating the problem into parts * Joining parts * Tracking down errors * Scale * Figuring out where errors occur * Biting off more than you can chew * Grammar * Variables and Expressions * Procedure call vs. assignment statement * Sam's hack: Simulate lookahead by passing identifier * Better strategy: Permit more lookahead * Differentiating related things Splitting up work in the type checker: * Create a new class with a simple check() method. The default behavior is to recursively check all the children. * For certain kinds of nonterminals, we need to override that method * Keep a hash table of nonterminal/overridden methods * The "overriden methods" can be built in separate classes checker.add(PascalNonterminals.WHILELOOP, Paul.whileChecker); checker.add(PascalNonterminals.EXPRESSON, Dimitar.expressionChecker);