Stack Snippets were recently added to PPCG! Reminiscent of JSFiddle, Stack Snippets allow HTML, CSS, and JavaScript to be run directly in posts!
Here is a very simple Stack Snippet:
alert('This is JavaScript')
h3 { color: red } /* This is CSS */
<h3>This is HTML</h3>
This feature of Stack Exchange would be very useful for us if languages besides JavaScript were supported. (The answers to challenges could be tested on the spot, example inputs could be generated dynamically, etc.) This is where you come in.
Challenge
The goal of this challenge is to write an interpreter for some programming language using Stack Snippets and JavaScript. The point is to make something that can be easily copied and used in future PPCG questions and answers.
More or less, you need to create a Stack Snippet that has a "run" button and two textboxes, one for code and one for input. Clicking the run button will execute the code (written in the language you're interpreting) on the input and display the result (probably in another textbox). The snippet should be something akin to cjam.aditsu.net or the sample answer.
For most languages it would make sense for the input and output to represent stdin and sdout respectively, and you might have another input box for the command line. But not all languages have have such traditional I/O mechanisms. HQ9+, for example, doesn't even have input, making a textbox for it pointless. So feel free to take some liberties, design around the language, not this spec. The main requirement is that your language be "runnable" in a Stack Snippet in the accepted sense of the term.
Notes
- Implementing every single feature of your language, though ideal, is not required. Some things like reading and writing files or importing libraries may be unwieldy or impossible. Focus on making an interpreter that maximizes utility for use on this site.
- Posting a "language X to JavaScript" interpreter that you didn't write is ok (with attribution).
- Stack Exchange limits answers to 30,000 characters, so plan accordingly if your interpreter is likely to be long.
- It is best that you make a version of your interpreter as easy as possible to include in future posts. For example, in the sample answer, the raw Markdown for the entire snippet is provided, with obvious places to put code and input.
Although this question is intended to be more a compendium of interpreters than a proper challenge, it is still a popularity-contest, so the highest voted answer wins.
List of Current Interpreters
(sorted alphabetically by language name)
- Brainfuck
- Deadfish
- JavaScript (sample answer)
(This question might be better suited for Meta but it will be more visible here. People might actually produce very useful interpreters, I think they deserve the rep for it.)