From f3e99ee76d4d1bebc17ed2aec154564412a06d3d Mon Sep 17 00:00:00 2001 From: Brandon Dyck Date: Thu, 8 Jun 2023 08:16:32 -0600 Subject: [PATCH] Use record syntax for Token --- Program.cs | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/Program.cs b/Program.cs index 5c65f8a..376ed78 100644 --- a/Program.cs +++ b/Program.cs @@ -69,7 +69,7 @@ class Program } } -enum TokenType +public enum TokenType { LParen, RParen, LBrace, RBrace, @@ -107,26 +107,7 @@ enum TokenType EOF } -class Token -{ - public readonly TokenType type; - public readonly String lexeme; - public readonly Object? literal; - public readonly int line; - - public Token(TokenType type, String lexeme, Object? literal, int line) - { - this.type = type; - this.lexeme = lexeme; - this.literal = literal; - this.line = line; - } - - public override string ToString() - { - return $"{type} {lexeme} {literal}"; - } -} +public record Token(TokenType type, String lexeme, Object? literal, int line); class Scanner {