Commit Graph

487 Commits

Author SHA1 Message Date
Artyom
935f3eeecc Fix the explanation for 'try' 2015-09-23 10:57:47 +06:00
Artyom
a7d96ce56b Update .gitignore 2015-09-23 00:08:58 +03:00
mrkkrp
de63d7a0ad fixed a couple of typos in comments 2015-09-22 23:30:54 +06:00
mrkkrp
75eb620de0 fixed typos in ‘README.md’ 2015-09-22 17:36:21 +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
4a2aedb8c1 add link to Parsec repository in ‘README.md’ 2015-09-21 23:26:25 +06:00
mrkkrp
1e66bf7d3d at attempt to reduce repetition
Not sure if it actually makes it better. Sometimes I miss certain
features of languages like Common Lisp.
2015-09-21 23:12:17 +06:00
mrkkrp
5ba4fa8060 updated ‘README.md’ file
Note that we have Hackage badge here, although we haven't uploaded the
library yet. This is put here in advance because the badge is created
only after uploading but then it's too late to attach it. Oh.
2015-09-21 21:42:10 +06:00
mrkkrp
f8a02e25ea minor (mainly cosmetic) corrections 2015-09-21 21:40:27 +06:00
Mark Karpov
5140f3039d Merge pull request #33 from neongreen/master
Add some tests for monad transformers (see #27)
2015-09-21 19:30:06 +05:00
Artyom
3f23081f60 Add some tests for monad transformers (see #27) 2015-09-21 17:05:41 +03:00
mrkkrp
17bdba05f7 revised ‘CHANGELOG.md’ 2015-09-21 18:53:23 +06:00
mrkkrp
dbfa03221c correct ‘lookAhead’ and ‘notFollowedBy’
…for some instances of ‘MonadParsec’.
2015-09-21 15:31:19 +06:00
Mark Karpov
b70472a2de Merge pull request #31 from mrkkrp/monad-transformer
Monad transformer
2015-09-20 15:06:15 +05: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
5242b8d5fd minor changes in tests to make them compile
Recent changes (mainly eliminating of built-in backtracking user state)
require some changes in the tests.
2015-09-18 15:41:18 +06:00
mrkkrp
f021fb52f5 change type signatures to fix the old test 9 2015-09-18 15:39:55 +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
601c809a91 extend the list of contributors 2015-09-14 21:26:26 +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
eed0e48a60 travis: run 1000 iterations per test 2015-09-13 21:21:43 +06:00
mrkkrp
0d39e44f40 Merge branch 'new-lexer' 2015-09-13 21:16:39 +06:00
mrkkrp
704f84f018 finished tests for ‘Text.Megaparsec.Lexer’
Covered the rest of public functions:

* ‘space’
* ‘symbol’
* ‘symbol'’
* ‘indentGuard’
* ‘skipLineComment’
* ‘skipBlockComment’
2015-09-13 21:00: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
26f3039c8b added more tests for ‘Text.Megaparsec.Lexer’
The following functions are covered:

* ‘float’
* ‘number’
* ‘signed’
2015-09-12 17:06:58 +06:00
mrkkrp
de16f4242f started writing tests for ‘Text.Megaparsec.Lexer’
Currently the following combinators are tested:

* ‘charLiteral’
* ‘integer’
* ‘decimal’
* ‘hexadecimal’
* ‘octal’
2015-09-11 17:15:46 +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
7133fb54b7 extend list of contributors 2015-09-11 14:21:23 +06:00
mrkkrp
f256532c69 refresh ‘.gitignore’ 2015-09-11 14:20:01 +06:00
Mark Karpov
28d201ed1d Merge pull request #30 from tulcod/master
Add a few synthetic benchmarks
2015-09-11 13:24:00 +05:00
Auke Booij
a7fbf2fe04 Add a few synthetic benchmarks
This code benchmarks the "string" primitive and various non-primitive combinators.
The code coverage of these benchmarks is not 100%: new benchmarks should be added
as relevant performance questions are discovered.
2015-09-10 18:11:46 +02: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
bf863e03c3 fix a typo in ‘.travis.yml’ file 2015-09-06 19:18:39 +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
183c996e6a fix flaw in test for ‘eol’ character parser 2015-08-30 18:16: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
b35ecbc31f added tests for ‘Text.Megaparsec.Expr’
The single test covers 100 % of the module's code. However it doesn't
check quality of error messages, so we still have room for improvement.

Manual tests show that error messages are good.
2015-08-29 22:24:55 +06:00
mrkkrp
0b3efb649b refactoring of ‘Text.Megaparsec.Expr’ 2015-08-29 16:54:15 +06:00