Commit Graph

314 Commits

Author SHA1 Message Date
mrkkrp
718b0f358a Don't use hints with custom error messages
Close #75.

Now accumulated hints are not used with ‘ParseError’ records that have
only custom messages in them (created with ‘Message’ constructor, as
opposed to ‘Unexpected’ or ‘Expected’). This strips “expected” line from
custom error messages where it's unlikely to be relevant anyway.
2016-01-02 20:19:40 +06:00
mrkkrp
028b775885 Use ‘const’ 2016-01-02 20:18:55 +06:00
mrkkrp
c73a2239b9 ‘readFromFile’ → ‘parseFromFile’ 2016-01-02 20:18:18 +06:00
mrkkrp
e94b39fc0d Initial design of new indentation-sensitive helpers 2016-01-01 23:00:38 +06:00
mrkkrp
f317936613 Cosmetic whims in ‘Text.Megaparsec.Lexer’ 2016-01-01 23:00:38 +06:00
mrkkrp
8ea4ebe606 improve rendering of ‘Message’s
Arbitrary messages created with ‘Message’ constructor should not be
rendered as “or”-separated list. This commit makes every such message be
displayed on new line.
2015-12-11 12:18:11 +06:00
Herbert Valerio Riedel
bc54b46d07 Canonicalise Applicative/Monad instances
This avoids subtle performance issues and makes the code more
future proof.
2015-11-22 19:03:46 +01:00
mrkkrp
c202151150 minor documentation improvements 2015-11-10 14:28:28 +06:00
mrkkrp
3bc781d270 minor improvements in ‘Text.Megaparsec.Combinator’ 2015-11-09 13:19:34 +06:00
mrkkrp
3d66a02eaf make source name in ‘SourcePos’ strict 2015-11-07 18:36:44 +06:00
mrkkrp
ac62addce8 cosmetic improvements 2015-11-07 16:24:45 +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
73042c28f3 fix build once again for older GHCs 2015-11-03 01:59:30 +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
9f6fc4844c correct error message signalled by ‘many’
Close #69.

Although previously used syntax is correct Haskell syntax for multi-line
string literals, CPP extension that we need to use for compatibility
reasons obviously makes ‘\’ symbol escape following newline character
that leads to ‘\t’ being interpreted as tab character.

The proposed solution just concatenates result error message from list
of strings — the most lightweight and reliable solution in our case.
2015-10-31 18:03:33 +06:00
mrkkrp
8c7de12ab7 rather fail loudly instead of silent correction 2015-10-30 21:40:22 +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
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
4e6dffd785 fix build for older GHCs 2015-10-26 14:06:15 +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
c548226a1c map monad with ‘liftM’ for older GHCs 2015-10-26 02:20:25 +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
ec6098c7ac various whims 2015-10-25 22:20:05 +06:00
mrkkrp
05177a6c3c make ‘ParseError’ instance of ‘Exception’
Close #66.
2015-10-24 11:24:13 +06:00
mrkkrp
258dd2a0d4 add documentation for ‘StorableStream’ type class 2015-10-22 16:56:51 +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
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
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
bedad01d98 cosmetic improvements 2015-10-20 22:10:52 +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
3e5dc6d5a4 improve wording in doc-string for ‘charLiteral’ 2015-10-16 16:31:22 +06:00
mrkkrp
81b0081028 add missing ‘L.’ in doc-string of ‘signed’ 2015-10-16 15:57:46 +06:00
mrkkrp
9e1cac87b8 removed redundant labels in ‘Text.Megaparsec.Char’
This is handled by ‘showToken’ in ‘char’ anyway, so there is no need to
label these things manually.
2015-10-16 15:01:35 +06:00
mrkkrp
79ceb7962f eliminate indentation in error messages
Indented text returned by ‘showMessages’ may be undesirable, but we
cannot add indentation outside of the function (edge case: strings
including newline are displayed in the messages).
2015-10-15 15:12:28 +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
a9421728d6 typos and corrections 2015-10-10 20:45:27 +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
Benjamin Kaestner
65aa745a58 Add #if for bool :: a -> a -> Bool -> a. 2015-10-03 16:52:20 +02:00
Benjamin Kaestner
d97398a016 Add compatibility to base-4.7.0.x
This patch introduces compatibility to base-4.7.0.x. It was tested
on Win 8.1 x86_64, using GHC 7.8.4. It mainly consists of a bunch
of #if !MIN_VERSION(4,8,0) ... #endif additions and a lower bound
on base in the cabal file as well as a general introduction of the
CPP extension via default-extensions.

