Files
mpc/README.md
2013-09-23 22:41:58 +01:00

1.3 KiB

Micro Parser Combinators

mpc is a lightweight Parser Combinator library for C.

Features

  • Full Type Generic Parser Combinator
  • Error Message Support
  • Regular Expression Support
  • Packaged with AST generator
  • Easy to including in source
  • Written in clean ANSI C

Alternatives

The current main alternative is a branch of (https://github.com/wbhart/Cesium3)[Cesium3].

The main advantages of mpc over this are:

  • Works for Generic Types
  • Doesn't rely on Boehm-Demers-Weiser Garbage Collection
  • Doesn't use setjmp and longjmp for errors
  • Doesn't pollute namespace

Example




Parsers

Combinators

Regular Expressions

Combinator Grammars

Abstract Syntax Tree

If you want to do all the data processing after the parsing stage mpc comes packaged with a basic AST type which makes the grammar declaration much cleaner as you don't have to pass around destructors and fold functions. All these functions reside under mpca_*.

This also allows for the use of parser grammars that can be declared directly in C strings similarly to regular expressions.



Reference