Commit Graph

47 Commits

Author SHA1 Message Date
mrkkrp
8e095bab8c A correction to ‘getPosition’ and ‘setPosition’
Make ‘getPosition’ and ‘setPosition’ work with current file, not with
the whole stack.
2016-04-26 23:01:09 +07:00
mrkkrp
f22cd69ff7 Cosmetic polishing 2016-04-26 00:37:06 +07:00
mrkkrp
13578590da Adjustments for compatibility 2016-04-25 19:51:13 +07:00
mrkkrp
98b08b752a Update tests for ‘Text.Megaparsec.Prim’ 2016-04-24 21:56:45 +07:00
mrkkrp
a3254f5371 Move language extensions to files
This turns out that it's easier for readers to lookup the list of
extensions in current file than go to Cabal file.
2016-04-10 19:26:54 +07:00
mrkkrp
aa805864af Add simple tests for ‘Text’ and ‘ByteString’
These are primitive tests, but nevertheless they check ‘uncons’ and
‘updatePos’ — everything we need.
2016-03-29 09:19:50 +06:00
mrkkrp
00ae88a8e7 Add a test to check that ‘tokens’ never consumes 2016-03-28 22:51:07 +06:00
mrkkrp
ac99fc0fac More flexible position-advancing function
This should improve experience of users who use Megaparsec with Alex and
Happy. The commit also introduces some minor changes in
‘Text.Megaparsec.Pos’ module (improving argument order).
2016-03-24 18:12:25 +06:00
recursion-ninja
dccfc82152 Replace ‘String’ with ‘Foldable f => f Char’
The commit also deals with GHC 8 warnings about redundant constraints.
2016-03-11 15:52:55 +06:00
mrkkrp
75512ddde5 Use ‘mzero’ to fail (tests) 2016-02-19 16:04:49 +06:00
mrkkrp
bfe173ff07 Improve coverage of primitive combinators 2016-02-19 15:16:26 +06:00
mrkkrp
e9df1ba30a Correct ‘withRecovery’ so that it passes the tests 2016-02-18 13:09:19 +06:00
mrkkrp
4ff95dd2a8 Add tests for ‘withRecovery’ primitive 2016-02-18 02:07:08 +06:00
mrkkrp
1285699b74 Improve coverage of older primitives 2016-02-18 00:12:27 +06:00
mrkkrp
3baa263eab Auto-backtracking for ‘tokens’ and friends 2016-02-17 23:32:48 +06:00
mrkkrp
e1be100bd6 Cosmetic whims
Can't help it…
2016-02-08 13:36:39 +06:00
mrkkrp
2bfc724d8d Add tests for returned state on failure 2016-02-08 00:41:09 +06:00
mrkkrp
e5ad380832 Remove redundant mode annotations 2016-01-25 12:56:41 +06:00
mrkkrp
e5508941c8 Add year 2016 to copyright notices 2016-01-09 18:56:33 +06:00
mrkkrp
ac62addce8 cosmetic improvements 2015-11-07 16:24:45 +06:00
mrkkrp
f7f3b02e45 uppercase disclaimer in license
Otherwise it may look like “fine print” for some. Crazy…
2015-10-30 19:43:34 +06:00
mrkkrp
c7ed5fe909 after some consulting, it should be “FreeBSD”
What Parsec used is called “FreeBSD” or “BSD 2 clause”. Addition of the
third clause may require contacting all the authors. To hell with it,
let it be “FreeBSD” (which is anyway better than “BSD-like”), I'm a
hacker, not a lawyer (tm).
2015-10-30 17:26:45 +06:00
mrkkrp
503a1db4be clarify used license and add missing clause
This commit clarifies license of the software replacing “BSD3” with more
conventional “BSD 3 clause”.

Another change is addition of the third clause originally missing in
license of Parsec (which is licensed under BSD 2 clause license). The
addition of the third clause in form:

* Neither the names of the copyright holders nor the names of
  contributors may be used to endorse or promote products derived from
  this software without specific prior written permission.

does not violate original BSD 2 clause license effectively making it BSD
3 clause license (which I find preferable).
2015-10-30 13:52:30 +06:00
mrkkrp
aa11968514 tests: various improvements and corrections
Some cosmetic whims as well as new tests.
2015-10-28 17:51:35 +06:00
mrkkrp
354760202e introduced ‘failure’ method of ‘MonadParsec’
Close #43.

The method allows to fail with arbitrary collection of
messages. ‘unexpected’ is not defined in terms of ‘failure’. One
consequence of this design decision is that ‘failure’ is now method of
‘MonadParsec’, while ‘unexpected’ is not.
2015-10-26 13:52:21 +06:00
mrkkrp
a5819c6d00 allow to supply and extract parser state
Close #47, close #57.

This commit introduces ‘runParser'’ and ‘runParserT'’ functions that
take and return parser state. This makes it possible to partially parse
input, resume parsing, specify non-standard initial textual position,
etc.

Internal changes involve some refactoring to make ‘Reply’ more
readable and facilitate extraction of complete parser state on failure
as well as success.

The commit adds basic tests for the new functionality as well.
2015-10-26 02:13:39 +06:00
mrkkrp
a839a21ce4 more tests for ‘Text.Megaparsec.Prim’ module 2015-10-25 22:20:30 +06:00
mrkkrp
aad1702589 use ‘if’ instead of ‘bool’
This should make maintenance a bit easier. After all ‘if’ looks even
better than ‘bool’ in many cases.
2015-10-22 14:34:25 +06:00
Benjamin Kaestner
3078c04f8f Add #if for bool in tests 2015-10-03 17:00:29 +02:00
mrkkrp
1617f9b1b8 even more cosmetic corrections
Make details consistent and fix some minor cosmetic issues.
2015-09-23 19:46:24 +06:00
mrkkrp
d0409a897e implemented flexible tab width
Closes #38.

Now tab width can be manipulated with via the following functions:

* ‘getTabWidth’
* ‘setTabWidth’

Other auxiliary changes were performed, such as updating of
‘updatePosChar’.

This also corrects a bit obsolete descriptions of some functions.
2015-09-23 16:47:17 +06:00
mrkkrp
dcc53ad0b7 improved error messages for labelled ‘many’
Closes #35.

Since ‘many’ (and thus ‘some’) are the only combinator that can succeed
consuming input and produce hints at the same time we can conclude that
‘cok'’ continuation in ‘pLabel’ combinator is only called when ‘many’ is
labelled. By correcting label in this case prepending the phrase “rest
of ” to actual label we can greatly improve result error message.
2015-09-22 15:09:40 +06:00
mrkkrp
1e66bf7d3d at attempt to reduce repetition
Not sure if it actually makes it better. Sometimes I miss certain
features of languages like Common Lisp.
2015-09-21 23:12:17 +06:00
mrkkrp
f8a02e25ea minor (mainly cosmetic) corrections 2015-09-21 21:40:27 +06:00
Artyom
3f23081f60 Add some tests for monad transformers (see #27) 2015-09-21 17:05:41 +03:00
mrkkrp
5242b8d5fd minor changes in tests to make them compile
Recent changes (mainly eliminating of built-in backtracking user state)
require some changes in the tests.
2015-09-18 15:41:18 +06:00
mrkkrp
2fc5455591 make ‘Text.Megaparsec.Prim.token’ more flexible
Closes #29.

Now testing function can return ‘Either [Message] a’ so it can construct
full list of error messages. This may be useful in some cases when
tokens are more complex than simple characters.
2015-09-14 14:15:31 +06:00
mrkkrp
6ac08b0956 added new parser ‘string'’
This is like ‘string’, but is case-insensitive.
2015-09-04 18:12:59 +06:00
mrkkrp
8b05353a32 new test to check that ‘hidden’ always works 2015-08-29 16:03:41 +06:00
mrkkrp
49e80775ef added test to catch bugs similar to #25 2015-08-26 16:15:30 +06:00
mrkkrp
a891ff6522 improved tests for ‘(<|>)’
Fixed a detail in existing test ‘prop_alternative_1’ and added new test
‘prop_alternative_2’ to directly catch bugs like #23. Re-indexed some
tests.
2015-08-24 16:35:58 +06:00
mrkkrp
7dd2ad94ff minor corrections 2015-08-22 15:02:34 +06:00
mrkkrp
aa4189f4bc move test helpers to ‘Util’ module
So we can reuse them to test other modules.
2015-08-22 02:46:13 +06:00
mrkkrp
85be098854 more tests for ‘Text.Megaparsec.Prim’
Added test for the following primitive combinators:

* ‘lookAhead’
* ‘token’
* ‘tokens’
2015-08-22 01:13:20 +06:00
mrkkrp
24afab66c8 more tests for ‘Text.Megaparsec.Prim’
Combinator-specific tests added:

* ‘label’
* ‘hidden’
* ‘try’
* ‘lookAhead’
* ‘notFollowedBy’
2015-08-21 20:21:55 +06:00
mrkkrp
816da3d682 tests for ‘Text.Megaparsec.Prim’ written
More tests need to be written, especially for primitive
combinators. This commit also improves testing utilities and refactors
some stuff.
2015-08-20 17:12:44 +06:00
mrkkrp
866bcdec58 some tests written 2015-08-03 13:19:23 +06:00