use crate::defines::{LiteralFloat, LiteralInt}; use crate::span::Span; #[cfg(test)] use serde_derive::{Deserialize, Serialize}; #[derive(PartialEq, Debug)] #[cfg_attr(test, derive(Serialize, Deserialize))] pub struct LexToken { pub token_type: TokenType, pub span: Span, } #[derive(PartialEq, Debug, Clone)] #[cfg_attr(test, derive(Serialize, Deserialize))] pub enum TokenType { EndOfFile, WhiteSpace, Identifier(String), IntegerLiteral(LiteralInt), FloatLiteral(LiteralFloat), StringLiteral(String), Semicolon, Colon, ColonColon, Comma, Dot, QuestionMark, OpenBracket, CloseBracket, OpenCurlyBracket, CloseCurlyBracket, OpenBlockBracket, CloseBlockBracket, // Keywords AndKeyword, AbstractKeyword, AutoKeyword, BoolKeyword, BreakKeyword, CaseKeyword, CastKeyword, CatchKeyword, ClassKeyword, ConstKeyword, ContinueKeyword, DefaultKeyword, DoKeyword, DoubleKeyword, ElseKeyword, EnumKeyword, ExplicitKeyword, ExternalKeyword, FalseKeyword, FinalKeyword, FloatKeyword, ForKeyword, FromKeyword, FuncDefKeyword, FunctionKeyword, GetKeyword, IfKeyword, ImportKeyword, InKeyword, InOutKeyword, IntKeyword, InterfaceKeyword, Int8Keyword, Int16Keyword, Int32Keyword, Int64Keyword, IsKeyword, MixinKeyword, NamespaceKeyword, NotKeyword, NullKeyword, OrKeyword, OutKeyword, OverrideKeyword, PrivateKeyword, PropertyKeyword, ProtectedKeyword, ReturnKeyword, SetKeyword, SharedKeyword, SuperKeyword, SwitchKeyword, ThisKeyword, TrueKeyword, TryKeyword, TypeDefKeyword, UintKeyword, Uint8Keyword, Uint16Keyword, Uint32Keyword, Uint64Keyword, VoidKeyword, WhileKeyword, XorKeyword, // AssignOp Equals, PlusEquals, MinusEquals, StarEquals, SlashEquals, LineEquals, AmpersandEquals, RoofEquals, PercentEquals, StarStarEquals, LeftLeftEquals, RightRightEquals, RightRightRightEquals, // LogicOp AmpersandAmpersand, LineLine, RoofRoof, // CompOp EqualsEquals, NotEquals, NotIsKeyword, GreaterThan, GreaterThanEquals, LessThan, LessThanEquals, // MathOp Plus, Minus, Star, Slash, Percent, StarStar, // BitOp Ampersand, VerticalLine, Roof, LeftLeft, RightRight, RightRightRight, // ExprPreOp ExclamationMark, PlusPlus, MinusMinus, Tilde, AtSymbol, }