open Parser open Evaluator open System.IO let usage() = printfn "Usage: dotnet run [debug]" printfn "where" printfn " is a Blub program" printfn " [debug] is \"true\" or \"false\" (or false if omitted)" exit 1 [] let main argv : int = (* Check for proper usage *) if argv.Length <> 1 && argv.Length <> 2 then usage() (* read in the input file *) let file = argv[0] if not (System.IO.File.Exists file) then printfn $"ERROR: Cannot find file '{file}'." usage() let input = File.ReadAllText file (* does the user want parser debugging turned on? *) let do_debug = if argv.Length = 2 && argv[1] = "true" then true else false (* try to parse what they gave us *) let ast_maybe = parse input do_debug (* try to evaluate what we parsed... or not *) match ast_maybe with | Some ast -> eval ast Map.empty |> ignore 0 | None -> printfn "Invalid program." 1