Skip to content

Commit

Permalink
Use older ingoreSpaces for Xcode 14.2
Browse files Browse the repository at this point in the history
  • Loading branch information
bradhowes committed Jul 15, 2023
1 parent 390ee49 commit 1788204
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Sources/MathParser/MathParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ final public class MathParser {
)
private lazy var operand: some TokenParser = Parse {
Skip { Whitespace(0...) }
ignoreSpaces
OneOf {
negatedOperand
nonNegatedOperand
Expand Down Expand Up @@ -280,11 +280,11 @@ final public class MathParser {
"("
self.subexpression
Optionally {
Skip { Whitespace(0...) }
ignoreSpaces
","
self.subexpression
}
Skip { Whitespace(0...) }
ignoreSpaces
")"
}
}.map { (identifier: Substring, call: (Token, Token?)?) -> Token in
Expand Down Expand Up @@ -339,15 +339,15 @@ final public class MathParser {
// MARK: - Operator Parsers
private let additionOrSubtractionOperator: some TokenReducerParser = Parse {
Skip { Whitespace(0...) }
ignoreSpaces
OneOf {
"+".map { { Token.reducer(lhs: $0, rhs: $1, op: (+), name: "+") } }
"-".map { { Token.reducer(lhs: $0, rhs: $1, op: (-), name: "-") } }
}
}
private lazy var multiplicationOrDivisionOperator: some TokenReducerParser = Parse {
Skip { Whitespace(0...) }
ignoreSpaces
OneOf {
"*".map { self.multiplicationReducer }
"×".map { self.multiplicationReducer }
Expand All @@ -366,6 +366,9 @@ final public class MathParser {
private func findUnary(name: Substring) -> UnaryFunction? { self.unaryFunctions(String(name)) }
}
/// Common expression for ignoring spaces in other parsers
private let ignoreSpaces = Skip { Optionally { Prefix<Substring> { $0.isWhitespace } } }
typealias TokenParser = Parser<Substring, Token>
typealias TokenReducer = (Token, Token) -> Token
typealias TokenReducerParser = Parser<Substring, TokenReducer>

0 comments on commit 1788204

Please sign in to comment.