Skip to content

Implement Block Scalar support#110

Open
bradcypert wants to merge 1 commit intokubkon:mainfrom
bradcypert:push-qmlwxzslkwxz
Open

Implement Block Scalar support#110
bradcypert wants to merge 1 commit intokubkon:mainfrom
bradcypert:push-qmlwxzslkwxz

Conversation

@bradcypert
Copy link

Hey there! Thank you for the library! I am using it in one of my zig projects and noticed that I couldn't parse yaml with block scalars. When the parser encountered these indicators, it would fail with parsing errors.

I implemented basic support for YAML block scalars by:

1. Tokenizer Enhancements (src/Tokenizer.zig)

  • Added two new token types: block_literal (|) and block_folded (>)
  • Added tokenization rules to recognize these characters as block scalar indicators

2. Parser Implementation (src/Parser.zig)

  • Added blockScalar() function to handle block scalar parsing
  • Implemented indentation-based content collection
  • Added logic to differentiate between literal (preserves newlines) and folded (converts to spaces) styles
  • Updated value() function to dispatch to blockScalar() when these tokens are encountered

3. Examples Created

  • examples/block_scalars.yml - Simple demonstration
  • examples/block_scalar_demo.yml - Comprehensive examples with real-world use cases

Would love it if we can merge this in, but no worries if not! I know this PR came out of the blue (and I'll update my dep to use my fork in the meantime 😄). Thanks again!

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.

1 participant