It also removes a potential error source in tests/Util.hs, since
the backslash in /=\ can lead to strange quirks on certain systems
(backslash and newline only separated by whitespace).

Other, squashed commits:

- Remove 'recent version of base' from Readme

- Change necessary version of GHC
2015-09-30 20:18:25 +02:00
Artyom
5efa258644 reponsibilitity → responsibility 2015-09-30 16:09:08 +03:00
mrkkrp
321b781e29 refresh values of “Portability” field
‘Text.Megaparsec.Prim’ cannot be considered portable since it uses
multi-parameter type classes and functional dependencies.

Other modules that depend on these non-portable features from
‘Text.Megaparsec.Prim’ should be considered non-portable too.
2015-09-27 14:46:12 +06:00
mrkkrp
319addf767 use ‘ExistentialQuantification’ locally
Only in module ‘Text.Megaparsec.Perm’ where it is necessary.
2015-09-27 14:27:01 +06:00
mrkkrp
9774ed9de9 rename ‘parse'’ → ‘parseMaybe’ 2015-09-24 17:13:06 +06:00
mrkkrp
1896856e1c move fixity declaration for (<?>) where it belongs 2015-09-23 21:04:51 +06: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
3975ae52d0 cosmetic improvements, courtesy of @neongreen
Closes #37.

Most part of these changes is proposed by @neongreen. To apply precisely
what I deem acceptable, correct some of them in other way, and add some
other things, I've manually re-edited this.
2015-09-23 17:23: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
38abf590db make ‘string'’ return actually parsed input
Closes #36.

We should try to preserve original information where possible. User then
can convert case of parsed string if necessary. Previous implementation
discarded actually parsed string and returned argument of the
function — this can be considered as data loss of a sort.
2015-09-23 11:43:58 +06:00
mrkkrp
9adf4c7d46 use constant instead of literal string 2015-09-23 11:13:22 +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
Artyom
935f3eeecc Fix the explanation for 'try' 2015-09-23 10:57:47 +06:00
mrkkrp
de63d7a0ad fixed a couple of typos in comments 2015-09-22 23:30:54 +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
dbfa03221c correct ‘lookAhead’ and ‘notFollowedBy’
…for some instances of ‘MonadParsec’.
2015-09-21 15:31:19 +06:00
mrkkrp
ce1655c980 some transformers are instances of ‘MonadParsec’
In particular:

* ‘Lazy.StateT’
* ‘Strict.StateT’
* ‘ReaderT’
* ‘Lazy.WriterT’
* ‘Strict.WriterT’
* ‘IndentityT’
2015-09-20 15:21:35 +06:00
mrkkrp
d8515202fe eliminate obsolete ‘GenParser’ type synonym 2015-09-19 21:13:53 +06:00
mrkkrp
1a7981ba34 move ‘(<?>)’ outside of ‘MonadParsec’ type class 2015-09-19 21:02:37 +06:00
mrkkrp
303e739584 remove redundant and somewhat obsolete text 2015-09-18 21:53:09 +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
02ebc7ee23 make combinators more general
Now all the combinators in ‘Text.Megaparsec.Combinator’ are defined for
any instance of ‘Control.Alternative’ (sometimes ‘Control.Applicative’).

Some combinators are inlined.
2015-09-18 15:31:32 +06:00
mrkkrp
4c1858f900 fix a typo: it's called ‘token’ now 2015-09-14 22:44:34 +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
0d39e44f40 Merge branch 'new-lexer' 2015-09-13 21:16:39 +06:00
mrkkrp
ec3b5934f0 fix a typo (columns starts from 1) 2015-09-13 21:00:22 +06:00
mrkkrp
193d7ade07 fixed ‘skipLineComment’ and ‘skipBlockComment’
Multi-character staring/ending sequences should be wrapped with
‘try’. Also, ‘lookAhead’ should not be used in ‘skipBlockComment’.
2015-09-13 18:51:15 +06:00
mrkkrp
4e8a1c298a fixed the failing old test
Multi-character operators should use ‘try’ in order to be reported
correctly (as “operator”). I've mentioned it in doc-string of
‘makeExprParser’.

