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

Allow commas in unquoted string + empty map #42

Merged
merged 2 commits into from
Nov 21, 2024

Conversation

gwenzek
Copy link
Contributor

@gwenzek gwenzek commented Sep 3, 2024

Hi Jakub,
thanks for the lib.

I found two minor issues with the libraries:

  • , is a valid character for unquoted string, except in flow

From: https://yaml.org/spec/1.2.2/#733-plain-style
inside flow collections, plain scalars must not contain the “[”, “]”, “{”, “}” and “,” characters.
To handle this the tokenizer need to tracks if it's within a flow or not.

  • {} is a valid map.

I can split the PR in two if you prefer, but also the two commits are easy to review independently.

From: https://yaml.org/spec/1.2.2/#733-plain-style
**inside** flow collections, plain scalars must not contain the “[”, “]”, “{”, “}” and “,” characters.

added test cases
else => {
log.err("Unhandled token in map: {}", .{key});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me know if you find this is too much

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine but I think if we had some error reporting layer setup it would have been even better.

Copy link
Owner

@kubkon kubkon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I've got some questions if you wouldn't mind answering them and helping me to understand the changes better.

@@ -6,6 +6,7 @@ const testing = std.testing;

buffer: []const u8,
index: usize = 0,
in_flow: usize = 0,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come it's not enough for in_flow to be a bool?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this handle nesting of list/mapping. If there are several nested list, I need to remember how many closing tag I need to see before setting "in_flow" to false.

@lunjon
Copy link
Contributor

lunjon commented Nov 19, 2024

Great work! I think there's also a problem when parsing unquoted strings containing colon. For instance, the following currently fails for me:

key: a::b

@gwenzek
Copy link
Contributor Author

gwenzek commented Nov 20, 2024

@kubkon sorry, I forgot about this PR, I answered your question

I think there's also a problem when parsing unquoted strings containing colon.

@lunjon do you mean a problem in this branch or on main ?

@lunjon
Copy link
Contributor

lunjon commented Nov 20, 2024

@kubkon sorry, I forgot about this PR, I answered your question

I think there's also a problem when parsing unquoted strings containing colon.

@lunjon do you mean a problem in this branch or on main ?

In main, and I believe the issue could be related to the issue this PR fixes.

@gwenzek
Copy link
Contributor Author

gwenzek commented Nov 21, 2024

@lunjon it's not directly related, you can see previous PR #27 or my own more complete implem gwenzek#1

@lunjon
Copy link
Contributor

lunjon commented Nov 21, 2024

@lunjon it's not directly related, you can see previous PR #27 or my own more complete implem gwenzek#1

Oh I see. Is there any plans to integrate these changes to main anytime soon?

Copy link
Owner

@kubkon kubkon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@kubkon kubkon merged commit bd6a184 into kubkon:main Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants