package morbig

  1. Overview
  2. Docs

Module MorbigSource

Main API points

Parsing shell scripts
Sourceval 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.

Raises exceptions from Errors.

Sourceval 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.

Serialization of CST
Sourceval load_binary_cst : in_channel -> CST.program

load_binary_cst cin retrieves a serialized CST from input_channel cin.

Sourceval save_binary_cst : out_channel -> CST.program -> unit

save_binary_cst cout cst stores a serialized cst in cout.

Sourceval load_json_cst : in_channel -> CST.program

load_json_cst cin retrieves a CST in JSON format from input_channel cin.

Sourceval save_json_cst : out_channel -> CST.program -> unit

save_json_cst cout cst stores a cst using JSON format in cout.

Sourceval save_dot_cst : out_channel -> CST.program -> unit

save_dot_cst cout cst stores a cst using DOT format in cout.

CST helpers
Sourceval on_located : ('a -> 'b) -> 'a CST.located -> 'b

on_located f applies f on a located value, preserving its location.

Sourceval start_of_position : CST.position -> Lexing.position

start_of_position p returns the beginning of a position p.

Sourceval end_of_position : CST.position -> Lexing.position

end_of_position p returns the end of a position p.

Sourceval filename_of_position : CST.position -> string

filename_of_position p returns the filename of a position p.

Sourceval 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.

Sourceval remove_quotes : string -> string

remove_quotes s yields a copy of string s, with all quotes removed as described in the POSIX specification.

Other modules

Sourcemodule Aliases : sig ... end
Sourcemodule Assignment : sig ... end
Sourcemodule CSTHelpers : sig ... end
Sourcemodule CST : sig ... end
Sourcemodule Debug : sig ... end
Sourcemodule Engine : sig ... end
Sourcemodule Errors : sig ... end
Sourcemodule ExtMenhirLib : sig ... end
Sourcemodule HereDocument : sig ... end

HereDocument.Lexer handles here documents. It does:

Sourcemodule JsonHelpers : sig ... end
Sourcemodule Keyword : sig ... end
Sourcemodule Name : sig ... end
Sourcemodule Nesting : sig ... end
Sourcemodule Options : sig ... end
Sourcemodule Parser : sig ... end
Sourcemodule Prelexer : sig ... end

This module implements the token recognizer when it is not in the mode that recognizes here-documents, and in cases where the recognition of tokens is independent from the parsing context, as specified by:

Sourcemodule PrelexerState : sig ... end
Sourcemodule Pretokenizer : sig ... end
Sourcemodule Pretoken : sig ... end
Sourcemodule QuoteRemoval : sig ... end
Sourcemodule RecursiveParser : sig ... end
Sourcemodule Scripts : sig ... end
Sourcemodule Token : sig ... end
OCaml

Innovation. Community. Security.