Trying to understand how parsers work in parser-ts, but encountered a pretty unexpected behaviour, a simple P.many
parser run on a string just hangs for ever, what am I doing wrong?
const everything = pipe(
Ch.alphanum,
P.alt(() => S.spaces)
);
const input1 = `hello [123]`;
const res = run(P.many(everything), input1); // this never finishes, i expect "hello "
const res = run(everything, input1); // this finishes, but only reads one char
console.log(JSON.stringify(res, null, 2));
The ultimate goal of this parser is to be able to distinguish tokens (that look like [123]) and all other text, whatever it may be