It's tempting to include ‘try’ directly in expression parsing code, but
following general spirit of Parsec toward ‘try’, I think current
solution is the best.
2015-09-11 15:10:14 +06:00
mrkkrp
3de3f6965d make ‘hexadecimal’ and ‘octal’ more powerful
Various languages may vary in how hexadecimal and octal literals should
be prefixed. Following the spirit of the new lexer we leave this to
programmer to decide.
2015-09-09 14:15:39 +06:00
mrkkrp
c6f06b2ed1 fix a typo 2015-09-08 20:27:49 +06:00
mrkkrp
7298c01387 first version of the new lexer module 2015-09-08 17:34:02 +06:00
mrkkrp
f58d5bfe1c further refinement 2015-09-06 15:23:12 +06:00
mrkkrp
b6a43c3335 started work on new lexer
Eliminated ‘Text.Megaparsec.Language’ module because at this point it is
clear that already existing definitions are of little use in
Megaparsec. I started writing “default” language definition in
‘Text.Megaparsec.Lexer’.

At this point it should be possible to parse languages where indentation
matters, although we will need to provide more helpers to make it
easier.
2015-09-06 15:23:12 +06:00
mrkkrp
d8d810e78e add sections to ‘Text.Megaparsec.Char’ module 2015-09-06 15:22:37 +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
0b3efb649b refactoring of ‘Text.Megaparsec.Expr’ 2015-08-29 16:54:15 +06:00
mrkkrp
eb14e7d327 improve functioning of ‘hidden’ combinator
When ‘p’ in ‘hidden p’ fails we should discard all expected messages and
don't add any new messages.
2015-08-29 16:01:36 +06:00
mrkkrp
89f34688ab don't create hints for errors without messages 2015-08-26 17:26:06 +06:00
mrkkrp
cb3078d07c don't put older hints before newer ones, fixes #25
Obviously order does matter here, since ‘Monoid’ instance for ‘Hints’ is
derived from [], so (<>) is the same as (++) and we should be careful
to keep things in the right order.
2015-08-26 15:53:37 +06:00
mrkkrp
c31f0769fd rewrite ‘choice’ as synonym of ‘asum’ 2015-08-26 06:37:41 +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
40d92a19a0 rewritten ‘showMessages’ in clearer manner 2015-08-24 22:19:19 +06:00
mrkkrp
d431b396f4 improve indentation for readability 2015-08-24 16:38:00 +06:00
mrkkrp
a8577275c7 treat carriage return like ordinary character 2015-08-24 14:00:56 +06:00
mrkkrp
45f449ddb2 prefer longest match in ‘mergeError’, fixes #23
Since ‘mergeError’ is only used to merge errors from alternative
branches of parsing, longest match should be preferred.
2015-08-24 01:45:12 +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
7dd2ad94ff minor corrections 2015-08-22 15:02:34 +06:00
mrkkrp
6e5735167f flip argument order for ‘label’, close #21 2015-08-22 14:57:16 +06:00
mrkkrp
20984c20f2 cosmetic changes in ‘Text.Megaparsec.Prim’
Also eliminated dead segment of code in ‘token'’.
2015-08-22 01:12:26 +06:00
mrkkrp
d0cdb85e89 don't use ‘try’ in ‘manyTill’ unconditionally 2015-08-21 20:29:06 +06:00
mrkkrp
2fa2805aea derive ‘Eq’ instance for ‘Message’ and ‘ParseError’ 2015-08-21 14:02:29 +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
3661da90e5 temporarily simplify token parsing
The improved error messages in Megaparsec are quite sensitive to how
parsers are written, which parts of parser are labeled, etc. Current
implementation of token parsers in ‘Text.Megaparsec.Token’ is written
without this in mind. We will improve the module later, for now let us
rewrite/simplify some parts to avoid failing tests.
2015-08-20 01:38:00 +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
fc5abbc7fc ‘lookAhead p’ should discard hints produced by ‘p’ 2015-08-20 01:38:00 +06:00
mrkkrp
d45c2c0658 accumulate hints when previous parser consumes
If ‘x’ in ‘x >>= y’ consumes input but produces some hints, we should
accumulate them nonetheless. Why it's important can be demonstrated by
the following test:

  many (char 'a') >> many (char 'b') >> eof

This should fail on input "ac" with the following message:

  parse error at line 1, column 2:
  unexpected 'c'
  expecting 'a', 'b' or end of input

As you can see even though parser ‘many (char 'a')’ consumed input, its
hits may be useful later.
2015-08-20 01:38:00 +06:00
mrkkrp
987381eaa7 derive ‘Monoid’ instance for ‘Hints’ 2015-08-20 01:37:58 +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
mrkkrp
287a777e6c cosmetic changes (indentation, etc) 2015-08-13 00:02:49 +06:00
mrkkrp
77a54394b5 extend collection of character parsers, close #16
Added new character parsers in ‘Text.Megaparsec.Char’:

