use oak_core::{Token, TokenType, UniversalTokenRole};
pub type PrologToken = Token<PrologTokenType>;
impl PrologTokenType {
pub fn is_token(&self) -> bool {
!self.is_element()
}
pub fn is_element(&self) -> bool {
matches!(self, Self::Root | Self::Functor | Self::Clause | Self::Rule | Self::Fact | Self::Query | Self::Directive | Self::List | Self::Structure)
}
}
impl TokenType for PrologTokenType {
type Role = UniversalTokenRole;
const END_OF_STREAM: Self = Self::Error;
fn is_ignored(&self) -> bool {
false
}
fn role(&self) -> Self::Role {
match self {
_ => UniversalTokenRole::None,
}
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum PrologTokenType {
Whitespace,
Newline,
Comment,
Atom,
Integer,
Float,
String,
Variable,
Unify, NotUnify, Equal, NotEqual, ArithEqual, ArithNotEqual, Less, Greater, LessEqual, GreaterEqual, Is, Plus, Minus, Multiply, Divide, IntDivide, Modulo, Power, BitwiseAnd, BitwiseOr, BitwiseXor, BitwiseNot, LeftShift, RightShift,
LeftParen, RightParen, LeftBracket, RightBracket, LeftBrace, RightBrace, Comma, Dot, Pipe, Semicolon, Cut, Question, Colon, ColonMinus, QuestionMinus,
Functor,
Clause,
Rule,
Fact,
Query,
Directive,
List,
Structure,
Root,
Error,
}