use oak_core::{Token, TokenType, UniversalTokenRole};
pub type JasmToken = Token<JasmTokenType>;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[repr(u16)]
pub enum JasmTokenType {
Root,
ClassKw,
VersionKw,
MethodKw,
FieldKw,
StringKw,
SourceFileKw,
StackKw,
LocalsKw,
EndKw,
CompiledKw,
FromKw,
InnerClassKw,
NestMembersKw,
BootstrapMethodKw,
SuperKw,
InterfaceKw,
ImplementsKw,
ExtendsKw,
SourceKw,
CatchKw,
AttributeKw,
StackMapKw,
Public,
Private,
Protected,
Static,
Super,
Final,
Abstract,
Synchronized,
Native,
Synthetic,
Deprecated,
Varargs,
ALoad0,
ALoad1,
ALoad2,
ALoad3,
ILoad0,
ILoad1,
ILoad2,
ILoad3,
Ldc,
LdcW,
Ldc2W,
InvokeSpecial,
InvokeVirtual,
InvokeStatic,
InvokeInterface,
InvokeDynamic,
GetStatic,
PutStatic,
GetField,
PutField,
New,
CheckCast,
InstanceOf,
NewArray,
ANewArray,
ArrayLength,
AThrow,
MonitorEnter,
MonitorExit,
MultiANewArray,
IfNull,
IfNonNull,
Goto,
GotoW,
Jsr,
JsrW,
Ret,
TableSwitch,
LookupSwitch,
IReturn,
LReturn,
FReturn,
DReturn,
AReturn,
Return,
BiPush,
SiPush,
IInc,
Wide,
BreakPoint,
ImpDep1,
ImpDep2,
Nop,
Dup,
Pop,
AConstNull,
IConstM1,
IConst0,
IConst1,
IConst2,
IConst3,
IConst4,
IConst5,
LConst0,
LConst1,
FConst0,
FConst1,
FConst2,
DConst0,
DConst1,
ALoad,
ILoad,
LLoad,
FLoad,
DLoad,
AStore,
IStore,
LStore,
FStore,
DStore,
BALoad,
CALoad,
SALoad,
AALoad,
IALoad,
LALoad,
FALoad,
DALoad,
BAStore,
CAStore,
SAStore,
AAStore,
IAStore,
LAStore,
FAStore,
DAStore,
Swap,
Swap2,
DupX1,
DupX2,
Dup2,
Dup2X1,
Dup2X2,
IAdd,
LAdd,
FAdd,
DAdd,
ISub,
LSub,
FSub,
DSub,
IMul,
LMul,
FMul,
DMul,
IDiv,
LDiv,
FDiv,
DDiv,
IRem,
LRem,
FRem,
DRem,
INeg,
LNeg,
FNeg,
DNeg,
IShl,
LShl,
IShr,
LShr,
IUShr,
LUShr,
IAnd,
LAnd,
IOr,
LOr,
IXor,
LXor,
I2L,
I2F,
I2D,
L2I,
L2F,
L2D,
F2I,
F2L,
F2D,
D2I,
D2L,
D2F,
LCmp,
FCmpL,
FCmpG,
DCmpL,
DCmpG,
IfEq,
IfNe,
IfLt,
IfGe,
IfGt,
IfLe,
IfICmpEq,
IfICmpNe,
IfICmpLt,
IfICmpGe,
IfICmpGt,
IfICmpLe,
IfACmpEq,
IfACmpNe,
LeftBrace,
RightBrace,
LeftBracket,
RightBracket,
LeftParen,
RightParen,
Comma,
Colon,
Semicolon,
Eq,
Dot,
Slash,
At,
Identifier,
String,
Number,
Comment,
Whitespace,
Newline,
Eof,
}
impl TokenType for JasmTokenType {
type Role = UniversalTokenRole;
const END_OF_STREAM: Self = Self::Eof;
fn is_ignored(&self) -> bool {
matches!(self, Self::Whitespace | Self::Newline | Self::Comment)
}
fn role(&self) -> Self::Role {
use UniversalTokenRole::*;
match self {
Self::ClassKw
| Self::VersionKw
| Self::MethodKw
| Self::FieldKw
| Self::StringKw
| Self::SourceFileKw
| Self::StackKw
| Self::LocalsKw
| Self::EndKw
| Self::CompiledKw
| Self::FromKw
| Self::InnerClassKw
| Self::NestMembersKw
| Self::BootstrapMethodKw
| Self::Public
| Self::Private
| Self::Protected
| Self::Static
| Self::Super
| Self::Final
| Self::Abstract
| Self::Synchronized
| Self::Native
| Self::Synthetic
| Self::Deprecated
| Self::Varargs
| Self::ALoad0
| Self::ALoad1
| Self::ALoad2
| Self::ALoad3
| Self::ILoad0
| Self::ILoad1
| Self::ILoad2
| Self::ILoad3
| Self::Ldc
| Self::LdcW
| Self::Ldc2W
| Self::InvokeSpecial
| Self::InvokeVirtual
| Self::InvokeStatic
| Self::InvokeInterface
| Self::InvokeDynamic
| Self::GetStatic
| Self::PutStatic
| Self::GetField
| Self::PutField
| Self::Return
| Self::IReturn
| Self::AReturn
| Self::LReturn
| Self::FReturn
| Self::DReturn
| Self::Nop
| Self::Dup
| Self::Pop
| Self::New => Keyword,
Self::String | Self::Number => Literal,
Self::Identifier => Name,
Self::LeftBrace | Self::RightBrace | Self::LeftParen | Self::RightParen | Self::LeftBracket | Self::RightBracket | Self::Colon | Self::Semicolon | Self::Dot | Self::Comma | Self::Slash => Punctuation,
Self::Whitespace | Self::Newline => Whitespace,
Self::Comment => Comment,
_ => None,
}
}
}