You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1.1 KiB


You can use plugins by simply passing them to the generate method (e.g. peg.generate(grammar, { plugins: [plugin1, plugin2, etc] })).

Creating a Plugin

Plugins are expected to be an object that contains at least one method: use( session, options )

Here is a simple example:

import customGrammarParser from "./parser";

export function use( session, options ) {

    // Replace the grammar parser
    session.parser = customGrammarParser;

    // always output the source
    options.output = "source";



You can find some plugins to use on