css_parse/syntax/
no_prelude_allowed.rs1use crate::{Cursor, CursorSink, Parse, Parser, Peek, Result, Span, T, ToCursors, ToSpan, diagnostics};
2
3#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
9#[cfg_attr(feature = "serde", derive(serde::Serialize), serde())]
10pub struct NoPreludeAllowed;
11
12impl<'a> Parse<'a> for NoPreludeAllowed {
13 fn parse(p: &mut Parser<'a>) -> Result<Self> {
14 if p.peek::<T![LeftCurly]>() || p.peek::<T![;]>() {
15 Ok(Self {})
16 } else {
17 Err(diagnostics::Unexpected(p.next()))?
18 }
19 }
20}
21
22impl<'a> Peek<'a> for NoPreludeAllowed {
23 fn peek(_: &Parser<'a>, _: Cursor) -> bool {
24 false
25 }
26}
27
28impl ToCursors for NoPreludeAllowed {
29 fn to_cursors(&self, _: &mut impl CursorSink) {
30 }
32}
33
34impl ToSpan for NoPreludeAllowed {
35 fn to_span(&self) -> Span {
36 Span::ZERO
37 }
38}