Simple Interpreter
From AlanMacek.com
Summary
This program is an interpreter for a simple programming language. It type checks and has informative error messages. It uses 'Bison' and 'Flex' to create the parser. The type checker and interpreter are written in C++. I wrote it mostly to see if I could. At this time it has very little practical use.
Author:
Language:
The program is written in C++.
Requirements:
Warranty:
This software comes with absolutely NO WARRANTY. Use this software at your own risk. If you come across any problems please let me know but I take no responsibility for any problems or damage that may happen.
Download:
- interpreter-1.0.tar.gz (8.6 k)
- If you do not have access to Bison and Flex you can download their output (grammar.h, grammar.cpp, lexical.cpp). I encourage you to find access to Bison and Flex so you can easily modify the grammar of the simple language.
License
Emailware - please check out the program and source code. Send me an email if you plan on using it or modifying it.
Acknowledgements
This project grew out of a class I took on Programming Languages at the University of British Columbia (CPSC 311 taught by Gregor Kiczales). The simple language and interpreter ideas are straight out of the interpreter we wrote in class (in Scheme) but the implementation in C++ is my own.
Other Notes:
- Programming Style - general poor. There should be more comments (maybe I'll add more at some time) and the program has huge memory leaks.
- Porting - this program should work without changes on Unix. If you make the change mentioned in the 'Readme' file, it will work on Linux. I have also got it working on Windows 95 with Visual Studio 5.0. The only changes necessary are the equivalent of change in the 'Readme' file and to comment out line 26 of 'lexical.cpp' ("#include < unistd.h >"). Let me know of any successes or problems.
Examples:
let x = 5 in xResult Type: int
Result Value: 5
let p = proc (int a) if =(a, 5) then false else true in call p(6)Result Type: bool
Result Value: true
let p = proc ([int - int] q, int a) =(call q(a), a) in call p( proc (int b) b, 5)Result Type: bool Result Value: true
let x = 3 in begin set x = 4, x endResult Type: int
Result Value: 4