From e42b18dc0a85a24802bac74921bf1f37c17757d3 Mon Sep 17 00:00:00 2001 From: tacosontitan Date: Fri, 29 Mar 2024 23:19:50 -0500 Subject: [PATCH] Cleaned up string token handling. --- src/Pasper.Json/Parsing/JsonLexer.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Pasper.Json/Parsing/JsonLexer.cs b/src/Pasper.Json/Parsing/JsonLexer.cs index 4859c45..cda82c6 100644 --- a/src/Pasper.Json/Parsing/JsonLexer.cs +++ b/src/Pasper.Json/Parsing/JsonLexer.cs @@ -119,12 +119,12 @@ private bool TryGetStringToken([NotNullWhen(true)] out IToken? token) throw new UnexpectedTokenException(_lineNumber, _columnNumber, "EOF"); var value = json.Substring(startIndex + 1, endIndex - startIndex - 1); - var isProperty = Previous is BeginObjectToken or EndValueToken; - token = isProperty - ? new PropertyNameToken(value) - : Previous is EndNameToken - ? new LiteralStringToken(value) - : throw new UnexpectedTokenException(_lineNumber, _columnNumber, value); + token = Previous switch + { + EndNameToken => new LiteralStringToken(value), + BeginObjectToken or EndValueToken => new PropertyNameToken(value), + _ => throw new UnexpectedTokenException(_lineNumber, _columnNumber, value) + }; _currentIndex = endIndex + 1; return true;