Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007
Fall2002 Midterm 2 Review: Parsing
a. Recursive descent parsing-
- Each non-terminal maps to a method/function/procedure in the language
- The method/function/procedure is responsible for recognizing the related non-terminal (including calling another method/function/procedure as needed)
- Use your scanner to supply tokens
Transcript show: 'Expression'; cr.
(scanner peek = '+')
ifTrue: [Transcript show: '+'; cr.
Transcript show: 'Factor'; cr.
c. It has no look-ahead? Can someone confirm this?
c. I don't think lookahead has anything to do with it, since it just returns all tokens found. You can do lookahead if you want. For one thing I am pretty sure you have to use ' ' as the delimiter, which would restrict you if you were parsing something that didn't use strictly spaces as dilimiters. I mean the basic problem is that you can not express how it will recognize tokens. c++; would come out has 'c++;' it wouldn't see it as 'c', '+', '+', ';' or 'c', '++', ';'. Same thing for 5+5. It would see that as '5+5'.
Link to this Page