From 9ab65b0b021d6aeac2dfa6e01c39a7b40f0d4c6d Mon Sep 17 00:00:00 2001 From: dkanus Date: Thu, 7 Aug 2025 13:49:19 +0700 Subject: [PATCH] Add missing tokens to lexer --- rottlib/src/lexer/lexing.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/rottlib/src/lexer/lexing.rs b/rottlib/src/lexer/lexing.rs index a55b5d9..d70f54f 100644 --- a/rottlib/src/lexer/lexing.rs +++ b/rottlib/src/lexer/lexing.rs @@ -2,7 +2,7 @@ //! //! ## Notable details //! -//! Lexer for UnrealScript that recognises inline `cpptext { … }` blocks. +//! Lexer for UnrealScript that recognizes inline `cpptext { … }` blocks. //! //! In UnrealScript, `cpptext` lets authors embed raw C++ between braces. //! Because whitespace, newlines, or comments may appear between the @@ -41,14 +41,14 @@ pub struct LexerState { } /// Are these braces "real" UnrealScript braces, or the start/end of a C++ block? -#[derive(Debug, PartialEq, Clone, Copy)] +#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)] pub enum BraceKind { Normal, CppBlock, } /// All UnrealScript tokens that our compiler distinguishes. -#[derive(logos::Logos, Debug, PartialEq, Clone, Copy)] +#[derive(logos::Logos, Debug, PartialEq, Eq, Hash, Clone, Copy)] #[logos(extras = LexerState)] pub enum Token { // # Compiler/directive keywords @@ -247,9 +247,9 @@ pub enum Token { #[token("~")] BitwiseNot, // ## Vector - #[token("dot")] + #[regex("(?i)dot")] Dot, - #[token("cross")] + #[regex("(?i)cross")] Cross, // ## Multiplicative #[token("*")] @@ -290,6 +290,8 @@ pub enum Token { NotEqual, #[token("~=")] ApproximatelyEqual, + #[regex("(?i)clockwisefrom")] + ClockwiseFrom, // ## Bitwise #[token("&")] BitwiseAnd, @@ -297,11 +299,11 @@ pub enum Token { BitwiseOr, #[token("^")] BitwiseXor, - #[token("^^")] - BooleanXor, // ## Logical #[token("&&")] And, + #[token("^^")] + Xor, #[token("||")] Or, // ## Assigments @@ -311,6 +313,8 @@ pub enum Token { MultiplyAssign, #[token("/=")] DivideAssign, + #[token("%=")] + ModuloAssign, #[token("+=")] PlusAssign, #[token("-=")] @@ -341,6 +345,10 @@ pub enum Token { Period, #[token(":")] Colon, + #[token("#")] + Hash, + #[token("?")] + Question, // # Comments & whitespaces #[regex(r"//[^\r\n]*")]