parsing: more robust double-quoted commodities - anything but a space or newline or double quote
This commit is contained in:
parent
3305141206
commit
b97d2690de
@ -12,6 +12,8 @@ import Hledger.Data.Utils
|
|||||||
import Hledger.Data.Types
|
import Hledger.Data.Types
|
||||||
|
|
||||||
|
|
||||||
|
nonsimplecommoditychars = "0123456789-.@;\n \""
|
||||||
|
|
||||||
-- convenient amount and commodity constructors, for tests etc.
|
-- convenient amount and commodity constructors, for tests etc.
|
||||||
|
|
||||||
unknown = Commodity {symbol="", side=L,spaced=False,comma=False,precision=0}
|
unknown = Commodity {symbol="", side=L,spaced=False,comma=False,precision=0}
|
||||||
|
|||||||
@ -157,7 +157,7 @@ import Hledger.Data.Amount
|
|||||||
import Hledger.Data.Transaction
|
import Hledger.Data.Transaction
|
||||||
import Hledger.Data.Posting
|
import Hledger.Data.Posting
|
||||||
import Hledger.Data.Journal
|
import Hledger.Data.Journal
|
||||||
import Hledger.Data.Commodity (dollars,dollar,unknown)
|
import Hledger.Data.Commodity (dollars,dollar,unknown,nonsimplecommoditychars)
|
||||||
import System.FilePath(takeDirectory,combine)
|
import System.FilePath(takeDirectory,combine)
|
||||||
import System.Time (getClockTime)
|
import System.Time (getClockTime)
|
||||||
|
|
||||||
@ -545,17 +545,18 @@ nosymbolamount = do
|
|||||||
<?> "no-symbol amount"
|
<?> "no-symbol amount"
|
||||||
|
|
||||||
commoditysymbol :: GenParser Char st String
|
commoditysymbol :: GenParser Char st String
|
||||||
commoditysymbol = (quotedcommoditysymbol <|>
|
commoditysymbol = (quotedcommoditysymbol <|> simplecommoditysymbol) <?> "commodity symbol"
|
||||||
many1 (noneOf "0123456789-.@;\n \"")
|
|
||||||
) <?> "commodity symbol"
|
|
||||||
|
|
||||||
quotedcommoditysymbol :: GenParser Char st String
|
quotedcommoditysymbol :: GenParser Char st String
|
||||||
quotedcommoditysymbol = do
|
quotedcommoditysymbol = do
|
||||||
char '"'
|
char '"'
|
||||||
s <- many1 $ noneOf "-.@;\n\""
|
s <- many1 $ noneOf ";\n\""
|
||||||
char '"'
|
char '"'
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
simplecommoditysymbol :: GenParser Char st String
|
||||||
|
simplecommoditysymbol = many1 (noneOf nonsimplecommoditychars)
|
||||||
|
|
||||||
priceamount :: GenParser Char st (Maybe MixedAmount)
|
priceamount :: GenParser Char st (Maybe MixedAmount)
|
||||||
priceamount =
|
priceamount =
|
||||||
try (do
|
try (do
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user