[self-interest] Re: Grammar questions
Stefan Matthias Aust
sma at kiel.netsurf.de
Tue Dec 22 21:43:42 UTC 1998
> I'm working on a parser too. So far, I've only implemented the
>lexer portion. Your recent email on that shows that you have
>discovered how to handle that.
Perhaps I should tell you a little bit more about my program. I used
VisualWorks smalltalk to implement the parser. A "SelfScanner" class
implements the scanner (lexer) while a call called "SelfParser" does all
the dirty work. The scanner provides token/value pairs which are used by
the parser. With the exception of number tokens, all values are strings
(or symbols, a special kind of constant String in Smalltalk). The parser
maintains a token-push-back-stack which is needed for looking ahead in the
I think the scanner is finished. The parser still needs work. I can parse
most SELF expression already, but there's no real code generator yet. And
of course, I don't know how to deal with expressions and parenthesis!
I actually wrote that parser just out of curiosity. I wanted to study the
original morphic code and wanted to get rid of all that superfluous
information the original SELF source files are bloaded with. I thought
perhaps I could write a small program to extract method definitions from
these files. I incrementally extended this to a whole parser :-)
Now, there's the intriguing idea to add a VM simulator to the system. I
already create "SelfObject" instances for each method. Each contains a
number of slots (one of SelfMutableDataSlot, SelfImmutableDataSlot,
SelfAssignerSlot, SelfArgumentSlot and SelfMethodSlot) and a list of
SelfExpression objects, which eventually will hold a parse tree of message
send (and resend) operations.
>As for the longest whitespace, personally that will
>work, but I think that any of the '=-' or ('=' operator) should
Well, I just try to implement the grammar. I don't reason about it :-) But
(allow me one thought) if you make '=' an illegal operator, you need
another operator for testing equality. Because '==' is already used to
test identity, you cannot use this or you need to change the language even
more. I'm not sure whether this would be a good idea.
>C did this for the same reasons. '=- 1' vs '= -1' is
>hard to read, the standard '-=' is much easier to read.
As for many other things (perhaps too many) in SELF, this should be
considered as a convention but not a rule expressed in the grammar.
Otherwise I'd agree withh you.
>Thanks for posting your questions (and answers). The info has
>saved me _a_lot_ of time.
Stefan Matthias Aust // Are you ready to discover the twilight zone?
E-group home: http://www.eGroups.com/list/self-interest
Free Web-based e-mail groups by eGroups.com
More information about the Self-interest