A parser combinator library. There are not enough parsers implemented yet to make this a useful library. The parsers that are implemented might be buggy on top of it.
If you want to look at how a parser defined in terms of parsecomb
might look,
please look at the example JSON parser in examples/json.zp
.
A short list of parsers that are in fact implemented:
Takes two parsers, either must work.
Takes two parsers and parses sequentially.
Takes a variable number of parsers and parses sequentially.
Matches a given string.
Matches a given char.
Matches a given char case-insensitively.
Matches binary digits.
Matches octal digits.
Matches decimal digits.
Matches hexadecimal digits.
Matches whitespace characters.
Takes a parser that must match zero or more times. Think of the *
operator in regexes.
Takes a parser that must match one or more times. Think of the ?
operator in regexes.
Takes a parser and skips its' input.
Takes a parser for elements and a parser for separators and tries to intersperse them.
Takes many parsers and applies one of them if possible.
Takes a parser that must consume the entire input string.
Lots. If you have any suggestions that are not in any parser combinator library I know somewhat well (parsec, mpc), hit me up with your cool ideas.
This library does not handle left-recursive grammars well. This means that there are some limitations on recursive parsers, i.e.
(parsecomb:define-parser r (either r (string "lol")))
will build a parser that never terminates.
Have fun!