A parser library based on functional composition of stream consumers.
$ npm install --save voltrevo-parser
'use strict';
var parser = require('voltrevo-parser');
var foo = parser.string('foo');
var bar = parser.string('bar');
var baz = parser.string('baz');
var demo = parser.sequence(
parser.oneOrMore(foo),
parser.many(bar),
baz
);
var stream = parser.Stream('foobarbarbarbaz');
console.log(demo.consume(stream)); /*
{ name: 'sequence(oneOrMore("foo"), many("bar"), "baz")',
value: [ [ 'foo' ], [ 'bar', 'bar', 'bar' ], 'baz' ],
accepted: true,
valid: true,
invalidations: [],
location: [ [Function], [Function] ] }
*/
MIT © Andrew Morris