sonic-pi

https://github.com/sonic-pi-net/sonic-pi

C++

Code. Music. Live.

Parslet::Accelerator#apply

Given a parslet atom and a set of rules, tries to match the rules 
recursively through the parslet atom. Once a rule could be matched, 
its action block will be called.

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)"')

Source | Google | Stack overflow

Edit

git clone [email protected]:sonic-pi-net/sonic-pi.git

cd sonic-pi

open app/server/ruby/vendor/parslet/lib/parslet/accelerator.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-Parslet--Accelerator-apply-for-pr


# Commit to git

git add app/server/ruby/vendor/parslet/lib/parslet/accelerator.rbgit commit -m "better docs for Parslet::Accelerator#apply"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-Parslet--Accelerator-apply-for-pr

hub pull-request


# Celebrate!