forked from BranchTaken/Hemlock
-
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
Jason Evans
committed
Sep 10, 2024
1 parent
fc40cce
commit 9bb1152
Showing
5 changed files
with
7,434 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(executables | ||
(names mlc) | ||
(libraries Basis Hmc Mlc)) | ||
|
||
(install | ||
(section bin) | ||
(files (mlc.exe as mlc))) |
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,40 @@ | ||
open Basis | ||
include Basis.Rudiments | ||
open Mlc | ||
|
||
let scan_file path = | ||
let rec fn scanner = begin | ||
let scanner', tok = Scan.next scanner in | ||
File.Fmt.stdout | ||
|> Fmt.fmt " " | ||
|> Scan.Token.pp tok | ||
|> Fmt.fmt "\n" | ||
|> ignore; | ||
match tok with | ||
| Scan.Token.Tok_end_of_input _ -> () | ||
| _ -> fn scanner' | ||
end in | ||
let () = match File.of_path path with | ||
| Ok f -> begin | ||
let stream = File.Stream.of_file f in | ||
let text = Text.of_bytes_stream ~path stream in | ||
let scanner = Scan.init text in | ||
fn scanner | ||
end | ||
| Error err -> halt ( | ||
String.Fmt.empty | ||
|> Fmt.fmt "File.of_path error: " | ||
|> Fmt.fmt (Errno.to_string err) | ||
|> Fmt.fmt "\n" | ||
|> Fmt.to_string | ||
) | ||
in | ||
() | ||
|
||
let _ = | ||
match Array.length Os.argv with | ||
| 0L | 1L -> halt "mlc usage: mlc <path>" | ||
| _ -> begin | ||
let path = Path.of_bytes (Bytes.Slice.init (Array.get 1L Os.argv)) in | ||
scan_file path | ||
end |
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,6 @@ | ||
(library | ||
(name Mlc) | ||
(public_name Hemlock.Mlc) | ||
(libraries Basis Hmc) | ||
(synopsis "OCaml bootstrap transpiler library") | ||
) |
Oops, something went wrong.