use oak_core::{ElementType, Parser, UniversalElementRole};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum PurescriptElementType {
Whitespace,
Newline,
Comment,
Ado,
Case,
Class,
Data,
Derive,
Do,
Else,
False,
Forall,
Foreign,
If,
Import,
In,
Infix,
Infixl,
Infixr,
Instance,
Let,
Module,
Newtype,
Of,
Then,
True,
Type,
Where,
Arrow,
FatArrow,
Backslash,
Pipe,
Equal,
ColonColon,
Dot,
DotDot,
Plus,
Minus,
Star,
Slash,
Percent,
Caret,
EqualEqual,
NotEqual,
Less,
Greater,
LessEqual,
GreaterEqual,
And,
Or,
Not,
LeftParen,
RightParen,
LeftBracket,
RightBracket,
LeftBrace,
RightBrace,
Comma,
Semicolon,
Colon,
Dollar,
Append,
LeftArrow,
Underscore,
Identifier,
Constructor,
Operator,
StringLiteral,
IntLiteral,
NumberLiteral,
CharLiteral,
ModuleDeclaration,
ImportDeclaration,
DataDeclaration,
NewtypeDeclaration,
TypeAliasDeclaration,
ClassDeclaration,
InstanceDeclaration,
ForeignImportDeclaration,
TypeSignature,
ValueDeclaration,
Pattern,
Expression,
LiteralExpression,
IdentifierExpression,
PrefixExpression,
InfixExpression,
ApplicationExpression,
LambdaExpression,
LetExpression,
CaseExpression,
CaseArm,
DoExpression,
TypeNode,
SourceFile,
Compose,
ComposeFlipped,
Apply,
ApplyFlipped,
Bind,
BindFlipped,
Question,
Exclamation,
At,
Tick,
UpperIdentifier,
QualifiedIdentifier,
BooleanLiteral,
Root,
Eof,
Error,
}
impl ElementType for PurescriptElementType {
type Role = UniversalElementRole;
fn role(&self) -> Self::Role {
match self {
Self::Root => UniversalElementRole::Root,
Self::SourceFile => UniversalElementRole::Root,
Self::Error => UniversalElementRole::Error,
_ => UniversalElementRole::None,
}
}
}
impl From<crate::lexer::token_type::PurescriptTokenType> for PurescriptElementType {
fn from(token: crate::lexer::token_type::PurescriptTokenType) -> Self {
use crate::lexer::token_type::PurescriptTokenType as T;
match token {
T::Whitespace => Self::Whitespace,
T::Newline => Self::Newline,
T::Comment => Self::Comment,
T::Ado => Self::Ado,
T::Case => Self::Case,
T::Class => Self::Class,
T::Data => Self::Data,
T::Derive => Self::Derive,
T::Do => Self::Do,
T::Else => Self::Else,
T::False => Self::False,
T::Forall => Self::Forall,
T::Foreign => Self::Foreign,
T::If => Self::If,
T::Import => Self::Import,
T::In => Self::In,
T::Infix => Self::Infix,
T::Infixl => Self::Infixl,
T::Infixr => Self::Infixr,
T::Instance => Self::Instance,
T::Let => Self::Let,
T::Module => Self::Module,
T::Newtype => Self::Newtype,
T::Of => Self::Of,
T::Then => Self::Then,
T::True => Self::True,
T::Type => Self::Type,
T::Where => Self::Where,
T::Arrow => Self::Arrow,
T::FatArrow => Self::FatArrow,
T::Backslash => Self::Backslash,
T::Pipe => Self::Pipe,
T::Equal => Self::Equal,
T::ColonColon => Self::ColonColon,
T::Dot => Self::Dot,
T::DotDot => Self::DotDot,
T::Plus => Self::Plus,
T::Minus => Self::Minus,
T::Star => Self::Star,
T::Slash => Self::Slash,
T::Percent => Self::Percent,
T::Caret => Self::Caret,
T::EqualEqual => Self::EqualEqual,
T::NotEqual => Self::NotEqual,
T::Less => Self::Less,
T::Greater => Self::Greater,
T::LessEqual => Self::LessEqual,
T::GreaterEqual => Self::GreaterEqual,
T::And => Self::And,
T::Or => Self::Or,
T::Append => Self::Append,
T::Compose => Self::Compose,
T::ComposeFlipped => Self::ComposeFlipped,
T::Apply => Self::Apply,
T::ApplyFlipped => Self::ApplyFlipped,
T::Bind => Self::Bind,
T::BindFlipped => Self::BindFlipped,
T::LeftParen => Self::LeftParen,
T::RightParen => Self::RightParen,
T::LeftBrace => Self::LeftBrace,
T::RightBrace => Self::RightBrace,
T::LeftBracket => Self::LeftBracket,
T::RightBracket => Self::RightBracket,
T::Comma => Self::Comma,
T::Semicolon => Self::Semicolon,
T::Colon => Self::Colon,
T::Question => Self::Question,
T::Exclamation => Self::Exclamation,
T::At => Self::At,
T::Underscore => Self::Underscore,
T::Tick => Self::Tick,
T::IntLiteral => Self::IntLiteral,
T::NumberLiteral => Self::NumberLiteral,
T::StringLiteral => Self::StringLiteral,
T::CharLiteral => Self::CharLiteral,
T::BooleanLiteral => Self::BooleanLiteral,
T::Identifier => Self::Identifier,
T::UpperIdentifier => Self::UpperIdentifier,
T::Operator => Self::Operator,
T::QualifiedIdentifier => Self::QualifiedIdentifier,
T::Root => Self::Root,
T::SourceFile => Self::SourceFile,
T::Error => Self::Error,
T::Eof => Self::Eof,
}
}
}