#!/usr/bin/perl

use 5.012;
use experimental 'switch';

use Mylisp;
use Mylisp::LintMyAst;
use Mylisp::ToPerl;

my $mylisp_file = $ARGV[0];

sub MyToPerl {
  my $file     = shift;
  my $code     = read_file($file);
  my $ast      = MyToAst($code);
  my $lint     = LintMyAst($ast);
  my $perl_str = AstToPerl( $lint, $ast );
  return $perl_str;
}

my $flag = $ARGV[0];
my $file = $ARGV[1];
given ($flag) {
  when ('-repl') { SppRepl() }
  when ('-update') { UpdateSppAst() }
  when ('-spp') { Spp($file) }
  when ('-toperl') { say MyToPerl($file) }
  when ('-parse') {
    my $target = $ARGV[2];
    say Parse($file, $target);
  }
  default {
    say 'mylisp -repl';
  }
}

