From 65cccc1c9154596635706fa5e343489050302db9 Mon Sep 17 00:00:00 2001 From: Dimi Racordon Date: Wed, 27 Dec 2023 03:26:37 +0100 Subject: [PATCH] Remove 'NilLiteralExpr' --- Sources/Core/AST/AST+Walk.swift | 7 ------- Sources/Core/AST/Expr/NilLiteralExpr.swift | 10 ---------- Sources/Core/AST/NodeIDs/NodeKind.swift | 1 - Sources/FrontEnd/Parse/Lexer.swift | 1 - Sources/FrontEnd/Parse/Parser.swift | 6 ------ Sources/FrontEnd/Parse/Token.swift | 1 - Tests/HyloTests/LexerTests.swift | 7 +++---- Tests/HyloTests/ParserTests.swift | 6 ------ 8 files changed, 3 insertions(+), 36 deletions(-) delete mode 100644 Sources/Core/AST/Expr/NilLiteralExpr.swift diff --git a/Sources/Core/AST/AST+Walk.swift b/Sources/Core/AST/AST+Walk.swift index 16e3cba16..7025f0572 100644 --- a/Sources/Core/AST/AST+Walk.swift +++ b/Sources/Core/AST/AST+Walk.swift @@ -129,8 +129,6 @@ extension AST { traverse(self[n] as! MatchExpr, notifying: &o) case NameExpr.self: traverse(self[n] as! NameExpr, notifying: &o) - case NilLiteralExpr.self: - traverse(self[n] as! NilLiteralExpr, notifying: &o) case ParameterTypeExpr.self: traverse(self[n] as! ParameterTypeExpr, notifying: &o) case PragmaLiteralExpr.self: @@ -544,11 +542,6 @@ extension AST { walk(roots: n.arguments.map(\.value), notifying: &o) } - /// Visits the children of `n` in pre-order, notifying `o` when a node is entered or left. - public func traverse( - _ n: NilLiteralExpr, notifying o: inout O - ) {} - /// Visits the children of `n` in pre-order, notifying `o` when a node is entered or left. public func traverse( _ n: ParameterTypeExpr, notifying o: inout O diff --git a/Sources/Core/AST/Expr/NilLiteralExpr.swift b/Sources/Core/AST/Expr/NilLiteralExpr.swift deleted file mode 100644 index bec182b22..000000000 --- a/Sources/Core/AST/Expr/NilLiteralExpr.swift +++ /dev/null @@ -1,10 +0,0 @@ -/// A nil literal expression. -public struct NilLiteralExpr: Expr { - - public let site: SourceRange - - public init(site: SourceRange) { - self.site = site - } - -} diff --git a/Sources/Core/AST/NodeIDs/NodeKind.swift b/Sources/Core/AST/NodeIDs/NodeKind.swift index 5ecd15fcf..ad719d679 100644 --- a/Sources/Core/AST/NodeIDs/NodeKind.swift +++ b/Sources/Core/AST/NodeIDs/NodeKind.swift @@ -116,7 +116,6 @@ extension NodeKind { MapLiteralExpr.self, MatchExpr.self, NameExpr.self, - NilLiteralExpr.self, ParameterTypeExpr.self, PragmaLiteralExpr.self, RemoteExpr.self, diff --git a/Sources/FrontEnd/Parse/Lexer.swift b/Sources/FrontEnd/Parse/Lexer.swift index a40262945..e2e72b7bd 100644 --- a/Sources/FrontEnd/Parse/Lexer.swift +++ b/Sources/FrontEnd/Parse/Lexer.swift @@ -109,7 +109,6 @@ public struct Lexer: IteratorProtocol, Sequence { case "let": token.kind = .`let` case "match": token.kind = .`match` case "namespace": token.kind = .`namespace` - case "nil": token.kind = .`nil` case "operator": token.kind = .`operator` case "postfix": token.kind = .`postfix` case "prefix": token.kind = .`prefix` diff --git a/Sources/FrontEnd/Parse/Parser.swift b/Sources/FrontEnd/Parse/Parser.swift index 75542be7a..75fcfe06c 100644 --- a/Sources/FrontEnd/Parse/Parser.swift +++ b/Sources/FrontEnd/Parse/Parser.swift @@ -1661,12 +1661,6 @@ public enum Parser { site: head.site)) return AnyExprID(expr) - case .nil: - // Nil literal. - _ = state.take() - let expr = state.insert(NilLiteralExpr(site: head.site)) - return AnyExprID(expr) - case .under: // Wildcard expression. _ = state.take() diff --git a/Sources/FrontEnd/Parse/Token.swift b/Sources/FrontEnd/Parse/Token.swift index 0fb8436e7..c6eef1b49 100644 --- a/Sources/FrontEnd/Parse/Token.swift +++ b/Sources/FrontEnd/Parse/Token.swift @@ -41,7 +41,6 @@ public struct Token { case `let` case `match` case `namespace` - case `nil` case `operator` case `poundElse` case `poundElseif` diff --git a/Tests/HyloTests/LexerTests.swift b/Tests/HyloTests/LexerTests.swift index d0acddba0..7cbf67276 100644 --- a/Tests/HyloTests/LexerTests.swift +++ b/Tests/HyloTests/LexerTests.swift @@ -133,9 +133,9 @@ final class LexerTests: XCTestCase { func testKeywords() { let input: SourceFile = """ any break catch conformance continue do else extension for fun if import in infix init inout - let match namespace nil operator postfix prefix property private public remote return set - sink some spawn static subscript trait try type typealias var where while yield yielded - #if #else #elseif #endif + let match namespace operator postfix prefix property private public remote return set sink + some spawn static subscript trait try type typealias var where while yield yielded #if #else + #elseif #endif """ assert( @@ -160,7 +160,6 @@ final class LexerTests: XCTestCase { TokenSpecification(.`let`, "let"), TokenSpecification(.`match`, "match"), TokenSpecification(.`namespace`, "namespace"), - TokenSpecification(.`nil`, "nil"), TokenSpecification(.`operator`, "operator"), TokenSpecification(.`postfix`, "postfix"), TokenSpecification(.`prefix`, "prefix"), diff --git a/Tests/HyloTests/ParserTests.swift b/Tests/HyloTests/ParserTests.swift index ec2a10266..f278c28e8 100644 --- a/Tests/HyloTests/ParserTests.swift +++ b/Tests/HyloTests/ParserTests.swift @@ -1160,12 +1160,6 @@ final class ParserTests: XCTestCase { XCTAssertEqual(expr.value, "Hylo") } - func testNilLiteralExpr() throws { - let input: SourceFile = "nil" - let (exprID, _) = try input.parse(with: Parser.parseExpr(in:)) - XCTAssertEqual(exprID?.kind, .init(NilLiteralExpr.self)) - } - func testPragmaLiteralExpr() throws { let input: SourceFile = "#file" let (exprID, ast) = try input.parse(with: Parser.parseExpr(in:))