voltrevo-parser
v0.1.3
Published
A parser library based on functional composition of stream consumers.
Downloads
4
Readme
parser
A parser library based on functional composition of stream consumers.
Install
$ npm install --save voltrevo-parser
Usage
'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] ] }
*/
License
MIT © Andrew Morris