Commit Graph

75 Commits

Author SHA1 Message Date
Mark Karpov
63dcf13c09 Performance tweaks (#179)
* Use default implementation of ‘many’
* Improve ‘count’ and ‘count'’
* Update the ‘CHANGELOG.md’ file
2017-01-29 19:39:21 +04:00
mrkkrp
5300e80c1c Mention benchmark improvements in the ‘CHANGELOG.md’ file 2017-01-29 02:32:32 +03:00
mrkkrp
970a9ecc96 Update ‘CHANGELOG.md’ to mention #161 2016-12-28 01:19:20 +03:00
Mark Karpov
08d1ae8e61 Allow ‘many’ run parsers that do not consume input (#160) 2016-12-26 16:49:48 +04:00
Mark Karpov
dd2386aafc Add ‘MonadParsec’ instance for ‘RWST’ (#152) 2016-11-21 19:18:27 +04:00
mrkkrp
fdc4f8071f Version bump (5.1.2), update ‘CHANGELOG.md’ 2016-10-06 22:46:30 +03:00
mrkkrp
d1649b63ad Export ‘observing’ from ‘Text.Megaparsec’ 2016-10-04 10:07:06 +03:00
mrkkrp
97257f3c7f Add the ‘observing’ primitive
Close #145.
2016-10-02 19:38:50 +03:00
mrkkrp
de4338ed2c Mention the new ‘dbg’ function in ‘CHANGELOG.md’ 2016-10-02 19:36:34 +03:00
mrkkrp
6772b88e93 Make ‘try’ truly backtrack parser state
Close #142.

This seemingly has no effect on performance.
2016-09-27 09:41:23 +03:00
mrkkrp
979e7d504a A minor update to ‘CHANGELOG.md’ 2016-09-25 21:38:50 +03:00
mrkkrp
e8174d4700 Add some ‘Arbitrary’ instances 2016-09-04 16:44:24 +03:00
mrkkrp
5478537cf7 Eliminate the ‘old-tests’ test suite 2016-09-04 16:33:40 +03:00
mrkkrp
badec4a9df Expose the ‘parseErrorTextPretty’ function
Close #137.
2016-09-04 14:48:40 +03:00
mrkkrp
82994e45d4 Allow line comments end with end of input
Close #119.
2016-08-13 20:00:49 +03:00
mrkkrp
33098be1ea Define ‘displayException’ for ‘ParseError’ 2016-07-29 21:27:52 +03:00
mrkkrp
033cbeb3fa Update the ‘CHANGELOG.md’ file 2016-07-11 21:36:14 +03:00
mrkkrp
11d10c7d85 Mention performance improvements in ‘CHANGELOG.md’ 2016-07-11 10:52:44 +03:00
mrkkrp
7d47a7b8f9 Derive more ‘Data’ and ‘Typeable’ instances
Close #112. Derive ‘Data’ instance for ‘ParseError’, ‘Data’ and
‘Typeable’ instances for ‘SourcePos’.
2016-06-23 22:52:29 +03:00
mrkkrp
46132a8048 Update the ‘CHANGELOG.md’ file (line folds) 2016-05-11 00:25:24 +07:00
mrkkrp
9240896e6b Update the ‘CHANGELOG.md’ file 2016-04-28 00:07:15 +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
0b4abd81ae Update the ‘CHANGELOG.md’ file 2016-03-28 21:23:23 +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
b0124d1ea2 Remove ‘parseFromFile’ and ‘StorableStream’
Removed ‘parseFromFile’ and ‘StorableStream’ type-class that was
necessary for it. The reason for removal is that reading from file and
then parsing its contents is trivial for every instance of ‘Stream’ and
this function provides no way to use newer methods for running a parser,
such as ‘runParser'’. So, simply put, it adds little value and was
included in 4.x versions for compatibility purposes.
2016-02-22 19:52:57 +06:00
mrkkrp
30fcbb64ef Fix the build for older GHCs 2016-02-19 17:01:08 +06:00
mrkkrp
5a68665a90 Change collection of constraints for ‘MonadParsec’
Collection of constraints changed from ‘Alternative m, Monad m, Stream s
t’ to ‘MonadPlus m, Stream s t’. This is done to make it easier to write
more abstract code with older GHC where such primitives as ‘guard’ are
defined for instances of ‘MonadPlus’, not ‘Alternative’.
2016-02-19 16:02:52 +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
4f5d73f230 Remove statement about performance
More recent benchmarks made after all changes show no considerable
difference. It's faster than Parsec for sure, so…
2016-02-18 13:22:38 +06:00
mrkkrp
3baa263eab Auto-backtracking for ‘tokens’ and friends 2016-02-17 23:32:48 +06:00
mrkkrp
4c5aae7098 Update ‘CHANGELOG.md’ and ‘README.md’ 2016-02-12 22:12:30 +06:00
mrkkrp
4ba5bd7df1 Update ‘CHANGELOG.md’ file 2016-02-07 19:58:41 +06:00
mrkkrp
618f5dbcb6 Updated ‘CHANGELOG.md’ to reflect changes in 4.3.0 2016-01-07 19:30:37 +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
92d28bb7e8 allow ‘number’ be used with ‘signed’
Close #67.
2015-10-28 13:46:32 +06:00
mrkkrp
6aedfdbc79 removed deprecated combinators
Expression parser should be improved a bit now before 4.2.0 is released,
see #64.
2015-10-26 18:54:02 +06:00
mrkkrp
3807a5d56b minor corrections 2015-10-26 14:29:26 +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
05177a6c3c make ‘ParseError’ instance of ‘Exception’
Close #66.
2015-10-24 11:24:13 +06:00
mrkkrp
7043a6fbc0 move ‘parseFromFile’ to ‘Text.Megaparsec.Prim’
Close #65.

Previously we had 5 nearly identical definitions of the function,
varying only in type-specific ‘readFile’ function. Now the problem is
solved by introduction of ‘StorableStream’ type class. All supported
stream types are instances of the class out of box and thus we have
polymorphic version of ‘parseFromFile’.
2015-10-22 15:32:33 +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
mrkkrp
8356a05919 made interface of ‘Text.Megaparsec.Pos’ smarter
Now it's impossible to create ‘SourcePos’ with non-positive line number
or column number. Unfortunately we cannot use ‘Numeric.Natural’ because
we need to support older versions of ‘base’.
2015-10-21 17:33:29 +06:00
mrkkrp
f3be336ebe fix implementation of ‘sepEndBy’ and ‘sepEndBy1’
Fixes #63.

Deprecation notes were removed and new tests written.
2015-10-20 16:37:24 +06:00
mrkkrp
b062a397ee made format of error messages conventional
Closes #56.

In particular, file name and textual position are represented like this:

  filename.hs:5:6:
    error message

This format should be more conventional, so various tools will be able
to parse it and provide some support (for example, Emacs can work with
this format).
2015-10-14 17:48:44 +06:00
mrkkrp
a70e07a408 do not export ‘Consumed’ and ‘Reply’
‘Text.Megaparsec’ and ‘Text.Megaparsec.Prim’ do not export these data
types and their constructors anymore. These data types are rather
low-level implementation detail that should not be visible to
end-user. They are also subject to certain changes in future.
2015-10-06 22:36:59 +06:00
mrkkrp
17ba4fb4ee update changelog (GHC 7.6 is supported now) 2015-10-04 21:09:01 +06:00