iris

small scheme interpreter
git clone git://git.2f30.org/iris
Log | Files | Refs | LICENSE

commit 03ece0a99e28d8ccfe582569ded57988fbae8515
parent 17c7caca5822e8c7e266b4a1717109ca5989714d
Author: sin <sin@2f30.org>
Date:   Mon, 19 May 2014 18:13:33 +0100

Make iris work non-interactively as well

Diffstat:
Mrepl.c | 14++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/repl.c b/repl.c @@ -1,20 +1,26 @@ /* See LICENSE file for copyright and license details. */ #include <stdbool.h> #include <stdio.h> +#include <unistd.h> #include "parser.h" int main(void) { + int interactive = isatty(0); + init(); - puts("Welcome to iris - use ^C to quit"); + if (interactive) + puts("Welcome to iris - use ^C to quit"); do { - printf("> "); - fflush(stdout); + if (interactive) { + printf("> "); + fflush(stdout); + } print(eval(sexpression(stdin))); putchar('\n'); fflush(stdout); - } while (1); + } while (!feof(stdin)); /* not reachable */ return 0; }