about summary refs log tree commit diff
path: root/src/main.rs
blob: d476b96ed6349eeb27f991f55f9f57dcbd6fcfbb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#![feature(str_split_once)]

use clap::Clap;

pub mod ast;
pub mod codegen;
pub(crate) mod commands;
pub(crate) mod common;
pub mod compiler;
pub mod interpreter;
#[macro_use]
pub mod parser;
pub mod tc;

pub use common::{Error, Result};

#[derive(Clap)]
struct Opts {
    #[clap(subcommand)]
    subcommand: Command,
}

#[derive(Clap)]
enum Command {
    Eval(commands::Eval),
    Compile(commands::Compile),
    Check(commands::Check),
}

fn main() -> anyhow::Result<()> {
    let opts = Opts::parse();
    match opts.subcommand {
        Command::Eval(eval) => Ok(eval.run()?),
        Command::Compile(compile) => Ok(compile.run()?),
        Command::Check(check) => Ok(check.run()?),
    }
}