Nesting Quotes

Its been slow going, adding small bits here and there. I’m most of the way there, I just need to re-integrate the macro handling system back into the compiler. I have added a preprocessor that replaces the quoted literals like ‘X with the macro (quote X). This allows nested quoted literals to survive the parsing process, which didn’t happen before. Before, a quoted literal meant the parser entered a different mode whereby it only scanned lists, atoms, numbers and strings. This resulted in a long literal. While nested lists could be present, there was no way to tell if these nested lists were originally quoted. This has obvious implications for functions, for example:

(defun min (a b)
(if (< a b) a b) ) [/sourcecode] To the old compiler, if the macro system was correct and not a total hack, it would have produced something akin to this: [sourcecode lang="cpp"] (defun 'min '(a b) '(if '(< a b) a b) ) [/sourcecode] Obviously the nested quote would have been lost. In the new system, we have: [sourcecode lang="cpp"] (defun (quote min) (quote (a b)) (quote (if (quote (< a b)) a b)) ) [/sourcecode] The compiler can then correctly handle the nested structure. This is what I have working (it produces such a string as a mid-stage) but currently the macro system isn't working, so quote is treated as a function whose arguments tend to fail to compile by themselves. The above code produces an error about 'min' not having a value. I am hopeful that this last restructuring effort will be easy enough. The new system should be less complicated to parse, and once all the legacy cruft is removed could be simpler to compile too. For the moment now, any program that uses the quote feature is broken until I finish this. So no snippets today.


2 Responses to “Nesting Quotes”

  1. Wow! I’ve been majorly neglecting reading journal over the last month, and you’ve been tinkering away at this bombshell for the last few weeks. 🙂

    I’m really impressed at how far you’ve managed to get in such a short period of time. I’ve played around with the same thing before (albeit Scheme rather than Lisp), but it didn’t get as far as your experiment here. Perhaps you should consider rolling out some articles on the topic!

  2. Well, that was sort of what I had planned. Not an article, but rather a in-depth analysis of my current implementation, what I’m happy with and what I am not, etc.

    I’ve hit a block now. I have everything looking like its working, but then it won’t. Some odd problems with scopes and variables, possibly related with how my macro hack is working (or… not working). My energy that got the project off the ground is draining trying to track down this bug, especially because I think I have some kind of throat problem or something, and between work (I work in a customer support center for a mobile phone network in Ireland, fun with the throat thing) and that the energy is a bit low at the moment. However, I am finishing up work in a week, so I should have more time then to dive into this project. I have made progress, but I’m close enough that I’ve been putting off writing an update until I’m over this hurdle.

    But thank you for your comment anyway, nice to know someone reads.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: