Module API
module API: sig
.. end
This interface defines the API of Morbig
Parsing shell scripts
val parse_file : string -> CST.program
parse_file filename
performs the syntactic analysis of
filename
and returns a concrete syntax tree if filename
content
is syntactically correct.
Raise or otherwise.
val parse_string : string -> string -> CST.program
parse_string filename content
is similar to parse_file
except the
script source code is provided as a string.
module Errors: sig
.. end
Errors
Serialization of CST
val load_binary_cst : Pervasives.in_channel -> CST.program
load_binary_cst cin
retrieves a serialized CST from
input_channel cin
.
val save_binary_cst : Pervasives.out_channel -> CST.program -> unit
save_binary_cst cout cst
stores a serialized cst
in cout
.
val load_json_cst : Pervasives.in_channel -> CST.program
load_json_cst cin
retrieves a CST in JSON format from
input_channel cin
.
val save_json_cst : Pervasives.out_channel -> CST.program -> unit
save_json_cst cout cst
stores a cst
using JSON format in cout
.
val save_dot_cst : Pervasives.out_channel -> CST.program -> unit
save_dot_cst cout cst
stores a cst
using DOT format in cout
.
CST helpers
val on_located : ('a -> 'b) -> 'a CST.located -> 'b
on_located f
applies f
on a located value, preserving its location.
val start_of_position : CST.position -> Lexing.position
start_of_position p
returns the beginning of a position p
.
val end_of_position : CST.position -> Lexing.position
end_of_position p
returns the end of a position p
.
val filename_of_position : CST.position -> string
filename_of_position p
returns the filename of a position p
.
val string_of_lexing_position : Lexing.position -> string
string_of_lexing_position p
returns a human-readable
representation of the lexing position p
, using a format
recognized by Emacs, and other decent editors.
val remove_quotes : string -> string
remove_quotes s
yields a copy of string s
, with all
quotes removed as described in the POSIX specification.