forked from jonsterling/dreamtt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
012c678
commit 47398dd
Showing
7 changed files
with
57 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,41 @@ | ||
let () = | ||
print_endline "Hello, world" | ||
open Frontend | ||
open Cmdliner | ||
|
||
type options = { mode : [ `Stdin | `File of string ] } | ||
|
||
let main { mode } = | ||
match Driver.process_file mode with | ||
| Ok () -> `Ok () | ||
| Error () -> `Error (false, "encountered one or more errors") | ||
|
||
let proginfo = | ||
let doc = | ||
"A pedagogic abstract bidirectional elaborator for dependent type theory." | ||
in | ||
let err_exit = Term.exit_info ~doc:"on ill-formed types or terms." 1 in | ||
Term.info "dreamtt" ~version:"0.0" ~doc | ||
~exits:(err_exit :: Term.default_exits) | ||
|
||
let opt_input_file = | ||
let doc = "The file to typecheck. When $(docv) is -, read stdin." in | ||
let parse_dash = | ||
Term.( | ||
app @@ const @@ Option.map | ||
@@ fun str -> if str = "-" then `Stdin else `File str) | ||
in | ||
Arg.( | ||
parse_dash & value | ||
& pos ~rev:true 0 (some string) None | ||
& info [] ~doc ~docv:"FILE") | ||
|
||
let consolidate_options input_file : options Term.ret = | ||
match input_file with | ||
| Some input_file -> `Ok { mode = input_file } | ||
| None -> `Error (true, "scripting mode expects an input file") | ||
|
||
let () = | ||
let options : options Term.t = | ||
Term.(ret (const consolidate_options $ opt_input_file)) | ||
in | ||
let t = Term.ret @@ Term.(const main $ options) in | ||
Term.exit @@ Term.eval ~catch:true ~err:Format.std_formatter (t, proginfo) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
let process_file input = | ||
match input with | ||
| `Stdin -> | ||
print_endline "stdin"; | ||
Ok () | ||
| `File f -> | ||
print_endline f; | ||
Ok () |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
val process_file : [ `Stdin | `File of string ] -> (unit, unit) result | ||
(** Process a file from stdin or filename *) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -171,3 +171,5 @@ struct | |
and+ code1 = distill_ltm tm1 in | ||
R (Pair (code0, code1)) | ||
end | ||
|
||
module Driver = Driver |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,3 @@ | |
(flags | ||
(:standard -w -37)) | ||
(public_name dreamtt.frontend)) | ||
|
||
|