multi-language GUI / shells in Smalltalk

Yoshiki Ohshima yoshiki at squeakland.org
Fri May 4 00:21:05 UTC 2007


> And very recently Alex and Yoshiki ported the Meta parser from Coke  
> to Squeak, this is a couple of changesets in the OLPC image.
> 
> Might be worth checking out.

  Wow, thank you for mentioning it, Bert!

  The good thing about META in Squeak is its size (10 classes
including the bootstrap parser), meta circular definition (it is
written in itself), ability to write actions anywhere in production
definitions (actually, there is no real distinction between actions
and lhs syntactical symbols), integration with Squeak browser (you
simply write production rules in a browser), no-real need to write
tokenizer and parser separately, and linear time parsing with
unlimited look ahead and back-tracking.

  There is very little pre-defined things.  For example, you would
write a tokenizer for parsing a number (an equivalent of

 "<number> : [0-9]+ (\. [0-9]*) ? ;"

and "{'1' value asNumber}" in SmaCC) would be written in Meta like a method:

--------------------
number ::=
	`0`:r (<char>:c ?`c isDigit` `r * 10 + c digitValue`:r)+ `r`
--------------------

Things enclosed by back-ticks (`) are like things in {} in SmaCC, a
colon (:) followed by a name is like naming in SmaCC ('expression'),
but this is a real assignment.  (So, the calculated value in the long
action is re-assigned to the same variable.) Question and back-tick
(?``) is a predicate that tells whether the parsing should continue or
not.  A name enclosed by <> is a method call (or production call).
And, the last item in the production is the result value.  This is a
tokenizer example, but the parser production is written in the same
way.

  We haven't gotten around to port the left-recursion case over to the
Squeak version.  Without the left-recursion, it can be painful
sometime.  We plan to port that to Meta in Squeak sometime soon.

  Ah, yes, the bottom line is that I think it is interesting and worth
to take a look at.

-- Yoshiki



More information about the Squeak-dev mailing list