A SIMPLESEM Interpreter
In my Programming Languages course, taught by Shannon Tauro we have been using a fake assembly language of sorts called SIMPLESEM to gain experience translating the semantics of a high level programming language, to a simple processor.
Since SIMPLESEM is a made up language that was created just for our textbook, there was no way for me to execute the SIMPLESEM programs that I was writing for the homework assignments. This was annoying because SIMPLESEM is a low level language which makes it hard to notice mistakes. Of course, it is very easy to make a mistake any time you are programming but it is even harder to catch those mistakes if you are working at close to assembly level.
As a fun exercise I implemented an interpreter for SIMPLESEM using Ruby and published it as a RubyGem. Fortunately, I choose to use Nathan Sobo’s Treetop gem to aide in the development. Using Treetop, I wrote a parsing expression grammar to parse SIMPLESEM commands. This resulted in my SIMPLESEM interpreter being a lot more flexible than I had originally anticipated. After I familiarized myself with the basics of writing Treetop grammars I found it very easy to make changes to my grammar definitions to add language features one by one.
Installing the SIMPLESEM interpreter should be easy if you are on Linux or OS X, and possible if you are on Windows. The program is packaged as a rubygem. *nix folks should have rubygems packaged with their system. Windows users should visit the RubyGems page to get running. Once you are setup with RubyGems, install the simplesem gem from Gemcutter:
$ sudo gem install simplesem --source http://gemcutter.org
The gem installs a command called simplesem. To test it out download this sample SIMPLESEM program that prints “hello world!” five times. Run it by passing the name of the file as an argument to the command.
$ simplesem hello-world.txt hello world! hello world! hello world! hello world! hello world!
You can view other sample SIMPLESEM programs here. To learn more about SIMPLESEM or the interpreter check out the README.
-
SIMPLESEM Interpreter - Source code available on GitHub.
Comments
One Response to “A SIMPLESEM Interpreter”
Leave a Reply

[...] writing unit tests for my simplesem interpreter, one test in particular was problematic. In simplesem, the set write instruction prints output to [...]