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

feat(css_parser): CSS Parser pseudo element selector #268 #673

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 16 additions & 32 deletions crates/biome_css_factory/src/generated/node_factory.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 10 additions & 50 deletions crates/biome_css_factory/src/generated/syntax_factory.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 6 additions & 16 deletions crates/biome_css_parser/src/syntax/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use biome_parser::parse_lists::ParseSeparatedList;
use biome_parser::parse_recovery::{ParseRecovery, RecoveryResult};
use biome_parser::prelude::ParsedSyntax;
use biome_parser::prelude::ParsedSyntax::{Absent, Present};
use biome_parser::{token_set, Parser, ParserProgress, TokenSet};
use biome_parser::{token_set, CompletedMarker, Parser, ParserProgress, TokenSet};

const RULE_RECOVERY_SET: TokenSet<CssSyntaxKind> =
token_set![T![#], T![.], T![*], T![ident], T![:], T![::], T!['{']];
Expand All @@ -27,30 +27,22 @@ pub(crate) fn parse_root(p: &mut CssParser) {
m.complete(p, CSS_ROOT);
}

#[inline]
pub(crate) fn parse_rule_list(p: &mut CssParser) {
let mut progress = ParserProgress::default();

let rules = p.start();
while !p.at(EOF) {
progress.assert_progressing(p);

if parse_rule(p)
.or_recover(
p,
&ParseRecovery::new(CSS_BOGUS_RULE, RULE_RECOVERY_SET),
expect_any_selector,
)
.is_err()
{
break;
}
parse_rule(p);
}

rules.complete(p, CSS_RULE_LIST);
}

#[inline]
pub(crate) fn parse_rule(p: &mut CssParser) -> ParsedSyntax {
pub(crate) fn parse_rule(p: &mut CssParser) -> CompletedMarker {
let m = p.start();

CssSelectorList.parse_list(p);
Expand All @@ -63,12 +55,10 @@ pub(crate) fn parse_rule(p: &mut CssParser) -> ParsedSyntax {
)
.is_err()
{
m.abandon(p);
return Absent;
return m.complete(p, CSS_BOGUS_RULE);
}

let completed = m.complete(p, CSS_RULE);
Present(completed)
m.complete(p, CSS_RULE)
}

const SELECTOR_RECOVERY_SET: TokenSet<CssSyntaxKind> = RULE_RECOVERY_SET.union(token_set![T![,]]);
Expand Down
Loading
Loading