lexer: produce nullsafe -> tokens

This commit is contained in:
Ryan Chandler 2022-08-09 21:23:47 +01:00
parent 529bc6f40f
commit 489cb0e884
No known key found for this signature in database
GPG Key ID: F113BCADDB3B0CCA
2 changed files with 6 additions and 0 deletions

View File

@ -229,6 +229,10 @@ impl Lexer {
self.col += 1; self.col += 1;
self.next(); self.next();
TokenKind::QuestionColon TokenKind::QuestionColon
} else if self.try_read("->") {
self.col += 1;
self.skip(3);
TokenKind::NullsafeArrow
} else { } else {
TokenKind::Question TokenKind::Question
} }

View File

@ -16,6 +16,7 @@ pub enum TokenKind {
Array, Array,
ArrayCast, ArrayCast,
Arrow, Arrow,
NullsafeArrow,
As, As,
Asterisk, Asterisk,
Attribute, Attribute,
@ -162,6 +163,7 @@ impl Display for TokenKind {
Self::And => "&&", Self::And => "&&",
Self::AndEqual => "&=", Self::AndEqual => "&=",
Self::Arrow => "->", Self::Arrow => "->",
Self::NullsafeArrow => "?->",
Self::Array => "array", Self::Array => "array",
Self::ArrayCast => "(array)", Self::ArrayCast => "(array)",
Self::As => "as", Self::As => "as",