Skip to main content

oak_lean/parser/
element_type.rs

1use oak_core::{ElementType, Parser, UniversalElementRole};
2#[cfg(feature = "serde")]
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
6#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
7pub enum LeanElementType {
8    Root,
9    Error,
10}
11
12impl ElementType for LeanElementType {
13    type Role = UniversalElementRole;
14
15    fn role(&self) -> Self::Role {
16        match self {
17            _ => UniversalElementRole::None,
18        }
19    }
20}
21
22impl From<crate::lexer::token_type::LeanTokenType> for LeanElementType {
23    fn from(token: crate::lexer::token_type::LeanTokenType) -> Self {
24        use crate::lexer::token_type::LeanTokenType;
25        match token {
26            LeanTokenType::Root => LeanElementType::Root,
27            _ => LeanElementType::Error,
28        }
29    }
30}