@@ -576,11 +576,12 @@ let _check_subset : stopped_implicitly -> Token.t = fun t -> (t :> Token.t)
576
576
- The type of token that the block parser stops at. See discussion above. *)
577
577
type ('block, 'stops_at_which_tokens) context =
578
578
| Top_level : (Ast .block_element , stops_at_delimiters ) context
579
- | In_shorthand_list : (Ast .nestable_block_element , stopped_implicitly ) context
579
+ | In_implicitely_ended :
580
+ [ `Tag | `Shorthand_list ]
581
+ -> (Ast .nestable_block_element , stopped_implicitly ) context
580
582
| In_explicit_list : (Ast .nestable_block_element , stops_at_delimiters ) context
581
583
| In_table_cell : (Ast .nestable_block_element , stops_at_delimiters ) context
582
584
| In_code_results : (Ast .nestable_block_element , code_stop ) context
583
- | In_tag : (Ast .nestable_block_element , stopped_implicitly ) context
584
585
585
586
(* This is a no-op. It is needed to prove to the type system that nestable block
586
587
elements are acceptable block elements in all contexts. *)
@@ -592,11 +593,10 @@ let accepted_in_all_contexts :
592
593
fun context block ->
593
594
match context with
594
595
| Top_level -> (block :> Ast.block_element )
595
- | In_shorthand_list -> block
596
+ | In_implicitely_ended ( `Tag | `Shorthand_list ) -> block
596
597
| In_explicit_list -> block
597
598
| In_table_cell -> block
598
599
| In_code_results -> block
599
- | In_tag -> block
600
600
601
601
(* Converts a tag to a series of words. This is used in error recovery, when a
602
602
tag cannot be generated. *)
@@ -672,9 +672,9 @@ let rec block_element_list :
672
672
| { value = `End ; _ } as next_token -> (
673
673
match context with
674
674
| Top_level -> (List. rev acc, next_token, where_in_line)
675
- | In_shorthand_list -> (List. rev acc, next_token, where_in_line)
675
+ | In_implicitely_ended (`Tag | `Shorthand_list ) ->
676
+ (List. rev acc, next_token, where_in_line)
676
677
| In_explicit_list -> (List. rev acc, next_token, where_in_line)
677
- | In_tag -> (List. rev acc, next_token, where_in_line)
678
678
| In_table_cell -> (List. rev acc, next_token, where_in_line)
679
679
| In_code_results -> (List. rev acc, next_token, where_in_line))
680
680
| { value = `Right_brace ; _ } as next_token -> (
@@ -683,10 +683,10 @@ let rec block_element_list :
683
683
possible values of [context]. *)
684
684
match context with
685
685
| Top_level -> (List. rev acc, next_token, where_in_line)
686
- | In_shorthand_list -> (List. rev acc, next_token, where_in_line)
686
+ | In_implicitely_ended (`Tag | `Shorthand_list ) ->
687
+ (List. rev acc, next_token, where_in_line)
687
688
| In_explicit_list -> (List. rev acc, next_token, where_in_line)
688
689
| In_table_cell -> (List. rev acc, next_token, where_in_line)
689
- | In_tag -> (List. rev acc, next_token, where_in_line)
690
690
| In_code_results ->
691
691
junk input;
692
692
consume_block_elements where_in_line acc)
@@ -710,8 +710,8 @@ let rec block_element_list :
710
710
(* Blank lines terminate shorthand lists ([- foo]) and tags. They also
711
711
terminate paragraphs, but the paragraph parser is aware of that
712
712
internally. *)
713
- | In_shorthand_list -> ( List. rev acc, next_token, where_in_line)
714
- | In_tag -> (List. rev acc, next_token, where_in_line)
713
+ | In_implicitely_ended ( `Tag | `Shorthand_list ) ->
714
+ (List. rev acc, next_token, where_in_line)
715
715
(* Otherwise, blank lines are pretty much like single newlines. *)
716
716
| _ ->
717
717
junk input;
@@ -778,15 +778,11 @@ let rec block_element_list :
778
778
(* If a tag starts at the beginning of a line, it terminates the preceding
779
779
tag and/or the current shorthand list. In this case, return to the
780
780
caller, and let the caller decide how to interpret the tag token. *)
781
- | In_shorthand_list ->
781
+ | In_implicitely_ended ( `Tag | `Shorthand_list ) ->
782
782
if where_in_line = `At_start_of_line then
783
783
(List. rev acc, next_token, where_in_line)
784
784
else recover_when_not_at_top_level context
785
785
| In_table_cell -> recover_when_not_at_top_level context
786
- | In_tag ->
787
- if where_in_line = `At_start_of_line then
788
- (List. rev acc, next_token, where_in_line)
789
- else recover_when_not_at_top_level context
790
786
| In_code_results -> recover_when_not_at_top_level context
791
787
(* If this is the top-level call to [block_element_list], parse the
792
788
tag. *)
@@ -823,7 +819,8 @@ let rec block_element_list :
823
819
consume_block_elements `After_text (tag :: acc)
824
820
| (`Deprecated | `Return ) as tag ->
825
821
let content, _stream_head, where_in_line =
826
- block_element_list In_tag ~parent_markup: token input
822
+ block_element_list (In_implicitely_ended `Tag )
823
+ ~parent_markup: token input
827
824
in
828
825
let tag =
829
826
match tag with
@@ -837,7 +834,8 @@ let rec block_element_list :
837
834
consume_block_elements where_in_line (tag :: acc)
838
835
| (`Param _ | `Raise _ | `Before _ ) as tag ->
839
836
let content, _stream_head, where_in_line =
840
- block_element_list In_tag ~parent_markup: token input
837
+ block_element_list (In_implicitely_ended `Tag )
838
+ ~parent_markup: token input
841
839
in
842
840
let tag =
843
841
match tag with
@@ -852,7 +850,8 @@ let rec block_element_list :
852
850
consume_block_elements where_in_line (tag :: acc)
853
851
| `See (kind , target ) ->
854
852
let content, _next_token, where_in_line =
855
- block_element_list In_tag ~parent_markup: token input
853
+ block_element_list (In_implicitely_ended `Tag )
854
+ ~parent_markup: token input
856
855
in
857
856
let location =
858
857
location :: List. map Loc. location content |> Loc. span
@@ -1024,7 +1023,8 @@ let rec block_element_list :
1024
1023
| _ -> () );
1025
1024
1026
1025
match context with
1027
- | In_shorthand_list -> (List. rev acc, next_token, where_in_line)
1026
+ | In_implicitely_ended `Shorthand_list ->
1027
+ (List. rev acc, next_token, where_in_line)
1028
1028
| _ ->
1029
1029
let items, where_in_line =
1030
1030
shorthand_list_items next_token where_in_line input
@@ -1060,16 +1060,12 @@ let rec block_element_list :
1060
1060
in
1061
1061
1062
1062
match context with
1063
- | In_shorthand_list ->
1063
+ | In_implicitely_ended ( `Tag | `Shorthand_list ) ->
1064
1064
if where_in_line = `At_start_of_line then
1065
1065
(List. rev acc, next_token, where_in_line)
1066
1066
else recover_when_not_at_top_level context
1067
1067
| In_explicit_list -> recover_when_not_at_top_level context
1068
1068
| In_table_cell -> recover_when_not_at_top_level context
1069
- | In_tag ->
1070
- if where_in_line = `At_start_of_line then
1071
- (List. rev acc, next_token, where_in_line)
1072
- else recover_when_not_at_top_level context
1073
1069
| In_code_results -> recover_when_not_at_top_level context
1074
1070
| Top_level ->
1075
1071
if where_in_line <> `At_start_of_line then
@@ -1175,11 +1171,11 @@ let rec block_element_list :
1175
1171
let where_in_line =
1176
1172
match context with
1177
1173
| Top_level -> `At_start_of_line
1178
- | In_shorthand_list -> `After_shorthand_bullet
1174
+ | In_implicitely_ended `Shorthand_list -> `After_shorthand_bullet
1179
1175
| In_explicit_list -> `After_explicit_list_bullet
1180
1176
| In_table_cell -> `After_table_cell
1181
1177
| In_code_results -> `After_tag
1182
- | In_tag -> `After_tag
1178
+ | In_implicitely_ended `Tag -> `After_tag
1183
1179
in
1184
1180
1185
1181
consume_block_elements where_in_line []
@@ -1219,7 +1215,8 @@ and shorthand_list_items :
1219
1215
junk input;
1220
1216
1221
1217
let content, stream_head, where_in_line =
1222
- block_element_list In_shorthand_list ~parent_markup: bullet input
1218
+ block_element_list (In_implicitely_ended `Shorthand_list )
1219
+ ~parent_markup: bullet input
1223
1220
in
1224
1221
if content = [] then
1225
1222
Parse_error. should_not_be_empty ~what: (Token. describe bullet)
0 commit comments