boseiju/lexer/tokens/
intermediates.rs1mod action_keywords;
2mod ambiguous_tokens;
3mod any_number_of_clause;
4mod card_actions;
5mod choice;
6mod choice_reference;
7mod control_flow;
8mod count_specifier;
9mod damage_kind;
10mod english_keywords;
11mod global_zone;
12mod in_addition_to_paying_its_other_costs;
13mod keyword_ability;
14mod non_kind;
15mod not_of_a_kind;
16mod number;
17mod number_of_times;
18mod number_operation;
19mod player_action;
20mod player_properties;
21mod player_specifier;
22mod plus_minus;
23mod tap_untap_cost;
24mod under_control;
25mod win_lose_clauses;
26
27pub use action_keywords::ActionKeyword;
28pub use ambiguous_tokens::AmbiguousToken;
29pub use any_number_of_clause::AnyNumberOfClause;
30pub use card_actions::CardActions;
31pub use choice::Choice;
32pub use choice_reference::ChoiceReference;
33pub use control_flow::ControlFlow;
34pub use count_specifier::CountSpecifier;
35pub use damage_kind::DamageKind;
36pub use english_keywords::EnglishKeyword;
37pub use global_zone::GlobalZone;
38pub use in_addition_to_paying_its_other_costs::InAdditionToPayingItsOtherCost;
39pub use keyword_ability::KeywordAbility;
40pub use non_kind::NonKind;
41pub use not_of_a_kind::NotOfAKind;
42pub use number::Number;
43pub use number_of_times::NumberOfTimes;
44pub use number_operation::NumberOperation;
45pub use player_action::PlayerAction;
46pub use player_properties::PlayerProperties;
47pub use player_specifier::PlayerSpecifier;
48pub use plus_minus::PowerToughnessModElements;
49pub use tap_untap_cost::TapUntapCost;
50pub use under_control::UnderControl;
51pub use win_lose_clauses::WinLoseClause;
52
53#[derive(idris_derive::Idris)]
54#[derive(serde::Serialize, serde::Deserialize)]
55#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
56pub enum VhyToSortLater {
57 Life {
58 #[cfg(feature = "spanned_tree")]
59 span: crate::ability_tree::span::TreeSpan,
60 },
61 Source {
62 #[cfg(feature = "spanned_tree")]
63 span: crate::ability_tree::span::TreeSpan,
64 },
65 Cost {
66 #[cfg(feature = "spanned_tree")]
67 span: crate::ability_tree::span::TreeSpan,
68 },
69 Player {
70 #[cfg(feature = "spanned_tree")]
71 span: crate::ability_tree::span::TreeSpan,
72 },
73 Turn {
74 #[cfg(feature = "spanned_tree")]
75 span: crate::ability_tree::span::TreeSpan,
76 },
77 Mana {
78 #[cfg(feature = "spanned_tree")]
79 span: crate::ability_tree::span::TreeSpan,
80 },
81 Ability {
82 #[cfg(feature = "spanned_tree")]
83 span: crate::ability_tree::span::TreeSpan,
84 },
85 Effect {
86 #[cfg(feature = "spanned_tree")]
87 span: crate::ability_tree::span::TreeSpan,
88 },
89}
90
91#[cfg(feature = "spanned_tree")]
92impl VhyToSortLater {
93 pub fn span(&self) -> crate::ability_tree::span::TreeSpan {
94 match self {
95 Self::Life { span } => *span,
96 Self::Source { span } => *span,
97 Self::Cost { span } => *span,
98 Self::Player { span } => *span,
99 Self::Turn { span } => *span,
100 Self::Mana { span } => *span,
101 Self::Ability { span } => *span,
102 Self::Effect { span } => *span,
103 }
104 }
105}
106
107impl VhyToSortLater {
108 pub fn try_from_span(span: &crate::lexer::Span) -> Option<Self> {
109 match span.text {
110 "ability" => Some(Self::Ability {
111 #[cfg(feature = "spanned_tree")]
112 span: span.into(),
113 }),
114 "life" => Some(Self::Life {
115 #[cfg(feature = "spanned_tree")]
116 span: span.into(),
117 }),
118 "mana" => Some(Self::Life {
119 #[cfg(feature = "spanned_tree")]
120 span: span.into(),
121 }),
122 "player" => Some(Self::Player {
123 #[cfg(feature = "spanned_tree")]
124 span: span.into(),
125 }),
126 "effect" => Some(Self::Effect {
127 #[cfg(feature = "spanned_tree")]
128 span: span.into(),
129 }),
130 "source" => Some(Self::Source {
131 #[cfg(feature = "spanned_tree")]
132 span: span.into(),
133 }),
134 "cost" | "costs" => Some(Self::Cost {
135 #[cfg(feature = "spanned_tree")]
136 span: span.into(),
137 }),
138 "turn" | "turns" => Some(Self::Turn {
139 #[cfg(feature = "spanned_tree")]
140 span: span.into(),
141 }),
142 _ => None,
143 }
144 }
145}
146
147impl std::fmt::Display for VhyToSortLater {
148 fn fmt(&self, _: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
149 Ok(())
150 }
151}