#!/usr/bin/perl -w

use Lisp::Reader      qw(lisp_read);
use Lisp::Printer     qw(lisp_print);
use Lisp::Interpreter qw(lisp_eval);
use Lisp::Symbol      qw(symbol);

use Lisp::Subr::All;  # make builtins available

use Getopt::Std;
use vars qw($opt_v $opt_f);

unless (getopts("vf:")) {
    $0 =~ s,.*/,,;
    die "Usage: $0 [-v] [-f <file>] <forms>...\n";
}

$Lisp::Interpreter::DEBUG++ if $opt_v;


$text = "";
$text = `cat $opt_f` if $opt_f;

if (@ARGV) {
    $text .= "@ARGV";
}

my $form = lisp_read($text);
unshift(@$form, symbol("progn")) if ref($form->[0]) eq "ARRAY";

#print lisp_print($form), "\n";

my $res = lisp_eval($form);
print lisp_print($res), "\n";
