package ppxlib
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=89a98c95ddd0bfbac17b5a936f6811af7097be3258c482d5859b73e9de9b4552
sha512=b19306473d867252d382e58e9b697531c5edccdc9283b5eaf72f524803c2fca2a58a5e8f25bee198b00de82cf8ef805b43f7488791c3ac5beb0ffba938ded826
doc/ppxlib/Ppxlib/Pp_ast/index.html
Module Ppxlib.Pp_ast
Source
This module implements pretty printers for the OCaml AST's version used by ppxlib.
Those pretty printers show the AST as its OCaml representation and do not pretty print the corresponding source code. For printing ASTs as source code use the Ppxlib.Pprintast
module instead.
For example, calling Pp_ast.expression Format.std_formatter [%expr x + 2]
will print:
Pexp_apply ( Pexp_ident (Lident "+") , [ ( Nolabel, Pexp_ident (Lident "x")) ; ( Nolabel, Pexp_constant (Pconst_integer ( "2", None))) ] )
To keep the output easily readable, records with _desc
fields such as Ppxlib.Ast.expression
or Ppxlib.Ast.pattern
are not printed as such and only the value of the corresponding _desc
field is printed instead. This prevents AST nodes metadata, such as locations or attributes, from polluting the output, keeping it relatively concise and clean. The same goes for Location.loc
values which are printed as the value of their txt
field.
Location.t
and Ppxlib.Ast.attributes
are not displayed by default even outside of the records mentioned above.
The Config
module below allows to override part or all of this behaviour. When configured to display locations or attributes, the entire record will be displayed, not only its _desc
field.