Skip to content

Commit

Permalink
Make ParserUtils public
Browse files Browse the repository at this point in the history
  • Loading branch information
Nef10 committed Jul 19, 2020
1 parent 2e21578 commit 3fc2478
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Sources/SwiftBeanCountParser/ParserUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@

import Foundation

enum ParserUtils {
/// Helper methods for parsing a ledger file
public enum ParserUtils {

static let accountGroup = "([^\\s]+:[^\\s]+)"
static let decimalGroup = "([-+]?[0-9]+(,[0-9]{3})*(.[0-9]+)?)"
static let commodityGroup = "([^\\s]+)"
static let amountGroup = "\(decimalGroup)\\s+\(commodityGroup)"

static func parseAmountDecimalFrom(string: String) -> (Decimal, Int) {
/// Parses an string into an Decimal
/// - Parameter string: string with the amount
/// - Returns: Tuple with the decimal ane the number of decimal palces the string contained
public static func parseAmountDecimalFrom(string: String) -> (Decimal, Int) {
var amountString = string
var sign = FloatingPointSign.plus
while let index = amountString.firstIndex(of: ",") {
Expand Down

0 comments on commit 3fc2478

Please sign in to comment.