Skip to content

CPARSEC2 - a parser combinator library for C language

License

Notifications You must be signed in to change notification settings

mori0091/cparsec2

Repository files navigation

CPARSEC2 - a parser combinator library for C language

https://img.shields.io/codacy/grade/3884708954694573829f978709ff6dae.svg?logo=codacy https://circleci.com/gh/mori0091/cparsec2.svg?style=shield https://codecov.io/gh/mori0091/cparsec2/branch/master/graph/badge.svg

This project is an exercise to construct parsec like library for C11.

What is this?

The CPARSEC2 is a parser combinator library for C/C++ language.

Example 1 (using built-in parser)Example 2 (using parser-combinator)
docs/images/parsec1.pngdocs/images/parsec2.png
Supporting C/C++ standards
  • C11
  • C++17
Supporting OS/Environments
  • Msys (MSYS2 on 64bit Windows)
  • Mingw (MINGW64 on 64bit Windows)
  • Ubuntu 18.04 (including WSL - Windows Subsystem for Linux)
  • or else (probably works well but not tested)

Why for C11?

  1. It’s my exercise 😆
  2. Maybe useful to develop C compiler written in C
  3. Maybe useful to develop a testing framework for C
  4. To research more useful usecase of _Generic selector of C11
  5. etc.

How to build

To build anything all in the CPARSEC2 project, it is convenient to use build.sh - a batch-make shell script.

Usage
build.sh [options] [target] …

build.sh [options] [target] ... run make -C <dir> [options] [target] ... for all directory <dir> in the project where a GNUmakefile or a Makefile exists.

To build and test anything all in the project:

# at the top of project directory
./build.sh all test

See also HOW TO BUILD to build/test each subproject individually.

Sample Applications

calc
A simple calculator
calcc
A simple calculator (compiler version)
excc
An experimental C compiler subset
digit3
example of user-defined parser
digit3b
example of user-defined parser
mult
example of user-defined parser-class
extend_cparsec2
an example how to add user-defined type Person to the CPARSEC2 library.

Tutorial

See tutorials for making your custom parser.

API

See API Reference contents.