Conversation
|
3c6b1fd to
f3debf9
Compare
WalkthroughThe YAML lexer now supports block properties—anchors and tags—by introducing a new path to consume and lex properties starting with '!' or '&'. The mapping-start disambiguation logic has been refactored: Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Comment Tip CodeRabbit can use TruffleHog to scan for secrets in your code with verification capabilities.Add a TruffleHog config file (e.g. trufflehog-config.yml, trufflehog.yml) to your project to customize detectors and scanning behavior. The tool runs only when a config file is present. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/biome_yaml_parser/src/lexer/mod.rs (1)
1131-1141: Minor note:is_tag_charis more permissive than the YAML spec.The spec requires
ns-uri-char(URI-safe characters) for tags, but this implementation accepts any non-blank character excluding!and flow indicators. This is fine for lenient parsing—strict validation can be handled at the parser or analyzer level if needed.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/biome_yaml_parser/src/lexer/mod.rs` around lines 1131 - 1141, is_tag_char currently allows any non-blank char except '!' and flow indicators which is more permissive than the YAML spec's ns-uri-char; either restrict is_tag_char to only accept URI-safe characters per the spec or explicitly document/flag the lenient behavior. Modify the is_tag_char implementation (and keep is_anchor_char unchanged) to validate against the ns-uri-char character set (or call a new helper like is_ns_uri_char(c)), or add a clear comment/TODO above fn is_tag_char stating that tag validation is intentionally lenient and strict URI validation is handled later.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@crates/biome_yaml_parser/src/lexer/mod.rs`:
- Around line 1131-1141: is_tag_char currently allows any non-blank char except
'!' and flow indicators which is more permissive than the YAML spec's
ns-uri-char; either restrict is_tag_char to only accept URI-safe characters per
the spec or explicitly document/flag the lenient behavior. Modify the
is_tag_char implementation (and keep is_anchor_char unchanged) to validate
against the ns-uri-char character set (or call a new helper like
is_ns_uri_char(c)), or add a clear comment/TODO above fn is_tag_char stating
that tag validation is intentionally lenient and strict URI validation is
handled later.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3aaf1b66-38bb-4528-b220-1c9c683b5df6
📒 Files selected for processing (3)
crates/biome_yaml_parser/src/lexer/mod.rscrates/biome_yaml_parser/src/lexer/tests/mod.rscrates/biome_yaml_parser/src/lexer/tests/property.rs
| /// For example, `: abc` is a valid yaml mapping, which is equivalent | ||
| /// to `{null: abc}` | ||
| fn consume_mapping_key(&mut self, current: u8) -> LinkedList<LexToken> { | ||
| fn consume_explicit_mapping_key(&mut self, current: u8) -> LinkedList<LexToken> { |
There was a problem hiding this comment.
It would be nice to keep the docstring. Let's update it
| @@ -125,21 +125,32 @@ impl<'src> YamlLexer<'src> { | |||
| } | |||
|
|
|||
| /// Consume and disambiguate a YAML value to determine whether it's a YAML block map or just a | |||
There was a problem hiding this comment.
The logic changed, does the doc still apply?
| LexToken::new(COMMENT, start, self.current_coordinate) | ||
| } | ||
|
|
||
| fn consume_block_properties(&mut self) -> LinkedList<LexToken> { |
There was a problem hiding this comment.
You know, I noticed we don't use #[inline] throughout the parser.
Let's keep it as is, but maybe we could set up some benchmarks, and eventually see if the derive can help
Summary
Follow up of #9220. With this PR, YAML lexer can now lex yaml properties like
Having the parser consuming these tokens will be the work of a different PR
Test Plan
Added new YAML snippets containing properties to the lexer test suite
Docs
N/A