I have an embedded script in a YAML file, and I want to provide users with exact line/col information of possible syntax errors. I am having trouble getting the correct column for a multiline string.
For instance, for the print() statement in
script: |
print()
I expect location.col to be 2.
This is how I do it, not sure if I use the correct API.
TEST(rapidyaml, fails)
{
ryml::Parser parser{ ryml::ParserOptions().locations(true) };
auto tree = parser.parse_in_arena("file", "script: |\n print()");
auto script = tree["script"];
auto val = script.val();
EXPECT_TRUE(val == "print()\n");
auto location = parser.val_location(val.str);
EXPECT_EQ(location.line, 1);
EXPECT_EQ(location.col, 2);
}
Thanks for rapidyaml!
I have an embedded script in a YAML file, and I want to provide users with exact line/col information of possible syntax errors. I am having trouble getting the correct column for a multiline string.
For instance, for the
print()
statement inI expect location.col to be 2.
This is how I do it, not sure if I use the correct API.
however, the test fails with col == 0:
Any help would be greatly appreciated. TIA!