/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
usecrate::tokenizer::Token; usecrate::{BasicParseError, Parser, ToCss}; use std::char; use std::fmt;
/// One contiguous range of code points. /// /// Can not be empty. Can represent a single code point when start == end. #[derive(PartialEq, Eq, Clone, Hash)] #[repr(C)] pubstruct UnicodeRange { /// Inclusive start of the range. In [0, end]. pub start: u32,
/// Inclusive end of the range. In [0, 0x10FFFF]. pub end: u32,
}
impl UnicodeRange { /// https://drafts.csswg.org/css-syntax/#urange-syntax pubfn parse<'i>(input: &mut Parser<'i, '_>) -> Result<Self, BasicParseError<'i>> { // <urange> = // u '+' <ident-token> '?'* | // u <dimension-token> '?'* | // u <number-token> '?'* | // u <number-token> <dimension-token> | // u <number-token> <number-token> | // u '+' '?'+
input.expect_ident_matching("u")?; let after_u = input.position();
parse_tokens(input)?;
// This deviates from the spec in case there are CSS comments // between tokens in the middle of one <unicode-range>, // but oh well… let concatenated_tokens = input.slice_from(after_u);
let range = match parse_concatenated(concatenated_tokens.as_bytes()) {
Ok(range) => range,
Err(()) => { return Err(input
.new_basic_unexpected_token_error(Token::Ident(concatenated_tokens.into())))
}
}; if range.end > char::MAX as u32 || range.start > range.end {
Err(input.new_basic_unexpected_token_error(Token::Ident(concatenated_tokens.into())))
} else {
Ok(range)
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.