Skip to content

Commit 349b42f

Browse files
committed
re #524: fix parse of complex map. Thanks @MatthewSteel!
1 parent 338385b commit 349b42f

3 files changed

Lines changed: 50 additions & 4 deletions

File tree

changelog/current.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
### Fixes
2+
3+
- Fix [#524](https://github.com/biojppm/rapidyaml/issues/524) ([PR#525](https://github.com/biojppm/rapidyaml/pull/525)): problem parsing nested map value in complex map. Kudos to @MatthewSteel!
4+
5+
6+
### Thanks
7+
8+
- @MatthewSteel

src/c4/yml/parse_engine.def.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6563,7 +6563,7 @@ void ParseEngine<EventHandler>::_handle_map_block()
65636563
csubstr maybe_filtered = _maybe_filter_key_scalar_squot(sc); // KEY!
65646564
m_evt_handler->set_key_scalar_squoted(maybe_filtered);
65656565
_maybe_skip_whitespace_tokens();
6566-
_set_indentation(m_evt_handler->m_curr->line_contents.indentation);
6566+
//_set_indentation(m_evt_handler->m_curr->line_contents.indentation);
65676567
// keep the child state on RVAL
65686568
addrem_flags(RVAL, RNXT);
65696569
}
@@ -6604,7 +6604,7 @@ void ParseEngine<EventHandler>::_handle_map_block()
66046604
csubstr maybe_filtered = _maybe_filter_key_scalar_dquot(sc); // KEY!
66056605
m_evt_handler->set_key_scalar_dquoted(maybe_filtered);
66066606
_maybe_skip_whitespace_tokens();
6607-
_set_indentation(m_evt_handler->m_curr->line_contents.indentation);
6607+
//_set_indentation(m_evt_handler->m_curr->line_contents.indentation);
66086608
// keep the child state on RVAL
66096609
addrem_flags(RVAL, RNXT);
66106610
}
@@ -6666,7 +6666,7 @@ void ParseEngine<EventHandler>::_handle_map_block()
66666666
csubstr maybe_filtered = _maybe_filter_key_scalar_plain(sc, m_evt_handler->m_curr->indref); // KEY!
66676667
m_evt_handler->set_key_scalar_plain(maybe_filtered);
66686668
_maybe_skip_whitespace_tokens();
6669-
_set_indentation(m_evt_handler->m_curr->line_contents.indentation);
6669+
//_set_indentation(m_evt_handler->m_curr->line_contents.indentation);
66706670
// keep the child state on RVAL
66716671
addrem_flags(RVAL, RNXT);
66726672
}
@@ -6846,7 +6846,7 @@ void ParseEngine<EventHandler>::_handle_map_block()
68466846
m_evt_handler->begin_map_val_block();
68476847
_handle_annotations_and_indentation_after_start_mapblck(startindent, startline);
68486848
m_evt_handler->set_key_scalar_plain_empty();
6849-
_set_indentation(m_evt_handler->m_curr->line_contents.indentation);
6849+
//_set_indentation(m_evt_handler->m_curr->line_contents.indentation);
68506850
// keep the child state on RVAL
68516851
addrem_flags(RVAL, RNXT);
68526852
}

test/test_parse_engine_6_qmrk.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,44 @@ ENGINE_TEST(QmrkWithTags,
574574
}
575575

576576

577+
ENGINE_TEST(QmrkGithub524,
578+
("? outer\n"
579+
": inner1: 1\n"
580+
" inner2: 2\n",
581+
"outer:\n"
582+
" inner1: 1\n"
583+
" inner2: 2\n"),
584+
"+STR\n"
585+
"+DOC\n"
586+
"+MAP\n"
587+
"=VAL :outer\n"
588+
"+MAP\n"
589+
"=VAL :inner1\n"
590+
"=VAL :1\n"
591+
"=VAL :inner2\n"
592+
"=VAL :2\n"
593+
"-MAP\n"
594+
"-MAP\n"
595+
"-DOC\n"
596+
"-STR\n")
597+
{
598+
___(ps.begin_stream());
599+
___(ps.begin_doc());
600+
___(ps.begin_map_val_block());
601+
___(ps.set_key_scalar_plain("outer"));
602+
___(ps.begin_map_val_block());
603+
___(ps.set_key_scalar_plain("inner1"));
604+
___(ps.set_val_scalar_plain("1"));
605+
___(ps.add_sibling());
606+
___(ps.set_key_scalar_plain("inner2"));
607+
___(ps.set_val_scalar_plain("2"));
608+
___(ps.end_map());
609+
___(ps.end_map());
610+
___(ps.end_doc());
611+
___(ps.end_stream());
612+
}
613+
614+
577615
//-----------------------------------------------------------------------------
578616

579617
ENGINE_TEST(QmrkFlow0,

0 commit comments

Comments
 (0)