Import of Ian Piumarta's peg/leg recursive-descent parser generators for C
peg
and leg
are tools for generating recursive-descent parsers: programs that perform pattern matching on
text. They processes a Parsing Expression Grammar (PEG)[Ford 2004] to produce a program that recognises legal sentences of that grammar.
peg
processes PEGs written using the original syntax described by Ford.
leg
processes PEGs written using slightly different syntax and conventions that are intended to make it an attractive replacement for parsers built with lex
and yacc
.
Unlike lex
and yacc
, peg
and leg
support unlimited backtracking, provide ordered choice as a means for disambiguation, and can combine scanning (lexical analysis) and parsing (syntactic analysis) into a single activity.
peg
is distributed under the MIT license. It will not infect your project with a contagious license disease if you
decide to modify it for your own use. The parser generators that peg
creates are unencumbered and you are free to use and/or
distribute them any way you like.
peg
/leg
is copyright (c) 2007 by Ian Piumarta.
peg
/leg
manual page: peg.1.html
[Ford 2004] Bryan Ford, Parsing Expression Grammars: A Recognition-Based Syntactic Foundation. ACM SIGPLAN Symposium on Principles of Programming Languages (POPL), 2004.
-P
option to disable #line
directives.#line
directives for all actions.#line
directives for header and trailer in the generated source file.@{...}
actions that are performed during matching.YY_FREE
fixed (thanks to Andrew Dunham).yytext
(thanks to Grégory Pakosz).
Hexadecimal character escapes are supported by leg
(thanks to Hugo Etchegoyen).getopt()
in Windows build."~"
operator.getline
-> nextline
to avoid C namespace conflict.leg
actions.