Propellisp - A Scheme compiler for the Propeller
toroidalcode
Posts: 4
Hi there! This is my first real forum post ever for anything so I'm a little nervous, but here goes:
I'm writing a Scheme compiler that targets Propeller 1 and (hopefully/eventually) Propeller 2. I've been working on this for about two weeks now, on again - off again sort of work due to school, but progressing nonetheless. It's nowhere near useful (doesn't even have a heap yet), but it's usable for small computations and interesting math.
I'm curious what sort of responses the community has. Would people be interested in seeing a compliant Scheme running on the Propeller? Even if I could only support a small subset of the spec due to space or computation limitations, would there still be interest?
If you'd like more info, I recommend looking at the repo here: https://github.com/toroidal-code/propellisp , as it has much more than I'm putting here.
Also, if people are interested in assisting in development, the project is open-source and MIT-licensed, and pull-requests/patches are always more than welcome.
Thanks!
I'm writing a Scheme compiler that targets Propeller 1 and (hopefully/eventually) Propeller 2. I've been working on this for about two weeks now, on again - off again sort of work due to school, but progressing nonetheless. It's nowhere near useful (doesn't even have a heap yet), but it's usable for small computations and interesting math.
I'm curious what sort of responses the community has. Would people be interested in seeing a compliant Scheme running on the Propeller? Even if I could only support a small subset of the spec due to space or computation limitations, would there still be interest?
If you'd like more info, I recommend looking at the repo here: https://github.com/toroidal-code/propellisp , as it has much more than I'm putting here.
Also, if people are interested in assisting in development, the project is open-source and MIT-licensed, and pull-requests/patches are always more than welcome.
Thanks!
Comments
I know nothing about lisp, but it sounds like a great project.
I hope others that are able will help you in the development.
Bean
For new learners, small is beautiful. These days, entering programing on a PC often buries the new learn in the vast resources available.
So this may be a very useful presentation for Lisp.
It will be interesting to see what sort of projects people will come up with for Lisp on the Propeller. With Algol family languages you are always dealing with numeric data types. Everything is ultimately a number. The first time I wrote a Lisp program was mind blowing because it didn't have a single number in it! Instead it was all about symbolic problem solving without any concerns for a numeric value for the symbols. Certainly you can deal with numbers with Lisp, but you don't have to.
Thanks for the support! I'll keep working on the this summer, as time allows. We'll see if I have anything good done by the time school rolls around again. I'll keep posting updates on this thread, if people are interested in that sort of thing.
David:
Right now, there aren't any plans to have the compiler be able to run on the Propeller itself, though it would be very interesting to see something like that happen. I could imagine eventually having a dedicated cog for emission, but at that point it wouldn't be emitting ASM anymore, it would have to be pure bytecode for the Prop. There's are some complexities in trying to get it running on that level, because I'd have to emulate a lot of what propgcc's GCC/AS is doing. Currently Petite Chez actually does all the really heavy lifting for me. Since it's a Lisp, evaluating Lisp, there's next to no lexing or parsing to be done. Abstract Syntax Tree-ish nodes are determined based on simple predicate testing and then the assembly is put together using a recursive-descent system. Though, if I got this compiler to be able to handle the full R6RS spec (the one I'm using for assembly emission code), one could theoretically compile the compiler source (with the modified bytecode emission) and run it on the Propeller. There's a lot of theoretical in there, so I wouldn't count on it happening for at least a while, if ever, haha.
So for now the compilation is going to happen all on the computer side, the way GCC and other compilers work, because with a microcontroller, that's the easiest model to use.
Yeah, having a working REPL running on the processor isn't really an immediate goal. Scheme is actually less interpreted than Common Lisp is, with compilers like Chicken, Stalin, and Ikarus, which don't always have an interpreter. The paper I'm working with is actually by the same person who wrote Ikarus, which compiles directly to x86/x86_64 assembly, similar to what I'm doing here. Petite Chez, and I think Racket, on the other hand, are both interpreted. Chicken also has an interpreter. It's just a choice of backend. It's much easier to deal with separate compile/assemble/link steps in this project, where some of those are managed by existing tools.
If I really wanted to write a super-robust compiler, I'd go about doing it completely differently, with a Flex lexer and a Bison-based parser, building up the AST and then mapping the AST nodes to emitted Intermediate Representation, and then transforming the IR to ASM using the LLVM or GCC backends, and then assembling and linking the binary. But I'm not nearly that skilled or knowledgable yet, and this is a first attempt at writing a simplistic compiler.
Eventually though, one might be able to implement a REPL on the Propeller, since, if I remember correctly, a REPL is just where read would take from a serial connection, and display would send to the same. Eval is where it would be tricky, since that would have to execute the commands on the Propeller.
We'll have to see. I'm still new to all this
Yeah, it's certainly possible, it's just not something I'm going to focus on right now. I'm having trouble enough dealing with basic features like stack allocation. There's not even proper vector/pair support because of that. I'll have to see how the basic stuff goes before I get to the complex, haha.