a parser of Web IDL
latest version v1.4 surrpots Web IDL Editor’s Draft, 6 August 2018
opam install webidl
- gen-bs is a sample application which uses this library
- convert Web IDL files to a bucklescript code
- an example code is the below.
let () =
try
Webidl.Parse.data_from_file "file.idl" (* 1. *)
|> Webidl.Parse.show_data (* 2. *)
|> print_string
with
| Webidl.Parse.Syntax_error e -> (* 3. *)
print_string "[!]Syntax Error\nInfo:\n";
Webidl.Parse.show_syntax_error e (* 4. *)
|> print_string
|> print_newline
-
Webidl.Parse.data_from_file
This function parses webidl from file and generate OCaml data which expresses the webidl.
The OCaml data is difined in src/lib/data.ml. Please see it if you would like to know details.
You can access webidl by this result. -
Webidl.Parse.show_data
print parsed webidl data. -
Webidl.Parse.Syntax_error e
if there is an syntax error,exception Syntax_error
is raised.e
is a record which is defined in src/lib/parse.ml -
Webidl.Parse.show_syntax_error
print infomation of parse error