View this PageEdit this Page (locked)Attachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

Fall2002 Midterm 2 Review: Parsing

a. Recursive descent parsing-


b.
expression
Transcript show: 'Expression'; cr.
self factor.
(scanner peek = '+')
ifTrue: [Transcript show: '+'; cr.
scanner advance.
self expression].

factor
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