#![allow(missing_docs)]
use graphforge_core::Span;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Keyword {
Match,
Optional,
Where,
Return,
With,
As,
Distinct,
Union,
All,
Create,
Merge,
On,
Set,
Remove,
Delete,
Detach,
Call,
Yield,
Unwind,
Order,
By,
Skip,
Limit,
Not,
And,
Or,
Xor,
In,
Is,
Null,
Starts,
Ends,
Contains,
Case,
When,
Then,
Else,
End,
True,
False,
Any,
None,
Single,
Exists,
ShortestPath,
AllShortestPaths,
Count,
Reduce,
Filter,
Extract,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Token {
Keyword(Keyword, Span),
IntLit(i64, Span),
FloatLit(f64, Span),
StrLit(String, Span),
BoolLit(bool, Span),
NullLit(Span),
Ident(String, Span),
Param(String, Span),
LParen(Span),
RParen(Span),
LBracket(Span),
RBracket(Span),
LBrace(Span),
RBrace(Span),
Dot(Span),
Comma(Span),
Colon(Span),
Semi(Span),
Pipe(Span),
DotDot(Span),
Eq(Span),
Neq(Span),
Lt(Span),
Lte(Span),
Gt(Span),
Gte(Span),
Plus(Span),
Minus(Span),
Star(Span),
Slash(Span),
Percent(Span),
Caret(Span),
RegexMatch(Span),
Whitespace(Span),
Comment(String, Span),
Eof(Span),
}
impl Token {
#[must_use]
pub fn span(&self) -> Span {
match self {
Self::Keyword(_, s)
| Self::IntLit(_, s)
| Self::FloatLit(_, s)
| Self::StrLit(_, s)
| Self::BoolLit(_, s)
| Self::Param(_, s)
| Self::Ident(_, s)
| Self::Comment(_, s)
| Self::NullLit(s)
| Self::LParen(s)
| Self::RParen(s)
| Self::LBracket(s)
| Self::RBracket(s)
| Self::LBrace(s)
| Self::RBrace(s)
| Self::Dot(s)
| Self::Comma(s)
| Self::Colon(s)
| Self::Semi(s)
| Self::Pipe(s)
| Self::DotDot(s)
| Self::Eq(s)
| Self::Neq(s)
| Self::Lt(s)
| Self::Lte(s)
| Self::Gt(s)
| Self::Gte(s)
| Self::Plus(s)
| Self::Minus(s)
| Self::Star(s)
| Self::Slash(s)
| Self::Percent(s)
| Self::Caret(s)
| Self::RegexMatch(s)
| Self::Whitespace(s)
| Self::Eof(s) => *s,
}
}
#[must_use]
pub fn is_trivia(&self) -> bool {
matches!(self, Self::Whitespace(_) | Self::Comment(_, _))
}
}