Language Interpreter in PortablE
I’m sure you have noticed by my posts that I’ve been on an Amiga E language binge. More specifically I am using PortablE by Chris Handley, which I have already posted about. I’m writing PortablE code using the AROS operating system.
Chris asked me what I would like to write in PortablE. I told him how I have always wanted to learn how to create my own programming language, but I needed more experience. He basically said I should just start trying to do it and learn that way. Chris has actually taken me under his wing and has been helping me with it. I am blessed that he has taken the time to help me with this. I cannot thank him enough.
So, Chris took his knowledge of parsers and wrote a very simple toy interpreter in PortablE. We have been calling it the toy interpreter for now. He sent it to me and explained that it could only parse a PRINT command in a file named code.txt. You could only print numbers with it. This gave me a great starting point. I studied the code carefully. I had to look up many statements, because I didn’t know the PortablE language yet. But it turned out to be a very good learning experience.
Chris commented the code well too. This helped me while tracing through the code trying to figure out what it was doing.
My next challenge was to make the interpreter understand how to print a string and not just a number. I studied the interpreter code many times and finally realized what I needed to change to make it print a string. I had an old code file of the toy interpreter that Chris had sent me to compare to see if I was correct in my thinking and I was. Chris has made some adjustments to improve the code as we have worked our way through this. He plans to include the toy interpreter as an example when he officially releases PortablE.
Of course this is just a start and I have many more features to add to this. I plan to keep making additions to the interpreter and expand my learning experience even further. I am really enjoying the PortablE/Amiga E style of programming.
If your reading this thinking, “what about Lisp?”. I haven’t quit using Lisp. I plan to split my time between PortablE and Common Lisp. I think my experience so far with this interpreter will help me when I try to write parsers in Common Lisp. I’m feeling very comfortable about concentrating on these two languages. Besides Lisp, I have been trying out many different languages in the past six months and I feel like I have finally settled on these two languages.
What’s that? You want to see what PortablE code looks like? No problem at all. Here is the code for the toy interpreter so far. I’ll provide it as a link since it is too long to post. This code has parseLET() included, but I have not worked with it yet. I was concentrating on the PRINT command first.
No comments yet
Leave a reply