Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    pegjs-requirepublic

    PEG.js Require Extension

    This is an extension that enables PEG.js grammars to be loaded via require.

    It is simply a shortcut to:

    require('pegjs').buildParser(fs.readFileSync(filename, 'utf8'));
    

    Install

    Install via npm:

    npm install pegjs-require
    

    Use

    Simply require this module:

    require('pegjs-require');
    

    And then require any PEG.js grammar:

    var parser = require('./grammar.pegjs');
    

    Then use the parser as normal:

    parser.parse("Hello World!");
    

    Bonus

    This module also exports PEG.js via module.exports so you should only have to require this one module.

    install

    npm i pegjs-require

    Downloadsweekly downloads

    75

    version

    2.0.0

    license

    MIT

    repository

    githubgithub

    last publish

    collaborators

    • avatar