[OT] Writing a parser for BASIC in Smalltalk/Squeak ?

Richard A. O'Keefe ok at atlas.otago.ac.nz
Tue Jan 15 01:24:52 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... 

About 5 or 6 years ago I supervised a student whose self-chosen honours
project was to write some kind of software tool for analysing a whole lot
of programs his company had in their own object-oriented extensions to
DEC Basic (now Compaq Basic).

He learned a lot about lex and yacc (and many programming languages from
Ada to Haskell have something similar by now), but the project foundered.
Not his fault, he didn't fail.  He succeeded in learning.

No, the problem was that the documentation for DEC Basic just plain
wasn't good enough.  It provided syntax, but was massively unclear about
semantics, and I'm talking about the reference manual.  Actually, it wasn't
as clear as it could have been about syntax either.

You'll find advice about object-oriented compiling in lots of places,
like Sigplan notices, OOPSLA, and of course by reading the Squeak
compiler.

I've written a few parsers in C for legacy languages using Lex and Yacc,
and while it's true that Lex is stunningly short compared with hand-coded
C (and Smalltalk isn't going to be any shorter than Lex), in legacy languages
you keep running into things that give Lex a hard time, and you end up writing
a hand-coded lexical analyser anyway.  Yacc can usually cope.  The same is
likely to be true for doing things in Smalltalk.

I don't think you are going to find designing the parse tree data structure
or writing the parser the hard part.

I think you are going to find decoding all the details, and then discovering
all the little quirks that aren't in the current manual but the existing
programs exploit anyway, to be the VERY hard part.



More information about the Squeak-dev mailing list