deterministic recursive descent parser with ordered-choice semantics
librdesc is a portable, table-driven, algorithm-only parsing library written
in standard C99. It provides the flexibility of a recursive descent parser with
high degree of control in manual stack management.
Check out online documentation for details!
Full API documentation is auto-generated using Doxygen:
make docs
Contributions are welcome! Please check our Code of Conduct before submitting pull requests.
librdesc uses a modular build system with separate Makefiles for the library,
tests, and examples.
Build the main library:
make # Build release version (default)
make MODE=debug # Build with debug symbols and ASAN
make MODE=test # Build with coverage instrumentationProviding FEATURES variable, you can toggle modules linked to the library. By
default, only stack feature is enabled.
make FEATURES='stack dump_bnf dump_cst'| Feature | Description |
|---|---|
stack |
Use built-in stack implementation in backtracing, which uses malloc/free family functions. |
dump_bnf |
Dump rdesc_grammar in Backus-Naur form. |
dump_cst |
Dump rdesc_node (Concrete Syntax Tree) as dotlang graph. |
You may use feature flag full to include all features.
Tests are organized into three categories and built independently:
cd tests
make covr # Build coverage-instrumented tests (integration, unit, fuzz)
make debug # Build debug tests with ASAN (integration, unit)
make fuzz # Build optimized fuzz testsOr from project root:
./runtests.sh # Build and run all tests with coverageExamples build using their Makefile, and example output will be present in
dist/examples/ folder.
cd examples
make # Build example programsExamples statically links librdesc in tests mode.
make install PREFIX=/installation/pathThis command copies headers into $PREFIX/include and librdesc.so/a into
$PREFIX/lib.
Leave it empty to install librdesc system-wide:
sudo make installAlso you can specify build mode and features for installation:
sudo make install FEATURES=full MODE=debugNote: Test mode is not recommended for installation.
Copy include/*.h to your project and static link against librdesc.a or
dynamic link against librdesc.so.