use oak_core::{Token, TokenType, UniversalTokenRole};
pub type ZigToken = Token<ZigTokenType>;
impl TokenType for ZigTokenType {
type Role = UniversalTokenRole;
const END_OF_STREAM: Self = Self::Eof;
fn is_ignored(&self) -> bool {
matches!(self, Self::Whitespace | Self::Newline | Self::Comment | Self::DocComment)
}
fn role(&self) -> Self::Role {
match self {
Self::Whitespace | Self::Newline => UniversalTokenRole::Whitespace,
Self::Comment | Self::DocComment => UniversalTokenRole::Comment,
Self::Error => UniversalTokenRole::Error,
Self::Eof => UniversalTokenRole::Eof,
_ => UniversalTokenRole::None,
}
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub enum ZigTokenType {
Root,
Whitespace,
Newline,
Comment,
DocComment,
Error,
Eof,
Identifier,
StringLiteral,
CharLiteral,
IntegerLiteral,
FloatLiteral,
BooleanLiteral,
Const,
Var,
Fn,
Struct,
Union,
Enum,
Opaque,
Type,
Comptime,
Inline,
NoInline,
Pub,
Export,
Extern,
Packed,
Align,
CallConv,
LinkSection,
If,
Else,
Switch,
While,
For,
Break,
Continue,
Return,
Defer,
ErrDefer,
Unreachable,
NoReturn,
ErrorKeyword,
Test,
Async,
Await,
Suspend,
Resume,
Cancel,
Undefined,
Null,
Volatile,
AllowZero,
NoAlias,
And,
Or,
AnyFrame,
AnyType,
ThreadLocal,
Bool,
I8,
I16,
I32,
I64,
I128,
Isize,
U8,
U16,
U32,
U64,
U128,
Usize,
F16,
F32,
F64,
F80,
F128,
CShort,
CUshort,
CInt,
CUint,
CLong,
CUlong,
CLongLong,
CUlongLong,
CLongDouble,
CVoid,
Void,
ComptimeInt,
ComptimeFloat,
Plus,
Minus,
Star,
Slash,
Percent,
StarStar,
PlusPercent,
MinusPercent,
StarPercent,
PlusPlus,
MinusMinus,
Ampersand,
Pipe,
Caret,
Tilde,
LessLess,
GreaterGreater,
Equal,
NotEqual,
Less,
Greater,
LessEqual,
GreaterEqual,
AndAnd,
OrOr,
Assign,
PlusAssign,
MinusAssign,
StarAssign,
SlashAssign,
PercentAssign,
AmpersandAssign,
PipeAssign,
CaretAssign,
LessLessAssign,
GreaterGreaterAssign,
LeftParen,
RightParen,
LeftBrace,
RightBrace,
LeftBracket,
RightBracket,
Semicolon,
Comma,
Dot,
DotDot,
DotDotDot,
DotQuestion,
DotStar,
Colon,
Question,
Exclamation,
Arrow,
FatArrow,
OrElse,
CatchKeyword,
TryKeyword,
AwaitKeyword,
At,
BuiltinIdentifier,
StringStart,
StringEnd,
StringContent,
InterpolationStart,
InterpolationEnd,
MultilineStringStart,
MultilineStringEnd,
MultilineStringContent,
CompileDirective,
Text,
VarDeclaration,
FnDeclaration,
StructDeclaration,
EnumDeclaration,
UnionDeclaration,
Block,
IfStatement,
WhileStatement,
ForStatement,
ReturnStatement,
}