use winnow::prelude::*;

mod parser;
mod parser_ast;
mod parser_lexer;

fn main() -> Result<(), lexopt::Error> {
    let args = Args::parse()?;

    let input = args.input.as_deref().unwrap_or("1 + 1");
    if let Err(err) = calc(input, args.implementation) {
        println!("FAILED");
        println!("{}", err);
    }

    Ok(())
}

fn calc(
    input: &str,
    imp: Impl,
) -> Result<(), winnow::error::ParseError<&str, winnow::error::ContextError>> {
    println!("{} =", input);
    match imp {
        Impl::Eval => {
            let result = parser::expr.parse(input)?;
            println!("  {}", result);
        }
        Impl::Ast => {
            let result = parser_ast::expr.parse(input)?;
            println!("  {:#?}={}", result, result.eval());
        }
        Impl::Lexer => {
            let tokens = parser_lexer::lex.parse(input)?;
            println!("  {:#?}", tokens);
            let result = parser_lexer::expr.parse(tokens.as_slice()).unwrap();
            println!("  {:#?}={}", result, result.eval());
        }
    }
    Ok(())
}

#[derive(Default)]
struct Args {
    input: Option<String>,
    implementation: Impl,
}

enum Impl {
    Eval,
    Ast,
    Lexer,
}

impl Default for Impl {
    fn default() -> Self {
        Self::Eval
    }
}

impl Args {
    fn parse() -> Result<Self, lexopt::Error> {
        use lexopt::prelude::*;

        let mut res = Args::default();

        let mut args = lexopt::Parser::from_env();
        while let Some(arg) = args.next()? {
            match arg {
                Long("impl") => {
                    res.implementation = args.value()?.parse_with(|s| match s {
                        "eval" => Ok(Impl::Eval),
                        "ast" => Ok(Impl::Ast),
                        "lexer" => Ok(Impl::Lexer),
                        _ => Err("expected `eval`, `ast`"),
                    })?;
                }
                Value(input) => {
                    res.input = Some(input.string()?);
                }
                _ => return Err(arg.unexpected()),
            }
        }
        Ok(res)
    }
}
