views:

244

answers:

1

I'm trying to work my way through Compilers: Backend to Frontend (and Back to Front Again) by Abdulaziz Ghuloum. It seems abbreviated from what one would expect in a full course/seminar, so I'm trying to fill in the pieces myself.

For instance, I have tried to use his testing framework in the R5RS flavor of DrScheme, but it doesn't seem to like the macro stuff:

src/ghuloum/tests/tests-driver.scm:6:4: read: illegal use of open square bracket

I've read his intro paper on the course, An Incremental Approach to Compiler Construction, which gives a great overview of the techniques used, and mentions a couple of Schemes with features one might want to implement for 'extra credit', but he doesn't mention the Scheme he uses in the course.

Update

I'm still digging into the original question (investigating options such as Petit Scheme suggested by Eli below), but found an interesting link relating to Gholoum's work, so I am including it here.

[Ikarus Scheme](http://en.wikipedia.org/wiki/Ikarus_(Scheme_implementation)) is the actual implementation of Ghuloum's ideas, and appears to have been part of his Ph.D. work. It's supposed to be one of the first implementations of R6RS. I'm trying to install Ikarus now, but the configure script doesn't want to recognize my system's install of libgmp.so, so my problems are still unresolved.

Example

The following example seems to work in PLT 2.4.2 running in DrEd using the Pretty Big

(require lang/plt-pretty-big)

(load "/Users/donaldwakefield/ghuloum/tests/tests-driver.scm") 
(load "/Users/donaldwakefield/ghuloum/tests/tests-1.1-req.scm") 
(define (emit-program x) 
  (unless (integer? x) (error "---")) 
  (emit " .text") 
  (emit " .globl scheme_entry") 
  (emit " .type scheme_entry, @function") 
  (emit "scheme_entry:") 
  (emit " movl $~s, %eax" x) 
  (emit " ret")
  )

Attempting to replace the require directive with #lang scheme results in the error message

foo.scm:7:3: expand: unbound identifier in module in: emit

which appears to be due to a failure to load tests-driver.scm. Attempting to use #lang r6rs disables the REPL, which I'd really like to use, so I'm going to try to continue with Pretty Big.

My thanks to Eli Barzilay for his patient help.

+2  A: 

The language he uses is most likely Chez Scheme. Regardless, the R5RS language in PLT is a pretty strict version of R5RS, with extensions like square brackets throwing errors -- and you may get more mileage using the default #lang scheme language. (Or, if that fails, try and see if you can work with Petit -- the free version of Chez.)

Eli Barzilay
Are [] really illegal in strict R5RS? I thought they were just specified as behaving identically to ().(Later) Yup, section 7.2 makes no mention of [], just (). So I guess they are illegal.
Nathan Sanders
Yes, they were always reserved for a "future extension", and made to be the same as "()"s in R6RS. In any case, several schemes have such an extension, but the popular request for the PLT R5RS language was to make it very strict.
Eli Barzilay
Eli, thanks for the recommendation. I'm exploring Petite Scheme, though having library problems with my Linux box. Maybe I'll have better luck with my Mac at home.Has anyone successfully installed Ikarus? I assume, originating with Mr. Ghuloum, that it tolerates [].
Don Wakefield
Well, yeah -- using Ikarus might be better, though not necessarily. (IIRC, he started working on Ikarus shortly after that.) As for []s, it will obviously deal with them since it's R6RS. But if you're stuck with that, then why not try PLT since you already have it installed and []s are it's *natural* mode of work...
Eli Barzilay
I just upgraded to PLT 2.4.2 on my home machine (the earlier version was 2.1.x), and tried switching to Pretty Big: (require lang/plt-pretty-big); since Module and R5RS both had problems with the brackets, and it seems to behave better. There is no menu pick for R6RS, however.
Don Wakefield
Re the language choice -- "Pretty Big" is really there as a legacy language. It might be fitting in your case though, in case Aziz uses `load` to combine files, but it'll just work better to translate that to plain requires since it plays better with the module system. Re the Module language, it should not have issues with brackets if you use `#lang scheme`. Finally, to use R6RS, use the module language with `#lang r6rs`.
Eli Barzilay