Commit Graph

104 Commits

Author SHA1 Message Date
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
f576945a4a Update tests for ‘Text.Megaparsec.Lexer’ 2016-04-24 21:56:45 +07:00
mrkkrp
e11066f07a Update tests for ‘Text.Megaparsec.Expr’ 2016-04-24 21:56:45 +07:00
mrkkrp
98b08b752a Update tests for ‘Text.Megaparsec.Prim’ 2016-04-24 21:56:45 +07:00
mrkkrp
643842ac1e Update tests for ‘Text.Megaparsec.Perm’ 2016-04-24 21:56:45 +07:00
mrkkrp
9089ed3325 Update tests for ‘Text.Megaparsec.Combinator’ 2016-04-24 21:56:45 +07:00
mrkkrp
6f69306515 Update tests for ‘Text.Megaparsec.Char’ 2016-04-24 21:56:45 +07:00
mrkkrp
35dc3a4469 Write tests for the new ‘Text.Megaparsec.Error’ 2016-04-24 21:56:40 +07:00
mrkkrp
14b1aeea8a Write tests for the new ‘Text.Megaparsec.Pos’ 2016-04-24 20:21:36 +07:00
mrkkrp
a1df59221b Update ‘Util’ module in test suite 2016-04-24 20:21:07 +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
747993e0bb Add ‘skipBlockCommentNested’ function
Close #96.
2016-03-30 14:50:35 +06:00
mrkkrp
18d192ba70 Use ‘Scientific’ as target type for floats
Close #95.

Here we introduce ‘scientific’ parser that can parse arbitrary big
numbers without error or memory overflow. ‘float’ still returns
‘Double’, but it's defined in terms of ‘scientific’ now. Since
‘Scientific’ type can reliably represent integer values as well as
floating point values, ‘number’ now returns ‘Scientific’ instead of
‘Either Integer Double’ (‘Integer’ or ‘Double’ can be extracted from
‘Scientific’ value anyway). This in turn makes ‘signed’ parser more
natural and general, because we do not need ad-hoc ‘Signed’ type class
anymore.
2016-03-29 16:42:51 +06: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
eef1fa7ea9 Further improve coverage 2016-02-19 16:15:32 +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
4c34c488cc Remove ‘Enum’ instance of ‘Message’
This was Parsec's legacy that we should eliminate now. ‘Message’ does
not constitute enumeration, ‘toEnum’ was never properly defined for
it. The idea to use ‘fromEnum’ to determine type of ‘Message’ is also
ugly, for this purpose new functions ‘isUnexpected’, ‘isExpected’, and
‘isMessage’ are defined in ‘Text.Megaparsec.Error’.
2016-02-18 16:26:29 +06:00
mrkkrp
52b41d4992 Add the ‘eitherP’ combinator
Close #85.
2016-02-18 14:46:55 +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
611f2a4e7e Minor improvements for new combinators
In particular, if input has no newline at the end, we need to treat it
specially, because otherwise we will get confusing “incorrect
indentation” message.
2016-01-10 23:23:26 +06:00
mrkkrp
e5508941c8 Add year 2016 to copyright notices 2016-01-09 18:56:33 +06:00
mrkkrp
b8e3029041 Tests for new combinators and some refactoring 2016-01-09 17:55:54 +06:00
mrkkrp
ac62addce8 cosmetic improvements 2015-11-07 16:24:45 +06:00
mrkkrp
f129683dca new tests for ‘Text.Megaparsec.Expr’
These check error messages in some cases.
2015-11-03 17:42:01 +06:00
mrkkrp
60910b520f don't parse row of prefix/postfix operators
After some thinking I decided that this may be not desirable in some
cases, so we should not enable it by default. I've edited documentation
of ‘makeExprParser’ to explain why this doesn't work by default and how
to make it work.
2015-11-03 16:09:35 +06:00
mrkkrp
d595562e88 allow to parse rows of prefix/postfix operators
Close #64.

‘makeExprParser’ now generates parser that can handle several
occurrences of the same prefix or postfix operator in a row. This allows
to parse something like C pointers (for example ‘**i’) without resorting
to hacks.

The feature is experimental, I'm not entirely sure it's not
buggy. Upcoming additional tests for ‘Text.Megaparsec.Expr’ will show
whether it behaves correctly in all cases and doesn't have adverse
effects. For now, I've edited existing test to generate data with
repeating prefix negations and postfix factorials. Current code-base
passes the test.
2015-11-03 01:55:18 +06:00
mrkkrp
dd27063c03 added test to check how ‘newPos’ throws exceptions 2015-11-01 22:28:50 +06:00
mrkkrp
8c7de12ab7 rather fail loudly instead of silent correction 2015-10-30 21:40:22 +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
5a7340f5bb a minor correction in test for ‘between’ 2015-10-24 15:29:48 +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
mrkkrp
6cf7e918ce fix build for older versions of ‘base’ 2015-10-21 19:57:23 +06:00
mrkkrp
48528af655 various changes in ‘Text.Megaparsec.Error’
Close #62.

Apart from some refactoring, the following important changes were
introduced:

* ‘ParseError’ is now a monoid.

* Added functions ‘addErrorMessages’ and ‘newErrorMessages’.
2015-10-21 19:36:43 +06:00