boseiju/lexer/tokens/intermediates/
global_zone.rs1#[derive(idris_derive::Idris)]
2#[derive(serde::Serialize, serde::Deserialize)]
3#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
4pub enum GlobalZone {
5 TheBattlefield {
6 #[cfg(feature = "spanned_tree")]
7 span: crate::ability_tree::span::TreeSpan,
8 },
9 Anywhere {
10 #[cfg(feature = "spanned_tree")]
11 span: crate::ability_tree::span::TreeSpan,
12 },
13}
14
15#[cfg(feature = "spanned_tree")]
16impl GlobalZone {
17 pub fn span(&self) -> crate::ability_tree::span::TreeSpan {
18 match self {
19 Self::TheBattlefield { span } => *span,
20 Self::Anywhere { span } => *span,
21 }
22 }
23}
24
25impl GlobalZone {
26 pub fn try_from_span(span: &crate::lexer::Span) -> Option<Self> {
27 match span.text {
28 "the battlefield" => Some(Self::TheBattlefield {
29 #[cfg(feature = "spanned_tree")]
30 span: span.into(),
31 }),
32 "anywhere" => Some(Self::Anywhere {
33 #[cfg(feature = "spanned_tree")]
34 span: span.into(),
35 }),
36 _ => None,
37 }
38 }
39}