package morbig

  1. Overview
  2. Docs
type atom =
  1. | WordComponent of string * CST.word_component
  2. | QuotingMark of quote_kind
  3. | AssignmentMark
and quote_kind =
  1. | SingleQuote
  2. | DoubleQuote
  3. | OpeningBrace
module AtomBuffer : sig ... end
type prelexer_state = {
  1. nesting_context : Nesting.t list;
  2. buffer : AtomBuffer.t;
}
val buffer : prelexer_state -> atom list
val initial_state : prelexer_state
val at_toplevel : prelexer_state -> bool
val push_word_component : atom list -> (string * CST.word_component) -> atom list
val push_string : prelexer_state -> string -> prelexer_state
val parse_pattern : CST.word_component -> CST.word_component list
val push_character : prelexer_state -> char -> prelexer_state
val push_separated_string : prelexer_state -> string -> prelexer_state
val pop_character : atom list -> atom list
val push_word_closing_character : prelexer_state -> char -> prelexer_state

push_word_closing_character b c push a character c to mark it as part of the string representing the current word literal but with no interpretation as a word CSTs. Typically, if the word is "$(1)", the string representing the current word is "$(1)" so the character ')' must be pushed as part of this string representation but ')' is already taken care of in the word CST WordSubshell (_, _) associated to this word so we do not push ')' as a WordLiteral CST.

val string_of_word : CST.word -> string
val string_of_attribute : CST.variable_attribute -> string
val push_parameter : ?with_braces:bool -> ?attribute:CST.variable_attribute -> prelexer_state -> string -> prelexer_state
val string_of_atom : atom -> string
val contents_of_atom_list : atom list -> string
val string_of_atom_list : atom list -> string
val contents : prelexer_state -> string
val components_of_atom_list : atom list -> CST.word_component list
val components : prelexer_state -> CST.word_component list
val push_quoting_mark : quote_kind -> prelexer_state -> prelexer_state
val pop_quotation : quote_kind -> prelexer_state -> prelexer_state
val push_assignment_mark : prelexer_state -> prelexer_state
val is_assignment_mark : atom -> bool
val recognize_assignment : prelexer_state -> prelexer_state
val digit_regexp : Str.regexp

(return ?with_newline lexbuf current tokens) returns a list of pretokens consisting of, in that order:

  • WORD(w), where w is the contents of the buffer current in case the buffer current is non-empty;
  • all the elements of tokens;
  • NEWLINE, in case ?with_newline is true (default: false).

We know that tokens does not contain any Word pretokens. In fact, the prelexer produces Word pretokens only from contents he has collected in the buffer.

val return : ?with_newline:bool -> Stdlib.Lexing.lexbuf -> prelexer_state -> Pretoken.t list -> (Pretoken.t * Stdlib.Lexing.position * Stdlib.Lexing.position) list
exception NotAWord of string
val word_of : (Pretoken.t * 'a * 'b) list -> CST.word
val located_word_of : (Pretoken.t * 'a * 'b) list -> CST.word * 'a * 'b
val provoke_error : prelexer_state -> Stdlib.Lexing.lexbuf -> (Pretoken.t * Stdlib.Lexing.position * Stdlib.Lexing.position) list
val escape_analysis : ?for_backquote:bool -> ?for_dquotes:bool -> Nesting.t list -> prelexer_state -> int option

A double quote can be escaped if we are already inside (at least) two levels of quotation. For instance, if the input is <dquote> <dquote> <backslash><backslash> <dquote> <dquote> <dquote>, the escaped backslash is used to escape the quote character.

val escape_analysis_predicate : ?for_backquote:bool -> ?for_dquotes:bool -> Nesting.t list -> prelexer_state -> bool
val under_here_document : prelexer_state -> bool
val escaped_backquote : prelexer_state -> bool
val escaped_single_quote : prelexer_state -> bool
val escaped_double_quote : prelexer_state -> bool
val nesting_context : prelexer_state -> Nesting.t list
val enter_double_quote : prelexer_state -> prelexer_state
val enter_here_document : bool -> string -> prelexer_state -> prelexer_state
val enter_braces : prelexer_state -> prelexer_state
val quit_double_quote : prelexer_state -> prelexer_state
val quit_braces : prelexer_state -> prelexer_state
val enter_backquotes : char -> int -> prelexer_state -> prelexer_state
val under_backquote : prelexer_state -> bool
val under_braces : prelexer_state -> bool
val under_backquoted_style_command_substitution : prelexer_state -> bool
val under_double_quote : prelexer_state -> bool
val under_real_double_quote : prelexer_state -> bool
val is_escaping_backslash : prelexer_state -> 'a -> char -> bool
val closest_backquote_depth : Nesting.t list -> int
val backquote_depth : prelexer_state -> int option
val found_current_here_document_delimiter : ?buffer:Stdlib.Buffer.t -> prelexer_state -> bool
val remove_contents_suffix : Stdlib.Lexing.position -> string -> string -> CST.word_component list -> string * CST.word_component list
val debug : ?rule:string -> Stdlib.Lexing.lexbuf -> prelexer_state -> unit
OCaml

Innovation. Community. Security.