Alex Chen
f7fd6e6525
lib: refactor the raw number parser [API]
...
- Purpose: to reduce the verbosity of the previous implementation
- Split off `AmbiguousNumber` into its own type
- Introduce a function `AmbiguousNumber -> RawNumber` explicitly capturing the
disambiguation logic
- Reduce the number of remaining constructors in `RawNumber` to just two,
`WithSeparator` and `NoSeparator`
- The choice to distinguish by the presence of digit separators is motivated
by the need for this information later on when disallowing exponents on
numbers with digit separators
2018-05-27 07:50:26 -07:00
Alex Chen
6ffa9cb3cd
lib: rename pdigitgroup to digitgroupp for consistency
2018-05-27 07:50:26 -07:00
Alex Chen
cf9b2001e7
lib: refactor sign parser
...
- Extracts the handling of signs out of `fromRawNumber` and into `signp` itself
- Rationale: The sign can be applied independently from the logic in
`fromRawNumber`
2018-05-27 07:50:26 -07:00
Alex Chen
84c7e2c403
lib: superficial changes to parsers
2018-05-24 09:35:27 -07:00
Alex Chen
121ba92ade
lib: refactor the raw number parser [API change]
2018-05-24 09:35:27 -07:00
Alex Chen
93fbac99d3
lib: refactor date parser
2018-05-24 09:35:27 -07:00
Alex Chen
12e8d0e282
lib: change some parsers to use takeWhileP
2018-05-22 12:16:46 -07:00
Alex Chen
558c11596f
lib: refactor the account name parser
2018-05-22 12:16:46 -07:00
Alex Chen
b245ec7b3d
lib: remove the megaparsec compatability module
2018-05-22 12:16:46 -07:00
Alex Chen
676ea912b3
lib: fix issue where spaces were allowed as decimal points
...
- Fixes #749
- Also enabling the tests prepared for #749
2018-05-20 20:17:57 -07:00
awjchen
46aae19a54
lib: fix parsing of amounts with a whitespace digits separator
2018-05-20 16:02:59 -06:00
Simon Michael
581d02162c
resolve all current build warnings with the supported GHC versions
...
If I'm lucky.
2018-05-17 20:43:55 -07:00
Alex Chen
67ed2d6cbf
lib: superficial changes to comment parsers
2018-05-17 18:15:06 -07:00
Alex Chen
188583e232
lib: cleanup: remove redundant comment parsing alternatives
2018-05-17 18:15:06 -07:00
Alex Chen
892a1c6434
lib: refactor: make the bracketed date tags parser a SimpleTextParser
2018-05-17 18:15:06 -07:00
Alex Chen
0cff1634be
lib: refactor: make the bracketed datetags parser a SimpleTextParser in all but type
2018-05-17 18:15:06 -07:00
Alex Chen
b3a91a49d8
lib: refactor: factor out a TextParser from datep
2018-05-17 18:15:06 -07:00
Alex Chen
09fd8132b7
lib: refactor: weaken types of comment parsers
2018-05-17 18:15:06 -07:00
Alex Chen
31b72f0415
lib: replace notChar for backwards compatibility with megaparsec 5
2018-05-16 22:35:22 -07:00
Alex Chen
99e457f1da
lib: fix performance regression introduced in 30ae9914
2018-05-15 19:29:59 -07:00
Alex Chen
12ddcb1784
lib: extend export list of Read/Common.hs
2018-05-15 11:52:29 -07:00
Alex Chen
17b11aaf1e
lib: refactor parsing of bracketed posting dates
2018-05-15 11:52:29 -07:00
Alex Chen
fcc10f018d
lib: merge parsing of date-tags with that of tags
2018-05-15 11:52:29 -07:00
Alex Chen
ec85271a0b
lib: refactor tags parser: be more efficient, save SourcePos for later
2018-05-15 11:52:29 -07:00
Stephen Morgan
6c2385331c
Allow comments for periodic transactions.
2018-05-14 18:28:27 -07:00
Mykola Orliuk
64c7eb78f4
GHC 8.0 compatibility
2018-05-13 14:41:08 -07:00
Stephen Morgan
5bc5bb5533
Fix doctest error introduced by 49c8c093ac.
2018-05-11 07:25:17 -07:00
Simon Michael
7040289d54
add some exports to fix warnings ( #762 )
2018-05-11 07:17:38 -07:00
Alex Chen
3aa72bdf16
lib: Clean up new code introduced for #655
2018-05-11 06:41:13 -07:00
Alex Chen
30ae991484
lib: Strip comment before parsing tags ( #655 )
2018-05-11 06:41:13 -07:00
Alex Chen
09ec6041bd
lib: Report source positions from internal comment parsers
2018-05-11 06:41:13 -07:00
Alex Chen
b06d22a418
lib: Refactor common comment parsers
2018-05-11 06:41:13 -07:00
Alex Chen
c2199b1125
lib: Add explicit export list to Common.hs
2018-05-11 06:41:13 -07:00
Alex Chen
a409d09435
lib: restrict backtracking when parsing postings ( #747 )
2018-05-09 22:09:15 -07:00
Simon Michael
49c8c093ac
lib: clarify rawnumberp doc
...
[ci skip]
2018-05-09 10:22:39 -07:00
Simon Michael
0b380971f7
journal: require a decimal point in commodity/format/D directives
...
A commodity directive that doesn't specify the decimal point character
increases ambiguity and the chance of misparsing numbers, especially
as it overrides all style information inferred from the journal amounts.
In some cases it caused amounts with a decimal point to be parsed as if
with a digit group separator so 1.234 became 1234.
We could augment it with extra info from the journal amounts, when available,
but it would still be possible to be ambiguous, and that won't be obvious.
A commodity directive is what we recommend to nail down the style.
It seems the simple and really only way to do this reliably is to require
an explicit decimal point character. Most folks probably do this already.
Unfortunately, it makes another potential incompatiblity with ledger and
beancount journals. But the error message will be clear and easy to
work around.
2018-04-20 21:56:06 -07:00
Simon Michael
3f2827424c
refactor: number parsing docs
2018-04-20 21:39:06 -07:00
Simon Michael
f2d3b3e1d4
csv: handle the other double negation cases: -(N), ((N)) ( fix #736 )
2018-04-18 07:39:33 -07:00
Dmitry Astapov
d82370d10b
lib, app, web: remove differences between command line and journal file aliases
2018-04-17 16:09:11 -07:00
Dmitry Astapov
ecf49b1e4b
lib: auto postings generated before amount inference and balance checks ( #729 )
2018-04-17 14:33:32 -07:00
Everett Hildenbrandt
c69fbff6d9
CsvReader: print more information about amount-in/out errors
2018-04-15 16:52:52 -07:00
Simon Michael
4ff3a749c6
lib: note an oddity with runJournalParser
2018-03-31 02:44:31 +01:00
Mykola Orliuk
b377bff90a
lib: support scientific number notation ( #704 , #706 )
...
closes simonmichael/hledger#704
2018-03-31 01:49:46 +01:00
Moritz Kiefer
d7b68fbd7d
Use skipMany/skipSome for parsing spacenonewline
...
This avoids allocating the list of space characters only to then
discard it.
2018-03-25 22:59:05 +01:00
Simon Michael
84579bb1b4
silence redundant import warnings with ghc 8.4
2018-03-24 22:51:56 +00:00
Simon Michael
13855d6b53
csv: no csv records is no longer an error
2018-02-01 09:41:03 -08:00
Simon Michael
d420a8b534
journal: account directive: parse and store a numeric account code also
2018-01-23 11:33:23 -08:00
Simon Michael
81e964502b
lib: refactor low-level text file reading
2018-01-04 16:17:25 -08:00
Simon Michael
ecdbc05703
Merge branch 'feature/space-as-digits-sep' of https://github.com/ony/hledger into ony-feature/space-as-digits-sep
2017-12-30 09:29:22 -08:00
Nadrieril
9e6e06033f
lib: Allow balance-only entries in csv reader
2017-12-14 18:26:29 -08:00