pub struct Parser<'a> { /* private fields */ }Expand description
CSS parser consuming tokens and producing syntax structures.
Implementations§
Source§impl<'a> Parser<'a>
impl<'a> Parser<'a>
Sourcepub fn parse_declarations(&mut self) -> ParseResult<Vec<CssNode>>
pub fn parse_declarations(&mut self) -> ParseResult<Vec<CssNode>>
Parse a bare declaration list (e.g. the value of a style attribute).
Unlike parse(), this does not expect selectors or a surrounding block.
It consumes declarations until EOF or } and returns them as
Declaration nodes, mirroring the body of a rule.
Sourcepub fn parse(&mut self) -> ParseResult<CssNode>
pub fn parse(&mut self) -> ParseResult<CssNode>
Parse the entire CSS source into a syntax tree.
This method consumes tokens until Token::EOF is reached and constructs
a CssNode representing the stylesheet root.
Parsing behavior:
- Whitespace tokens are ignored
- Qualified rules and at-rules are parsed into child nodes
- No semantic validation is performed
Sourcepub fn parse_lossy(&mut self) -> CssNode
pub fn parse_lossy(&mut self) -> CssNode
Parses a stylesheet while recovering from unsupported top-level items.
Browser stylesheets are frequently generated and may contain selectors
or declarations that this engine does not support yet. Dropping the
entire stylesheet for one such rule would also discard all compatible
rules, so this mode skips the failing item and resumes at the next
top-level boundary. The strict Self::parse entry point remains
available for validation and unit tests.
pub fn parse_tokens_to_css_value(tokens: Vec<Token>) -> ParseResult<CssValue>
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Parser<'a>
impl<'a> RefUnwindSafe for Parser<'a>
impl<'a> Send for Parser<'a>
impl<'a> Sync for Parser<'a>
impl<'a> Unpin for Parser<'a>
impl<'a> UnsafeUnpin for Parser<'a>
impl<'a> UnwindSafe for Parser<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more