package libsail

  1. Overview
  2. Docs

Module for breaking AST into syntactic chunks and interleaving comments.

This module is part of the Sail formatting system. It takes a parsed AST (not a desugared AST, as for formatting we need to preserve as much as possible), and breaks it up into more abstract syntactic elements - 'chunks' for want of a better term.

type binder =
  1. | Var_binder
  2. | Let_binder
  3. | Internal_plet_binder
val binder_keyword : binder -> string
type if_format = {
  1. then_brace : bool;
  2. else_brace : bool;
}
type match_kind =
  1. | Try_match
  2. | Match_match
val match_keywords : match_kind -> string * string option
val comment_type_delimiters : Lexer.comment_type -> string * string
type chunk =
  1. | Comment of Lexer.comment_type * int * int * string
  2. | Spacer of bool * int
  3. | Function of {
    1. id : Parse_ast.id;
    2. clause : bool;
    3. rec_opt : chunks option;
    4. typq_opt : chunks option;
    5. return_typ_opt : chunks option;
    6. funcls : pexp_chunks list;
    }
  4. | Val of {
    1. id : Parse_ast.id;
    2. extern_opt : Parse_ast.extern option;
    3. typq_opt : chunks option;
    4. typ : chunks;
    }
  5. | Enum of {
    1. id : Parse_ast.id;
    2. enum_functions : chunks list option;
    3. members : chunks list;
    }
  6. | Function_typ of {
    1. mapping : bool;
    2. lhs : chunks;
    3. rhs : chunks;
    }
  7. | Exists of {
    1. vars : chunks;
    2. constr : chunks;
    3. typ : chunks;
    }
  8. | Typ_quant of {
    1. vars : chunks;
    2. constr_opt : chunks option;
    }
  9. | App of Parse_ast.id * chunks list
  10. | Field of chunks * Parse_ast.id
  11. | Tuple of string * string * int * chunks list
  12. | Intersperse of string * chunks list
  13. | Atom of string
  14. | String_literal of string
  15. | Pragma of string * string
  16. | Unary of string * chunks
  17. | Binary of chunks * string * chunks
  18. | Ternary of chunks * string * chunks * string * chunks
  19. | Index of chunks * chunks
  20. | Delim of string
  21. | Opt_delim of string
  22. | Block of bool * chunks list
  23. | Binder of binder * chunks * chunks * chunks
  24. | Block_binder of binder * chunks * chunks
  25. | If_then of bool * chunks * chunks
  26. | If_then_else of if_format * chunks * chunks * chunks
  27. | Struct_update of chunks * chunks list
  28. | Match of {
    1. kind : match_kind;
    2. exp : chunks;
    3. aligned : bool;
    4. cases : pexp_chunks list;
    }
  29. | Foreach of {
    1. var : chunks;
    2. decreasing : bool;
    3. from_index : chunks;
    4. to_index : chunks;
    5. step : chunks option;
    6. body : chunks;
    }
  30. | While of {
    1. repeat_until : bool;
    2. termination_measure : chunks option;
    3. cond : chunks;
    4. body : chunks;
    }
  31. | Vector_updates of chunks * chunk list
  32. | Chunks of chunks
  33. | Raw of string
and chunks = chunk Queue.t
and pexp_chunks = {
  1. funcl_space : bool;
  2. pat : chunks;
  3. guard : chunks option;
  4. body : chunks;
}
val prerr_chunk : string -> chunk -> unit
val chunk_defs : string -> Lexer.comment list -> Parse_ast.def list -> chunks
OCaml

Innovation. Community. Security.