5.0.1 • Published 2 years ago

@otesunki/numb v5.0.1

Weekly downloads
-
License
GPL-2.0
Repository
github
Last release
2 years ago

numb

a PEG combinatorial parser

install

npm i @otesunki/numb

example

let {any, chain, just, match, operators, recursive} = require('@otesunki/numb');

let expr = recursive(expr =>
  operators({
    infop: (lhs, op, rhs) => op == '+' ? lhs + rhs : lhs - rhs,
    preop: (term, op) => -term,
  }, any(
    match(/\d+/).process(Number),
    chain(just('(').ignore(), expr, just(')').ignore()),
  ),
    [{prefix: '-'}],
    [{infix: '+', assc: 'ltr'}, {infix: '-', assc: 'ltr'}]
  )
);

console.log(expr.parse_raw('(1 + 2) - (-3)'));
5.0.1

2 years ago

4.0.0

2 years ago

5.0.0

2 years ago

3.0.0

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago