Add missing tokens to lexer
This commit is contained in:
parent
9ff20c7a60
commit
9ab65b0b02
@ -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]*")]
|
||||
|
Loading…
Reference in New Issue
Block a user