examples/operators/operator-example.js
function makeTree(left, ops, rights, minPrecedence = 0) {
  while (ops.length > 0 && precedence[ops[0]] >= minPrecedence) {
    let op = ops.shift();
    let right = rights.shift();
    while (ops.length > 0 && (precedence[ops[0]] > precedence[op] ||
        associativity[ops[0]] === 'R' && precedence[ops[0]] === precedence[op])) {
      right = makeTree(right, ops, rights, precedence[ops[0]]);
    }
    left = new BinaryExpression(left, op, right);
  }
  return left;
}
function makeTree(left, ops, rights, minPrecedence = 0) {
  while (ops.length > 0 && precedence[ops[0]] >= minPrecedence) {
    let op = ops.shift();
    let right = rights.shift();
    while (ops.length > 0 && (precedence[ops[0]] > precedence[op] ||
        associativity[ops[0]] === 'R' && precedence[ops[0]] === precedence[op])) {
      right = makeTree(right, ops, rights, precedence[ops[0]]);
    }
    left = new BinaryExpression(left, op, right);
  }
  return left;
}
function makeTree ( left , ops , rights , minPrecedence = 0 ) { while ( ops . length > 0 && precedence [ ops [ 0 ] ] >= minPrecedence ) { let op = ops . shift ( ) ; let right = rights . shift ( ) ; while ( ops . length > 0 && ( precedence [ ops [ 0 ] ] > precedence [ op ] || associativity [ ops [ 0 ] ] === 'R' && precedence [ ops [ 0 ] ] === precedence [ op ] ) ) { right = makeTree ( right , ops , rights , precedence [ ops [ 0 ] ] ) ; } left = new BinaryExpression ( left , op , right ) ; } return left ; }
Modified Richards and Whitby-Stevens precedence climbing method.
Modified Richards and Whitby - Stevens precedence climbing method .