small-parser
v0.2.0
Published
minimalist parser with post processing
Downloads
6
Readme
Small Parser
Minimalist parser with post processing.
Example
const example = parser(
rule(
/\d+/, (a, b) => a + +b,
repeat(
rule(
/[-+]/, (x, y) => x * (y == '-' ? -1 : 1),
rule(/\d+/, (_, x) => +x, end())),
(_, x) => x.reduce((a, b) => a + b, 0),
0, Infinity,
end(true)
)));
console.log(example('3+4-2+5+2'))