Created
January 5, 2018 09:55
-
-
Save prepor/e43e1107e0d41fd6015b66378df24d8c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open! Core | |
let format_error = function | |
| `NoInput -> "No input to parse" | |
| `SyntaxError(file, line, col) -> sprintf "Syntax error in namespace %s at line %i column %i" file (line + 1) col | |
let () = | |
let open Command.Let_syntax in | |
Command.basic | |
~summary: "parser, yeeehaa!" | |
[%map_open | |
let input = anon ("INPUT" %: file) in | |
fun () -> | |
let source = In_channel.read_all input in | |
match Orcml.parse source with | |
| Ok(parsed) -> | |
printf "Parsed:\n%s\n" (Orcml.sexp_of_ast parsed |> Sexp.to_string_hum) | |
| Error(err) -> | |
printf "Parser error: %s\n" (format_error err) | |
] | |
|> Command.run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment