Stephen Morgan
07dd30c1e5
lib,cli,ui: Change to consistent naming scheme for Hledger.Utils.Regex.
2020-09-01 11:36:34 +10:00
Stephen Morgan
b91b391d08
lib: Replace some regex functions with parsers.
2020-08-31 22:44:41 +10:00
Stephen Morgan
af31d6e140
lib,cli,ui: Remove redundant Typeable and Data instances.
...
Also add some explicit import lists.
2020-08-31 15:41:30 +10:00
Stephen Morgan
01f5a92761
lib: Improve Read and Show instances for Regexp, get rid of custom show instance for Query.
2020-08-31 12:04:47 +10:00
Stephen Morgan
e3b2c94353
lib: Remove unneeded total Query code.
2020-08-31 12:04:47 +10:00
Stephen Morgan
e5371d5a6a
lib,cli,ui,web: Make Regexp a wrapper for Regex.
2020-08-31 12:04:45 +10:00
Stephen Morgan
ccd6fdd7b9
lib: Remove unused Tree functions.
2020-08-31 11:51:25 +10:00
Stephen Morgan
ba59fed6b2
lib: Replace more instances of fromIntegral with safer versions.
2020-08-30 22:20:58 +10:00
Simon Michael
3822c27bfe
;lib: regex: rename & export RegexError, export toRegex_, docs ( #1312 )
2020-08-06 15:25:58 -07:00
Simon Michael
4957008890
;lib: regex utilities: cleanup ( #1312 )
2020-08-06 11:35:04 -07:00
Simon Michael
a112085092
lib: add alternate regex utilities that don't call error ( #1312 )
2020-08-06 11:18:08 -07:00
Simon Michael
ede4bfd5b4
;mark more partial functions ( #1312 )
2020-08-05 17:29:43 -07:00
Simon Michael
3f55c23603
;review, tag all error calls with an easier to find PARTIAL: comment ( #1312 )
2020-08-05 16:08:33 -07:00
Stephen Morgan
ffb5cf0773
lib: Ensure parsed years have at least 4 digits.
2020-07-31 17:22:27 -07:00
Stephen Morgan
081ee390ab
lib: Change skipMany spacenonewline to takeWhileP Nothing isNonNewlineSpace.
2020-07-22 14:58:53 -07:00
Stephen Morgan
dc076b0d5b
lib: Use text library functions for stripping.
2020-07-16 10:03:25 -07:00
Stephen Morgan
ed99aea7d5
lib: Introduce takeEnd to get rid of some reverse . take n . reverse.
2020-07-16 10:03:25 -07:00
Simon Michael
765fb732c9
debug: move command parsing debug output down to level 8
2020-07-03 11:37:01 -07:00
Simon Michael
122309ced7
;lib: Debug comment
2020-06-19 14:39:32 -07:00
Simon Michael
562480efea
;lib: debug doc
2020-06-14 17:27:15 -07:00
Simon Michael
684cb45e1a
tweak debug levels, document some guidelines
...
Beginnings of a project-wide policy for what output to show at
each debug level, for now. Later we'll want more flexibility,
eg filtering by topic.
2020-06-14 17:17:09 -07:00
Simon Michael
b86ced5ee9
lib: replace jsonPrettyText with toJsonText in Hledger.Data.Json
2020-06-06 12:54:58 -07:00
Simon Michael
d963944c99
lib: add jsonPrettyText helper, depend on aeson-pretty
2020-06-04 15:12:57 -07:00
Simon Michael
3ef2fc9567
show a clearer error message on encountering a malformed regexp
2020-05-07 17:33:05 -07:00
Simon Michael
e0c3275d74
lib: debug helpers traceAt, traceAtWith
2020-03-11 19:08:05 -07:00
Stephen Morgan
e0dde6fe57
lib: Remove non-law-abiding Monoid instance for Journal.
2020-03-02 12:45:30 -08:00
Simon Michael
50f8539911
;lib: comments
...
[ci skip]
2020-03-01 14:06:29 -08:00
Simon Michael
c3680b868b
lib: Hledger.Utils.Parse: restofline can go to eof also
2020-02-29 09:48:03 -08:00
Simon Michael
7ec25da13a
web: edit/upload: normalise line endings, avoiding parse errors ( #1194 )
...
Renamed: writeValidJournal -> writeJournalTextIfValidAndChanged
Added comments clarifying line ending behaviour of:
add, import, appendToJournalFileOrStdout, readFilePortably,
writeFileWithBackupIfChanged, writeJournalTextIfValidAndChanged
Summary of current behaviour:
- hledger add and import commands will append with (at least some)
unix line endings, possibly causing the file to have mixed line
endings
- hledger-web edit and upload forms will write the file with
the current system's native line endings, ie changing all
line endings if the file previously used foreign line endings.
2020-02-24 14:04:44 -08:00
Simon Michael
bb6e1e3ce2
;lib: export textQuoteIfNeeded
...
[ci skip]
2020-02-03 10:10:46 -08:00
Simon Michael
ce5eccfbc0
;spelling fix
...
[ci skip]
2020-01-04 21:17:50 -08:00
Jacek Generowicz
29211868bb
Fix issue 457
...
Issue #457 pointed out that commands such as
hledger ui 'amt:>200'
failed. This was becasue the process of dispatching from `hledger ui`
to `hledger-ui` (note addition of `-`) lost the quotes around
`amt:>20` and the `>` character was interpreted as a shell redirection
operator, rather than as part of the argument.
The machinery for quoting or escaping arguements which cointain
characters which require quoting or escaping (thus far whitespace and
quotes) already existed. This solution simply adds shell stdio
redirection characters to this set.
Fixes #457
2019-12-08 18:33:43 +01:00
Simon Michael
2b2a0b3cf8
;tests: use "test" alias for testCase everywhere
...
Easier to type and read, and a little clearer to my eyes;
"testCase" implies a single case, but it can contain many assertions.
2019-11-28 15:33:33 -08:00
Simon Michael
030b633cd6
;fix build issues with old GHC versions
2019-11-28 15:22:12 -08:00
Simon Michael
5dac8af2ef
;ui: fix build error due to tests rewrite
2019-11-27 21:54:31 -08:00
Simon Michael
b36f6df110
tests: port all unit tests to tasty, second pass ( #1090 )
...
Hledger.Util.Tests helpers have been cleaned up, and test names are
now shown.
Tests have been cleaned up a bit. Some groups of unnamed tests have
been collapsed into a single named test containing a sequence of
assertions. The test command counts named tests, not assertions, so
the reported unit test count has dropped from 199 to 188.
2019-11-27 13:17:34 -08:00
Simon Michael
13a3542464
tests: port all unit tests to tasty, first cut ( #1090 )
...
easytest is not actively maintained and requires an old version of
hedgehog which does not support base-compat 0.11 & ghc 8.8.
This is still using the old easytest helpers, and not displaying test
names properly.
2019-11-27 12:43:43 -08:00
Mykola Orliuk
31ae3d3aaf
;lib: drop SystemString left from GHC pre 7.2
...
We are relying on base-4.9 or newer. Thus we don't compile anymore with
GHC version lower than 8.0.1.
2019-11-18 17:38:39 -08:00
Dmitry Astapov
24bba96ea2
lib: more robust multi-line joining in csv parser
2019-11-05 21:16:42 +00:00
Dmitry Astapov
e4add6df83
lib: fix for multiline descriptions in csv ( fixes #841 , #416 )
2019-11-05 21:16:42 +00:00
Simon Michael
c7746131fc
;lib: clarify parser monad transformers a little
...
[ci skip]
2019-09-08 10:40:47 -07:00
Simon Michael
35799142dd
Merge pull request #914 from simonmichael/rule-tags
...
tags for matching rule-generated txns and postings
2019-07-17 18:38:14 +01:00
Caleb Maclennan
11d9e5eb6a
code: Strip extraneous trailing whitespace from Haskell sources
2019-07-15 16:40:49 +01:00
Simon Michael
45198d3faa
lib: debug helpers: add ptraceAtWith, dbgNWith
2019-06-02 08:48:41 -07:00
Simon Michael
573a13fc27
lib: expectParseStateOn helper
2019-01-18 16:40:35 -08:00
Simon Michael
b5df5fb5f0
lib: comment
2018-10-18 14:43:00 -07:00
Simon Michael
2c2d10f9c2
lib: plog, plogAt: add missing newline, note issue
2018-10-18 14:43:00 -07:00
Alex Chen
3d2584d869
lib: switch to megaparsec 7
2018-09-30 20:15:12 -06:00
Alex Chen
3e54fc77a4
lib: make 'includedirectivep' an 'ErroringJournalParser'
...
- Update tests as well, requiring test utilities in Utils/Test.hs
analogous to the those for 'JournalParser' but instead for
'ErroringJournalParser'
2018-09-29 22:34:52 -06:00
Alex Chen
855a8f1985
lib: Re-implement the 'ExceptT' layer of the parser
...
We previously had another parser type, 'type ErroringJournalParser =
ExceptT String ...' for throwing parse errors without the possibility of
backtracking. This parser type was removed under the assumption that it
would be possible to write our parser without this capability. However,
after a hairy backtracking bug, we would now prefer to have the option
to prevent backtracking.
- Define a 'FinalParseError' type specifically for the 'ExceptT' layer
- Any parse error can be raised as a "final" parse error
- Tracks the stack of include files for parser errors, anticipating the
removal of the tracking of stacks of include files in megaparsec 7
- Although a stack of include files is also tracked in the 'StateT
Journal' layer of the parser, it seems easier to guarantee correct
error messages in the 'ExceptT FinalParserError' layer
- This does not make the 'StateT Journal' stack redundant because the
'ExceptT FinalParseError' stack cannot be used to detect cycles of
include files
2018-09-29 22:33:34 -06:00
Simon Michael
91b111b60d
rename easytests_* to tests_*
2018-09-06 13:13:26 -07:00
Simon Michael
ce96001cfc
lib: keep Tests building with ghc 7.10
...
The doctests test suite fails to bulid with ghc 7.10, not fixed.
2018-09-04 14:27:10 -07:00
Simon Michael
4003264129
lib: drop HUnit helpers, rename expectEqPP
2018-09-04 13:52:36 -07:00
Simon Michael
51618adc37
tests: use is in a few more places
2018-09-04 13:39:21 -07:00
Simon Michael
dcc44d10a5
lib: export HasCallStack from Hledger.Utils.Test
2018-09-04 09:59:48 -07:00
Simon Michael
bbecb28cae
tests: Utils -> easytest
2018-09-03 15:54:53 -07:00
Simon Michael
f713a413ff
clarify expectEq' arguments
2018-09-03 15:54:13 -07:00
Simon Michael
1fced57c81
lib: export expectEq' helper
2018-09-03 15:30:27 -07:00
Simon Michael
cd67f8ea68
tests: clear out old boilerplate
2018-08-31 18:12:17 -07:00
Simon Michael
776d575610
test helpers: more line breaks, clarify monadic behaviour
2018-08-20 10:38:02 +01:00
Simon Michael
d6fb96cb4c
tests: expectParse, expectParseError helpers; parse to end of input
2018-08-20 08:59:06 +01:00
Simon Michael
5d9d9a8edb
tests: drop obsolete helpers
2018-08-20 08:25:03 +01:00
Simon Michael
89357bb7b6
another parse test helper, use the IO variant always, port more tests
2018-08-19 19:02:59 +01:00
Simon Michael
7ab8bc2685
tests: import cleanups
2018-08-18 19:47:52 +01:00
Simon Michael
a8031de729
tests: fix build error with GHC < 8.4
2018-08-18 19:26:07 +01:00
Simon Michael
d778a92561
tests: export HUnit/EasyTest from Hledger.Utils.Test; more helpers
2018-08-18 15:19:59 +01:00
Simon Michael
b4c336c874
test/_test/it/_it helpers; refactor easytests
...
This makes skipping/unskipping tests easier, and improves readability
a bit.
Note it's also possible to just write the test name with no preceding
function, when the type is constrained (see Journal.hs).
2018-08-17 13:40:37 +01:00
Simon Michael
b1bbbf0d93
lib: expectParseEqIO helper
2018-08-17 12:42:05 +01:00
Simon Michael
dab75d98c8
lib: expectEq', expectParseEq: pretty-print compared values ( #812 )
2018-08-16 06:31:37 +01:00
Simon Michael
536eadb809
lib: improve expectParseEq ( #812 )
...
Show a pretty parse error, and avoid sequenced scopes
which are confusing (you can't run only the second).
2018-08-16 06:03:44 +01:00
Simon Michael
09d8e302db
lib: use unspaced scopes to simplify command lines ( #812 )
2018-08-16 05:58:17 +01:00
Simon Michael
50d666d5a0
test: refactor, document, organise easytests, port amountp tests ( #812 )
2018-08-15 19:58:07 +01:00
Simon Michael
ab7dc3294e
lib: more informative failure output for amount tests ( #812 )
2018-08-15 11:24:52 +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
1e0a7ec8f1
remove some unneeded CPP pragmas
2018-08-02 08:25:49 +01:00
Simon Michael
d5430e7ddf
clean up debug helpers (api change)
2018-07-16 15:28:58 +01:00
Simon Michael
9d2e80aa2c
lib: Debug: simplify pprint, export ppShow as pshow (api change)
2018-07-16 12:51:50 +01:00
Alex Chen
0382bb5cd4
lib: move custom parse errors to Text.Megaparsec.Custom
2018-06-11 13:58:56 -06:00
Alex Chen
846a38139d
lib: add license to the code copied from megaparsec
2018-06-11 13:58:56 -06:00
Alex Chen
2b22f857ac
lib: make the parse errors module backwards compatible
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
132f8706d7
lib: edit comments to satisfy doctest
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
Alex Chen
ca201e4618
lib: add a module for custom parse errors
...
... for displaying the source line on which parse errors occured
Over the following set of commits, I will to refactor the parsers to
obviate the `ExceptT String` layer of the `ErroringJournalParser` type
so that all parse errors go through Megaparsec's parse error machinery.
2018-06-11 13:57:22 -06: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
Pavlo Kerestey
63d4c51dc4
Use quoteIfNeeded in quoteIfSpaced. Fix escapeDoubleQuotes to escape
2018-04-12 12:04:20 -07:00
Pavlo Kerestey
980210070a
Explicit exports of Hledger.Utils.Text
2018-04-12 12:04:20 -07: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
Mykola Orliuk
48623b4ceb
lib: fix backtracking in periodexpr parser
...
- Simplify doctests for periodexpr.
- Besides consuming leading space consume ending space for periodexpr also.
- Drop implicit option (def, def) behaviour of periodexpr. I.e. disallow
hledger reg -p '' and auto-transaction with heading just '~'.
- Slightly re-factor periodexpr.
- Ensure that reportinginterval doesn't consume trailing space.
Useful if we'll start disallowing periods like "every1stjan2009-".
2017-11-27 06:38:47 -08:00
Simon Michael
f02d35ff39
lib, web: remove obsolete conditionals for old GHC
2017-08-25 17:15:26 -07:00
Simon Michael
d7d5f8a064
add support for megaparsec 6 ( fixes #594 )
...
Older megaparsec is still supported.
Also cleans up our custom parser types,
and some text (un)packing is done in different places
(possible performance impact).
2017-07-27 19:20:46 -07:00
Simon Michael
1d5f3a44d5
lib: debug: add a log0 that writes to debug.log in the current directory
...
Seems to work somewhat, might have some laziness issues.
2017-06-30 19:14:57 +01:00
Simon Michael
9a86c9ee52
lib: begin supporting colour
...
Add some basic helpers for working with ANSI colour codes,
and make strWidth and the various string layout functions aware of them.
2017-04-25 18:27:25 -07:00
Simon Michael
b402fc7e7d
lib: optserror -> usageError, consolidate with other error functions ( #529 )
2017-03-29 08:00:51 -07:00
Shubham Lagwankar
37b7ebfe22
use isSpace in lstrip ( #441 )
2016-12-20 09:29:12 -08:00
Johannes Gerer
74502f7e50
more general parser types enabling reuse outside of IO ( #439 )
2016-12-09 15:57:17 -08:00