1. 9
  1.  

  2. 1

    I submitted this recently but it didn’t get any attention https://lobste.rs/s/gbmmbd/implementing_pegs_parsing_expression_grammars_using_pegs

    1. 2

      I hadn’t seen that! I’m interested to hear your thoughts on it.

    2. 1

      The context here is that PEGs (the kind of grammar Packrat parses) are an extended subset of context-free grammars which are easy to write, composable in a way e.g. LALR grammars aren’t, and pretty efficient to parse; Warth’s OMeta is a version that uses PEGs to specify arbitrary object tree transformations, e.g. compiler optimizations. In practice I think that the linear-time guarantee provided by Packrat (which has the size of the grammar as part of its constant factor) may not be nearly as useful as other optimizations, e.g. using a little bit of lookahead to avoid a lot of backtracking. Darius Bacon’s Peglet is a practical and comfortable PEG parsing library for Python, and I wrote the self-compiling PEG that @ika linked in their comment.