Dru,
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 token stream.
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 be illegal.
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.
You're welcome.
bye -- 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
[Using VW Smalltalk
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 token stream.
Is this from T Gen or something else? Sounds neat.
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!
Yeah, I finished my lexer and it is time for the parser and code gen. I don't really know how I will deal with some of those issues as well. I'll tell you what, though, Smalltalk is a lot better to debug than C. I sometimes get those nice gdb stack traces with the '??' as the name for each function. :-)
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 :-)
Same here. I did it for fun, and to work on stuff that I haven't worked on before. I have never run self though :-)
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.
Emulating Self with Smalltalk. I'm sure the Self guys will get a kick out of that. Then you could run their Smalltalk emulation system under it.
As for the longest whitespace, personally that will work, but I think that any of the '=-' or ('=' operator) should be illegal.
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.
Sorry, I was kind of thinking in BNF '=' operator* . ie. any operator or series of operators following equal (except ==) of course... what you say next, of course makes this moot...
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.
Agreed...
Thanks for posting your questions (and answers). The info has saved me _a_lot_ of time.
You're welcome.
I just want to mention, though, that I really like the Smalltalk/Self syntax. That is one of the main reasons I like this language.
------------------------------------------------------------------------ eGroup home: http://www.eGroups.com/list/self-interest Free Web-based e-mail groups by eGroups.com
self-interest@lists.selflanguage.org