"use strict"; const { parse } = require("./index"); const { wholeMatch, either, peek, oneOrMore } = require("./operations"); function* A() { return yield "hello"; } function* Whitespace() { return yield " "; // FIXME } function* B1() { yield peek(oneOrMore("world")); // yield peek("world"); return yield "world"; } function* B2() { return yield "earth"; } function* B3() { let result = yield /(moon|jupiter)/; return result.$positional[0]; } module.exports = function* TestParser() { return yield wholeMatch(function* innerWholeMatch () { yield A; yield Whitespace; return yield either([ B1, B2, B3 ]); }); }; parse(process.argv[2], module.exports).then((result) => { console.log(result); });