Commit Graph

20 Commits

Author SHA1 Message Date
steve-chavez
b866236aad fix: mpc_sepby1 not applying fold correctly
`mpc_sepby1` takes a single fold function but this doesn't apply to the
whole list of entries. Instead it applies the fold twice,
one for `mpc_and` and another for `mpc_many`.

Introduce a new repeat repeat parser type MPC_TYPE_SEPBY1 that combines
the results and applies the fold once for all entries.
2023-08-20 21:12:50 -05:00
steve-chavez
c24e27f0b8 feat: add sepby1 combinator
`sepby1` is a common reusable combinator in Haskell Parsec.

This adds `mpc_sepby1(mpc_fold_t f, mpc_parser_t *sep, mpc_parser_t *a)` according to Haskell's implementation:

https://hackage.haskell.org/package/parsec-3.1.16.1/docs/src/Text.Parsec.Combinator.html#sepBy1

Reuses existing `mpc_and`, `mpc_many`, and `mpcf_snd_free`.
2023-08-08 14:25:18 -05:00
Carlos Rueda
afbaab89fe remove mpcf_maths from mpc.c and adjust maths test 2023-01-05 15:51:14 -08:00
Joshua Crowgey
0edd06ec44 Removed trailing whitespace 2020-01-08 22:07:32 -08:00
Daniel Holden
37c4de35a3 Fixed bug with end of file and parsing from a file 2018-12-15 16:11:39 -05:00
Daniel Holden
4a992d91ab Added mode option to regex and also changed example from a line reader to a tokenizer. 2018-10-14 17:20:11 -04:00
Daniel Holden
fbc5d8f9ae Added line-reader example. Changed behaviour of eof on regex to parse either eof or a newline followed be eof (better matchers other regex engines). 2018-10-13 18:27:42 -04:00
Daniel Holden
65060137b1 Adjust the behaviour of mpc_eoi so that it only is successful in matching the end of input once. 2018-10-13 17:35:21 -04:00
Daniel Holden
4da2ae5feb Updated copy function to work properly with larger parsers 2016-03-03 10:34:52 +00:00
Daniel Holden
3643fbe6bb Fixed bug in behaviour of counting parser. Removed changelog (git is the changelog). 2015-08-28 19:20:39 +01:00
Daniel Holden
123a7919d1 Added string stripping functions 2015-03-10 10:44:29 +00:00
Daniel Holden
5094d2c015 Removed comments describing changes. Fixed warnings reported by gcc in the test suite 2014-10-16 15:38:27 +01:00
Daniel Holden
7487398279 Updated tests. Added some tests for new boundary parse. 2014-04-16 19:19:25 +01:00
Daniel Holden
d5e2bdf977 Added flags to language specifiction. Added optional expect string to language specification. Added some exaple grammars for testing and demos 2014-01-26 11:25:50 +00:00
Daniel Holden
7059268b9b WIP refactoring 2013-11-10 14:17:32 +00:00
Daniel Holden
82aa2eefc7 Changed argument order of many functions 2013-11-10 12:52:01 +00:00
Daniel Holden
f5347e550b Removed else and also 2013-11-10 12:42:47 +00:00
Daniel Holden
a625db585d strictly ansi C now 2013-09-30 20:55:57 +01:00
Daniel Holden
eadb0417b9 big update to readme 2013-09-26 13:15:00 +01:00
Daniel Holden
48812155a1 Updated testing framework 2013-09-23 22:41:58 +01:00