-
-
Notifications
You must be signed in to change notification settings - Fork 475
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
feat(css_parser): CSS Parser pseudo element selector #268 #883
Conversation
- better error recovery and diagnostic for pseudo class selector
use biome_parser::prelude::ParsedSyntax; | ||
use biome_parser::prelude::ParsedSyntax::{Absent, Present}; | ||
use biome_parser::{token_set, CompletedMarker, Parser, ParserProgress, TokenSet}; | ||
|
||
const SELECTOR_RECOVERY_SET: TokenSet<CssSyntaxKind> = RULE_RECOVERY_SET.union(token_set![T![,]]); | ||
const SELECTOR_FUNCTION_RECOVERY_SET: TokenSet<CssSyntaxKind> = token_set![T![')'], T!['{']]; | ||
|
||
#[inline] | ||
fn parse_selector_function_close_token(p: &mut CssParser) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed a way how we recover if we don't find a close token.
I think that it's okey to consume all tokens until we find a )
or a }
.
See snapshots for examples.
Parser conformance results onjs/262
jsx/babel
symbols/microsoft
ts/babel
ts/microsoft
|
- better error recovery and diagnostic for pseudo class selector
Present(m.complete(p, CSS_PSEUDO_CLASS_SELECTOR)) | ||
let kind = match parse_pseudo_class(p).or_add_diagnostic(p, expected_any_pseudo_class) { | ||
Some(_) => CSS_PSEUDO_CLASS_SELECTOR, | ||
None => CSS_BOGUS_SUB_SELECTOR, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It covers a case when we have only a double column token: :
Summary
:host-context(h1) .div {}
.eat_or_recover_selector_function_close_token
, which attempts to consume a)
token; if unsuccessful, it recovers by consuming all tokens as bogus.recover_selector_function_parameter
to handle invalid parameters by consuming all tokens until)
.Test Plan
cargo test