Commit Graph

356 Commits

Author SHA1 Message Date
Simon Michael
e077aeff5f lib: more informative test failure message (#812) 2018-08-14 16:05:06 +01:00
Simon Michael
321635274c lib: move assertParseEqual' (#812) 2018-08-14 16:05:06 +01:00
Simon Michael
b03584dbce lib: parse helper haddocks 2018-08-14 16:05:06 +01:00
Simon Michael
cfaa0501e6 lib: update some journal parser tests (#812) 2018-08-14 16:05:06 +01:00
Jakub Zárybnický
c67404c73d lib: Fix compile errors in tests 2018-08-14 16:05:06 +01:00
Simon Michael
e88a9c4a5f lib: followingcomment: parse no comment as "", not "\n"
Same-line & next-line comments of transactions, postings, etc.
are now parsed a bit more precisely. Previously parsing no comment
gave the same result as an empty comment (a single newline); now
it gives an empty string.

Also, and perhaps as a consequence of the above, when there's no
same-line comment but there is a next-line comment, we'll insert an
empty first line, otherwise next-line comments would get moved up to
the same line when rendered.

Some doctests have been added.
2018-08-03 19:38:55 +01:00
Joseph Weston
40d70ad10b lib: fail when file to include is in stack of 'include' files 2018-08-02 18:43:00 +01:00
Joseph Weston
1d91ea43a5 lib: add whitespace around '$' operator 2018-08-02 18:43:00 +01:00
Simon Michael
d685d1aa9b lib,rewrite: simplify transactionModifierToFunction
This removes transactionModifierToFunction's extra query parameter;
the rewrite command sets it in the TransactionModifier instead, which
I think is equivalent. I had to change one functional test, but it
seems correct now, so perhaps it wasn't working right before ?
2018-08-02 08:25:49 +01:00
Simon Michael
eae9d78bb1 lib: generateAutomaticPostings -> applyTransactionModifiers 2018-08-02 08:25:49 +01:00
Simon Michael
bb36693155 lib: refactor, txnTieKnot automatically 2018-08-02 08:25:49 +01:00
Simon Michael
572f5a4b31 lib: drop parseAndFinaliseJournal', seems unused (api change) 2018-08-02 08:25:49 +01:00
Simon Michael
efc54c4c25 lib: ModifierTransaction -> TransactionModifier; try to clarify a bit 2018-07-30 19:38:21 +01:00
Simon Michael
d9d94e2cf6 journal: fix breakage in auto posting rule parser (#745)
I was negligent and did not test enough. This should ignore
transaction comments in auto posting rules more safely.
It also adds support for trailing comments on the first line of auto
posting rules, which previously were misparsed as part of the query.
2018-07-26 15:54:21 +01:00
Simon Michael
e2f5e98926 lib: clarify account name parsing rules 2018-07-26 08:30:32 +01:00
Simon Michael
41c985b5fb journal: ignore transaction comments in auto posting rules (#745)
Previously they were misparsed as account names.
2018-07-26 08:29:02 +01:00
Joseph Weston
f2c1586238 lib: sort the matched include files lexicographically
Now the files are included in the same order as they would be
listed by 'ls'.
2018-07-26 06:12:31 +01:00
Joseph Weston
1ec16c2dc0 lib: explicitly specify that the 'Glob' package should be used
Without this there are conflicts with the 'filemanip' package,
which itself exports a module 'System.FilePath.Glob'.
2018-07-26 06:12:31 +01:00
Joseph Weston
c69b16d826 lib: prefer use of 'parseErrorAt' to generic 'fail'
'fail' will just terminate the current parse branch, whereas here
we have encountered a definite error. Also bring the code to
get the current working directory inside 'getFilePaths', as it
logically belongs there.
2018-07-26 06:12:31 +01:00
Joseph Weston
5077443a84 lib: add tests and code for nonexistant files and malformed globs 2018-07-26 06:12:31 +01:00
Joseph Weston
2c4d0c0acd lib: factor out logic for obtaining a list of files to include 2018-07-26 06:12:31 +01:00
Joseph Weston
0ade323d2a lib: use glob matching if filename in 'include' directive is a glob pattern 2018-07-26 06:12:31 +01:00
Joseph Weston
96f7a03487 lib: factor out parsing child journal into separate function 2018-07-26 06:12:31 +01:00
Joseph Weston
52da073828 lib: expand current directory separately from filepath
We will need the current directory as an absolute path when
adding glob patterns in a few commits time.
2018-07-26 06:12:31 +01:00
Joseph Weston
9e56ad24e2 lib: reorder code for reading include files
This should be before all journal and parser state manipulations,
so that those can be readily factored in a few commits time.
2018-07-26 06:12:31 +01:00
Simon Michael
fe73f2a6b5 csv: interpolated field names in values are now case insensitive
Field names are supposed to be case insensitive, but a field assignment like

fields  ...,Transaction_Date,...
date %Transaction_Date

was failing, because of the capitalised letters. Fixed now.
2018-07-22 22:26:24 +01:00
Simon Michael
d5430e7ddf clean up debug helpers (api change) 2018-07-16 15:28:58 +01:00
Simon Michael
6924e8390c lib: journal: let alias/apply account affect account directives (#825) 2018-06-27 11:33:12 +01:00
Alex Chen
e82b01bcf8 lib: refine parse errors and parser labels 2018-06-20 23:24:39 -06:00
Alex Chen
9674f2a8cc lib: tweak whitespace parsing for better parse errors
- expands the set of expected tokens when e.g. parsing the invalid
  posting `account  $1 a`
- whitespace can affect parse errors because of the longest match rule
  where errors that occur later take precedence over those that occur
  earlier
2018-06-20 23:24:39 -06:00
Alex Chen
ed0106b209 lib: reduce backtracking of various parsers 2018-06-20 23:24:39 -06:00
Alex Chen
e3a755b5b1 lib: refactor amount parsers to minimize backtracking
- inline `spaceamountormissingp` into `postingp`
- combine `rightsymbolamountp` and `nosymbolamountp`
- the multiplier symbol '*' for an amount must now always preceed a sign '-'
  [breaking change]
- make amount parser labels more generic to simplify error messages
2018-06-20 23:24:39 -06:00
Alex Chen
89b1fd7de3 lib: refactor date-time parser, add error messages
- also removed commented-out time-zone code
2018-06-20 23:24:39 -06:00
Simon Michael
c4d45cffc4 lib: journal: require a space between period expr. and other fields 2018-06-12 16:41:36 -07:00
Alex Chen
c6bfd92dd3 removing "re-parsing" for pull 807
For Data/Dates.hs in particular:
- Changed `SimpleTextParser` to `TextParser m` for all parsers
- Changed `string` to the case-insensitive `string'` to match the
  behaviour of `T.toLower` found in `parsePeriodExpr`
- export `periodexprp` for "direct" use
2018-06-12 16:41:36 -07:00
Simon Michael
e3507ad944 lib: journal: allow descriptions/comments in periodic transactions
Also period expressions relative to today's date can now be used,
for what it's worth.
2018-06-12 16:41:36 -07:00
Simon Michael
dfcafc2cdf lib: refactor some journal, period expression parsers 2018-06-12 16:41:36 -07:00
Alex Chen
0fb737bc39 lib: reduce backtracking in commoditydirectiveonelinep 2018-06-11 14:29:18 -06:00
Alex Chen
0382bb5cd4 lib: move custom parse errors to Text.Megaparsec.Custom 2018-06-11 13:58:56 -06:00
Alex Chen
ff2b042c7e lib: remove the ErroringJournalParser type 2018-06-11 13:58:56 -06:00
Alex Chen
39e7ef0311 lib: refine date parser error messages 2018-06-11 13:58:55 -06:00
Alex Chen
5f87e7cd5d lib: enable the custom parse errors 2018-06-11 13:57:30 -06:00
Alex Chen
2d21ec0174 lib: weaken parser types 2018-06-11 13:57:30 -06:00
Alex Chen
4a9e418b7a lib: refactor includedirectivep to avoid "re-parsing" 2018-06-11 13:57:30 -06:00
Alex Chen
b034fa7ca9 lib: weaken parser types 2018-06-11 13:57:30 -06:00
Alex Chen
9b6558401f lib: rewrite comment parsers [API]
- avoid the "re-parsing" of comments using the `match` parser combinator
2018-06-11 13:57:30 -06:00
Alex Chen
d707b351cc lib: switch to custom parse errors for parserErrorAt
Also weaken the types of the parsers that use it
2018-06-11 13:57:30 -06:00
Alex Chen
c5561f25f1 lib: switch parsers to the custom error type
Also add an explicit export list to `hledger-lib/Hledger/Utils/Parse.hs`
in order to re-export the custom error type (for convenience).
2018-06-11 13:57:30 -06:00
Simon Michael
0ce9c5728a switch to base-compat-batteries to fix ghc 7.10 support (#794)
base-compat-batteries provides the same API across more ghc versions
than base-compat does, at the cost of more dependencies. Eg it exports
Prelude.Compat ((<>)) with ghc 7.10/base 4.8, which we expect.
My belief is that several of our deps already require it so the added
cost is not too great. We should probably go back to base-compat when
possible though, eg when we stop supporting ghc 7.10.
2018-06-04 17:32:42 -07:00
Peter Simons
6db7f800ee hledger-lib: fix doctest suite after recent package updates
The new version of our package set apparently contains both base-compat and
base-compat-batteries in its transitive closure. This breaks the doctest suite,
which just imports everything into scope when the tests are run, thereby making
module names like Prelude.Compat ambiguous.
2018-06-04 21:41:15 +02:00