Skip to content

Latest commit

 

History

History
39 lines (29 loc) · 766 Bytes

README.md

File metadata and controls

39 lines (29 loc) · 766 Bytes

Bad parsers, don't use (except for fun)

const smolParser = Parser.gen(function* () {
	const hs = yield* many(char("h"));
	const ts = yield* many(char("t"));
	const v = yield* char("v");

	return { hs, ts, v };
});

const parseTexoport = Parser.gen(function* () {
	for (const i of "texoport") {
		yield* char(i);
	}
	return "texoport acquired" as const;
});

const bigParser = Parser.gen(function* () {
	const smol = yield* smolParser;
	const texStatus = yield* parseTexoport;

	return {
		smol,
		texStatus,
	};
});

const lol = bigParser.run("hhhtttvtexoport");
//     ^   ParserResult<{ smol: { hs: string[]; ts: string[]; v: string }, texStatus: "texoport acquired" }>

Either.match(lol, {
	onRight: console.log,
	onLeft: console.log,
});