var jcon = require('jcon');
var epsilon = jcon.string('');
var num = jcon.regex(/\d+/).setAst('num');
var sum_operator = jcon.regex(/[\+\-]/).setAst('operator');
var product_operator = jcon.regex(/[\*\/]/).setAst('operator');
var skips = jcon.regex(/\s*/).skip();
var product = jcon.lazy(function(){
return jcon.or(
num,
jcon.seq(num, product_rest)
);
}).setAst('product');
var product_rest = jcon.or(epsilon, jcon.seq(skips, product_operator, skips, product));
var sum = jcon.lazy(function(){
return jcon.or(product,
jcon.seq(product, sum_rest)
);
}).setAst('sum');
var sum_rest = jcon.or(epsilon, jcon.seq(skips, sum_operator, skips, sum));
var s = sum.parse('1+2*3+4/5').ast();
console.log(JSON.stringify(s, null, ' '));