Filename/callback interface to pegjs.
npm install quickpegquickpeg
========
Simple wrapper around pegjs; caches parsers built from grammar files; provides callback interface for parsing files.
See
``bash`
npm install quickpeg
`js
var quickpeg = require('quickpeg');
quickpeg('my.grammar', function (err, parser) {
parser.parseFile('my.source', function (err, result) {
// result of parsing my.source with my.grammar
// by default, parser is now cached to my.grammar.js
});
});
`
Converts a grammar file to a parser and caches the result (if caching is not
disabled). Returns the parser to the callback.
- grammarFile - The path to the peg grammar file.options
- - Options:cache
- - Set to one of the following values:true
- - Append .js to grammar file path and cache to that location.false
- - Disable parser caching.some/dir
- - Append .js to grammar filename and cache to some/dir.some/filename
- - Cache to some/filename.cb
- - Callback called with (err, parser). See below for the parser API.
Creates a quickpeg function with default options.
- options - Default options for the quickpeg function.quickpegFunction
- - Configured quickpeg function.
Parses a string with the parser and returns the result.
- sourceString - Source string to be parsed.result
- - Result of parsing sourceString with the parser.
See
Parses a file with the parser and returns the result on a callback.
- sourceFile - The path to the source file.cb
- - Callback called with (err, result)`.