Commit Graph

57 Commits

Author SHA1 Message Date
Mark Karpov
3ec48d12b9 Reorganize modules (#217) 2017-06-15 02:12:18 +07:00
Mark Karpov
d35cdd2e33 Drop per-stream type modules (#215) 2017-06-13 23:14:31 +07:00
mrkkrp
5a8d8f181a Update location of the tutorials 2017-06-08 17:33:14 +07:00
mrkkrp
ce7228346a Improve the documentation 2017-05-25 19:52:34 +07:00
mrkkrp
e651e689c3 Update my email address
[skip ci]
2017-05-24 19:30:10 +07:00
Mark Karpov
15b645f08e Add ‘getNextTokenPosition’ (#202) 2017-04-29 16:40:04 +03:00
mrkkrp
95f99774dc Various minor corrections to the docs 2017-04-02 21:52:04 +03:00
Mark Karpov
8ed11716e7 Add the ‘region’ combinator (#192)
Close #187.
2017-03-03 03:45:38 +04:00
Mark Karpov
e809c56b45 Implement the ‘match’ combinator (#184) 2017-02-06 22:31:10 +04:00
Mark Karpov
b307ba2342 Implement counting of processed tokens (#180) 2017-01-31 15:17:54 +04:00
mrkkrp
9459c8038b Include 2017 into copyright years range 2017-01-01 14:38:59 +03:00
mrkkrp
5aff6e3986 Mention ambiguous type variables and type signatures
Close #157.
2016-12-26 13:45:31 +03:00
mrkkrp
d1649b63ad Export ‘observing’ from ‘Text.Megaparsec’ 2016-10-04 10:07:06 +03:00
mrkkrp
01f828e5dd Add debugging primitive ‘dbg’ 2016-09-30 13:34:58 +03:00
mrkkrp
be4478b840 Clarify behavior of ‘many’ and ‘some’
See #141.
2016-09-18 14:34:27 +03:00
Albert Krewinkel
c234586435 Reflect renaming of alphaNum in docs (#136)
The `alphaNum` parser was renamed to `alphaNumChar`, yet the docs
weren't full updated to reflect this change.
2016-08-27 16:44:55 +04:00
mrkkrp
2062354709 Various corrections in ‘README.md’ and docs 2016-05-14 16:59:18 +07:00
mrkkrp
1094408b96 Add ‘pushPosition’ and ‘popPosition’
Close #83.
2016-04-27 00:04:56 +07:00
mrkkrp
f22cd69ff7 Cosmetic polishing 2016-04-26 00:37:06 +07:00
mrkkrp
17a6bb2baa Remove ‘MonadThrow’ instance, add ‘Dec’
‘Dec’ stands for “default error component”. We need this because
‘String’ looses information and thus we cannot write good enough tests
with it.
2016-04-22 19:48:34 +07:00
mrkkrp
84038a4fab Export ‘parseErrorPretty’ from ‘Text.Megaparsec’ 2016-04-18 20:48:31 +07:00
mrkkrp
acbae63a21 First attempt to outline Megaparsec 5.0.0
This is rather a sketch, we need to work on documentation, tests, and
perhaps on performance, but it should show the direction Megaparsec
5.0.0 is taking.
2016-04-17 20:08:13 +07: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
52b41d4992 Add the ‘eitherP’ combinator
Close #85.
2016-02-18 14:46:55 +06:00
mrkkrp
3edbe9f54a Implement the recovery feature
Close #80.
2016-02-09 13:59:21 +06:00
mrkkrp
e5508941c8 Add year 2016 to copyright notices 2016-01-09 18:56:33 +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
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
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
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
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
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
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
fbc08037ba eliminate little used type synonyms
The type synonyms seem to be little used: ‘SourceName’, ‘Line’, and
‘Column’. They rather contaminate name space.
2015-09-23 11:10:22 +06:00
mrkkrp
de63d7a0ad fixed a couple of typos in comments 2015-09-22 23:30:54 +06:00
mrkkrp
d8515202fe eliminate obsolete ‘GenParser’ type synonym 2015-09-19 21:13:53 +06:00
mrkkrp
fce6c3187c eliminated user state and written ‘MonadParsec’
Close # 27.

Backtracking user state can be achieved via combination of ‘StateT’
monad transformer and ‘ParsecT’:

  StateT StateType (ParsecT s m a)

This user state can be more flexible. This fact renders current built-in
user state redundant.

To help work with this new approach (combining monad transformers more
freely) we introduce ‘MonadParsec’ MTL-style type class. All tools that
come with Megaparsec library were modified to work smoothly with any
instance of ‘MonadParsec’, not only ‘ParsecT’.
2015-09-18 15:33:44 +06:00
mrkkrp
4c1858f900 fix a typo: it's called ‘token’ now 2015-09-14 22:44:34 +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
2ca6316f33 renamed ‘Text.Megaparsec.Token’ module
Now it's called ‘Text.Megaparsec.Lexer’. This commit contains other
cosmetic changes as well.
2015-08-30 16:00:07 +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
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