* ‘controlChar’
* ‘printChar’
* ‘markChar’
* ‘numberChar’
* ‘punctuationChar’
* ‘symbolChar’
* ‘separatorChar’
* ‘asciiChar’
* ‘latin1Char’
* ‘charCategory’

Renamed some parsers:

‘spaces’   → ‘space’
‘space’    → ‘spaceChar’
‘lower’    → ‘lowerChar’
‘upper’    → ‘upperChar’
‘letter’   → ‘letterChar’
‘alphaNum’ → ‘alphaNumChar’
‘digit’    → ‘digitChar’
‘octDigit’ → ‘octDigitChar’
‘hexDigit’ → ‘hexDigitChar’

Descriptions of old parsers have been updated to accent some
Unicode-specific moments. For example, old description of ‘letter’
stated that it parses letters from “a” to “z” and from “A” to “Z”. This
is wrong, since it used ‘Data.Char.isAlpha’ predicate internally and
thus parsed many more characters.
2015-08-12 23:00:03 +06:00
mrkkrp
bd04b4328c various minor changes 2015-08-12 18:41:22 +06:00
mrkkrp
c13ca493ae experimental branch with different Messages 2015-08-11 18:15:02 +06:00
mrkkrp
176fe8d9c1 improve quality of error messages, fixed #13 2015-08-11 03:21:52 +06:00
mrkkrp
bb074cc52b fixed a regression in ‘Text.Megaparsec.Error’
I've improved tests so this sort of bug won't appear in future.
2015-08-11 03:19:16 +06:00
mrkkrp
dedbe7a897 fix regression in ‘setErrorMessage’, add tests
New tests shows that I had wrong assumption about workings of this
particular function. This is not a problem, though, complete test-suite
will eliminate this sort of nuisance soon.
2015-08-09 00:38:30 +06:00
mrkkrp
c4350dca37 further cosmetic changes in ‘Text.Megaparsec.Char’ 2015-08-09 00:37:51 +06:00
mrkkrp
fcf1b972e8 a minor correction in doc-string of ‘setErrorMessage’ 2015-08-08 15:53:55 +06:00
mrkkrp
ebc1fae39c cosmetic changes in ‘Text.Megaparsec.Char’ 2015-08-08 15:50:50 +06:00
mrkkrp
80e93b90a6 fixing things in ‘Text.Megaparsec.Error’ 2015-08-08 15:48:20 +06:00
mrkkrp
3daa70f15a representation of tokens in error messages, fixed #12
* Type class ‘ShowToken’ introduced to pretty-print tokens.

* For now, we have defined instances for ‘String’ and ‘Char’.
2015-08-06 16:37:08 +06:00
mrkkrp
0608926db2 extends description of ‘Text.Megaparsec’ module 2015-08-04 00:15:16 +06:00
mrkkrp
cbbf27ddd0 export only useful (for user) functions
User still can import ‘Text.Megaparsec.Prim’ to access the stuff, but
it's very unlikely that this sort of things is used often.
2015-08-04 00:02:23 +06:00
mrkkrp
02e5f148e9 updated doc for ‘Text.Megaparsec.Prim.runParsecT’ 2015-08-04 00:01:38 +06:00
mrkkrp
be36490aa2 corrections for ‘Text.Megaparsec.Error’ 2015-08-03 23:44:40 +06:00
mrkkrp
79a378c9c4 remove parenthesis around “line & column” block 2015-08-03 20:45:09 +06:00
mrkkrp
437608c2c7 minor corrections in module ‘Text.Megaparsec.Pos’ 2015-08-03 13:20:15 +06:00
mrkkrp
3ef5e5e621 renamed ‘MegaParsec’ → ‘Megaparsec’, close #10 2015-08-01 22:24:45 +06:00
mrkkrp
3c69bc8f48 re-export ‘(<|>)’, ‘many’, ‘some’, and ‘optional’, fixes #9
These functions are now re-exported from ‘Control.Applicative’
module. ‘many’ and ‘some’ are now part of ‘Alternative’ instance of
‘ParsecT’.

Note that these functions are re-exported only in ‘Text.MegaParsec’
module, but not in ‘Text.MegaParsec.Prim’ to avoid duplication of
floating doc-strings. Others internal modules now just casually import
‘Control.Applicative’ for their needs.

