formulaParser.js
function _parseBinarySubformula(self, currentString, currentPrecedence, leftOperandJSON) {
  const binary = matchOperator(currentString, self.binaries);
  if (!binary || binary.precedence < currentPrecedence) {
    return null;
  }

  const nextPrecedence = binary.precedence + (binary.associativity === 'left');
  const parsedRightOperand = _parseFormula(self, sliceSymbol(currentString, binary.symbol), nextPrecedence);

  return {
    json: { [binary.key]: [leftOperandJSON, parsedRightOperand.json] },
    remainder: parsedRightOperand.remainder
  };
}
function _parseBinarySubformula(self, currentString, currentPrecedence, leftOperandJSON) {
  const binary = matchOperator(currentString, self.binaries);
  if (!binary || binary.precedence < currentPrecedence) {
    return null;
  }

  const nextPrecedence = binary.precedence + (binary.associativity === 'left');
  const parsedRightOperand = _parseFormula(self, sliceSymbol(currentString, binary.symbol), nextPrecedence);

  return {
    json: { [binary.key]: [leftOperandJSON, parsedRightOperand.json] },
    remainder: parsedRightOperand.remainder
  };
}
function _parseBinarySubformula ( self , currentString , currentPrecedence , leftOperandJSON ) { const binary = matchOperator ( currentString , self . binaries ) ; if ( ! binary || binary . precedence < currentPrecedence ) { return null ; } const nextPrecedence = binary . precedence + ( binary . associativity === 'left' ) ; const parsedRightOperand = _parseFormula ( self , sliceSymbol ( currentString , binary . symbol ) , nextPrecedence ) ; return { json : { [ binary . key ] : [ leftOperandJSON , parsedRightOperand . json ] } , remainder : parsedRightOperand . remainder } ; }
Attempts to parse a binary subformula at the head of a given string,
given a lower precedence bound and an AST node to be used as a left operand.
Returns an AST node and string remainder if successful, otherwise null.

@private
@param {FormulaParser} self
@param {string}        currentString     - remainder of input string left to parse
@param {number}        currentPrecedence - lowest binary precedence allowable at current parse stage
@param {Object}        leftOperandJSON   - AST node for already-parsed left operand
@returns {?Object}
Attempts to parse a binary subformula at the head of a given string given a lower precedence bound and an AST node to be used as a left operand . Returns an AST node and string remainder if successful otherwise null .