Skip to content

Commit 9c3fbe0

Browse files
hhugoclaude
andcommitted
Document why Std_ast exists
Add docstring explaining that the standard parser is used to verify formatting preserves semantics: two programs are equivalent if the compiler parses them identically. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0a0a0f5 commit 9c3fbe0

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

lib/Std_ast.mli

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,18 @@
99
(* *)
1010
(**************************************************************************)
1111

12-
(** Interface over the AST defined in vendor/ocaml-4.13 *)
12+
(** Standard OCaml parser AST (vendor/parser-standard).
13+
14+
OCamlformat uses an extended parser for formatting that supports
15+
additional syntax constructs (field punning, begin..end nodes, labeled
16+
tuples, etc.). To verify that formatting preserves semantics,
17+
ocamlformat re-parses both the original and formatted source with the
18+
standard OCaml parser and compares the resulting ASTs. If they differ,
19+
formatting changed the meaning of the program — which is a bug.
20+
21+
The standard parser is used for this comparison because it represents
22+
what the OCaml compiler sees: two programs are equivalent if the
23+
compiler parses them identically. *)
1324

1425
open Ocamlformat_parser_standard
1526

0 commit comments

Comments
 (0)