Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. C
  3. mpc

mpc

NOASSERTIONC0.9.0

A lightweight and powerful parser combinator library for C, enabling easy parsing of languages and data formats.

GitHubGitHub
2.9k stars304 forks0 contributors

What is mpc?

mpc is a parser combinator library for C that allows developers to build parsers by combining smaller parsers using intuitive operators. It simplifies parsing tasks such as building programming languages, data formats, or domain-specific languages by enabling grammar specification directly or through combinators.

Target Audience

C developers building parsers for new or existing programming languages, data formats, or embedded domain-specific languages.

Value Proposition

Developers choose mpc for its simplicity, single-file integration, type-generic design, and powerful features like automatic error generation and regex support, all without external dependencies.

Overview

A Parser Combinator library for C

Use Cases

Best For

  • Building parsers for new programming languages in C
  • Parsing existing data formats like JSON or custom configurations
  • Embedding domain-specific languages within C applications
  • Creating tokenizers for text processing
  • Implementing mathematical expression evaluators
  • Developing tools that require grammar-based parsing without heavy dependencies

Not Ideal For

  • Projects requiring Unicode text parsing or international character support
  • Applications that need to parse binary data containing null characters
  • Environments where automatic garbage collection is preferred over manual memory management
  • Teams working with highly left-recursive grammars unwilling to refactor them

Pros & Cons

Pros

Single-File Simplicity

Distributed as a single ANSI C source file, mpc can be integrated into any C project with minimal setup, avoiding complex build dependencies.

Flexible Type System

Supports generic types through function pointers, allowing parsers to output custom data structures like ASTs or computed values, as shown in the maths language case study.

Automatic Error Reporting

Generates clear, contextual error messages automatically, such as expected tokens and line numbers, which aids in debugging without extra user code.

Grammar DSL Convenience

Includes mpca_lang for specifying grammars in a concise domain-specific language, enabling rapid parser development from string-based rules.

Cons

ASCII-Only Limitation

Explicitly does not support Unicode, restricting its use to ASCII text parsing, which is a significant drawback for modern international applications.

Manual Memory Overhead

Requires users to provide destructor and fold functions for custom types, increasing complexity and risk of memory leaks if not handled correctly.

Left Recursion Incompatibility

Cannot parse left-recursive grammars, forcing users to rewrite rules to avoid infinite loops, as admitted in the limitations section.

Frequently Asked Questions

Quick Stats

Stars2,853
Forks304
Contributors0
Open Issues29
Last commit1 year ago
CreatedSince 2013

Tags

#parsing#c-library#domain-specific-language#regex-parser#grammar#recursive-descent#abstract-syntax-tree#parser-combinator

Built With

A
ANSI C

Included in

C3.8k
Auto-fetched 10 hours ago

Related Projects

libucllibucl

Universal configuration library parser

Stars1,744
Forks161
Last commit14 days ago
iniparseriniparser

ini file parser

Stars1,075
Forks436
Last commit1 month ago
hammerhammer

Parser combinators for binary formats, in C. Yes, in C. What? Don't look at me like that.

Stars292
Forks73
Last commit6 years ago
libconfinilibconfini

Yet another INI parser

Stars181
Forks27
Last commit4 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub