Module Dune_lang

module Atom : sig ... end
module Syntax : sig ... end
type syntax = Syntax.t =
| Jbuild
| Dune
module Template : sig ... end
type t =
| Atom of Atom.t
| Quoted_string of string
| List of t list
| Template of Template.t

The S-expression type

val atom : string -> t

atom s convert the string s to an Atom.

raises Exn.Code_error

if s does not satisfy Atom.is_valid s.

val atom_or_quoted_string : string -> t
val unsafe_atom_of_string : string -> t
val to_string : t -> syntax:syntax -> string

Serialize a S-expression

val pp : syntax -> Stdlib.Format.formatter -> t -> unit

Serialize a S-expression using indentation to improve readability

val pp_quoted : Stdlib.Format.formatter -> t -> unit

Serialization that never fails because it quotes atoms when necessary TODO remove this once we have a proper sexp type

val pp_split_strings : Stdlib.Format.formatter -> t -> unit

Same as pp ~syntax:Dune, but split long strings. The formatter must have been prepared with prepare_formatter.

val prepare_formatter : Stdlib.Format.formatter -> unit

Prepare a formatter for pp_split_strings. Additionaly the formatter escape newlines when the tags "makefile-action" or "makefile-stuff" are active.

module Ast : sig ... end with type sexp := t

Abstract syntax tree

val add_loc : t -> loc:Stdune.Loc.t -> Ast.t
module Cst : sig ... end with type sexp := t

Concrete syntax tree

val insert_comments : Cst.t list -> (Stdune.Loc.t * Cst.Comment.t) list -> Cst.t list

Insert comments in a concrete syntax tree. Comments are inserted based on their location.

module Parse_error : sig ... end
exception Parse_error of Parse_error.t

Exception raised in case of a parsing error

module Lexer : sig ... end
module Parser : sig ... end
val parse_string : fname:string -> mode:'a Parser.Mode.t -> ?⁠lexer:Lexer.t -> string -> 'a
val parse_cst_string : fname:string -> ?⁠lexer:Lexer.t -> string -> Cst.t list
module Encoder : sig ... end with type sexp := t
module Decoder : sig ... end
module type Conv = sig ... end
val to_sexp : t Stdune.Sexp.Encoder.t
module Io : sig ... end