My agentic slop goes here. Not intended for anyone else!

more

Changed files
+29 -14
yaml
ocaml-yamle
+2
yaml/ocaml-yamle/lib/error.ml
···
| Invalid_tag_directive of string
| Reserved_directive of string
| Illegal_flow_key_line (** Key and : must be on same line in flow context *)
+
| Block_sequence_disallowed (** Block sequence entries not allowed in this context *)
(* Parser errors *)
| Unexpected_token of string
···
| Invalid_tag_directive s -> Printf.sprintf "invalid TAG directive: %s" s
| Reserved_directive s -> Printf.sprintf "reserved directive: %s" s
| Illegal_flow_key_line -> "key and ':' must be on the same line in flow context"
+
| Block_sequence_disallowed -> "block sequence entries are not allowed in this context"
| Unexpected_token s -> Printf.sprintf "unexpected token: %s" s
| Expected_document_start -> "expected document start '---'"
| Expected_document_end -> "expected document end '...'"
-2
yaml/ocaml-yamle/lib/parser.ml
···
t.state <- pop_state t;
Event.Mapping_end, tok.span
| _ ->
-
Printf.eprintf "DEBUG parser parse_block_mapping_key: unexpected token at %d:%d\n%!"
-
tok.span.start.line tok.span.start.column;
Error.raise_span tok.span Expected_key
(** Parse block mapping value *)
+17 -12
yaml/ocaml-yamle/lib/scanner.ml
···
leading_blanks := true
end;
Input.consume_break t.input;
-
(* Line break allows simple key in both block and flow contexts *)
-
if in_flow then
-
t.allow_simple_key <- true;
-
if not in_flow then
-
t.allow_simple_key <- true;
+
(* Note: We do NOT set allow_simple_key here during plain scalar scanning.
+
Setting it here would incorrectly allow ':' that appears on a continuation
+
line to become a mapping indicator. The flag will be set properly after
+
the scalar ends and skip_to_next_token processes line breaks. *)
(* Skip leading blanks on the next line *)
while Input.next_is_blank t.input do
ignore (Input.next t.input)
···
String.sub value 0 end_pos
in
let span = Span.make ~start ~stop:(Input.mark t.input) in
-
(value, span)
+
(* Return value, span, and whether we ended with leading blanks (crossed a line break) *)
+
(value, span, !leading_blanks)
(** Scan block scalar (literal | or folded >) *)
let scan_block_scalar t literal =
···
and fetch_block_entry t =
if t.flow_level = 0 then begin
-
(* Block entries don't require allow_simple_key to be true, because:
-
1. They're not simple keys themselves
-
2. They can appear after : on the same line (e.g., ": - a")
-
So we only check allow_simple_key in contexts where it's truly required.
-
For now, we allow block entries in block context. *)
+
(* Block entries require allow_simple_key to be true.
+
This prevents block sequences on the same line as a mapping value,
+
e.g., "key: - a" is invalid. *)
+
if not t.allow_simple_key then
+
Error.raise_at (Input.mark t.input) Block_sequence_disallowed;
let col = column t in
if roll_indent t col ~sequence:true then begin
let span = Span.point (Input.mark t.input) in
···
save_simple_key t;
t.allow_simple_key <- false;
t.document_has_content <- true;
-
let value, span = scan_plain_scalar t in
+
let value, span, ended_with_linebreak = scan_plain_scalar t in
+
(* If the plain scalar ended after crossing a line break (leading_blanks = true),
+
allow simple keys. This is important because the scanner already consumed the
+
line break and leading whitespace when checking for continuation. *)
+
if ended_with_linebreak then
+
t.allow_simple_key <- true;
emit t span (Token.Scalar { style = Scalar_style.Plain; value })
(** Check if we need more tokens to resolve simple keys *)
+10
yaml/ocaml-yamle/tests/dune
···
(executable (name test_dk4h) (modules test_dk4h) (libraries yamle))
(executable (name test_sy6v) (modules test_sy6v) (libraries yamle))
(executable (name test_3hfz) (modules test_3hfz) (libraries yamle))
+
(executable (name test_5u3a) (modules test_5u3a) (libraries yamle))
+
(executable (name test_2cms) (modules test_2cms) (libraries yamle))
+
(executable (name test_basic_yaml) (modules test_basic_yaml) (libraries yamle))
+
(executable (name test_loader_debug) (modules test_loader_debug) (libraries yamle test_suite_lib))
+
(executable (name test_229q_direct) (modules test_229q_direct) (libraries yamle))
+
(executable (name debug_from) (modules debug_from) (libraries yamle))
+
(executable (name test_2cms_quick) (modules test_2cms_quick) (libraries yamle))
+
(executable (name count_tests) (modules count_tests) (libraries test_suite_lib))
+
(executable (name test_bs4k) (modules test_bs4k) (libraries yamle))
+
(executable (name test_ks4u) (modules test_ks4u) (libraries yamle))