Note that ‘many1’ was renamed to ‘some’, the same is done for other
parsers that had ‘many1’ part in their names (for consistency).
2015-08-01 20:49:45 +06:00
Albert Netymk
189106f001 Remove try in float parser.
According to this post
(http://blog.ezyang.com/2014/05/parsec-try-a-or-b-considered-harmful/),
the error message could be confusing if using `try`. `"3.a"` is one case
to expose this behavior.
2015-07-31 23:45:42 +02:00
mrkkrp
1ce541aaba remove word ‘unsigned’ from descriptions 2015-08-01 01:31:31 +06:00
mrkkrp
7c0341af72 the grammars overlap so there should be a ‘try’ 2015-07-31 20:31:38 +06:00
mrkkrp
c5bcdfb220 rewritten parsing of numbers, fixes #2 and #3
Changed how numbers are parsed because they were parsed in a naïf and
hairy way. Added tests for #2 and #3 (in old Parsec project these are
number 35 and 39 respectively).

* Since Haskell report doesn't say anything about sign, I've made
  ‘integer’ and ‘float’ parse numbers without sign.

* Removed ‘natural’ parser, it's equal to new ‘integer’ now.

* Renamed ‘naturalOrFloat’ → ‘number’ — this doesn't parse sign too.

* Added new combinator ‘signed’ to parse all sorts of signed numbers.

* For the sake of convenience I've added ‘integer'’, ‘float'’, and
 ‘number'’ combinators that also can parse signed numbers out of box.
2015-07-31 17:30:38 +06:00
mrkkrp
b19dae4315 improve efficiency of applicative interface 2015-07-31 01:50:36 +06:00
mrkkrp
b936e3c3a9 improved documentation, fixes #1 2015-07-31 00:36:54 +06:00
mrkkrp
773e9ccabe cosmetic changes in copyright (headers) 2015-07-30 22:20:37 +06:00
mrkkrp
e6f2379b22 refactoring, phase 3 2015-07-30 21:45:06 +06:00
mrkkrp
137ce0a521 refactoring, phase 2 2015-07-29 14:44:58 +06:00
mrkkrp
227667f829 refactoring, phase 1 2015-07-28 19:32:19 +06:00
Ben Pence
dd14602877 Fixes minor documentation inconsistency 2015-05-17 11:18:05 -07:00
Simon Vandel Sillesen
4aeaede85d Fix documentation for emptyDef not rendering 2015-04-15 19:01:53 +02:00
Antoine Latter
19a62ae80a Remove split-base conditional compilation option. 2015-03-21 20:40:02 -05:00
Antoine Latter
03242e474c Export 'runP' from Text.Parsec
Fixes #27.
2015-03-19 10:30:21 -04:00
Joel Williamson
6382eeec38 Fixed type of argument to char in examples
The examples for identStart and identLetter were calling `char "_"`. char should take a character literal, not a string.
2015-03-07 13:16:49 -05:00
Tal Walter
2b74642d7d Fixed a mistake (Applicative to Alternative) in the parserZero comments 2015-01-24 09:07:01 +02:00
cdepillabout
640cbdd306 Fixing spelling mistake in doc for chain function
Fix a small spelling mistake in the haskell doc for chainr1, chainl1, chainr, and chainl.
2015-01-11 01:32:00 +09:00
Antoine Latter
37d34b23eb Merge branch 'master' into 3.1.7_maint
Conflicts:
	parsec.cabal
2015-01-09 20:44:02 -06:00
Antoine Latter
355d8f2fc6 Fix module exports for Stream, Consumed, Reply, and State. 2015-01-09 20:33:05 -06:00
Daniel Gorin
3fb40aaa68 Add an Eq instance for ParseError 2014-11-03 16:30:21 +00:00
Slava Shklyaev
22ee53e06d Fix a typo 2014-10-29 19:36:12 +02:00
Emil Skoeldberg
ed944b4a96 Spelling fix. ('seperate' -> 'separate'). 2014-10-29 11:21:46 +00:00
Marios Titas
f7faa2a1af lookAhead: reset error messages on success 2014-09-24 20:33:15 -05:00
Antoine Latter
f4601acddf Revert "Track current position in the 'tokens' function"
This reverts commit 860764939c.

This fixes #9.
2014-09-24 19:43:08 -05:00
Antoine Latter
fd8ecf5d03 Fix off-by-one error in Token charControl.
Fixes #2.
2014-09-09 20:17:49 -05:00