Skip to content

Commit

Permalink
add ? to custom operator list
Browse files Browse the repository at this point in the history
  • Loading branch information
Jintin committed May 6, 2017
1 parent 785281b commit 1f9442e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Parser/SwiftParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ let operatorList: [Character: [(String, Int)]] =
(">->", 3), (">", 1)],
"|": [("|||", 3), ("||=", 3), ("||", 2), ("|=", 2), ("|", 1)],
"!": [("!==", 3), ("!=", 2)],
"=": [("===", 3), ("==", 2), ("=", 1)]
"=": [("===", 3), ("==", 2), ("=", 1)],
"?" : []
]

fileprivate let negativeCheckSigns: [Character] =
Expand Down Expand Up @@ -91,6 +92,12 @@ class SwiftParser {
}
return space(with: operatorList[char]!)!
case "?":
if let spaceChar = operatorList[char] {
if let index = space(with: spaceChar) {
return index
}
}

if isNext(char: "?") {
// MARK: check double optional or nil check
return add(string: "??", length: 2)
Expand Down

0 comments on commit 1f9442e

Please sign in to comment.