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.
41 lines
687 B
JavaScript
41 lines
687 B
JavaScript
"use strict";
|
|
|
|
const { parse } = require("./index");
|
|
const { wholeMatch, either, peek, oneOrMore } = require("./operations");
|
|
|
|
function* A() {
|
|
yield "hello";
|
|
}
|
|
|
|
function* Whitespace() {
|
|
yield " "; // FIXME
|
|
}
|
|
|
|
function* B1() {
|
|
let worlds = oneOrMore("world");
|
|
|
|
// yield peek(worlds);
|
|
// yield peek("world");
|
|
yield worlds;
|
|
}
|
|
|
|
function* B2() {
|
|
yield "earth";
|
|
}
|
|
|
|
function* B3() {
|
|
yield either([ "moon", "jupiter" ]);
|
|
}
|
|
|
|
module.exports = function* TestParser() {
|
|
return yield wholeMatch(function* innerWholeMatch () {
|
|
yield A;
|
|
yield Whitespace;
|
|
yield either([ B1, B2, B3 ]);
|
|
});
|
|
};
|
|
|
|
// parse(process.argv[2], module.exports).then((result) => {
|
|
// console.log(result);
|
|
// });
|