Hi all. I am watching Principle of Programming Languages series on youtube. I would like to see how
https://github.com/rescript-lang/syntax is implemented. But I am not able to figure out the starting point of the program where it takes a file and returns an AST.
I cloned this syntax repo. How can I run this example?
October 26, 2020, 8:13pm
Not sure what you mean exactly, but this is the starting point of the rescript parser CLI:
("-ppx", Arg.String (fun txt -> ppx := txt), "Apply a specific built-in ppx before parsing, none or jsx. Default: none");
(* ("-report", Arg.String (fun txt -> report := txt), "Stylize errors and messages using color and context. Accepts `Pretty` and `Plain`. Default `Plain`") *)
let parse () = Arg.parse spec addFilename usage
module CliArgProcessor = struct
type backend = Parser: ('diagnostics) Res_driver.parsingEngine -> backend [@@unboxed]
let processFile ~isInterface ~width ~recover ~origin ~target ~report:_ ~ppx filename =
let len = String.length filename in
let processInterface =
isInterface || len > 0 && (String.get [@doesNotRaise]) filename (len - 1) = 'i'
let parsingEngine =
match origin with
| "reasonBinary" -> Parser Res_driver_reason_binary.parsingEngine
| "ml" | "ocaml" -> Parser Res_driver_ml_parser.parsingEngine
| _ -> Parser Res_driver.parsingEngine
Here is the relevant entry in the
The nice thing about rescript parser development is that you only need to install opam and the 4.06.1 switch, as stated in the README.