mreichelt / monkey-dart

Writing an interpreter for the Monkey 🐒 language in Dart
BSD 2-Clause "Simplified" License
28 stars 2 forks source link

Make `monkey` program support stdin/stdout/stderr properly #5

Open mreichelt opened 7 years ago

mreichelt commented 7 years ago
# Wouldn't it be beautiful if we could run monkey programs like this?
echo 'let a = 42; a;' | monkey

# or how about this?
monkey < helloworld.monkey

# or maybe even accept a program file as argument?
monkey helloworld.monkey

# and maybe even pipe the stdout to another file/process!
monkey helloworld.monkey | grep 'hello world'

Everything is possible! This version of the program should not simply start a REPL, but simply interpret the code and quit - without any extra strings polluting stdout or stderr.

Maybe we can add a command-line parameter -i for starting an interactive mode (which would be the REPL for now).