Frontend.Pretty_printingSome helpers to produce nice error messages and for auto-formatting Stan programs
val comments : Ast.comment_type list Core.refTo avoid cluttering the AST, comments are not associated with any particular AST node but instead come in a separate list. The pretty printer uses the AST nodes' location metadata to insert whitespace and comments. The comment list is stored in a global state that is accessed by set_comments, get_comments, and skip_comments.
val skipped :
([ `Block | `Include | `Line ] * string list * Middle.Location_span.t) list
Core.refval set_comments :
?inline_includes:bool ->
?strip_comments:bool ->
Ast.comment_type list ->
unitval get_comments :
Middle.Location.t ->
([> `Block | `Include | `Line ] * string list * Middle.Location_span.t) listval get_comments_until_separator :
Middle.Location.t ->
([> `Block | `Include | `Line ] * string list * Middle.Location_span.t) listval skip_comments : Middle.Location.t -> unitval remaining_comments :
unit ->
([ `Block | `Include | `Line ] * string list * Middle.Location_span.t)
Base__List.tval should_skip : Middle.Location.t -> boolChecks if something should be skipped based on the print_included setting
val pp_space :
bool ->
Stdlib.Format.formatter ->
(Middle.Location.t * Middle.Location.t) ->
unitval pp_comment :
Stdlib.Format.formatter ->
([< `Block | `Include | `Line ] * string list * Middle.Location_span.t) ->
unitval pp_spacing :
?newline:bool ->
Middle.Location.t option ->
Middle.Location.t option ->
Stdlib.Format.formatter ->
([< `Block | `Include | `Line Include Line ]
* string list
* Middle.Location_span.t)
list ->
unitval pp_comments_spacing :
?no_comment:unit Fmt.t ->
?before:unit Fmt.t ->
('a ->
([< `Block | `Include | `Line Block ]
* string list
* Middle.Location_span.t)
list) ->
Stdlib.Format.formatter ->
'a ->
unitval pp_unsizedtype : Middle.UnsizedType.t Fmt.tval pp_autodifftype :
Stdlib.Format.formatter ->
Middle.UnsizedType.autodifftype ->
unitval pp_returntype :
Stdlib.Format.formatter ->
Middle.UnsizedType.returntype ->
unitval pp_identifier : Stdlib.Format.formatter -> Ast.identifier -> unitval pp_operator : Stdlib.Format.formatter -> Middle.Operator.t -> unitval pp_start_funapp : Stdlib.Format.formatter -> Ast.identifier -> unitFor long function names, we let the indent of the arguments be ragged under the name, otherwise we align it under the "("
val pp_list_of :
(Stdlib.Format.formatter -> 'a -> unit) ->
('a -> Middle.Location_span.t) ->
Stdlib.Format.formatter ->
('a list * Middle.Location_span.t) ->
unitval pp_index : Ast.untyped_expression Ast.index Fmt.tval pp_list_of_indices :
Stdlib.Format.formatter ->
Ast.untyped_expression Ast.index list ->
unitval pp_expression : Stdlib.Format.formatter -> Ast.untyped_expression -> unitval pp_list_of_expression :
Stdlib.Format.formatter ->
(Ast.untyped_expression list * Middle.Location_span.t) ->
unitval pp_lvalue :
Stdlib.Format.formatter ->
((Ast.located_meta, unit, Core.Nothing.t) Ast.expr_with, Ast.located_meta)
Ast.lval_with
Ast.lvalue_pack ->
unitval pp_assignmentoperator :
Stdlib.Format.formatter ->
Ast.assignmentoperator ->
unitval pp_truncation :
Stdlib.Format.formatter ->
Ast.untyped_expression Ast.truncation ->
unitval pp_printable :
Stdlib.Format.formatter ->
Ast.untyped_expression Ast.printable ->
unitval pp_list_of_printables :
Stdlib.Format.formatter ->
Ast.untyped_expression Ast.printable list ->
unitval pp_bracketed_transform :
Stdlib.Format.formatter ->
Ast.untyped_expression Middle.Transformation.t ->
unitval pp_transformed_type :
(Ast.untyped_expression Middle.SizedType.t
* Ast.untyped_expression Middle.Transformation.t)
Fmt.tval pp_indent_unless_block :
Stdlib.Format.formatter ->
(Ast.untyped_statement * Middle.Location.t) ->
unitval pp_recursive_ifthenelse :
((Ast.untyped_expression, Ast.located_meta, Ast.untyped_lval, unit)
Ast.statement_with
* Middle.Location.t)
Fmt.tThis function helps write chained if-then-else-if-... blocks correctly. Without it, each IfThenElse would trigger a new vbox in front of the if, adding spaces for each level of IfThenElse.
val pp_statement : Ast.untyped_statement Fmt.tval pp_list_of_statements :
((Ast.untyped_expression, Ast.located_meta, Ast.untyped_lval, unit)
Ast.statement_with
list
* Middle.Location_span.t)
Fmt.tval pp_typed_expression :
Stdlib.Format.formatter ->
Ast.typed_expression ->
unit