You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
673 B
JavaScript

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