Skip to content
Merged
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
20 changes: 10 additions & 10 deletions src/rules_and_declarations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub trait DeclarationParser<'i> {
/// Parse the value of a declaration with the given `name`.
///
/// Return the finished representation for the declaration
/// as returned by `DeclarationListParser::next`,
/// as returned by `RuleBodyParser::next`,
/// or an `Err(..)` to ignore the entire declaration as invalid.
///
/// Declaration name matching should be case-insensitive in the ASCII range.
Expand Down Expand Up @@ -63,7 +63,7 @@ pub trait DeclarationParser<'i> {
///
/// Default implementations that reject all at-rules are provided,
/// so that `impl AtRuleParser<(), ()> for ... {}` can be used
/// for using `DeclarationListParser` to parse a declarations list with only qualified rules.
/// for using `RuleBodyParser` to parse a declarations list with only qualified rules.
pub trait AtRuleParser<'i> {
/// The intermediate representation of prelude of an at-rule.
type Prelude;
Expand Down Expand Up @@ -121,7 +121,7 @@ pub trait AtRuleParser<'i> {
/// The location passed in is source location of the start of the prelude.
///
/// Return the finished representation of the at-rule
/// as returned by `RuleListParser::next` or `DeclarationListParser::next`,
/// as returned by `StyleSheetParser::next` or `RuleBodyParser::next`,
/// or an `Err(..)` to ignore the entire at-rule as invalid.
///
/// This is only called when `parse_prelude` returned `WithBlock`, and a block
Expand All @@ -146,7 +146,7 @@ pub trait AtRuleParser<'i> {
///
/// Default implementations that reject all qualified rules are provided, so that
/// `impl QualifiedRuleParser<(), ()> for ... {}` can be used for example for using
/// `RuleListParser` to parse a rule list with only at-rules (such as inside
/// `StyleSheetParser` to parse a rule list with only at-rules (such as inside
/// `@font-feature-values`).
pub trait QualifiedRuleParser<'i> {
/// The intermediate representation of a qualified rule prelude.
Expand Down Expand Up @@ -179,7 +179,7 @@ pub trait QualifiedRuleParser<'i> {
/// The location passed in is source location of the start of the prelude.
///
/// Return the finished representation of the qualified rule
/// as returned by `RuleListParser::next`,
/// as returned by `StyleSheetParser::next`,
/// or an `Err(..)` to ignore the entire at-rule as invalid.
fn parse_block<'t>(
&mut self,
Expand All @@ -197,7 +197,7 @@ pub trait QualifiedRuleParser<'i> {
pub struct RuleBodyParser<'i, 't, 'a, P, I, E> {
/// The input given to the parser.
pub input: &'a mut Parser<'i, 't>,
/// The parser given to `DeclarationListParser::new`
/// The parser given to `RuleBodyParser::new`
pub parser: &'a mut P,

_phantom: std::marker::PhantomData<(I, E)>,
Expand All @@ -218,7 +218,7 @@ pub trait RuleBodyItemParser<'i, DeclOrRule, Error: 'i>:
}

impl<'i, 't, 'a, P, I, E> RuleBodyParser<'i, 't, 'a, P, I, E> {
/// Create a new `DeclarationListParser` for the given `input` and `parser`.
/// Create a new `RuleBodyParser` for the given `input` and `parser`.
///
/// Note that all CSS declaration lists can on principle contain at-rules.
/// Even if no such valid at-rule exists (yet),
Expand All @@ -230,7 +230,7 @@ impl<'i, 't, 'a, P, I, E> RuleBodyParser<'i, 't, 'a, P, I, E> {
/// since `AtRuleParser` provides default implementations of its methods.
///
/// The return type for finished declarations and at-rules also needs to be the same,
/// since `<DeclarationListParser as Iterator>::next` can return either.
/// since `<RuleBodyParser as Iterator>::next` can return either.
/// It could be a custom enum.
pub fn new(input: &'a mut Parser<'i, 't>, parser: &'a mut P) -> Self {
Self {
Expand Down Expand Up @@ -339,7 +339,7 @@ where
/// implementations of their methods.
///
/// The return type for finished qualified rules and at-rules also needs to be the same,
/// since `<RuleListParser as Iterator>::next` can return either. It could be a custom enum.
/// since `<StyleSheetParser as Iterator>::next` can return either. It could be a custom enum.
pub fn new(input: &'a mut Parser<'i, 't>, parser: &'a mut P) -> Self {
Self {
input,
Expand All @@ -349,7 +349,7 @@ where
}
}

/// `RuleListParser` is an iterator that yields `Ok(_)` for a rule or an `Err(..)` for an invalid one.
/// `StyleSheetParser` is an iterator that yields `Ok(_)` for a rule or an `Err(..)` for an invalid one.
impl<'i, R, P, E: 'i> Iterator for StyleSheetParser<'i, '_, '_, P>
where
P: QualifiedRuleParser<'i, QualifiedRule = R, Error = E>
Expand Down
Loading