From 489cb0e884a7ad2ce7383a89ff345d6e4b8080b8 Mon Sep 17 00:00:00 2001 From: Ryan Chandler Date: Tue, 9 Aug 2022 21:23:47 +0100 Subject: [PATCH] lexer: produce nullsafe -> tokens --- trunk_lexer/src/lexer.rs | 4 ++++ trunk_lexer/src/token.rs | 2 ++ 2 files changed, 6 insertions(+) diff --git a/trunk_lexer/src/lexer.rs b/trunk_lexer/src/lexer.rs index 0576b60..69d5187 100644 --- a/trunk_lexer/src/lexer.rs +++ b/trunk_lexer/src/lexer.rs @@ -229,6 +229,10 @@ impl Lexer { self.col += 1; self.next(); TokenKind::QuestionColon + } else if self.try_read("->") { + self.col += 1; + self.skip(3); + TokenKind::NullsafeArrow } else { TokenKind::Question } diff --git a/trunk_lexer/src/token.rs b/trunk_lexer/src/token.rs index 69ca561..44874ca 100644 --- a/trunk_lexer/src/token.rs +++ b/trunk_lexer/src/token.rs @@ -16,6 +16,7 @@ pub enum TokenKind { Array, ArrayCast, Arrow, + NullsafeArrow, As, Asterisk, Attribute, @@ -162,6 +163,7 @@ impl Display for TokenKind { Self::And => "&&", Self::AndEqual => "&=", Self::Arrow => "->", + Self::NullsafeArrow => "?->", Self::Array => "array", Self::ArrayCast => "(array)", Self::As => "as",