There are many challenges that say "interpret X", where X is a simple language. In my opinion, that is way too boring. To give all the procrastinating people on the internet something interesting to do, you can try to do this challenge:
Challenge
Choose a language $LANG
. $LANG
can be any turing complete programming language or a turing complete subset of a programming language. Beware that if you omit a feature of your language in $LANG
for interpretation, you must not use it for your own program, too, since your submission must be written in $LANG
, too.
Write a compiler / interpreter for $LANG
written in $LANG
. You may use all facilities (including eval
and friends) of your language that are available to write this compiler. To make the task more challenging, there is one restriction: You program should be able to interpret / compile all valid programs of $LANG
except your interpreter / compiler itself. If it occurs that the program to be interpreted / compiled is your interpreter or compiler itself (regardless of the filename), your program should do something completely unrelated to the functionality of an interpreter or compiler (such as barfing or printing Hello, world!
).
To make this task even more complex, your program must not read its own source when compiling or interpreting.
Specifications
- 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.
- Your program / script should read the program to be interpreted from a file. You may hardcode its path and name. When the file is read, you may either compile the file to another file (That must be executable on your system) or run it directly. If
$LANG
lacks file-reading capabilities, you can choose another way to read in the code that fits$LANG
. You may not choose$LANG
as a subset of another language but with file-reading capabilites removed. - Usual code-golf rules apply. That is: your personal pet-language that you made up just to solve this challenge is forbidden, if the solution becomes trivial using it (Such as defining a single-char program that exactly implements the solution). Abuse of rules is encouraged.