A PEG.js plugin for using CoffeeScript with the post-0.7 pegjs plugin API
CoffeeScript Shell
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
examples
src
test
.gitignore
.jshintrc
.npmignore
.travis.yml
Gruntfile.coffee
README.md
package.json

README.md

pegcoffee

Build Status endorse

pegcoffee is a PEG.js plugin for the post-0.7 plugin API that enables the use of CoffeeScript instead of JavaScript in your grammar files. Additionally, your code is given its own scope (the semi-hidden peg$coffee$scope object), giving @ or this much more intuitive behavior. You do not need to abuse the global scope to share state across actions and predicates, and coffee will safely scope any other variables to be local to the function.

To use from the console:

pegcoffee /path/to/grammar.pegcoffee

To use it via the API, you'd do something to the effect of:

PEG = require 'pegjs'
pegcoffee = require 'pegcoffee'
parser = PEG.buildParser "some grammar string",
  output: 'source'
  optimize: 'speed'
  plugins: [pegcoffee]
console.log parser