Skip to content

Commit

Permalink
Remove 'NilLiteralExpr'
Browse files Browse the repository at this point in the history
  • Loading branch information
kyouko-taiga committed Dec 27, 2023
1 parent 126775a commit 65cccc1
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 36 deletions.
7 changes: 0 additions & 7 deletions Sources/Core/AST/AST+Walk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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<O: ASTWalkObserver>(
_ 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<O: ASTWalkObserver>(
_ n: ParameterTypeExpr, notifying o: inout O
Expand Down
10 changes: 0 additions & 10 deletions Sources/Core/AST/Expr/NilLiteralExpr.swift

This file was deleted.

1 change: 0 additions & 1 deletion Sources/Core/AST/NodeIDs/NodeKind.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ extension NodeKind {
MapLiteralExpr.self,
MatchExpr.self,
NameExpr.self,
NilLiteralExpr.self,
ParameterTypeExpr.self,
PragmaLiteralExpr.self,
RemoteExpr.self,
Expand Down
1 change: 0 additions & 1 deletion Sources/FrontEnd/Parse/Lexer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
6 changes: 0 additions & 6 deletions Sources/FrontEnd/Parse/Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion Sources/FrontEnd/Parse/Token.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public struct Token {
case `let`
case `match`
case `namespace`
case `nil`
case `operator`
case `poundElse`
case `poundElseif`
Expand Down
7 changes: 3 additions & 4 deletions Tests/HyloTests/LexerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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"),
Expand Down
6 changes: 0 additions & 6 deletions Tests/HyloTests/ParserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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:))
Expand Down

0 comments on commit 65cccc1

Please sign in to comment.