Eastern Calculus

I lied again about updating on time. At some point I'll feel guilty about it and actually stay on schedule, but I've been too busy to care. Anyway, with that said, I've been working on an interpreter for a programming language I've been thinking about creating. The concept is intended to be very low level, just pushing data on and off of the stack. The code is interpreted as a series of tokens, so it is very simple to parse.

In many ways the language is meant to mimic a kind of generic assembly, but one significant addition is a more powerful macroing system. My intention is to have macros act like regular functions, but allow them to read code as arguments, and then produce code as output. These macros can run at compile time, so in other words, the language can extend and reinterpret itself. I only have an interpreter right now, and it's not finished, so it can't do much of this yet. I'll be updating this page with my progress as time goes on.


Try playing with the example script to see what's going on. Here's a link to the source.

NOTE: there is no error handling yet; make sure all tokens are seperated by whitespace.

Usage:

You can define a constant, say x, using the (^) macro. It pops a value off the stack and binds it to x. Thereafter, the value stored at the location on the stack specified by that value gets "re-pushed" wherever the x token appears.

The ($) token pushes the stack pointer onto the stack and we can use this to bind constants to any data we push.

The (->) macro reads a token and stores a value to its location on the stack.

Some output tokens for debugging are (%i), which pops an integer and prints it, and (%^) which displays the data associated with all defined tokens.

The comment macro starts with (/*) and ends with (*/). All other macros are currently terminated using the (;) symbol, although I might change this to brackets later, for readibility.


In the future, the (?) macro will execute tokens only if a non-zero value is at the top of the stack. Some token, maybe (:), will be used to define a block of code and place a reference to it on the stack for defining macros and functions. Of course all the other basic operators like (and), (or), (not), etc. will have to be added too.