[OCaml] Org mode parser.
1
(** Private raw parse tree types.
2
3
These types represent the output of the structural Menhir parser before
4
normalization. They are flat (no heading hierarchy), store inline content as
5
raw strings, and preserve the parsing order. The normalization phase
6
converts these into the public [Ast] types. *)
7
8
type raw_list_item = {
9
rli_indent : int;
10
rli_bullet : string;
11
rli_counter_set : int option;
12
rli_checkbox : string option; (** "[ ]", "[X]", or "[-]" *)
13
rli_tag : string option; (** Descriptive list tag text (raw) *)
14
rli_body_lines : string list; (** Continuation lines *)
15
}
16
(** A raw list item as classified by the lexer. Indentation is preserved for
17
later nesting. *)
18
19
type raw_property = { rp_name : string; rp_value : string option }
20
(** A raw property drawer entry. *)
21
22
type raw_planning = {
23
rpl_keyword : string; (** DEADLINE, SCHEDULED, or CLOSED *)
24
rpl_timestamp : string; (** Raw timestamp text *)
25
}
26
(** A raw planning line. *)
27
28
(** A raw table row. *)
29
type raw_table_row =
30
| Raw_table_standard of string (** | cell | cell | ... *)
31
| Raw_table_rule (** |---+---| *)
32
33
(** A block body. Opaque blocks store raw text; recursive blocks store nested
34
raw elements. *)
35
type raw_block_body =
36
| Opaque_body of string (** Source, example, export, comment *)
37
| Recursive_body of raw_element list (** Quote, center, verse, custom *)
38
39
(** A raw element produced by the structural parser. *)
40
and raw_element =
41
| Raw_heading of raw_heading
42
| Raw_paragraph of string list (** Consecutive text lines *)
43
| Raw_list_items of raw_list_item list (** Consecutive list items *)
44
| Raw_table of raw_table_row list (** Table rows *)
45
| Raw_block of raw_block
46
| Raw_drawer of raw_drawer
47
| Raw_keyword of string * string (** key, value *)
48
| Raw_affiliated of string * string option * string
49
(** name, optional, value *)
50
| Raw_comment of string list (** Consecutive comment lines *)
51
| Raw_fixed_width of string list (** Consecutive fixed-width lines *)
52
| Raw_horizontal_rule
53
| Raw_planning of raw_planning list (** Planning line entries *)
54
| Raw_property_drawer of raw_property list (** Property drawer *)
55
56
and raw_block = {
57
rb_name : string; (** Block type name (src, quote, etc.) *)
58
rb_params : string option; (** Parameters after #+begin_NAME *)
59
rb_body : raw_block_body;
60
}
61
(** A raw block. *)
62
63
and raw_drawer = { rd_name : string; rd_contents : raw_element list }
64
(** A raw drawer. *)
65
66
and raw_heading = {
67
rh_level : int;
68
rh_raw_title : string;
69
(** Everything after stars, to be parsed for TODO/priority/tags/inline *)
70
rh_body : raw_element list;
71
(** Elements until next heading of same or higher level *)
72
}
73
(** A raw heading (flat — no hierarchy yet). *)
74
75
type document = {
76
rd_preamble : raw_element list;
77
rd_headings : raw_heading list;
78
}
79
(** A raw document produced by the structural parser. *)
80