[OT] Writing a parser for BASIC in Smalltalk/Squeak ? (<CSOTD> included)

goran.hultgren at bluefish.se goran.hultgren at bluefish.se
Fri Jan 4 08:28:46 UTC 2002


"Andy Stoffel" <Andrew.Stoffel at jenzabar.net> wrote:
> This is very off-topic (I think anyway)... 
> 
> I was wondering if anyone has any links/sources/information pointers
> on writing a parser for other languages in Smalltalk ? Even just a 
> starting point would be useful... 
[SNIP]

A few years back I developed a "Smalltalk to
A-strange-bastard-of-BASIC-and-Pascal translator".
I used T-Gen with VisualWorks back then and since the code was all
"numbers, strings and dates" with a
bunch of functions included it was trivil to actually translate it into
running Smalltalk code.

I read later in the thread that you want to do other stuff to
(flowcharts etc) but anyway - if you have the parsetrees for the BASIC
code I think it would be almost trivial to generate Smalltalk and that
code you can run and debug in Squeak! Which perhaps would give you even
more insight.

Anyway, just my 2 cents.

regards, Göran

<CSOTD>"This one actually is borrowed from Leandro Caniglia. He
challenged me yesterday
to figure out why the method SmallInteger>>gcd: actually works. The
challenge can also be expressed
like this: Evaluate this code below and figure out why n=5.
One could ask oneself if the assignment (m _ n) is performed after or
before the
evaluation of the expression?
If it is done before - then n should become 4 right? (2 + 2)
And if it is done after then it should become 6... (3 + 3)
Gurus: don't spoil it for the newbies ok? Let them chew on it for a
while... :-)"
| m n |
n _ 2.
m _ 3.
n _ m + (m _ n)
</CSOTD>




More information about the Squeak-dev mailing list