Organisationsocaml-ppxocamlformat

ocamlformat

https://github.com/ocaml-ppx/ocamlformat
Branches (5)
fix-lexer-error-message
Print readable error messages in doc code blocks When parsing fails inside a `{@ocaml[...]}` block, the catch-all branch formatted the exception with `Exn.pp`, which for `Lexer.Error` produced the raw constructor pattern `Ocamlformat_parser_extended.Lexer.Error(_, _)`. `Lexer.Error` (and most other compiler-libs exceptions) register a printer via `Location.register_error_of_exn`, but that table is separate from the `Printexc` table `Exn.pp` consults, so the printer was never used. Route the catch-all through `Location.error_of_exn` instead: if a printer is registered, format its `main` message; otherwise fall back to `Exn.pp`. This handles `Lexer.Error` and any other registered exception (e.g. parser internals) without per-variant enumeration. The .err diff against the previous commit shows the before/after for the six variants the regression test exercises.
0b8ec2
fix-windows-crlf-codeblock
odoc-parser: consume CRLF in handle_last_newline handle_last_newline scans backward and matches '\n' immediately, leaving the preceding '\r' (if any) on the stripped string. Because deindent then splits on '\n' and rejoins with '\n', every '\r' on an intermediate line ends up followed by a '\n' — but the '\r' on the last line is bare, since String.concat puts no separator after the final element. The OCaml lexer's newline regex is '\r*\n', so a bare trailing '\r' falls through to the Illegal_character rule. This caused the Windows CI to fail on any {@ocaml[...]} block in a CRLF-checked-out file. Mirror handle_first_newline (which already eats a leading '\r' before matching '\n'): when handle_last_newline finds '\n', also drop a preceding '\r' so the full CRLF is consumed.
77b7b2
metaocaml
Add MetaOCaml support Add a --metaocaml flag to enable MetaOCaml syntax (brackets .< >., escape .~, run .!) in the lexer and formatter. Lexer changes: - Split symbolchar into symbolcharnodot/symbolchar to avoid capturing MetaOCaml tokens as operator characters - Gate .~ (escape) and >. (bracket close) behind the metaocaml flag; .< (bracket open) is always lexed as METAOCAML_BRACKET_OPEN - Add symbolchars sub-lexer for consuming remaining operator chars after >. when metaocaml is disabled - Thread ~metaocaml through parse.ml to set lex_metaocaml ref Formatter changes: - Detect metaocaml.bracket and metaocaml.escape extension nodes (synthetic, with ghost loc) and render them with sugar syntax (.< expr >. and .~expr) instead of [%metaocaml.bracket ...] - Parenthesize .~ argument unless it is a simple identifier - Skip comment relocation for metaocaml extension nodes in Cmts Configuration: - Add metaocaml boolean to opr_opts (Conf_t), default false - Wire --metaocaml/--no-metaocaml flag through Conf and CLI - Thread ~metaocaml through Extended_ast, Std_ast, Parse_with_comments, Toplevel_lexer
d974c1
mll-support
FMT
c7659b
simplify-extended-std-ast
Misc: fmt
2edc18
Refs Branches (8)
Initial support for metaocaml
Add MetaOCaml support Add a --metaocaml flag to enable MetaOCaml syntax (brackets .< >., escape .~, run .!) in the lexer and formatter. Lexer changes: - Split symbolchar into symbolcharnodot/symbolchar to avoid capturing MetaOCaml tokens as operator characters - Gate .~ (escape) and >. (bracket close) behind the metaocaml flag; .< (bracket open) is always lexed as METAOCAML_BRACKET_OPEN - Add symbolchars sub-lexer for consuming remaining operator chars after >. when metaocaml is disabled - Thread ~metaocaml through parse.ml to set lex_metaocaml ref Formatter changes: - Detect metaocaml.bracket and metaocaml.escape extension nodes (synthetic, with ghost loc) and render them with sugar syntax (.< expr >. and .~expr) instead of [%metaocaml.bracket ...] - Parenthesize .~ argument unless it is a simple identifier - Skip comment relocation for metaocaml extension nodes in Cmts Configuration: - Add metaocaml boolean to opr_opts (Conf_t), default false - Wire --metaocaml/--no-metaocaml flag through Conf and CLI - Thread ~metaocaml through Extended_ast, Std_ast, Parse_with_comments, Toplevel_lexer
d974c1
#2630
Format: Backport scan_push change
Format
38b460
#2778
Add neocaml-mode support to ocamlformat-before-save
Add changelog entry for neocaml-mode support
53e1c0
#2787
Simplify Extended_ast vs Std_ast
Misc: fmt
2edc18
#2791
Add ocamllex (.mll) file formatting support
FMT
c7659b
#2792
Fix formatting oscillation in if-then-else branches
s/needs_raw_cmts_after_kw/is_special_or_nested_special_beginend/g
f365c5
#2800
Print readable error messages in doc code blocks
Print readable error messages in doc code blocks When parsing fails inside a `{@ocaml[...]}` block, the catch-all branch formatted the exception with `Exn.pp`, which for `Lexer.Error` produced the raw constructor pattern `Ocamlformat_parser_extended.Lexer.Error(_, _)`. `Lexer.Error` (and most other compiler-libs exceptions) register a printer via `Location.register_error_of_exn`, but that table is separate from the `Printexc` table `Exn.pp` consults, so the printer was never used. Route the catch-all through `Location.error_of_exn` instead: if a printer is registered, format its `main` message; otherwise fall back to `Exn.pp`. This handles `Lexer.Error` and any other registered exception (e.g. parser internals) without per-variant enumeration. The .err diff against the previous commit shows the before/after for the six variants the regression test exercises.
0b8ec2
#2803
Fix Windows lexer error on CRLF code blocks
odoc-parser: consume CRLF in handle_last_newline handle_last_newline scans backward and matches '\n' immediately, leaving the preceding '\r' (if any) on the stripped string. Because deindent then splits on '\n' and rejoins with '\n', every '\r' on an intermediate line ends up followed by a '\n' — but the '\r' on the last line is bare, since String.concat puts no separator after the final element. The OCaml lexer's newline regex is '\r*\n', so a bare trailing '\r' falls through to the Illegal_character rule. This caused the Windows CI to fail on any {@ocaml[...]} block in a CRLF-checked-out file. Mirror handle_first_newline (which already eats a leading '\r' before matching '\n'): when handle_last_newline finds '\n', also drop a preceding '\r' so the full CRLF is consumed.
77b7b2
#2804