Last Modified
2014-09-11 14:51:21 +0000
Requires
  • parslet/accelerator/engine
  • parslet/accelerator/application

Description

Optimizes the parsers by pattern matching on the parser atoms and replacing matches with better versions. See the file qed/accelerators.md for a more in-depth description.

Example:

quote = str('"')
parser = quote >> (quote.absent? >> any).repeat >> quote

A = Accelerator # for making what follows a bit shorter
optimized_parser = A.apply(parser, 
  A.rule( (A.str(:x).absent? >> A.any).repeat ) { GobbleUp.new(x) })

optimized_parser.parse('"Parsing is now fully optimized! (tm)"')