Archive for August, 2008

Nesting Quotes

Posted in Uncategorized with tags on August 20, 2008 by bbarrett

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. Continue reading

One step forward, X steps backward.

Posted in LISP, programming with tags on August 18, 2008 by bbarrett

I’ve made some progress, but I think I’m after hitting a wall I didn’t anticipate. For your consideration, I will first post what I have working, then I’ll briefly discuss what isn’t and why I’m going in the wrong direction.
Continue reading

More work.

Posted in Uncategorized with tags on August 13, 2008 by bbarrett

Short update.

I’ve gotten local variables and function arguments to work, along with introducing a boolean type. And lambda. However, I’ve seen some serious flaws in how my current system handles complex literals. This impacts any code that will depend on them, such as versions of defun and if which don’t take strings as arguments. To counteract this, some serious restructuring of my parser may be required, and a lot of rethinking done. I spent between 4 and 5 hours today on a bus, so I have a few A4 pages full of notes and ideas that I think I might be able to manage. I have already begun to implement some of it.

What I have done now is made a complete “guess the number” game that I want to be able to compile. Over the next few days I’ll try my hardest to focus on features that are necessary to make it work. When that is done, I might write up a post on however the system works as of then. Looking over the last few entries, I am not happy with them. They are too focused on what I have working, not how I got them working – which is what I intended to write about. In the mean time though, I need sleep.

Conditionals and Functions, Oh My!

Posted in Uncategorized with tags on August 10, 2008 by bbarrett

Ok, with a bit of effort (and excessive quoting) I have conditionals working, and LISP functions. Until I make the parser programmable, any expressions that need delayed evaluation need to be enclosed in strings. The relevant functions (if, defun) simply use the same internal logic as eval does to evaluate the selected expressions. Currently, functions cannot take arguments, though they may return results. Recursion also appears to work!
Continue reading

More LISP

Posted in LISP, programming with tags on August 9, 2008 by bbarrett

Well, not really.

But I’ve come close:

(print (eval (readline)))

I’ve done a lot, although some of the big milestones that make a language useful aren’t finished.

Implemented to some degree:
* math functions
* list literals (I’ve fixed everything I could find with them)
* strings in quotes “”, which allow spaces and common escape characters
* multi line comments (again, lua style –[[ … ]])
* eval!

Eval is important, because using it I think I can “fake” control structures like if, while by using quoted arguments. I may even be able to implement defun. However, that would be a stop gap solution, one that I imagine would be very slow. Currently I am thinking of quoting the arguments to if and while, and just interpreting them on the fly.
Continue reading

It has been a while…

Posted in programming with tags , , on August 6, 2008 by bbarrett

A long while. Sorry. I have two excuses, a) I have a job and b) I haven’t done much programming lately.

Yesterday I have started a new project. I have been following a number of GD.net journals of late, and a number of users are making their own languages. This is an area that always fascinated me.

So my new project is such a language! Well, its not my own language – yet. At the moment I am using a syntax heavily inspired by LISP. Its been a while since I’ve used LISP, so some of the details might be different. The main reason for this is because I wanted to try my hand at writing my own parser. So far, its been pretty easy, with two notable exceptions. The first is the most pressing, error handling. Right now I have no way of reporting to the user which line a syntax error occurred on. The second is a minor one, list literals. At the moment, the parser will deep scan a list literal and find non literals inside it, whereas my intention is that it should eventually only find number, string and nested list literals inside a list literal. It shouldn’t be too hard to fix the latter, but I may have to make some larger changes to make a clean way of implementing the former.

For the moment, the actual runtime is coming along very well. I’ve gotten the following to work nicely:
Continue reading