Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions runtime/Swift/Sources/Antlr4/atn/ATNConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ public func ==(lhs: ATNConfig, rhs: ATNConfig) -> Bool {
return true
}

if (lhs is LexerATNConfig) && (rhs is LexerATNConfig) {
return (lhs as! LexerATNConfig) == (rhs as! LexerATNConfig)
if let l = lhs as? LexerATNConfig, let r = rhs as? LexerATNConfig {
return l == r


}
Expand All @@ -185,19 +185,7 @@ public func ==(lhs: ATNConfig, rhs: ATNConfig) -> Bool {
return false
}

var contextCompare = false

if lhs.context == nil && rhs.context == nil {
contextCompare = true
} else if lhs.context == nil && rhs.context != nil {
contextCompare = false
} else if lhs.context != nil && rhs.context == nil {
contextCompare = false
} else {
contextCompare = (lhs.context! == rhs.context!)
}

if !contextCompare {
if lhs.context != rhs.context {
return false
}

Expand Down
23 changes: 2 additions & 21 deletions runtime/Swift/Sources/Antlr4/atn/LexerATNConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,30 +108,11 @@ public func ==(lhs: LexerATNConfig, rhs: LexerATNConfig) -> Bool {
return false
}

if lhs.getLexerActionExecutor() == nil && rhs.getLexerActionExecutor() != nil {
if lhs.getLexerActionExecutor() != rhs.getLexerActionExecutor() {
return false
} else if lhs.getLexerActionExecutor() != nil && rhs.getLexerActionExecutor() == nil {
return false
} else if lhs.getLexerActionExecutor() == nil && rhs.getLexerActionExecutor() == nil {

} else if !(lhs.getLexerActionExecutor()! == rhs.getLexerActionExecutor()!) {
return false
}


var contextCompare = false

if lhs.context == nil && rhs.context == nil {
contextCompare = true
} else if lhs.context == nil && rhs.context != nil {
contextCompare = false
} else if lhs.context != nil && rhs.context == nil {
contextCompare = false
} else {
contextCompare = (lhs.context! == rhs.context!)
}

if !contextCompare{
if lhs.context != rhs.context {
return false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,8 @@ public func ==(lhs: SingletonPredictionContext, rhs: SingletonPredictionContext)
if lhs.returnState != rhs.returnState {
return false
}
var parentCompare = false
if (lhs.parent == nil) && (rhs.parent == nil) {
parentCompare = true
} else if lhs.parent == nil || rhs.parent == nil {
parentCompare = false
} else {
parentCompare = (lhs.parent! == rhs.parent!)
}

return parentCompare
return lhs.parent == rhs.parent
}


2 changes: 1 addition & 1 deletion runtime/Swift/Sources/Antlr4/tree/pattern/Chunk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public class Chunk: Equatable {
}

public func isEqual(_ other: Chunk) -> Bool {
return false
return self === other
}
}