Library to parse JavaScript in opam?

It’s fairly easy:

$ opam pin add flow_parser https://github.com/facebook/flow.git
[flow_parser.0.80.0] synchronised from git+https://github.com/facebook/flow.git
flow_parser is now pinned to git+https://github.com/facebook/flow.git (version 0.125.1)
... # prompts to continue rest of install
$ utop
utop # #require "flow_parser";;
utop # Parser_flow.program "var x = 1;";;
- : (Loc.t, Loc.t) Flow_ast.Program.t * (Loc.t * Parse_error.t) list =
... (* the parsed AST here *)

The AST is pretty noisy with location info, but it seem to work :slight_smile:

5 Likes