diff --git a/crates/hdx_lexer/src/span.rs b/crates/hdx_lexer/src/span.rs index 5c8d6175..4c76dd22 100644 --- a/crates/hdx_lexer/src/span.rs +++ b/crates/hdx_lexer/src/span.rs @@ -34,15 +34,14 @@ impl Span { &source_text[self.start as usize..self.end as usize] } - pub fn with_start(&self, span: &Self) -> Self { - Self { start: span.start, end: self.end } - } - - pub fn with_end(&self, span: &Self) -> Self { - Self { start: self.start, end: span.end } - } - - pub fn up_to(&self, span: &Self) -> Self { + /// Returns a `Span` from the beginning of `self` until the beginning of `end`. + /// + /// ```text + /// ____ ___ + /// self lorem ipsum end + /// ^^^^^^^^^^^^^^^^^ + /// ``` + pub fn until(&self, span: Self) -> Self { Self { start: self.start, end: span.start } } } diff --git a/crates/hdx_parser/src/css/component_values.rs b/crates/hdx_parser/src/css/component_values.rs index 72dcffe1..2d51de46 100644 --- a/crates/hdx_parser/src/css/component_values.rs +++ b/crates/hdx_parser/src/css/component_values.rs @@ -39,10 +39,10 @@ impl<'a> Parse<'a> for ComponentValue<'a> { match parser.cur().kind { Kind::LeftCurly | Kind::LeftSquare | Kind::LeftParen => { Ok(Self::SimpleBlock(SimpleBlock::parse(parser)?) - .spanned(span.up_to(&parser.cur().span))) + .spanned(span.until(parser.cur().span))) } Kind::Function => { - Ok(Self::Function(Function::parse(parser)?).spanned(span.up_to(&parser.cur().span))) + Ok(Self::Function(Function::parse(parser)?).spanned(span.until(parser.cur().span))) } _ => { let token = parser.cur().clone(); @@ -63,7 +63,7 @@ impl<'a> Parse<'a> for SimpleBlock<'a> { .ok_or_else(|| diagnostics::Unexpected(parser.cur().kind, span))?; parser.advance(); let value = parser.parse_component_values(pairwise.end(), true)?; - Ok(Self { value: parser.boxup(value), pairwise }.spanned(span.up_to(&parser.cur().span))) + Ok(Self { value: parser.boxup(value), pairwise }.spanned(span.until(parser.cur().span))) } } @@ -73,6 +73,6 @@ impl<'a> Parse<'a> for Function<'a> { let span = parser.cur().span; let name = parser.expect_function()?; let value = parser.parse_component_values(Kind::RightParen, false)?; - Ok(Self { name, value: parser.boxup(value) }.spanned(span.up_to(&parser.cur().span))) + Ok(Self { name, value: parser.boxup(value) }.spanned(span.until(parser.cur().span))) } } diff --git a/crates/hdx_parser/src/css/parser_extensions.rs b/crates/hdx_parser/src/css/parser_extensions.rs index eb42fc78..935fa590 100644 --- a/crates/hdx_parser/src/css/parser_extensions.rs +++ b/crates/hdx_parser/src/css/parser_extensions.rs @@ -30,7 +30,7 @@ impl<'a> Parser<'a> { let mut prelude = None; loop { match self.cur().kind { - Kind::Eof => Err(diagnostics::Unexpected(Kind::Eof, span.up_to(&self.cur().span)))?, + Kind::Eof => Err(diagnostics::Unexpected(Kind::Eof, span.until(self.cur().span)))?, Kind::RightCurly => { if nested { Err(diagnostics::Unexpected(self.cur().kind, self.cur().span))? @@ -181,7 +181,7 @@ impl<'a> Parser<'a> { Err(diagnostics::Unimplemented(span))?; } self.expect(Kind::Colon) - .map_err(|_| diagnostics::BadDeclaration(span.up_to(&self.cur().span)))?; + .map_err(|_| diagnostics::BadDeclaration(span.until(self.cur().span)))?; let value = Value::parse(self)?; let mut important = false; loop { diff --git a/crates/hdx_parser/src/css/properties.rs b/crates/hdx_parser/src/css/properties.rs index 25a711bc..6ee46a36 100644 --- a/crates/hdx_parser/src/css/properties.rs +++ b/crates/hdx_parser/src/css/properties.rs @@ -15,7 +15,7 @@ impl<'a> Parse<'a> for Custom<'a> { let checkpoint = parser.checkpoint(); let value_span = parser.cur().span; let value_like = ValueLike::parse(parser) - .unwrap_or(ValueLike::Unknown.spanned(value_span.up_to(&parser.cur().span))); + .unwrap_or(ValueLike::Unknown.spanned(value_span.until(parser.cur().span))); parser.rewind(checkpoint); let mut value = parser.parse_component_values(Kind::Semicolon, true)?; if parser.at(Kind::Semicolon) { @@ -33,7 +33,7 @@ impl<'a> Parse<'a> for Custom<'a> { } } Ok(Self { name, value_like, value: parser.boxup(value), important } - .spanned(span.up_to(&parser.cur().span))) + .spanned(span.until(parser.cur().span))) } } @@ -44,28 +44,26 @@ impl<'a> Parse<'a> for ValueLike<'a> { let token = parser.cur().clone(); let parsed = MathExpr::::parse(parser); if let Ok(value) = parsed { - return Ok(Self::Length(parser.boxup(value)).spanned(span.up_to(&parser.cur().span))); + return Ok(Self::Length(parser.boxup(value)).spanned(span.until(parser.cur().span))); } parser.rewind(checkpoint); let checkpoint = parser.checkpoint(); let parsed = MathExpr::::parse(parser); if let Ok(value) = parsed { return Ok( - Self::LengthPercentage(parser.boxup(value)).spanned(span.up_to(&parser.cur().span)) + Self::LengthPercentage(parser.boxup(value)).spanned(span.until(parser.cur().span)) ); } parser.rewind(checkpoint); let checkpoint = parser.checkpoint(); let parsed = Expr::::parse(parser); if let Ok(value) = parsed { - return Ok(Self::Color(parser.boxup(value)).spanned(span.up_to(&parser.cur().span))); + return Ok(Self::Color(parser.boxup(value)).spanned(span.until(parser.cur().span))); } parser.rewind(checkpoint); let parsed = ExprList::::parse(parser); if let Ok(value) = parsed { - return Ok( - Self::FontFamily(parser.boxup(value)).spanned(span.up_to(&parser.cur().span)) - ); + return Ok(Self::FontFamily(parser.boxup(value)).spanned(span.until(parser.cur().span))); } Err(diagnostics::Unexpected(token.kind, token.span).into()) } @@ -80,7 +78,7 @@ macro_rules! parse_properties { parser.parse_declaration( Some($prop::name_as_atom()), |parser: &mut Parser<'a>, _name: &Token, value: Spanned<<$prop as Declaration>::Value>, important: bool| { - Ok($prop { value: parser.boxup(value), important }.spanned(span.up_to(&parser.cur().span))) + Ok($prop { value: parser.boxup(value), important }.spanned(span.until(parser.cur().span))) }, ) } @@ -92,7 +90,7 @@ macro_rules! parse_properties { let span = parser.cur().span; if parser.cur().is_dashed_ident() { let custom = Custom::parse(parser)?; - return Ok(Property::Custom(parser.boxup(custom)).spanned(span.up_to(&parser.cur().span))); + return Ok(Property::Custom(parser.boxup(custom)).spanned(span.until(parser.cur().span))); } let checkpoint = parser.checkpoint(); let property = match PropertyId::from_atom(parser.cur().as_atom_lower().unwrap_or(atom!(""))) { @@ -110,10 +108,10 @@ macro_rules! parse_properties { let parsed = UnknownDeclaration::parse(parser).map(|p| Property::Unknown(parser.boxup(p))); parser.warnings.push(e); - parser.warnings.push(diagnostics::UnknownDeclaration(span.up_to(&parser.cur().span)).into()); + parser.warnings.push(diagnostics::UnknownDeclaration(span.until(parser.cur().span)).into()); parsed })?; - Ok(property.spanned(span.up_to(&parser.cur().span))) + Ok(property.spanned(span.until(parser.cur().span))) } } } diff --git a/crates/hdx_parser/src/css/rules/charset.rs b/crates/hdx_parser/src/css/rules/charset.rs index 21a91f39..fa8eff19 100644 --- a/crates/hdx_parser/src/css/rules/charset.rs +++ b/crates/hdx_parser/src/css/rules/charset.rs @@ -8,6 +8,6 @@ impl<'a> Parse<'a> for CSSCharsetRule { parser.expect_at_keyword_of(atom!("charset"))?; let encoding = parser.expect_string()?; parser.expect(Kind::Semicolon)?; - Ok(Self { encoding }.spanned(span.up_to(&parser.cur().span))) + Ok(Self { encoding }.spanned(span.until(parser.cur().span))) } } diff --git a/crates/hdx_parser/src/css/rules/mod.rs b/crates/hdx_parser/src/css/rules/mod.rs index d28d0830..848617d2 100644 --- a/crates/hdx_parser/src/css/rules/mod.rs +++ b/crates/hdx_parser/src/css/rules/mod.rs @@ -8,6 +8,6 @@ impl<'a> Parse<'a> for NoPreludeAllowed { fn parse(parser: &mut Parser<'a>) -> Result> { let span = parser.cur().span; parser.expect_without_advance(Kind::LeftCurly)?; - Ok(Self {}.spanned(span.up_to(&parser.cur().span))) + Ok(Self {}.spanned(span.until(parser.cur().span))) } } diff --git a/crates/hdx_parser/src/css/rules/page.rs b/crates/hdx_parser/src/css/rules/page.rs index 28cdfb03..d58dbf26 100644 --- a/crates/hdx_parser/src/css/rules/page.rs +++ b/crates/hdx_parser/src/css/rules/page.rs @@ -26,7 +26,7 @@ impl<'a> Parse<'a> for CSSPageRule<'a> { declarations: parser.boxup(declarations), rules: parser.boxup(rules), } - .spanned(span.up_to(&parser.cur().span))) + .spanned(span.until(parser.cur().span))) }, ) } @@ -36,7 +36,7 @@ impl<'a> Parse<'a> for PageSelectorList<'a> { fn parse(parser: &mut Parser<'a>) -> Result> { let span = parser.cur().span; let ok = Ok(Self { children: parser.parse_comma_list_of::()? } - .spanned(span.up_to(&parser.cur().span))); + .spanned(span.until(parser.cur().span))); ok } } @@ -59,7 +59,7 @@ impl<'a> Parse<'a> for PageSelector<'a> { } } } - Ok(Self { page_type, pseudos }.spanned(span.up_to(&parser.cur().span))) + Ok(Self { page_type, pseudos }.spanned(span.until(parser.cur().span))) } } @@ -69,7 +69,7 @@ impl<'a> Parse<'a> for PagePseudoClass { parser.expect(Kind::Colon)?; let name = parser.expect_ident()?; match Self::from_atom(name.clone()) { - Some(v) => Ok(v.spanned(span.up_to(&parser.cur().span))), + Some(v) => Ok(v.spanned(span.until(parser.cur().span))), _ => Err(diagnostics::UnexpectedPseudo(name, span).into()), } } @@ -86,7 +86,7 @@ impl<'a> Parse<'a> for CSSMarginRule<'a> { _rules: Vec<'a, Spanned>>, declarations: Vec<'a, Spanned>>| { Ok(Self { name: PageMarginBox::TopLeft, declarations } - .spanned(span.up_to(&parser.cur().span))) + .spanned(span.until(parser.cur().span))) }, ) } diff --git a/crates/hdx_parser/src/css/selector/mod.rs b/crates/hdx_parser/src/css/selector/mod.rs index cabf61e9..ef4ef600 100644 --- a/crates/hdx_parser/src/css/selector/mod.rs +++ b/crates/hdx_parser/src/css/selector/mod.rs @@ -91,7 +91,7 @@ impl<'a> Parse<'a> for Selector<'a> { } components.push(component); } - Ok(Self { components: parser.boxup(components) }.spanned(span.up_to(&parser.cur().span))) + Ok(Self { components: parser.boxup(components) }.spanned(span.until(parser.cur().span))) } } @@ -101,7 +101,7 @@ impl<'a> Parse<'a> for Component<'a> { match parser.cur().kind { Kind::Whitespace => { parser.next_token(); - Ok(Self::Combinator(Combinator::Descendant).spanned(span.up_to(&parser.cur().span))) + Ok(Self::Combinator(Combinator::Descendant).spanned(span.until(parser.cur().span))) } Kind::Ident => { let name = parser.cur().as_atom_lower().unwrap(); @@ -117,8 +117,7 @@ impl<'a> Parse<'a> for Component<'a> { let ident = parser.cur().as_atom().unwrap(); if let Some(selector) = PseudoElement::from_atom(ident) { parser.next_token(); - Ok(Self::PseudoElement(selector) - .spanned(span.up_to(&parser.cur().span))) + Ok(Self::PseudoElement(selector).spanned(span.until(parser.cur().span))) } else { Err(diagnostics::Unimplemented(parser.cur().span))? } @@ -128,10 +127,10 @@ impl<'a> Parse<'a> for Component<'a> { let ident = parser.cur().as_atom().unwrap(); if let Some(selector) = PseudoClass::from_atom(ident.clone()) { parser.next_token(); - Ok(Self::PseudoClass(selector).spanned(span.up_to(&parser.cur().span))) + Ok(Self::PseudoClass(selector).spanned(span.until(parser.cur().span))) } else if let Some(e) = LegacyPseudoElement::from_atom(ident.clone()) { parser.next_token(); - Ok(Self::LegacyPseudoElement(e).spanned(span.up_to(&parser.cur().span))) + Ok(Self::LegacyPseudoElement(e).spanned(span.until(parser.cur().span))) } else { Err(diagnostics::UnexpectedIdent(ident, parser.cur().span))? } @@ -142,7 +141,7 @@ impl<'a> Parse<'a> for Component<'a> { Kind::Hash => { let name = parser.cur().as_atom().unwrap(); parser.next_token(); - Ok(Self::Id(name).spanned(span.up_to(&parser.cur().span))) + Ok(Self::Id(name).spanned(span.until(parser.cur().span))) } Kind::Delim => match parser.cur().value.as_char() { Some('.') => { @@ -152,7 +151,7 @@ impl<'a> Parse<'a> for Component<'a> { parser.next_token(); let ident = parser.cur().as_atom().unwrap(); parser.next_token(); - Ok(Self::Class(ident).spanned(span.up_to(&parser.cur().span))) + Ok(Self::Class(ident).spanned(span.until(parser.cur().span))) } _ => Err(diagnostics::Unimplemented(parser.cur().span))?, } @@ -163,11 +162,11 @@ impl<'a> Parse<'a> for Component<'a> { Kind::Delim if next_token.value.as_char().unwrap() == '|' => { let (prefix, atom) = parse_wq_name(parser)?; Ok(Self::NSPrefixedType(parser.boxup((prefix, atom))) - .spanned(span.up_to(&parser.cur().span))) + .spanned(span.until(parser.cur().span))) } _ => { parser.next_token(); - Ok(Self::Wildcard.spanned(span.up_to(&parser.cur().span))) + Ok(Self::Wildcard.spanned(span.until(parser.cur().span))) } } } @@ -175,7 +174,7 @@ impl<'a> Parse<'a> for Component<'a> { }, Kind::LeftSquare => { let attr = Attribute::parse(parser)?; - Ok(Component::Attribute(parser.boxup(attr)).spanned(span.up_to(&parser.cur().span))) + Ok(Component::Attribute(parser.boxup(attr)).spanned(span.until(parser.cur().span))) } _ => Err(diagnostics::Unimplemented(parser.cur().span))?, } @@ -194,7 +193,7 @@ impl<'a> Parse<'a> for Attribute { Kind::RightSquare => { parser.next_token(); return Ok(Self { ns_prefix, name, value, modifier, matcher } - .spanned(span.up_to(&parser.cur().span))); + .spanned(span.until(parser.cur().span))); } Kind::Delim => { let delim_span = parser.cur().span; @@ -232,7 +231,7 @@ impl<'a> Parse<'a> for Attribute { Kind::RightSquare => { parser.next_token(); Ok(Self { ns_prefix, name, value, modifier, matcher } - .spanned(span.up_to(&parser.cur().span))) + .spanned(span.until(parser.cur().span))) } Kind::Ident => { let ident_span = parser.cur().span; @@ -243,7 +242,7 @@ impl<'a> Parse<'a> for Attribute { }; parser.expect(Kind::RightSquare)?; Ok(Self { ns_prefix, name, value, modifier, matcher } - .spanned(span.up_to(&parser.cur().span))) + .spanned(span.until(parser.cur().span))) } k => Err(diagnostics::Unexpected(k, parser.cur().span))?, } diff --git a/crates/hdx_parser/src/css/stylerule.rs b/crates/hdx_parser/src/css/stylerule.rs index e54b97c1..9c885859 100644 --- a/crates/hdx_parser/src/css/stylerule.rs +++ b/crates/hdx_parser/src/css/stylerule.rs @@ -16,14 +16,14 @@ impl<'a> Parse<'a> for CSSStyleRule<'a> { rules: Vec<'a, Spanned>>, declarations: Vec<'a, Spanned>>| { if selectors.is_none() { - Err(diagnostics::NoSelector(span, span.up_to(&parser.cur().span)))? + Err(diagnostics::NoSelector(span, span.until(parser.cur().span)))? } Ok(Self { selectors: parser.boxup(selectors.unwrap()), declarations: parser.boxup(declarations), rules: parser.boxup(rules), } - .spanned(span.up_to(&parser.cur().span))) + .spanned(span.until(parser.cur().span))) }, ) } diff --git a/crates/hdx_parser/src/css/stylesheet.rs b/crates/hdx_parser/src/css/stylesheet.rs index aca6027c..74f561e3 100644 --- a/crates/hdx_parser/src/css/stylesheet.rs +++ b/crates/hdx_parser/src/css/stylesheet.rs @@ -50,7 +50,7 @@ impl<'a> Parse<'a> for CSSStyleSheet<'a> { } } } - Ok(Self { rules }.spanned(span.up_to(&parser.cur().span))) + Ok(Self { rules }.spanned(span.until(parser.cur().span))) } } @@ -58,7 +58,7 @@ impl<'a> Parse<'a> for SelectorSet<'a> { fn parse(parser: &mut Parser<'a>) -> Result> { let span = parser.cur().span; Ok(Self { children: parser.parse_comma_list_of::()? } - .spanned(span.up_to(&parser.cur().span))) + .spanned(span.until(parser.cur().span))) } } diff --git a/crates/hdx_parser/src/css/unknown.rs b/crates/hdx_parser/src/css/unknown.rs index 4e9705c6..6ccfc97e 100644 --- a/crates/hdx_parser/src/css/unknown.rs +++ b/crates/hdx_parser/src/css/unknown.rs @@ -19,7 +19,7 @@ impl<'a> Parse<'a> for UnknownAtRule<'a> { rules: parser.boxup(rules), properties: parser.boxup(properties), } - .spanned(span.up_to(&parser.cur().span))) + .spanned(span.until(parser.cur().span))) }, ) } @@ -37,7 +37,7 @@ impl<'a> Parse<'a> for UnknownRule<'a> { rules: parser.boxup(rules), properties: parser.boxup(properties), } - .spanned(span.up_to(&parser.cur().span))) + .spanned(span.until(parser.cur().span))) }, ) } @@ -47,7 +47,7 @@ impl<'a> Parse<'a> for UnknownPrelude<'a> { fn parse(parser: &mut Parser<'a>) -> Result> { let span = parser.cur().span; let value = parser.parse_component_values(Kind::Semicolon, false)?; - Ok(Self { value: parser.boxup(value) }.spanned(span.up_to(&parser.cur().span))) + Ok(Self { value: parser.boxup(value) }.spanned(span.until(parser.cur().span))) } } @@ -81,7 +81,7 @@ impl<'a> Parse<'a> for UnknownDeclaration<'a> { parser.advance(); } Ok(Self { name, value_like, value: parser.boxup(value), important: false } - .spanned(span.up_to(&parser.cur().span))) + .spanned(span.until(parser.cur().span))) } } diff --git a/crates/hdx_parser/src/css/values/angle.rs b/crates/hdx_parser/src/css/values/angle.rs index 3c6e9a3d..28e5b3bd 100644 --- a/crates/hdx_parser/src/css/values/angle.rs +++ b/crates/hdx_parser/src/css/values/angle.rs @@ -15,17 +15,17 @@ impl<'a> Parse<'a> for Angle { ))? } parser.advance(); - Ok(Self::Zero.spanned(span.up_to(&parser.cur().span))) + Ok(Self::Zero.spanned(span.until(parser.cur().span))) } Kind::Dimension => { let value = parser.cur().value.as_f32().unwrap(); let unit = parser.cur_atom().unwrap(); parser.advance(); match unit { - atom!("deg") => Ok(Self::Deg(value).spanned(span.up_to(&parser.cur().span))), - atom!("grad") => Ok(Self::Grad(value).spanned(span.up_to(&parser.cur().span))), - atom!("rad") => Ok(Self::Rad(value).spanned(span.up_to(&parser.cur().span))), - atom!("turn") => Ok(Self::Turn(value).spanned(span.up_to(&parser.cur().span))), + atom!("deg") => Ok(Self::Deg(value).spanned(span.until(parser.cur().span))), + atom!("grad") => Ok(Self::Grad(value).spanned(span.until(parser.cur().span))), + atom!("rad") => Ok(Self::Rad(value).spanned(span.until(parser.cur().span))), + atom!("turn") => Ok(Self::Turn(value).spanned(span.until(parser.cur().span))), _ => Err(diagnostics::UnexpectedIdent(unit, parser.cur().span))?, } } diff --git a/crates/hdx_parser/src/css/values/backgrounds.rs b/crates/hdx_parser/src/css/values/backgrounds.rs index eb35d00e..cc3eb55f 100644 --- a/crates/hdx_parser/src/css/values/backgrounds.rs +++ b/crates/hdx_parser/src/css/values/backgrounds.rs @@ -79,7 +79,7 @@ impl<'a> Parse<'a> for BorderShorthand<'a> { break; } } - Ok(Self { color, line_style, line_width }.spanned(span.up_to(&parser.cur().span))) + Ok(Self { color, line_style, line_width }.spanned(span.until(parser.cur().span))) } } @@ -88,7 +88,7 @@ impl<'a> Parse<'a> for LineWidth { let span = parser.cur().span; match parser.cur().kind { Kind::Number | Kind::Dimension => { - Ok(Self::Length(Length::parse(parser)?).spanned(span.up_to(&parser.cur().span))) + Ok(Self::Length(Length::parse(parser)?).spanned(span.until(parser.cur().span))) } Kind::Ident => { let ident = parser.cur_atom().unwrap(); diff --git a/crates/hdx_parser/src/css/values/box.rs b/crates/hdx_parser/src/css/values/box.rs index 04347281..febdc3ad 100644 --- a/crates/hdx_parser/src/css/values/box.rs +++ b/crates/hdx_parser/src/css/values/box.rs @@ -13,13 +13,13 @@ impl<'a> Parse<'a> for MarginTrimValue { inline_start: false, inline_end: false, } - .spanned(span.up_to(&parser.cur().span))) + .spanned(span.until(parser.cur().span))) } else if ident == atom!("block") { Ok(Self { block_start: true, block_end: true, inline_start: false, inline_end: false } - .spanned(span.up_to(&parser.cur().span))) + .spanned(span.until(parser.cur().span))) } else if ident == atom!("inline") { Ok(Self { block_start: false, block_end: false, inline_start: true, inline_end: true } - .spanned(span.up_to(&parser.cur().span))) + .spanned(span.until(parser.cur().span))) } else { let mut value = Self { block_start: ident == atom!("block-start"), @@ -61,7 +61,7 @@ impl<'a> Parse<'a> for MarginTrimValue { _ => break, } } - Ok(value.spanned(span.up_to(&parser.cur().span))) + Ok(value.spanned(span.until(parser.cur().span))) } } } diff --git a/crates/hdx_parser/src/css/values/color.rs b/crates/hdx_parser/src/css/values/color.rs index 2895c2f5..0dc8427f 100644 --- a/crates/hdx_parser/src/css/values/color.rs +++ b/crates/hdx_parser/src/css/values/color.rs @@ -13,7 +13,7 @@ impl<'a> Parse<'a> for ColorValue<'a> { Kind::Hash => { let hash = parser.expect_hash()?; if let Some(hex) = ColorValue::from_hex(hash.as_ref()) { - Ok(hex.spanned(span.up_to(&parser.cur().span))) + Ok(hex.spanned(span.until(parser.cur().span))) } else { Err(diagnostics::BadHexColor(hash.clone(), span))? } @@ -22,10 +22,10 @@ impl<'a> Parse<'a> for ColorValue<'a> { let name = parser.expect_ident()?; match name { atom!("transparent") => { - Ok(ColorValue::Transparent.spanned(span.up_to(&parser.cur().span))) + Ok(ColorValue::Transparent.spanned(span.until(parser.cur().span))) } _ => match NamedColor::from_atom(name.clone()) { - Some(n) => Ok(ColorValue::Named(n).spanned(span.up_to(&parser.cur().span))), + Some(n) => Ok(ColorValue::Named(n).spanned(span.until(parser.cur().span))), None => Err(diagnostics::UnknownColor(name, span))?, }, } @@ -36,7 +36,7 @@ impl<'a> Parse<'a> for ColorValue<'a> { atom!("rgb") | atom!("rgba") => { let node = RGB::parse(parser)?; Ok(ColorValue::RGB(parser.boxup(node)) - .spanned(span.up_to(&parser.cur().span))) + .spanned(span.until(parser.cur().span))) } _ => Err(diagnostics::Unimplemented(span))?, } @@ -72,7 +72,7 @@ impl<'a> Parse<'a> for RGB<'a> { alpha = MathExpr::::parse(parser)?; } parser.expect(Kind::RightParen)?; - Ok(Self { r, g, b, alpha }.spanned(span.up_to(&parser.cur().span))) + Ok(Self { r, g, b, alpha }.spanned(span.until(parser.cur().span))) } } @@ -81,14 +81,14 @@ impl<'a> Parse<'a> for NumberPercentageOrNone { let span = parser.cur().span; match parser.cur().kind { Kind::Number => { - Ok(Self::Number(parser.expect_number()?).spanned(span.up_to(&parser.cur().span))) + Ok(Self::Number(parser.expect_number()?).spanned(span.until(parser.cur().span))) } Kind::Percentage => Ok(Self::Percentage(parser.expect_percentage()?) - .spanned(span.up_to(&parser.cur().span))), + .spanned(span.until(parser.cur().span))), Kind::Ident => match parser.expect_ident()? { atom!("none") => { parser.advance(); - Ok(Self::None.spanned(span.up_to(&parser.cur().span))) + Ok(Self::None.spanned(span.until(parser.cur().span))) } _ => Err(diagnostics::Unimplemented(span))?, }, diff --git a/crates/hdx_parser/src/css/values/content.rs b/crates/hdx_parser/src/css/values/content.rs index 2a1b9788..36a9fc25 100644 --- a/crates/hdx_parser/src/css/values/content.rs +++ b/crates/hdx_parser/src/css/values/content.rs @@ -9,11 +9,11 @@ impl<'a> Parse<'a> for ContentsValue<'a> { match parser.cur_atom_lower().unwrap() { atom!("normal") => { parser.advance(); - return Ok(Self::Normal.spanned(span.up_to(&parser.cur().span))); + return Ok(Self::Normal.spanned(span.until(parser.cur().span))); } atom!("none") => { parser.advance(); - return Ok(Self::None.spanned(span.up_to(&parser.cur().span))); + return Ok(Self::None.spanned(span.until(parser.cur().span))); } _ => {} } @@ -26,7 +26,7 @@ impl<'a> Parse<'a> for ContentsValue<'a> { // return Ok(Self::Replacement(ContentReplacement { image, alt: list.alt })); // } // } - Ok(Self::List(list).spanned(span.up_to(&parser.cur().span))) + Ok(Self::List(list).spanned(span.until(parser.cur().span))) } } @@ -47,7 +47,7 @@ impl<'a> Parse<'a> for ContentList<'a> { _ => Err(diagnostics::Unimplemented(parser.cur().span))?, } } - Ok(Self { values, alt }.spanned(span.up_to(&parser.cur().span))) + Ok(Self { values, alt }.spanned(span.until(parser.cur().span))) } } @@ -60,11 +60,11 @@ impl<'a> Parse<'a> for QuotesValue<'a> { match ident { atom!("none") => { parser.advance(); - return Ok(Self::None.spanned(span.up_to(&parser.cur().span))); + return Ok(Self::None.spanned(span.until(parser.cur().span))); } atom!("auto") => { parser.advance(); - return Ok(Self::Auto.spanned(span.up_to(&parser.cur().span))); + return Ok(Self::Auto.spanned(span.until(parser.cur().span))); } _ => Err(diagnostics::UnexpectedIdent(ident, parser.cur().span))?, } @@ -79,7 +79,7 @@ impl<'a> Parse<'a> for QuotesValue<'a> { break; } } - Ok(Self::Custom(custom).spanned(span.up_to(&parser.cur().span))) + Ok(Self::Custom(custom).spanned(span.until(parser.cur().span))) } k => Err(diagnostics::Unexpected(k, parser.cur().span))?, } diff --git a/crates/hdx_parser/src/css/values/counter_styles.rs b/crates/hdx_parser/src/css/values/counter_styles.rs index 130966c6..ad18c6c0 100644 --- a/crates/hdx_parser/src/css/values/counter_styles.rs +++ b/crates/hdx_parser/src/css/values/counter_styles.rs @@ -18,7 +18,7 @@ impl<'a> Parse<'a> for CounterStyle<'a> { let ident = parser.expect_ident()?; if ident == atom!("symbols") { let node = Symbols::parse(parser)?; - Ok(Self::Symbols(node).spanned(span.up_to(&parser.cur().span))) + Ok(Self::Symbols(node).spanned(span.until(parser.cur().span))) } else { Err(diagnostics::ExpectedFunction(atom!("symbols"), ident, parser.cur().span))? } diff --git a/crates/hdx_parser/src/css/values/display.rs b/crates/hdx_parser/src/css/values/display.rs index f5ffe253..a2f902c6 100644 --- a/crates/hdx_parser/src/css/values/display.rs +++ b/crates/hdx_parser/src/css/values/display.rs @@ -31,7 +31,7 @@ impl<'a> Parse<'a> for DisplayValue { inside = DisplayInside::from_atom(second).unwrap(); if let Some(marker) = DisplayMarker::from_atom(third.clone()) { Ok(DisplayValue::PairAndMarker(outside, inside, marker) - .spanned(span.up_to(&parser.cur().span))) + .spanned(span.until(parser.cur().span))) } else { Err(diagnostics::UnexpectedIdent(third, parser.cur().span).into()) } @@ -42,10 +42,10 @@ impl<'a> Parse<'a> for DisplayValue { outside = display; if let Some(display) = DisplayMarker::from_atom(second.clone()) { Ok(DisplayValue::PairAndMarker(outside, inside, display) - .spanned(span.up_to(&parser.cur().span))) + .spanned(span.until(parser.cur().span))) } else if let Some(display) = DisplayInside::from_atom(second.clone()) { Ok(DisplayValue::Pair(outside, display) - .spanned(span.up_to(&parser.cur().span))) + .spanned(span.until(parser.cur().span))) } else { Err(diagnostics::UnexpectedIdent(second, parser.cur().span).into()) } @@ -53,7 +53,7 @@ impl<'a> Parse<'a> for DisplayValue { inside = display; if let Some(display) = DisplayOutside::from_atom(second.clone()) { Ok(DisplayValue::Pair(display, inside) - .spanned(span.up_to(&parser.cur().span))) + .spanned(span.until(parser.cur().span))) } else { Err(diagnostics::UnexpectedIdent(second, parser.cur().span).into()) } @@ -64,7 +64,7 @@ impl<'a> Parse<'a> for DisplayValue { // | | | _ => { if let Some(display) = DisplayValue::from_atom(first.clone()) { - Ok(display.spanned(span.up_to(&parser.cur().span))) + Ok(display.spanned(span.until(parser.cur().span))) } else { Err(diagnostics::UnexpectedIdent(first, parser.cur().span).into()) } diff --git a/crates/hdx_parser/src/css/values/expr.rs b/crates/hdx_parser/src/css/values/expr.rs index ca6a3e56..994dcaa0 100644 --- a/crates/hdx_parser/src/css/values/expr.rs +++ b/crates/hdx_parser/src/css/values/expr.rs @@ -15,27 +15,27 @@ where Kind::Ident => { if let Some(val) = GlobalValue::from_atom(parser.cur().as_atom().unwrap()) { parser.advance(); - Self::GlobalValue(val).spanned(span.up_to(&parser.cur().span)) + Self::GlobalValue(val).spanned(span.until(parser.cur().span)) } else { - Self::Literal(T::parse(parser)?).spanned(span.up_to(&parser.cur().span)) + Self::Literal(T::parse(parser)?).spanned(span.until(parser.cur().span)) } } Kind::Function => match parser.cur().as_atom().unwrap() { atom!("var") | atom!("env") => { let node = Reference::parse(parser)?; - Self::Reference(node).spanned(span.up_to(&parser.cur().span)) + Self::Reference(node).spanned(span.until(parser.cur().span)) } atom!("calc") /*TODO! ...*/ => { Err(diagnostics::DisallowedMathFunction(parser.cur().as_atom().unwrap(), parser.cur().span))? }, _ => { let node = T::parse(parser)?; - Self::Literal(node).spanned(span.up_to(&parser.cur().span)) + Self::Literal(node).spanned(span.until(parser.cur().span)) } }, _ => { let node = T::parse(parser)?; - Self::Literal(node).spanned(span.up_to(&parser.cur().span)) + Self::Literal(node).spanned(span.until(parser.cur().span)) } }) } @@ -51,26 +51,26 @@ where Kind::Ident => { if let Some(val) = GlobalValue::from_atom(parser.cur().as_atom().unwrap()) { parser.advance(); - Self::GlobalValue(val).spanned(span.up_to(&parser.cur().span)) + Self::GlobalValue(val).spanned(span.until(parser.cur().span)) } else { let node = T::parse(parser)?; - Self::Literal(node).spanned(span.up_to(&parser.cur().span)) + Self::Literal(node).spanned(span.until(parser.cur().span)) } } Kind::Function => { match parser.cur().value.as_atom().unwrap() { atom!("var") | atom!("env") => { let node = Reference::parse(parser)?; - Self::Reference(node).spanned(span.up_to(&parser.cur().span)) + Self::Reference(node).spanned(span.until(parser.cur().span)) }, atom!("calc") /*TODO! ...*/ => { let node = MathFunc::parse(parser)?; - Self::Math(node).spanned(span.up_to(&parser.cur().span)) + Self::Math(node).spanned(span.until(parser.cur().span)) }, - _ => Self::Literal(T::parse(parser)?).spanned(span.up_to(&parser.cur().span)) + _ => Self::Literal(T::parse(parser)?).spanned(span.until(parser.cur().span)) } } - _ => Self::Literal(T::parse(parser)?).spanned(span.up_to(&parser.cur().span)), + _ => Self::Literal(T::parse(parser)?).spanned(span.until(parser.cur().span)), }) } } @@ -85,14 +85,14 @@ where Kind::Ident => { if let Some(val) = GlobalValue::from_atom(parser.cur().as_atom().unwrap()) { parser.advance(); - Self::GlobalValue(val).spanned(span.up_to(&parser.cur().span)) + Self::GlobalValue(val).spanned(span.until(parser.cur().span)) } else { Self::Values(parser.parse_comma_list_of::>()?) - .spanned(span.up_to(&parser.cur().span)) + .spanned(span.until(parser.cur().span)) } } _ => Self::Values(parser.parse_comma_list_of::>()?) - .spanned(span.up_to(&parser.cur().span)), + .spanned(span.until(parser.cur().span)), }) } } @@ -107,14 +107,14 @@ where Kind::Ident => { if let Some(val) = GlobalValue::from_atom(parser.cur().as_atom().unwrap()) { parser.advance(); - Self::GlobalValue(val).spanned(span.up_to(&parser.cur().span)) + Self::GlobalValue(val).spanned(span.until(parser.cur().span)) } else { Self::Values(parser.parse_comma_list_of::>()?) - .spanned(span.up_to(&parser.cur().span)) + .spanned(span.until(parser.cur().span)) } } _ => Self::Values(parser.parse_comma_list_of::>()?) - .spanned(span.up_to(&parser.cur().span)), + .spanned(span.until(parser.cur().span)), }) } } @@ -126,15 +126,15 @@ where fn parse(parser: &mut Parser<'a>) -> Result> { let span = parser.cur().span; Ok(match parser.cur().kind { - Kind::Ident => Self::Literal(T::parse(parser)?).spanned(span.up_to(&parser.cur().span)), + Kind::Ident => Self::Literal(T::parse(parser)?).spanned(span.until(parser.cur().span)), Kind::Function => match parser.cur().as_atom().unwrap() { - atom!("var") | atom!("env") => Self::Reference(Reference::parse(parser)?).spanned(span.up_to(&parser.cur().span)), + atom!("var") | atom!("env") => Self::Reference(Reference::parse(parser)?).spanned(span.until(parser.cur().span)), atom!("calc") /*TODO! ...*/ => { Err(diagnostics::DisallowedMathFunction(parser.cur().as_atom().unwrap(), parser.cur().span))? }, - _ => Self::Literal(T::parse(parser)?).spanned(span.up_to(&parser.cur().span)), + _ => Self::Literal(T::parse(parser)?).spanned(span.until(parser.cur().span)), }, - _ => Self::Literal(T::parse(parser)?).spanned(span.up_to(&parser.cur().span)), + _ => Self::Literal(T::parse(parser)?).spanned(span.until(parser.cur().span)), }) } } @@ -146,19 +146,19 @@ where fn parse(parser: &mut Parser<'a>) -> Result> { let span = parser.cur().span; Ok(match parser.cur().kind { - Kind::Ident => Self::Literal(T::parse(parser)?).spanned(span.up_to(&parser.cur().span)), + Kind::Ident => Self::Literal(T::parse(parser)?).spanned(span.until(parser.cur().span)), Kind::Function => { match parser.cur().as_atom().unwrap() { atom!("var") | atom!("env") => { - Self::Reference(Reference::parse(parser)?).spanned(span.up_to(&parser.cur().span)) + Self::Reference(Reference::parse(parser)?).spanned(span.until(parser.cur().span)) }, atom!("calc") /*TODO! ...*/ => { - Self::Math(MathFunc::parse(parser)?).spanned(span.up_to(&parser.cur().span)) + Self::Math(MathFunc::parse(parser)?).spanned(span.until(parser.cur().span)) }, - _ => Self::Literal(T::parse(parser)?).spanned(span.up_to(&parser.cur().span)) + _ => Self::Literal(T::parse(parser)?).spanned(span.until(parser.cur().span)) } } - _ => Self::Literal(T::parse(parser)?).spanned(span.up_to(&parser.cur().span)), + _ => Self::Literal(T::parse(parser)?).spanned(span.until(parser.cur().span)), }) } } @@ -186,7 +186,7 @@ where inner = Some(T::parse(parser)?) } parser.expect(Kind::RightParen)?; - Self::Var(name, parser.boxup(inner)).spanned(span.up_to(&parser.cur().span)) + Self::Var(name, parser.boxup(inner)).spanned(span.until(parser.cur().span)) } atom!("env") => { let name = parser.expect_ident()?; @@ -196,7 +196,7 @@ where inner = Some(T::parse(parser)?) } parser.expect(Kind::RightParen)?; - Self::Env(name, parser.boxup(inner)).spanned(span.up_to(&parser.cur().span)) + Self::Env(name, parser.boxup(inner)).spanned(span.until(parser.cur().span)) } _ => Err(diagnostics::UnexpectedFunction(ident, parser.cur().span))?, }) diff --git a/crates/hdx_parser/src/css/values/fonts.rs b/crates/hdx_parser/src/css/values/fonts.rs index 05b68438..f591fc23 100644 --- a/crates/hdx_parser/src/css/values/fonts.rs +++ b/crates/hdx_parser/src/css/values/fonts.rs @@ -12,13 +12,13 @@ impl<'a> Parse<'a> for FontWeightValue { Kind::Ident => { let ident = parser.expect_ident()?; if ident == atom!("normal") { - Ok(Self::Normal.spanned(span.up_to(&parser.cur().span))) + Ok(Self::Normal.spanned(span.until(parser.cur().span))) } else if ident == atom!("bold") { - Ok(Self::Bold.spanned(span.up_to(&parser.cur().span))) + Ok(Self::Bold.spanned(span.until(parser.cur().span))) } else if ident == atom!("bolder") { - Ok(Self::Bolder.spanned(span.up_to(&parser.cur().span))) + Ok(Self::Bolder.spanned(span.until(parser.cur().span))) } else if ident == atom!("lighter") { - Ok(Self::Lighter.spanned(span.up_to(&parser.cur().span))) + Ok(Self::Lighter.spanned(span.until(parser.cur().span))) } else { Err(diagnostics::UnexpectedIdent(ident, parser.cur().span))? } @@ -27,7 +27,7 @@ impl<'a> Parse<'a> for FontWeightValue { let num = parser.cur().value.as_f32().unwrap(); parser.advance(); if (1.0..=1000.0).contains(&num) { - Ok(Self::Number(num as u16).spanned(span.up_to(&parser.cur().span))) + Ok(Self::Number(num as u16).spanned(span.until(parser.cur().span))) } else { Err(diagnostics::NumberOutOfBounds(1.0, 1000.0, parser.cur().span))? } @@ -44,20 +44,20 @@ impl<'a> Parse<'a> for FontSizeValue { Kind::Ident => { let ident = parser.expect_ident()?; if ident == atom!("math") { - Ok(Self::Math.spanned(span.up_to(&parser.cur().span))) + Ok(Self::Math.spanned(span.until(parser.cur().span))) } else if let Some(val) = AbsoluteSize::from_atom(ident.clone()) { parser.advance(); - Ok(Self::Absolute(val).spanned(span.up_to(&parser.cur().span))) + Ok(Self::Absolute(val).spanned(span.until(parser.cur().span))) } else if let Some(val) = RelativeSize::from_atom(ident.clone()) { parser.advance(); - Ok(Self::Relative(val).spanned(span.up_to(&parser.cur().span))) + Ok(Self::Relative(val).spanned(span.until(parser.cur().span))) } else { Err(diagnostics::UnexpectedIdent(ident, parser.cur().span))? } } _ => { let node = PositiveLengthPercentage::parse(parser)?; - Ok(Self::LengthPercentage(node).spanned(span.up_to(&parser.cur().span))) + Ok(Self::LengthPercentage(node).spanned(span.until(parser.cur().span))) } } } @@ -70,30 +70,28 @@ impl<'a> Parse<'a> for FontFamilyValue { Kind::Ident => { let mut ident = parser.expect_ident_cased()?; match ident.to_ascii_lowercase() { - atom!("serif") => Ok(Self::Serif.spanned(span.up_to(&parser.cur().span))), + atom!("serif") => Ok(Self::Serif.spanned(span.until(parser.cur().span))), atom!("sans-serif") => { - Ok(Self::SansSerif.spanned(span.up_to(&parser.cur().span))) + Ok(Self::SansSerif.spanned(span.until(parser.cur().span))) } - atom!("cursive") => Ok(Self::Cursive.spanned(span.up_to(&parser.cur().span))), - atom!("fantasy") => Ok(Self::Fantasy.spanned(span.up_to(&parser.cur().span))), + atom!("cursive") => Ok(Self::Cursive.spanned(span.until(parser.cur().span))), + atom!("fantasy") => Ok(Self::Fantasy.spanned(span.until(parser.cur().span))), atom!("monospace") => { - Ok(Self::Monospace.spanned(span.up_to(&parser.cur().span))) + Ok(Self::Monospace.spanned(span.until(parser.cur().span))) } - atom!("system-ui") => { - Ok(Self::SystemUi.spanned(span.up_to(&parser.cur().span))) - } - atom!("emoji") => Ok(Self::Emoji.spanned(span.up_to(&parser.cur().span))), - atom!("math") => Ok(Self::Math.spanned(span.up_to(&parser.cur().span))), - atom!("fangsong") => Ok(Self::Fangsong.spanned(span.up_to(&parser.cur().span))), - atom!("ui-serif") => Ok(Self::UiSerif.spanned(span.up_to(&parser.cur().span))), + atom!("system-ui") => Ok(Self::SystemUi.spanned(span.until(parser.cur().span))), + atom!("emoji") => Ok(Self::Emoji.spanned(span.until(parser.cur().span))), + atom!("math") => Ok(Self::Math.spanned(span.until(parser.cur().span))), + atom!("fangsong") => Ok(Self::Fangsong.spanned(span.until(parser.cur().span))), + atom!("ui-serif") => Ok(Self::UiSerif.spanned(span.until(parser.cur().span))), atom!("ui-sans-serif") => { - Ok(Self::UiSansSerif.spanned(span.up_to(&parser.cur().span))) + Ok(Self::UiSansSerif.spanned(span.until(parser.cur().span))) } atom!("ui-monospace") => { - Ok(Self::UiMonospace.spanned(span.up_to(&parser.cur().span))) + Ok(Self::UiMonospace.spanned(span.until(parser.cur().span))) } atom!("ui-rounded") => { - Ok(Self::UiRounded.spanned(span.up_to(&parser.cur().span))) + Ok(Self::UiRounded.spanned(span.until(parser.cur().span))) } _ => { let mut name = String::new(); @@ -105,14 +103,14 @@ impl<'a> Parse<'a> for FontFamilyValue { name.push(' '); ident = parser.expect_ident_cased()?; } - Ok(Self::Named(Atom::from(name)).spanned(span.up_to(&parser.cur().span))) + Ok(Self::Named(Atom::from(name)).spanned(span.until(parser.cur().span))) } } } Kind::String => { let string = parser.cur_atom().unwrap(); parser.advance(); - Ok(Self::Named(string).spanned(span.up_to(&parser.cur().span))) + Ok(Self::Named(string).spanned(span.until(parser.cur().span))) } _ => Err(diagnostics::Unexpected(parser.cur().kind, parser.cur().span))?, } @@ -126,17 +124,17 @@ impl<'a> Parse<'a> for FontStyleValue<'a> { Kind::Ident => { let ident = parser.expect_ident()?; match ident { - atom!("normal") => Ok(Self::Normal.spanned(span.up_to(&parser.cur().span))), - atom!("italic") => Ok(Self::Italic.spanned(span.up_to(&parser.cur().span))), + atom!("normal") => Ok(Self::Normal.spanned(span.until(parser.cur().span))), + atom!("italic") => Ok(Self::Italic.spanned(span.until(parser.cur().span))), atom!("oblique") => { if matches!(parser.cur().kind, Kind::Dimension | Kind::Number) { let degrees = MathExpr::::parse(parser)?; - Ok(Self::Oblique(degrees).spanned(span.up_to(&parser.cur().span))) + Ok(Self::Oblique(degrees).spanned(span.until(parser.cur().span))) } else { Ok(Self::Oblique(Spanned::dummy(MathExpr::Literal(Spanned::dummy( Angle::Deg(14.0), )))) - .spanned(span.up_to(&parser.cur().span))) + .spanned(span.until(parser.cur().span))) } } _ => Err(diagnostics::UnexpectedIdent(ident, parser.cur().span))?, diff --git a/crates/hdx_parser/src/css/values/inline.rs b/crates/hdx_parser/src/css/values/inline.rs index a115b3d8..5fa1089f 100644 --- a/crates/hdx_parser/src/css/values/inline.rs +++ b/crates/hdx_parser/src/css/values/inline.rs @@ -12,7 +12,7 @@ impl<'a> Parse<'a> for LineHeightValue { Kind::Ident => { let ident = parser.expect_ident()?; if ident == atom!("normal") { - Ok(Self::Normal.spanned(span.up_to(&parser.cur().span))) + Ok(Self::Normal.spanned(span.until(parser.cur().span))) } else { Err(diagnostics::UnexpectedIdent(ident, parser.cur().span))? } @@ -20,11 +20,11 @@ impl<'a> Parse<'a> for LineHeightValue { Kind::Number => { let value = parser.cur().value.as_f32().unwrap(); parser.advance(); - Ok(Self::Number(value).spanned(span.up_to(&parser.cur().span))) + Ok(Self::Number(value).spanned(span.until(parser.cur().span))) } _ => { let node = LengthPercentage::parse(parser)?; - Ok(Self::LengthPercentage(node).spanned(span.up_to(&parser.cur().span))) + Ok(Self::LengthPercentage(node).spanned(span.until(parser.cur().span))) } } } @@ -38,17 +38,17 @@ impl<'a> Parse<'a> for BaselineShiftValue { let span = parser.cur().span; let ident = parser.expect_ident()?; match ident { - atom!("sub") => Ok(Self::Sub.spanned(span.up_to(&parser.cur().span))), - atom!("super") => Ok(Self::Super.spanned(span.up_to(&parser.cur().span))), - atom!("top") => Ok(Self::Top.spanned(span.up_to(&parser.cur().span))), - atom!("center") => Ok(Self::Center.spanned(span.up_to(&parser.cur().span))), - atom!("bottom") => Ok(Self::Bottom.spanned(span.up_to(&parser.cur().span))), + atom!("sub") => Ok(Self::Sub.spanned(span.until(parser.cur().span))), + atom!("super") => Ok(Self::Super.spanned(span.until(parser.cur().span))), + atom!("top") => Ok(Self::Top.spanned(span.until(parser.cur().span))), + atom!("center") => Ok(Self::Center.spanned(span.until(parser.cur().span))), + atom!("bottom") => Ok(Self::Bottom.spanned(span.until(parser.cur().span))), _ => Err(diagnostics::UnexpectedIdent(ident, span))?, } } _ => { let node = LengthPercentage::parse(parser)?; - Ok(Self::LengthPercentage(node).spanned(span.up_to(&parser.cur().span))) + Ok(Self::LengthPercentage(node).spanned(span.until(parser.cur().span))) } } } @@ -66,9 +66,9 @@ impl<'a> Parse<'a> for VerticalAlignShorthand<'a> { baseline_source = Shorthand::Explicit( parser.boxup( Expr::Literal( - BaselineSourceValue::First.spanned(span.up_to(&parser.cur().span)), + BaselineSourceValue::First.spanned(span.until(parser.cur().span)), ) - .spanned(span.up_to(&parser.cur().span)), + .spanned(span.until(parser.cur().span)), ), ); parser.advance(); @@ -77,9 +77,9 @@ impl<'a> Parse<'a> for VerticalAlignShorthand<'a> { baseline_source = Shorthand::Explicit( parser.boxup( Expr::Literal( - BaselineSourceValue::Last.spanned(span.up_to(&parser.cur().span)), + BaselineSourceValue::Last.spanned(span.until(parser.cur().span)), ) - .spanned(span.up_to(&parser.cur().span)), + .spanned(span.until(parser.cur().span)), ), ); parser.advance(); @@ -123,6 +123,6 @@ impl<'a> Parse<'a> for VerticalAlignShorthand<'a> { } } Ok(Self { baseline_source, alignment_baseline, baseline_shift } - .spanned(span.up_to(&parser.cur().span))) + .spanned(span.until(parser.cur().span))) } } diff --git a/crates/hdx_parser/src/css/values/length.rs b/crates/hdx_parser/src/css/values/length.rs index 0b807daf..6fb9d06c 100644 --- a/crates/hdx_parser/src/css/values/length.rs +++ b/crates/hdx_parser/src/css/values/length.rs @@ -10,7 +10,7 @@ impl<'a> Parse<'a> for Length { Kind::Dimension => { let (value, atom) = parser.expect_dimension()?; if let Some(unit) = Self::from_f32_and_atom(value, atom.clone()) { - Ok(unit.spanned(span.up_to(&parser.cur().span))) + Ok(unit.spanned(span.until(parser.cur().span))) } else { Err(diagnostics::UnexpectedDimension(atom, span))? } @@ -23,7 +23,7 @@ impl<'a> Parse<'a> for Length { parser.cur().span, ))? } - Ok(Self::Zero.spanned(span.up_to(&parser.cur().span))) + Ok(Self::Zero.spanned(span.until(parser.cur().span))) } k => Err(diagnostics::Unexpected(k, span))?, } @@ -38,7 +38,7 @@ impl<'a> Parse<'a> for PositiveLength { Kind::Dimension => { let (value, atom) = parser.expect_dimension_gte(0.0)?; if let Some(unit) = Self::from_f32_and_atom(value, atom.clone()) { - Ok(unit.spanned(span.up_to(&parser.cur().span))) + Ok(unit.spanned(span.until(parser.cur().span))) } else { Err(diagnostics::UnexpectedDimension(atom, span))? } @@ -48,7 +48,7 @@ impl<'a> Parse<'a> for PositiveLength { if value != 0.0 { Err(diagnostics::DisallowedValueWithoutDimension(atom!("px"), span))? } - Ok(Self::Zero.spanned(span.up_to(&parser.cur().span))) + Ok(Self::Zero.spanned(span.until(parser.cur().span))) } k => Err(diagnostics::Unexpected(k, span))?, } @@ -62,26 +62,26 @@ impl<'a> Parse<'a> for PositiveLengthPercentageOrNormal { match parser.cur().kind { Kind::Ident => { parser.expect_ident_of(atom!("normal"))?; - Ok(Self::Normal.spanned(span.up_to(&parser.cur().span))) + Ok(Self::Normal.spanned(span.until(parser.cur().span))) } Kind::Dimension => { let (value, atom) = parser.expect_dimension_gte(0.0)?; if let Some(unit) = Self::from_f32_and_atom(value, atom.clone()) { - Ok(unit.spanned(span.up_to(&parser.cur().span))) + Ok(unit.spanned(span.until(parser.cur().span))) } else { Err(diagnostics::UnexpectedDimension(atom, span))? } } Kind::Percentage => { let value = parser.expect_percentage_gte(0.0)?; - Ok(Self::Percentage(Percentage(value)).spanned(span.up_to(&parser.cur().span))) + Ok(Self::Percentage(Percentage(value)).spanned(span.until(parser.cur().span))) } Kind::Number => { let value = parser.expect_number()?; if value != 0.0 { Err(diagnostics::DisallowedValueWithoutDimension(atom!("px"), span))? } - Ok(Self::Zero.spanned(span.up_to(&parser.cur().span))) + Ok(Self::Zero.spanned(span.until(parser.cur().span))) } k => Err(diagnostics::Unexpected(k, span))?, } @@ -98,7 +98,7 @@ impl<'a> Parse<'a> for LengthPercentage { let atom = parser.cur().value.as_atom().unwrap(); if let Some(unit) = Self::from_f32_and_atom(value, atom.clone()) { parser.advance(); - Ok(unit.spanned(span.up_to(&parser.cur().span))) + Ok(unit.spanned(span.until(parser.cur().span))) } else { Err(diagnostics::UnexpectedDimension(atom, parser.cur().span))? } @@ -112,12 +112,12 @@ impl<'a> Parse<'a> for LengthPercentage { ))? } parser.advance(); - Ok(Self::Zero.spanned(span.up_to(&parser.cur().span))) + Ok(Self::Zero.spanned(span.until(parser.cur().span))) } Kind::Percentage => { let value = parser.cur().value.as_f32().unwrap(); parser.advance(); - Ok(Self::Percentage(Percentage(value)).spanned(span.up_to(&parser.cur().span))) + Ok(Self::Percentage(Percentage(value)).spanned(span.until(parser.cur().span))) } _ => Err(diagnostics::Unexpected(parser.cur().kind, parser.cur().span))?, } @@ -132,7 +132,7 @@ impl<'a> Parse<'a> for LengthPercentageOrNormal { Kind::Ident => { if parser.cur_atom_lower().unwrap() == atom!("normal") { parser.advance(); - Ok(Self::Normal.spanned(span.up_to(&parser.cur().span))) + Ok(Self::Normal.spanned(span.until(parser.cur().span))) } else { Err(diagnostics::UnexpectedIdent( parser.cur_atom_lower().unwrap(), @@ -145,7 +145,7 @@ impl<'a> Parse<'a> for LengthPercentageOrNormal { let atom = parser.cur().value.as_atom().unwrap(); if let Some(unit) = Self::from_f32_and_atom(value, atom.clone()) { parser.advance(); - Ok(unit.spanned(span.up_to(&parser.cur().span))) + Ok(unit.spanned(span.until(parser.cur().span))) } else { Err(diagnostics::UnexpectedDimension(atom, parser.cur().span))? } @@ -159,12 +159,12 @@ impl<'a> Parse<'a> for LengthPercentageOrNormal { ))? } parser.advance(); - Ok(Self::Zero.spanned(span.up_to(&parser.cur().span))) + Ok(Self::Zero.spanned(span.until(parser.cur().span))) } Kind::Percentage => { let value = parser.cur().value.as_f32().unwrap(); parser.advance(); - Ok(Self::Percentage(Percentage(value)).spanned(span.up_to(&parser.cur().span))) + Ok(Self::Percentage(Percentage(value)).spanned(span.until(parser.cur().span))) } _ => Err(diagnostics::Unexpected(parser.cur().kind, parser.cur().span))?, } @@ -184,7 +184,7 @@ impl<'a> Parse<'a> for PositiveLengthPercentage { let atom = parser.cur().value.as_atom().unwrap(); if let Some(unit) = Self::from_f32_and_atom(value, atom.clone()) { parser.advance(); - Ok(unit.spanned(span.up_to(&parser.cur().span))) + Ok(unit.spanned(span.until(parser.cur().span))) } else { Err(diagnostics::UnexpectedDimension(atom, parser.cur().span))? } @@ -198,7 +198,7 @@ impl<'a> Parse<'a> for PositiveLengthPercentage { ))? } parser.advance(); - Ok(Self::Zero.spanned(span.up_to(&parser.cur().span))) + Ok(Self::Zero.spanned(span.until(parser.cur().span))) } Kind::Percentage => { let value = parser.cur().value.as_f32().unwrap(); @@ -206,7 +206,7 @@ impl<'a> Parse<'a> for PositiveLengthPercentage { Err(diagnostics::NumberOutOfBounds(value, 0.0, parser.cur().span))?; } parser.advance(); - Ok(Self::Percentage(Percentage(value)).spanned(span.up_to(&parser.cur().span))) + Ok(Self::Percentage(Percentage(value)).spanned(span.until(parser.cur().span))) } _ => Err(diagnostics::Unexpected(parser.cur().kind, parser.cur().span))?, } @@ -220,7 +220,7 @@ impl<'a> Parse<'a> for LengthPercentageOrAuto { Kind::Ident => { if parser.cur_atom_lower().unwrap() == atom!("auto") { parser.advance(); - Ok(Self::Auto.spanned(span.up_to(&parser.cur().span))) + Ok(Self::Auto.spanned(span.until(parser.cur().span))) } else { Err(diagnostics::UnexpectedIdent( parser.cur_atom_lower().unwrap(), @@ -233,7 +233,7 @@ impl<'a> Parse<'a> for LengthPercentageOrAuto { let atom = parser.cur().value.as_atom().unwrap(); if let Some(unit) = Self::from_f32_and_atom(value, atom.clone()) { parser.advance(); - Ok(unit.spanned(span.up_to(&parser.cur().span))) + Ok(unit.spanned(span.until(parser.cur().span))) } else { Err(diagnostics::UnexpectedDimension(atom, parser.cur().span))? } @@ -247,12 +247,12 @@ impl<'a> Parse<'a> for LengthPercentageOrAuto { ))? } parser.advance(); - Ok(Self::Zero.spanned(span.up_to(&parser.cur().span))) + Ok(Self::Zero.spanned(span.until(parser.cur().span))) } Kind::Percentage => { let value = parser.cur().value.as_f32().unwrap(); parser.advance(); - Ok(Self::Percentage(Percentage(value)).spanned(span.up_to(&parser.cur().span))) + Ok(Self::Percentage(Percentage(value)).spanned(span.until(parser.cur().span))) } _ => Err(diagnostics::Unexpected(parser.cur().kind, parser.cur().span))?, } diff --git a/crates/hdx_parser/src/css/values/lists.rs b/crates/hdx_parser/src/css/values/lists.rs index 16bb87c7..fde42b79 100644 --- a/crates/hdx_parser/src/css/values/lists.rs +++ b/crates/hdx_parser/src/css/values/lists.rs @@ -62,7 +62,7 @@ impl<'a> Parse<'a> for ListStyleShorthand<'a> { break; } } - Ok(Self { position, image, marker }.spanned(span.up_to(&parser.cur().span))) + Ok(Self { position, image, marker }.spanned(span.until(parser.cur().span))) } } @@ -77,13 +77,13 @@ impl<'a> Parse<'a> for ListStyleTypeValue<'a> { Ok(Self::None.spanned(span)) } else { let node = CounterStyle::parse(parser)?; - Ok(Self::CounterStyle(node).spanned(span.up_to(&parser.cur().span))) + Ok(Self::CounterStyle(node).spanned(span.until(parser.cur().span))) } } Kind::String => Ok(Self::String(parser.expect_string()?).spanned(span)), _ => { let node = CounterStyle::parse(parser)?; - Ok(Self::CounterStyle(node).spanned(span.up_to(&parser.cur().span))) + Ok(Self::CounterStyle(node).spanned(span.until(parser.cur().span))) } } } @@ -100,12 +100,12 @@ impl<'a> Parse<'a> for ListStyleImageValue<'a> { Ok(Self::None.spanned(span)) } else { let node = Image::parse(parser)?; - Ok(Self::Image(node).spanned(span.up_to(&parser.cur().span))) + Ok(Self::Image(node).spanned(span.until(parser.cur().span))) } } _ => { let node = Image::parse(parser)?; - Ok(Self::Image(node).spanned(span.up_to(&parser.cur().span))) + Ok(Self::Image(node).spanned(span.until(parser.cur().span))) } } } diff --git a/crates/hdx_parser/src/css/values/mod.rs b/crates/hdx_parser/src/css/values/mod.rs index ed9d4e77..8c9c0a48 100644 --- a/crates/hdx_parser/src/css/values/mod.rs +++ b/crates/hdx_parser/src/css/values/mod.rs @@ -31,7 +31,7 @@ macro_rules! parse_for_enums { let span = parser.cur().span; let ident = parser.expect_ident()?; if let Some(val) = $prop::from_atom(ident.clone()) { - Ok(val.spanned(span.up_to(&parser.cur().span))) + Ok(val.spanned(span.until(parser.cur().span))) } else { Err(diagnostics::UnexpectedIdent(ident, span))? } diff --git a/crates/hdx_parser/src/css/values/non_standard.rs b/crates/hdx_parser/src/css/values/non_standard.rs index d46dfc99..079a2890 100644 --- a/crates/hdx_parser/src/css/values/non_standard.rs +++ b/crates/hdx_parser/src/css/values/non_standard.rs @@ -9,8 +9,8 @@ impl<'a> Parse<'a> for ZoomValue { Kind::Ident => { let ident = parser.cur_atom().unwrap(); match ident.to_ascii_lowercase() { - atom!("normal") => Ok(Self::Normal.spanned(span.up_to(&parser.cur().span))), - atom!("reset") => Ok(Self::Reset.spanned(span.up_to(&parser.cur().span))), + atom!("normal") => Ok(Self::Normal.spanned(span.until(parser.cur().span))), + atom!("reset") => Ok(Self::Reset.spanned(span.until(parser.cur().span))), _ => Err(diagnostics::UnexpectedIdent( parser.cur_atom().unwrap(), parser.cur().span, @@ -20,12 +20,12 @@ impl<'a> Parse<'a> for ZoomValue { Kind::Percentage => { let value = parser.cur().value.as_f32().unwrap(); parser.advance(); - Ok(Self::Percentage(value).spanned(span.up_to(&parser.cur().span))) + Ok(Self::Percentage(value).spanned(span.until(parser.cur().span))) } Kind::Number => { let value = parser.cur().value.as_f32().unwrap(); parser.advance(); - Ok(Self::Number(value).spanned(span.up_to(&parser.cur().span))) + Ok(Self::Number(value).spanned(span.until(parser.cur().span))) } _ => Err(diagnostics::Unexpected(parser.cur().kind, parser.cur().span))?, } diff --git a/crates/hdx_parser/src/css/values/page_floats.rs b/crates/hdx_parser/src/css/values/page_floats.rs index 9bb32c70..82ff5fdf 100644 --- a/crates/hdx_parser/src/css/values/page_floats.rs +++ b/crates/hdx_parser/src/css/values/page_floats.rs @@ -11,7 +11,7 @@ impl<'a> Parse<'a> for FloatDeferValue { match parser.cur().kind { Kind::Ident => { if let Some(val) = Self::from_atom(parser.expect_ident()?) { - Ok(val.spanned(span.up_to(&parser.cur().span))) + Ok(val.spanned(span.until(parser.cur().span))) } else { Err(diagnostics::UnexpectedIdent( parser.cur_atom().unwrap(), @@ -21,7 +21,7 @@ impl<'a> Parse<'a> for FloatDeferValue { } Kind::Number => { let node = parser.expect_int()?; - Ok(Self::Integer(node).spanned(span.up_to(&parser.cur().span))) + Ok(Self::Integer(node).spanned(span.until(parser.cur().span))) } _ => Err(diagnostics::Unexpected(parser.cur().kind, parser.cur().span))?, } @@ -34,7 +34,7 @@ impl<'a> Parse<'a> for FloatValue { match parser.cur().kind { Kind::Ident => { if let Some(val) = Self::from_atom(parser.expect_ident()?) { - Ok(val.spanned(span.up_to(&parser.cur().span))) + Ok(val.spanned(span.until(parser.cur().span))) } else { Err(diagnostics::UnexpectedIdent( parser.cur_atom().unwrap(), @@ -51,7 +51,7 @@ impl<'a> Parse<'a> for FloatValue { atom!("snap-block") => { if let Some(floated) = SnapBlockFloat::from_atom(floated_atom) { Ok(Self::SnapBlockFunction(length, floated) - .spanned(span.up_to(&parser.cur().span))) + .spanned(span.until(parser.cur().span))) } else { Err(diagnostics::UnexpectedIdent( parser.cur_atom().unwrap(), @@ -63,7 +63,7 @@ impl<'a> Parse<'a> for FloatValue { atom!("snap-inline") => { if let Some(floated) = SnapInlineFloat::from_atom(floated_atom) { Ok(Self::SnapInlineFunction(length, floated) - .spanned(span.up_to(&parser.cur().span))) + .spanned(span.until(parser.cur().span))) } else { Err(diagnostics::UnexpectedIdent( parser.cur_atom().unwrap(), diff --git a/crates/hdx_parser/src/css/values/shorthand.rs b/crates/hdx_parser/src/css/values/shorthand.rs index de06ea6b..c973c625 100644 --- a/crates/hdx_parser/src/css/values/shorthand.rs +++ b/crates/hdx_parser/src/css/values/shorthand.rs @@ -25,7 +25,7 @@ impl<'a, T: Parse<'a>> Parse<'a> for BoxShorthand<'a, T> { break; } } - Ok(Self { top, right, bottom, left }.spanned(span.up_to(&parser.cur().span))) + Ok(Self { top, right, bottom, left }.spanned(span.until(parser.cur().span))) } } @@ -38,9 +38,9 @@ impl<'a, T: Parse<'a>> Parse<'a> for XYShorthand<'a, T> { Kind::Ident | Kind::Function => { let node = T::parse(parser)?; Ok(Self { x, y: Shorthand::Explicit(parser.boxup(node)) } - .spanned(span.up_to(&parser.cur().span))) + .spanned(span.until(parser.cur().span))) } - _ => Ok(Self { x, y: Shorthand::Implicit }.spanned(span.up_to(&parser.cur().span))), + _ => Ok(Self { x, y: Shorthand::Implicit }.spanned(span.until(parser.cur().span))), } } } @@ -54,9 +54,9 @@ impl<'a, T: Parse<'a>> Parse<'a> for DoubleShorthand<'a, T> { Kind::Ident | Kind::Function => { let node = T::parse(parser)?; Ok(Self(first, Shorthand::Explicit(parser.boxup(node))) - .spanned(span.up_to(&parser.cur().span))) + .spanned(span.until(parser.cur().span))) } - _ => Ok(Self(first, Shorthand::Implicit).spanned(span.up_to(&parser.cur().span))), + _ => Ok(Self(first, Shorthand::Implicit).spanned(span.until(parser.cur().span))), } } } diff --git a/crates/hdx_parser/src/css/values/size_adjust.rs b/crates/hdx_parser/src/css/values/size_adjust.rs index 9f745e08..f86525c1 100644 --- a/crates/hdx_parser/src/css/values/size_adjust.rs +++ b/crates/hdx_parser/src/css/values/size_adjust.rs @@ -10,10 +10,10 @@ impl<'a> Parse<'a> for TextSizeAdjustValue { let ident = parser.expect_ident()?; match ident { atom!("none") => { - Ok(TextSizeAdjustValue::None.spanned(span.up_to(&parser.cur().span))) + Ok(TextSizeAdjustValue::None.spanned(span.until(parser.cur().span))) } atom!("auto") => { - Ok(TextSizeAdjustValue::Auto.spanned(span.up_to(&parser.cur().span))) + Ok(TextSizeAdjustValue::Auto.spanned(span.until(parser.cur().span))) } _ => Err(diagnostics::UnexpectedIdent(ident, span))?, } @@ -21,7 +21,7 @@ impl<'a> Parse<'a> for TextSizeAdjustValue { Kind::Percentage => { let value = parser.cur().value.as_f32().unwrap(); parser.advance(); - Ok(TextSizeAdjustValue::Percentage(value).spanned(span.up_to(&parser.cur().span))) + Ok(TextSizeAdjustValue::Percentage(value).spanned(span.until(parser.cur().span))) } k => Err(diagnostics::Unexpected(k, span))?, } diff --git a/crates/hdx_parser/src/css/values/sizing.rs b/crates/hdx_parser/src/css/values/sizing.rs index 792142f3..d0b9fd7b 100644 --- a/crates/hdx_parser/src/css/values/sizing.rs +++ b/crates/hdx_parser/src/css/values/sizing.rs @@ -28,7 +28,7 @@ impl<'a> Parse<'a> for Sizing { } _ => Err(diagnostics::Unimplemented(parser.cur().span))?, }; - Ok(sizing.spanned(span.up_to(&parser.cur().span))) + Ok(sizing.spanned(span.until(parser.cur().span))) } } @@ -58,7 +58,7 @@ impl<'a> Parse<'a> for MaxSizing { } _ => Err(diagnostics::Unimplemented(parser.cur().span))?, }; - Ok(sizing.spanned(span.up_to(&parser.cur().span))) + Ok(sizing.spanned(span.until(parser.cur().span))) } } diff --git a/crates/hdx_parser/src/css/values/text.rs b/crates/hdx_parser/src/css/values/text.rs index e61aeb1b..805f62f4 100644 --- a/crates/hdx_parser/src/css/values/text.rs +++ b/crates/hdx_parser/src/css/values/text.rs @@ -39,7 +39,7 @@ impl<'a> Parse<'a> for WhiteSpaceTrimValue { break; } } - Ok(Self::Discard { inner, after, before }.spanned(span.up_to(&parser.cur().span))) + Ok(Self::Discard { inner, after, before }.spanned(span.until(parser.cur().span))) } } @@ -146,6 +146,6 @@ impl<'a> Parse<'a> for WhiteSpaceShorthand<'a> { break; } } - Ok(Self::Expanded { collapse, wrap, trim }.spanned(span.up_to(&parser.cur().span))) + Ok(Self::Expanded { collapse, wrap, trim }.spanned(span.until(parser.cur().span))) } } diff --git a/crates/hdx_parser/src/css/values/text_decor.rs b/crates/hdx_parser/src/css/values/text_decor.rs index 1b31002b..17eb1c2b 100644 --- a/crates/hdx_parser/src/css/values/text_decor.rs +++ b/crates/hdx_parser/src/css/values/text_decor.rs @@ -56,7 +56,7 @@ impl<'a> Parse<'a> for TextDecorationShorthand<'a> { break; } } - Ok(Self { color, style, line }.spanned(span.up_to(&parser.cur().span))) + Ok(Self { color, style, line }.spanned(span.until(parser.cur().span))) } } @@ -65,7 +65,7 @@ impl<'a> Parse<'a> for TextDecorationLineValue { let span = parser.cur().span; if parser.at(Kind::Ident) && parser.cur().as_atom_lower().unwrap() == atom!("none") { parser.advance(); - return Ok(Self::None.spanned(span.up_to(&parser.cur().span))); + return Ok(Self::None.spanned(span.until(parser.cur().span))); } let mut underline = false; let mut overline = false; @@ -106,7 +106,7 @@ impl<'a> Parse<'a> for TextDecorationLineValue { parser.advance() } Ok(Self::Style { underline, overline, line_through, blink } - .spanned(span.up_to(&parser.cur().span))) + .spanned(span.until(parser.cur().span))) } } diff --git a/crates/hdx_parser/src/css/values/ui.rs b/crates/hdx_parser/src/css/values/ui.rs index 9ddb73ec..88bfee8c 100644 --- a/crates/hdx_parser/src/css/values/ui.rs +++ b/crates/hdx_parser/src/css/values/ui.rs @@ -10,7 +10,7 @@ impl<'a> Parse<'a> for CursorValue<'a> { let span = parser.cur().span; let ident = parser.expect_ident()?; if let Some(val) = CursorValue::from_atom(ident.clone()) { - Ok(val.spanned(span.up_to(&parser.cur().span))) + Ok(val.spanned(span.until(parser.cur().span))) } else { Err(diagnostics::UnexpectedIdent(ident, span))? } diff --git a/crates/hdx_parser/src/lib.rs b/crates/hdx_parser/src/lib.rs index d63df4c9..8ec7b156 100644 --- a/crates/hdx_parser/src/lib.rs +++ b/crates/hdx_parser/src/lib.rs @@ -107,7 +107,7 @@ impl<'a> Parser<'a> { } self.advance() } - self.errors.push(diagnostics::ExpectedEnd(span.up_to(&self.cur().span)).into()); + self.errors.push(diagnostics::ExpectedEnd(span.until(self.cur().span)).into()); } ParserReturn { output, warnings: self.warnings, errors: self.errors, panicked } }