Hi!
I've set up a web page for my first version of ``mySelf´´, my Self parser
and simulator written in Smalltalk! If you like, check out
http://freeweb.digiweb.com/computers/sma/
MySelf works both for VisualWorks Smalltalk and Squeak, however the Squeak
port is really crude. As Squeak's syntax unfortunately doesn't conform with
the "standard", I had to work around some problems, mainly the fact that
"_" isn't a valid character in message names. Therefore, I recommend
VisualWorks NC, which is also _much_ faster.
Happy New Year!
bye
--
Stefan Matthias Aust // Are you ready to discover the twilight zone?
------------------------------------------------------------------------
eGroup home: http://www.eGroups.com/list/self-interest
Free Web-based e-mail groups by eGroups.com
Dru Nelson wrote:
>[Using VW Smalltalk]
>Is this from T Gen or something else? Sounds neat.
It's something else. I wrote scanner and parser from scratch without any
generator program. No big deal for a grammar as small as for Self.
>[Status of completition]
>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. :-)
No comment :-) BTW, in the meantime I've nearly finished my parser and I
can simulate most expressions. Because of the way I wrote the simulator, I
cannot evaluate non-local-returns but otherwise, things work as expected.
[snip]
>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.
Probably :-)
bye
--
Stefan Matthias Aust // Are you ready to discover the twilight zone?
------------------------------------------------------------------------
eGroup home: http://www.eGroups.com/list/self-interest
Free Web-based e-mail groups by eGroups.com
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
Hi!
I was trying to understand the Self grammar to implement a Self parser. I
failed. Now I've a couple of questions regarding the ambiguities of the
grammar. I'm working with the grammar shown in appendix 2.C of the Self
4.0 language reference.
Currently, I've two problems: a) How can I distinguish a simple expression
enclosed in parenthesis from an object definition - and b) how to detect
the end of a slot list?
I expanded the BNF rules to deal with message precedence as follows:
expression = keyword-message
keyword-message = binary-message {keyword-send} | resend...
keyword-send = small-keyword keyword-message {cap-keyword keyword-message}
binary-message = unary-message {binary-send} | resend...
binary-send = operator unary-message
unary-message = primary {unary-send} | resend...
unary-send = identifier
primary = [receiver]
receiver = identifier | constant
now, to allow expressions in parentheses, we need to add a rule
receiver = "(" expression ")"
however, now there's no chance to distinguish this from the regular-object
definition, which is one alternative of constant, because "( 1 + 2 )" could
also be a valid method object. Did I miss something here?
The second problem is with operators. Appendix 2.B says about operators:
op-char = ... '-' | '^' | '|' | ...
operator = op-char {op-char}
which especially means that ^ and | are valid operators and furthermore,
that for example '=-1' is ambigious. Let's ignore _that_ problem for now.
My trouble are ^ and | as operators.
Currently, my parser will fail on (| a = 1 |) because it thinks that
there's a slot "a" to which a binary expression is assigned of which the
second part is missing. It doesn't detect the end of the slot list.
My parser also fails on this, which might be a legal Self expression
according to the grammar: (| | x = ( ... ) |) If "|" is a valid operator,
it must be possible to use it in a binary-slot definition.
Here's another problem with '^': ^12 can be parsed both as "self ^ 12"
and "return 12".
My solution would be to bann ^ and | as valid operators, but what does the
Self spec say, what does the offical Self parser do? I need help.
Thanks in advance,
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
I was reading the self grammar. Am I right in
assuming that...
doIt.
or a:
setSlot: 'x' With: doIt.
works, by having the receiver of the unary message
doIt (which is probably a slot), is parsed as a
null token for each of these expressions. Which
would imply the default 'self' :-) as the receiver?
Just a quick check,
------------------------------------------------------------------------
Free Web-based e-mail groups -- http://www.eGroups.com