Skip to content

yoshikiohshima/greg

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

greg is a re-entrant peg/leg, with some bug fixes.
<http://piumarta.com/software/peg/>

the most comprehensive example of greg usage is in
nagaqueen, an ooc grammar, used in rock, an ooc
compiler written in ooc.
<http://github.com/nddrylliog/nagaqueen>
<http://github.com/nddrylliog/rock>

peg/leg is copyright (c) 2007 by Ian Piumarta
released under an MIT license. as is greg.

This fork of greg supports the memoization of
failed rule application attempts.  For a language
with more elaborated syntax and operators, a PEG
parser can spend exponentially long time to try
the same rule application at the same input
location.  The typical solution for this problem
is to assume that a grammar rule always returns
the same result (or fail) at the same location and
remember the value (or failure), effectively in
the 2D table of (location, rule_id) -> value.

An interesting feature that Ian's leg has is that it
defers the semantic action execution until the
system "commits" a successfull parse.  (That is
why putting printf() in a failed choice in a rule
does not show any debug log, BTW.)  Because of
this, we cannot remember the successful result; as
it is calculated later while attempting a lot of
reduandant failures.  So, instead, this fork only
remembers the fact that the rule failed; next time
it trys the same rule at the location, it
short-cuts the work and fails.

About

a recursive-descent parser generator based on Ian Piumarta's peg/leg, re-entrant thanks to _why, and with better error-reporting features

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 100.0%