---
# System prepended metadata

title: Untitled

---

enum ExpressionParser {
    func parse(from input: String) -> Formula {
        let operandQueue: [Double] = []
        let operatorQueue: [Operator] = []
        
        operandQueue = componentsByOperators(from: input).map { Double($0) }
        operatorQueue
        for ele in input {
            if !ele.isNumber {
                operatorQueue.append(<#T##newElement: Operator##Operator#>)
            }
        }
        return Formula(operands: oper, operators: <#T##CalculatorItemQueue<Operator>#>)
    }
    
    func componentsByOperators(from input: String) -> [String] {
        
        var realNums: [String] = []
        var nums: [String] = []
        for element in input {
            if element.isNumber {
                nums.append(String(element))
            } else {
                realNums.append(nums.joined())
                nums = []
            }
        }
        
        
//        var numbers: [String] = []
//        for a in Operator.allCases {
//            switch a {
//            case .add:
//                numbers = input.split(with: "+")
//            case .subtract:
//                separateNumbers(sep: "-", numbers: &numbers)
//            case .divide:
//                separateNumbers(sep: "/", numbers: &numbers)
//            case .mulitiply:
//                separateNumbers(sep: "*", numbers: &numbers)
//            }
//        }
    }
    
    func separateNumbers(sep: Character, numbers: inout [String]) {
        for (idx, num) in numbers.enumerated() {
            if let _ = Int(num) {
                continue
            }
            numbers.remove(at: idx)
            for x in num.split(with: sep).reversed() {
                numbers.insert(x, at: idx)
            }
        }
    }
}
