[Cuis] OMeta
Phil (list)
pbpublist at gmail.com
Wed May 20 12:50:57 CDT 2015
On Wed, 2015-05-20 at 13:05 +0000, H. Hirzel wrote:
> This is a file-out of which component from which source?
>
A Smalltalk/Squeak scanner/parser from OMeta 2 (it ships as part of the
OMeta which is why it's a tricky package to load: parts of it are
written in itself). This is what 'pure' OMeta code looks like... in
most real world usage there would be squeak code on the right-hand side
action ('=> [some squeak code]') when a rule of interest is matched that
might, for example, populate an AST.
Fascinating, I'd never looked at how this code was used before until you
asked: In OMeta it's used to determine whether it's looking at Squeak
code since it will get handed both OMeta and Squeak code. The
fascinating part is that it's written twice: once in Smalltalk as part
of the stage 1 in bootstrap and then again in stage 2 in OMeta once the
foundation exists. So Casey can partially get his wish now: look at how
stage 1 does it vs stage 2 to see the difference between pure Smalltalk
and OMeta. For example the arrayConstr method in Squeak:
arrayConstr
^ self ometaOr: {[true
ifTrue: [self apply: #token withArgs: {'{'}.
self apply: #expr.
self
many: [true
ifTrue: [self apply: #token withArgs: {'.'}.
self apply: #expr]].
self ometaOr: {[self apply: #token withArgs: {'.'}]. [self apply:
#empty]}.
self apply: #token withArgs: {'}'}]]. [true
ifTrue: [self apply: #token withArgs: {'{'}.
self apply: #token withArgs: {'}'}]]}
and here's the OMeta version:
arrayConstr =
"{" expr ("." expr)* ("." | empty) "}"
| "{" "}"
>
>
> On 5/20/15, Phil (list) <pbpublist at gmail.com> wrote:
> > On Sat, 2015-05-16 at 14:18 -0700, Casey Ransberger wrote:
> >> It would be very cool to have a Cuis compiler written in OMeta to compare
> >> and contrast with the one we have inherited from Smalltalk. The
> >> performance of the two would be interesting to compare, as would be the
> >> number of source lines of code, as well as that foggy "legibility" thing.
> >>
> >
> > We've been so busy on the other thread(s), I forgot to show you this
> > (just a starting point, but still):
> >
<snip>
More information about the Cuis
mailing list