Skip to content

Commit

Permalink
imp: Add ' as possible digit separator
Browse files Browse the repository at this point in the history
It is used for Swiss Francs: CHF 1'000.
  • Loading branch information
ThreeFx committed Jul 18, 2022
1 parent c54fb4d commit 8cd6c3c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion hledger-lib/Hledger/Read/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,8 @@ disambiguateNumber msuggestedStyle (AmbiguousNumber grp1 sep grp2) =
-- Left (AmbiguousNumber "1" ',' "000")
-- >>> parseTest rawnumberp "1 000"
-- Right (WithSeparators ' ' ["1","000"] Nothing)
-- >>> parseTest rawnumberp "1'000"
-- Right (WithSeparators '\'' ["1","000"] Nothing)
--
rawnumberp :: TextParser m (Either AmbiguousNumber RawNumber)
rawnumberp = label "number" $ do
Expand Down Expand Up @@ -1060,7 +1062,7 @@ rawnumberp = label "number" $ do
pure $ NoSeparators grp1 (Just (decPt, mempty))

isDigitSeparatorChar :: Char -> Bool
isDigitSeparatorChar c = isDecimalMark c || c == ' '
isDigitSeparatorChar c = isDecimalMark c || c == ' ' || c == '\''

-- | Some kinds of number literal we might parse.
data RawNumber
Expand Down

0 comments on commit 8cd6c3c

Please sign in to comment.