Making a simple programming language – preramble

I’m just cleaning up the code for the first article in my planned series. In particular I scrubbed C++0x from it, because not everyone will support it.

Cleanup

I’m debating on whether to add extensive comments. I intend for this to be aimed at people who know C++, but the question is how well. I make liberal use of the standard library data structures and algorithms. I’m planning on keeping it a mid to high level discussion of the various problems and my solutions to them. I do plan to discuss the implementation itself but not in exhaustive detail.

Publishing Schedule


I think it will be worth taking some time to write up this base code, as it presents the foundation of the rest of the series. It is simple enough. For the moment, I support number literals and functions defined in C++. There are a small set of functions predefined, including the basic math operators and a print and println function. A function can be passed to another, but this isn’t particularly useful yet. It does allow one to implement a library function like std::accumulate(), where the operation to be run is specified as part of the data. I’ll probably have to split the initial implementation into three or so articles to keep them short and readable.

Implementation Stuff

So far I’ve implemented a simple value based system, everything is passed and returned by value. Functions are hard coded at compile time. This means that multiple invocations of a function will incur copies. This is fine at the moment as a function is just a string and a function pointer, but when I move to support user defined functions I don’t want to be needlessly be copying them around.

The current implementation merely starts a REPL interpreter. There is no support as yet for loading from a file or any command line parameters at all.

Show me the Code!

The code is available on github: https://github.com/rip-off/rasp-lang. I haven’t put in a build system or committed the Visual Studio project files as yet. I’m testing it on Linux too, so I’m not sure how I’m going to do that just yet.

Onward!

Leave a comment