Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle line advancement when parsing AnchorPrefix and TagPrefix #368

Closed
1 of 2 tasks
alienczf opened this issue Jul 16, 2024 · 5 comments
Closed
1 of 2 tasks

handle line advancement when parsing AnchorPrefix and TagPrefix #368

alienczf opened this issue Jul 16, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@alienczf
Copy link

Description

when parsing anchor_prefix and tag prefix, the code currently doesn't advance line if we happend to consume newline character.

this results in the subsequent tokens being labelled with wrong line number

            case lexical_token_t::ANCHOR_PREFIX:
            case lexical_token_t::TAG_PREFIX:
                deserialize_node_properties(lexer, type, line, indent);

                // Skip updating the current indent to avoid stacking a wrong indentation.
                //
                //   &foo bar: baz
                //   ^
                //   the correct indent width for the "bar" node key.

+               line = lexer.get_lines_processed();
                continue;

Reproduction steps

sample.yaml

values:
- &id070 !XXX
  source: !YYY
    name: fv
  include: false
#include "fkYAML/node.hpp"
int main(int argc, char* argv[]) {
  std::ifstream ifs("/tmp/sample.yaml");
  fkyaml::node root = fkyaml::node::deserialize(ifs);
  return 0;
}

Expected vs. actual results

wrongly throws indentation error

Minimal code example

No response

Error messages

No response

Compiler and operating system

clang17 ubuntu22

Library version

develop

Validation

@fktn-k
Copy link
Owner

fktn-k commented Jul 16, 2024

@alienczf
Thanks for filing the issue.
I'll take a look later.
The fix will be available hopefully this weekend (I'll be unavailable this weekdays).

@alienczf
Copy link
Author

alienczf commented Jul 17, 2024 via email

@fktn-k fktn-k added the bug Something isn't working label Aug 17, 2024
fktn-k added a commit that referenced this issue Aug 17, 2024
* fixed lacked line advancement for block mappings as a block sequence entry

* run amalgamation

* cleaned up redundant impl for node traversals before parsing a mapping key node

* modified comments for parsing node props
@fktn-k
Copy link
Owner

fktn-k commented Aug 17, 2024

@alienczf
Sorry for replying too late.
I've finally got enough time to investigate the root cause of the reported bug and fixed it with some related bugs which were also found during the investigation (PR #369).
The fixed version of this library is now available in the develop branch.

@alienczf
Copy link
Author

alienczf commented Aug 23, 2024 via email

@fktn-k
Copy link
Owner

fktn-k commented Aug 23, 2024

I'll close this issue since the reported bug has been fixed.
Please reopen this issue if there's something related to this issue but still unresolved.

@fktn-k fktn-k closed this as completed Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants