Duplicate? I knew somebody must've done this before.
Programming a programming language in itself is something that has interested me since I knew what a programming language was. So I thought I'd create a Code Golf challenge for you.
Create an interpreter for a given programming language, programmed entirely in itself. The interpreter should be able to run any valid program in that language, including itself.
The program can take it's input as a file passed as a parameter (e.g.
python myfile.py) or as lines from stdin (
cat myfile.py | python).
Whatever an interpreter would normally output, on the correct streams (stdout, stderr etc.)
- The code needs to be written in an interpretable language, and serve as an interpreter for its own language.
- It can't use an
eval()function to interpret code.
- It must run any valid program in that language. If the language allows external modules (or includes), it must be able to read those modules.
- This task is code golf. The submission with the least characters that is correct wins. In case of a tie, the solution that was submitted first wins.
- Yes, if you can interpret Java, Bytecode or HQ9++ in themselves, go ahead!
<script>is not allowed.