Commit Graph

159 Commits

Author SHA1 Message Date
mrkkrp
cd14be5db1 A minor correction in the changelog
[skip ci]
2017-12-15 11:49:55 +07:00
mrkkrp
f4ded98663 There will be no ‘megaparsec-6.2.1’
[skip ci]
2017-12-14 12:06:53 +07:00
Vladislav Zavialov
58ab67759f Add the 'customFailure' combinator (#260) 2017-12-14 11:20:04 +07:00
Vladislav Zavialov
576c29aefd Add an IsString instance and tests for it (#259) 2017-12-13 22:14:22 +07:00
Mark Karpov
b99174d7f1 Make ‘sconcat’ more efficient on ‘ParsecT’ (#253)
* Make ‘sconcat’ more efficient on ‘ParsecT’

* Do the same thing for ‘mconcat’
2017-10-15 16:26:28 +07:00
mrkkrp
07160049a8 Make ‘float’ consume only floating point literals
Now it no longer accepts plain integers, which should be a better behavior.
2017-09-21 22:01:39 +07:00
Mark Karpov
e2abc9ee5d Use ‘eok’ continuation in ‘tokens’ when matching empty chunk (#246) 2017-08-14 17:46:59 +07:00
Mark Karpov
aac10c8bee Add hint erasing when try backtracks consuming (#243) 2017-08-08 16:36:47 +07:00
Mark Karpov
5b6f6f30cf Fix rendering of offending line with tabs (#241) 2017-08-08 14:59:24 +07:00
mrkkrp
9a065e27b3 Allow ‘parser-combinators-0.2.0’ 2017-07-31 12:22:03 +07:00
mrkkrp
2484ee6a05 Update the changelog
[skip ci]
2017-07-28 11:47:09 +07:00
mrkkrp
1cfec2512a A minor tweak in ‘CHANGELOG.md’
[skip ci]
2017-07-25 16:56:12 +07:00
Mark Karpov
7cbab7c2ea Implement rendering of parse error context (#236) 2017-07-25 14:36:40 +07:00
Mark Karpov
214d1f2c18 Speed-up numeric parsers (#232) 2017-07-10 00:12:23 +07:00
mrkkrp
9e7b9aa7d5 Rename ‘Text.Megaparsec.Lexer’ to ‘Text.Megaparsec.Char.Lexer’
Also numerous documentation improvements and some inlineable pragmas.
2017-07-04 17:12:35 +07:00
mrkkrp
dfdabe54e1 Add ‘takeP’, ‘takeRest’, and ‘atEnd’ 2017-07-03 23:10:22 +07:00
Mark Karpov
3b9812bf76 Char and byte modules (#230) 2017-07-03 18:34:00 +07:00
Mark Karpov
45f30ae7e1 Extending stream (#229) 2017-07-02 23:56:01 +07:00
mrkkrp
f87276dcfb Whims
[skip ci]
2017-06-29 20:25:37 +07:00
Roman Cheplyaka
0919338c4b Add a MonadFix ParsecT instance (#225) 2017-06-29 20:23:03 +07:00
Mark Karpov
bda5fc822a Move error construction helpers into the library (#224) 2017-06-29 18:33:47 +07:00
Mark Karpov
cec0987264 Separate trivial and fancy parse errors (#223) 2017-06-29 12:13:22 +07:00
Mark Karpov
5ed815fde4 Refactor pos and error modules (#222) 2017-06-28 14:08:26 +07:00
Mark Karpov
ca564d1113 Display control characters in strings nicely (#221) 2017-06-26 23:23:53 +07:00
mrkkrp
556a8333c3 Update the changelog (5.3.1)
[skip ci]
2017-06-26 17:14:35 +07:00
Mark Karpov
3ec48d12b9 Reorganize modules (#217) 2017-06-15 02:12:18 +07:00
Mark Karpov
9453b9eda4 Define ‘Semigroup’ and ‘Monoid’ for ‘ParsecT’ (#203) 2017-04-29 23:34:18 +03:00
Mark Karpov
15b645f08e Add ‘getNextTokenPosition’ (#202) 2017-04-29 16:40:04 +03:00
Vladislav Zavialov
ae19a87cbf Make () an error component (#193) 2017-03-05 17:06:47 +04:00
Mark Karpov
8ed11716e7 Add the ‘region’ combinator (#192)
Close #187.
2017-03-03 03:45:38 +04:00
mrkkrp
e08851a99b Mention dropping support for GHC 7.6 in the changelog 2017-02-07 17:52:52 +03:00
Mark Karpov
e809c56b45 Implement the ‘match’ combinator (#184) 2017-02-06 22:31:10 +04:00
Mark Karpov
cb978200d5 Fix subtle ‘indentBlock’ bugs, add new tests (#182) 2017-02-01 20:03:02 +04:00
Mark Karpov
b307ba2342 Implement counting of processed tokens (#180) 2017-01-31 15:17:54 +04:00
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
mrkkrp
706ff2b964 update changelog 2015-10-01 15:55:38 +06:00
Mario Lang
50d631bdc2 Fix a typo. 2015-09-29 22:41:53 +02:00
mrkkrp
9774ed9de9 rename ‘parse'’ → ‘parseMaybe’ 2015-09-24 17:13:06 +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
17bdba05f7 revised ‘CHANGELOG.md’ 2015-09-21 18:53:23 +06:00
mrkkrp
7516ec4f23 added more case-insensitive character parsers
The following parsers are introduced:

* ‘char'’
* ‘oneOf'’
* ‘noneOf'’
2015-09-06 15:17:37 +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
2390f9f753 swap ‘count’ and ‘count'’ 2015-08-25 15:55:57 +06:00
mrkkrp
23b083cea6 deprecate some parsers, close #24
These parsers are considered deprecated:

* ‘chainl’
* ‘chainl1’
* ‘chainr’
* ‘chainr1’
* ‘sepEndBy’
* ‘sepEndBy1’

Apart from this, the commit includes various cosmetic changes in
module ‘Text.Megaparsec.Combinator’.
2015-08-25 02:04:10 +06:00
mrkkrp
b81962e44a added combinator ‘someTill’ 2015-08-23 23:12:45 +06:00
mrkkrp
d6947a901f various cosmetic changes (including renaming)
The following functions and data types have been renamed:

* ‘permute’ → ‘makePermParser’
* ‘buildExpressionParser’ → ‘makeExprParser’
* ‘GenLanguageDef’ → ‘LanguageDef’
* ‘GenTokenParser’ → ‘Lexer’
* ‘makeTokenParser’ → ‘makeLexer’
2015-08-23 21:07:03 +06:00
mrkkrp
6e5735167f flip argument order for ‘label’, close #21 2015-08-22 14:57:16 +06:00
mrkkrp
f9cfe390af various minor changes, renamed functions
Among other changes two functions have been renamed:

* ‘parseMaybe’ → ‘parse'’ (also added to change log)
* ‘putState’ → ‘setState’ (for consistency)
2015-08-20 16:37:52 +06:00
mrkkrp
110859b9c2 added new primitive combinator ‘hidden’
Added new primitive combinator ‘hidden p’ which hides “expected” tokens
in error message when parser ‘p’ fails.
2015-08-20 01:38:00 +06:00
mrkkrp
455bfa3076 major improvements of ‘Text.Megaparsec.Prim’
* Removed ‘optionMaybe’ parser, because ‘optional’ from
  ‘Control.Applicative’ does the same thing.

* Renamed ‘tokenPrim’ → ‘token’, removed old ‘token’, because
  ‘tokenPrim’ is more general and ‘token’ is little used.

* Fixed bug with ‘notFollowedBy’ always succeeded with parsers that
  don't consume input, see #6.

* Hint system introduced that greatly improved quality of error messages
  and made code of ‘Text.Megaparsec.Prim’ a lot clearer.

The improvements affected other modules too:

* Some parsers from ‘Text.Megaparsec.Combinators’ now live in
  ‘Text.Megaparsec.Prim’.

* Hint system improved error messages, so I needed to rewrite test for
  ‘Text.Megaparsec.Char.eol’, since it's error messages are very
  intelligent now and cannot be emulated by ‘newline’ and ‘crlf’ parsers
  used separately.

* Test for Bug9 from old-tests is passed successfully again.
2015-08-17 21:58:59 +06:00
mrkkrp
65fbedee1c added more powerful ‘count’ parser, close #17
This parser can be told to parse from ‘m’ to ‘n’ occurrences of some
thing. Old parser ‘count’ is now named ‘count’' and defined in terms of
that more powerful one.

This commit also reorders functions in module
‘Text.Megaparsec.Combinator’ and everywhere where the functions are
listed. The same order is used everywhere.
2015-08-13 01:02:33 +06:00