parser-combinators
An implementation of parser combinators.

GitHub page

README.

It can be obtained either with git from git://github.com/Ramarren/cl-parser-combinators.git , or by automatic tarball. It depends on iterate and Alexandria.

The implementation is fairly naive, which means that for highly ambiguous grammars it can become exponential in length of input unless the parser is carefully constructed. It is likely not suitable for parsing large amounts of data, but might be a useful replacement for regular expressions in some situations.

There is nothing which requires the parsed data to be characters, it will work just as well on vectors/list of arbitrary objects. The library cannot parse streams, since it requires the ability to arbitrarily backtrack.

There is no built-in error reporting as failure to parse is indistinguishable from normal backtracking. It is possible to create component parsers which will signal an error on failure, but this require knowing where the component failure means parse failure.

Simple example:

(defun example-parser ()
  (bracket? #\[ (sepby? (int?) #\,) #\]))

;;(parse-string* (example-parser) "[1,2,-5,4,-3]") => (1 2 -5 4 -3)

For some more examples see test suite.


library text parser