minipeg
minipeg copied to clipboard
A C peg parser generator (a fork of peg/leg)
Minipeg
minipeg is a tool for generating recursive-descent parsers for use from C.
Unlike lex and yacc, minipeg supports unlimited backtracking, provide ordered choice as a means for disambiguation, and can combine scanning (lexical analysis) and parsing (syntactic analysis) into a single activity.
minipeg is also easy to add to your C project by copying minipeg.c into your project.
Examples
See some examples:
- word count
- calculator
- basic interpeter
- x86_64 assembler
Documentation
Read it online at the project website.
Or read the man page directly:
man ./doc/minipeg.1
History
minipeg started as a fork of peg/leg https://www.piumarta.com/software/peg/.
The aim of the fork is simplification (by removing the 'peg' syntax out of peg/leg)
and improving ease of distribution with a single file amalgamation.
References
- [Ford 2004] Bryan Ford, Parsing Expression Grammars: A Recognition-Based Syntactic Foundation. ACM SIGPLAN Symposium on Principles of Programming Languages (POPL), 2004.
Version history
- unreleased Rename project to minipeg. Deprecate and remove peg syntax (leg is the new and only syntax). Add new amalgamated builds that can be distributed as a single file.
- 0.1.18
Add-Poption to disable#linedirectives.
Emit#linedirectives for all actions. - 0.1.17
Emit#linedirectives for header and trailer in the generated source file. - 0.1.16
Add@{...}actions that are performed during matching. - 0.1.15
Calls toYY_FREEfixed (thanks to Andrew Dunham). - 0.1.14
Documentation typos fixed (thanks to Giulio Paci). - 0.1.13
Predicate actions can refer toyytext(thanks to Grégory Pakosz). Hexadecimal character escapes are supported byleg(thanks to Hugo Etchegoyen). - 0.1.12
Use BSD-licensedgetopt()in Windows build.
Verbose mode handles Variable nodes. - 0.1.11
Add error actions via"~"operator.
Support declaration of local variables at the top level of semantic actions.
Dynamically grow data structures to remove artificial limits on rule recursion (thanks to Alex Klinkhamer).
Many small changes to better support C++.
Add build files for Win32 and MacOS (thanks to Fyodor Sheremetyev).
Update manual page to describe new features. - 0.1.9 Move global state into a structure to facilitate reentrant and thread-safe parsers (thanks to Dmitry Lipovoi).
- 0.1.8 Allow nested, matched braces within actions.
- 0.1.7 Fix matching of 8-bit chars to allow utf-8 sequences in matching expressions (thanks to Grégory Pakosz).
- 0.1.6 Allow octal escapes in character classes.
- 0.1.5
Remove dwarf sym dirs when cleaning.
Fix size calculation when resizing text buffers.
Backslash can be escaped. - 0.1.4
Fix match of a single single quote character.
Renamegetline->nextlineto avoid C namespace conflict. - 0.1.3
Allow matched braces inside
legactions.
Handle empty rules.
Handle empty grammars. - 0.1.2
Grow buffers while (not if) they are too small.
Remove dependencies on grammar files.
Add more basic examples. - 0.1.1 First public release.