// Generated by ReScript, PLEASE EDIT WITH CARE

import * as Caml_string from "rescript/lib/es6/caml_string.js";
import * as Res_parsetree_viewer from "./res_parsetree_viewer.js";

function expr(expr$1) {
  var match = Res_parsetree_viewer.processBracesAttr(expr$1);
  var optBraces = match[0];
  if (optBraces !== undefined) {
    return /* Braced */{
            _0: optBraces[0].loc
          };
  }
  var match$1 = expr$1.pexp_desc;
  if (typeof match$1 === "number") {
    return /* Nothing */1;
  }
  if (match$1.TAG !== /* Pexp_constraint */19) {
    return /* Nothing */1;
  }
  var tmp = match$1._0.pexp_desc;
  if (typeof tmp === "number") {
    return /* Parenthesized */0;
  }
  if (tmp.TAG !== /* Pexp_pack */32) {
    return /* Parenthesized */0;
  }
  var tmp$1 = match$1._1.ptyp_desc;
  if (typeof tmp$1 === "number" || tmp$1.TAG !== /* Ptyp_package */9) {
    return /* Parenthesized */0;
  } else {
    return /* Nothing */1;
  }
}

function callExpr(expr) {
  var match = Res_parsetree_viewer.processBracesAttr(expr);
  var optBraces = match[0];
  if (optBraces !== undefined) {
    return /* Braced */{
            _0: optBraces[0].loc
          };
  }
  var match$1 = expr.pexp_desc;
  var match$2 = Res_parsetree_viewer.filterParsingAttrs(expr.pexp_attributes);
  if (match$2 ? true : false) {
    return /* Parenthesized */0;
  }
  if (Res_parsetree_viewer.isUnaryExpression(expr) || Res_parsetree_viewer.isBinaryExpression(expr)) {
    return /* Parenthesized */0;
  }
  if (typeof match$1 === "number") {
    return /* Nothing */1;
  }
  switch (match$1.TAG | 0) {
    case /* Pexp_fun */4 :
        if (Res_parsetree_viewer.isUnderscoreApplySugar(expr)) {
          return /* Nothing */1;
        } else {
          return /* Parenthesized */0;
        }
    case /* Pexp_constraint */19 :
        var tmp = match$1._0.pexp_desc;
        if (typeof tmp === "number") {
          return /* Parenthesized */0;
        }
        if (tmp.TAG !== /* Pexp_pack */32) {
          return /* Parenthesized */0;
        }
        var tmp$1 = match$1._1.ptyp_desc;
        if (typeof tmp$1 === "number" || tmp$1.TAG !== /* Ptyp_package */9) {
          return /* Parenthesized */0;
        } else {
          return /* Nothing */1;
        }
    case /* Pexp_function */3 :
    case /* Pexp_match */6 :
    case /* Pexp_try */7 :
    case /* Pexp_setfield */13 :
    case /* Pexp_ifthenelse */15 :
    case /* Pexp_while */17 :
    case /* Pexp_for */18 :
    case /* Pexp_assert */27 :
    case /* Pexp_lazy */28 :
    case /* Pexp_newtype */31 :
        return /* Parenthesized */0;
    default:
      return /* Nothing */1;
  }
}

function structureExpr(expr) {
  var match = Res_parsetree_viewer.processBracesAttr(expr);
  var optBraces = match[0];
  if (optBraces !== undefined) {
    return /* Braced */{
            _0: optBraces[0].loc
          };
  }
  var match$1 = expr.pexp_desc;
  if (Res_parsetree_viewer.hasAttributes(expr.pexp_attributes) && !Res_parsetree_viewer.isJsxExpression(expr)) {
    return /* Parenthesized */0;
  }
  if (typeof match$1 === "number") {
    return /* Nothing */1;
  }
  if (match$1.TAG !== /* Pexp_constraint */19) {
    return /* Nothing */1;
  }
  var tmp = match$1._0.pexp_desc;
  if (typeof tmp === "number") {
    return /* Parenthesized */0;
  }
  if (tmp.TAG !== /* Pexp_pack */32) {
    return /* Parenthesized */0;
  }
  var tmp$1 = match$1._1.ptyp_desc;
  if (typeof tmp$1 === "number" || tmp$1.TAG !== /* Ptyp_package */9) {
    return /* Parenthesized */0;
  } else {
    return /* Nothing */1;
  }
}

function unaryExprOperand(expr) {
  var match = Res_parsetree_viewer.processBracesAttr(expr);
  var optBraces = match[0];
  if (optBraces !== undefined) {
    return /* Braced */{
            _0: optBraces[0].loc
          };
  }
  var match$1 = expr.pexp_desc;
  var match$2 = Res_parsetree_viewer.filterParsingAttrs(expr.pexp_attributes);
  if (match$2 ? true : false) {
    return /* Parenthesized */0;
  }
  if (Res_parsetree_viewer.isUnaryExpression(expr) || Res_parsetree_viewer.isBinaryExpression(expr)) {
    return /* Parenthesized */0;
  }
  if (typeof match$1 === "number") {
    return /* Nothing */1;
  }
  switch (match$1.TAG | 0) {
    case /* Pexp_fun */4 :
        if (Res_parsetree_viewer.isUnderscoreApplySugar(expr)) {
          return /* Nothing */1;
        } else {
          return /* Parenthesized */0;
        }
    case /* Pexp_constraint */19 :
        var tmp = match$1._0.pexp_desc;
        if (typeof tmp === "number") {
          return /* Parenthesized */0;
        }
        if (tmp.TAG !== /* Pexp_pack */32) {
          return /* Parenthesized */0;
        }
        var tmp$1 = match$1._1.ptyp_desc;
        if (typeof tmp$1 === "number" || tmp$1.TAG !== /* Ptyp_package */9) {
          return /* Parenthesized */0;
        } else {
          return /* Nothing */1;
        }
    case /* Pexp_function */3 :
    case /* Pexp_match */6 :
    case /* Pexp_try */7 :
    case /* Pexp_setfield */13 :
    case /* Pexp_ifthenelse */15 :
    case /* Pexp_while */17 :
    case /* Pexp_for */18 :
    case /* Pexp_assert */27 :
    case /* Pexp_lazy */28 :
    case /* Pexp_newtype */31 :
    case /* Pexp_extension */34 :
        return /* Parenthesized */0;
    default:
      return /* Nothing */1;
  }
}

function binaryExprOperand(isLhs, expr) {
  var match = Res_parsetree_viewer.processBracesAttr(expr);
  var optBraces = match[0];
  if (optBraces !== undefined) {
    return /* Braced */{
            _0: optBraces[0].loc
          };
  }
  var match$1 = expr.pexp_desc;
  var exit = 0;
  if (typeof match$1 === "number") {
    exit = 2;
  } else {
    switch (match$1.TAG | 0) {
      case /* Pexp_fun */4 :
          if (Res_parsetree_viewer.isUnderscoreApplySugar(expr)) {
            return /* Nothing */1;
          } else {
            return /* Parenthesized */0;
          }
      case /* Pexp_constraint */19 :
          var tmp = match$1._0.pexp_desc;
          if (typeof tmp === "number") {
            return /* Parenthesized */0;
          }
          if (tmp.TAG !== /* Pexp_pack */32) {
            return /* Parenthesized */0;
          }
          var tmp$1 = match$1._1.ptyp_desc;
          if (typeof tmp$1 === "number" || tmp$1.TAG !== /* Ptyp_package */9) {
            return /* Parenthesized */0;
          } else {
            return /* Nothing */1;
          }
      case /* Pexp_function */3 :
      case /* Pexp_newtype */31 :
          return /* Parenthesized */0;
      default:
        exit = 2;
    }
  }
  if (exit === 2) {
    if (Res_parsetree_viewer.isBinaryExpression(expr)) {
      return /* Parenthesized */0;
    }
    if (Res_parsetree_viewer.isTernaryExpr(expr)) {
      return /* Parenthesized */0;
    }
    if (typeof match$1 !== "number") {
      switch (match$1.TAG | 0) {
        case /* Pexp_assert */27 :
        case /* Pexp_lazy */28 :
            if (isLhs) {
              return /* Parenthesized */0;
            }
            break;
        default:
          
      }
    }
    
  }
  if (Res_parsetree_viewer.hasPrintableAttributes(expr.pexp_attributes)) {
    return /* Parenthesized */0;
  } else {
    return /* Nothing */1;
  }
}

function subBinaryExprOperand(parentOperator, childOperator) {
  var precParent = Res_parsetree_viewer.operatorPrecedence(parentOperator);
  var precChild = Res_parsetree_viewer.operatorPrecedence(childOperator);
  if (precParent > precChild || precParent === precChild && !Res_parsetree_viewer.flattenableOperators(parentOperator, childOperator)) {
    return true;
  } else if (parentOperator === "||") {
    return childOperator === "&&";
  } else {
    return false;
  }
}

function rhsBinaryExprOperand(parentOperator, rhs) {
  var match = rhs.pexp_desc;
  if (typeof match === "number") {
    return false;
  }
  if (match.TAG !== /* Pexp_apply */5) {
    return false;
  }
  var match$1 = match._0;
  var match$2 = match$1.pexp_desc;
  if (typeof match$2 === "number") {
    return false;
  }
  if (match$2.TAG !== /* Pexp_ident */0) {
    return false;
  }
  var match$3 = match$2._0;
  var operator = match$3.txt;
  switch (operator.TAG | 0) {
    case /* Lident */0 :
        if (match$1.pexp_attributes) {
          return false;
        }
        var match$4 = match._1;
        if (!match$4) {
          return false;
        }
        var match$5 = match$4.tl;
        if (!match$5) {
          return false;
        }
        if (match$5.tl) {
          return false;
        }
        var operator$1 = operator._0;
        if (!(Res_parsetree_viewer.isBinaryOperator(operator$1) && !(match$3.loc.loc_ghost && operator$1 === "^"))) {
          return false;
        }
        var precParent = Res_parsetree_viewer.operatorPrecedence(parentOperator);
        var precChild = Res_parsetree_viewer.operatorPrecedence(operator$1);
        return precParent === precChild;
    case /* Ldot */1 :
    case /* Lapply */2 :
        return false;
    
  }
}

function flattenOperandRhs(parentOperator, rhs) {
  var match = rhs.pexp_desc;
  if (typeof match !== "number") {
    switch (match.TAG | 0) {
      case /* Pexp_fun */4 :
          if (Res_parsetree_viewer.isUnderscoreApplySugar(rhs)) {
            return false;
          } else {
            return true;
          }
      case /* Pexp_apply */5 :
          var match$1 = match._0.pexp_desc;
          if (typeof match$1 !== "number" && match$1.TAG === /* Pexp_ident */0) {
            var match$2 = match$1._0;
            var operator = match$2.txt;
            switch (operator.TAG | 0) {
              case /* Lident */0 :
                  var match$3 = match._1;
                  if (match$3) {
                    var match$4 = match$3.tl;
                    if (match$4 && !match$4.tl) {
                      var operator$1 = operator._0;
                      if (Res_parsetree_viewer.isBinaryOperator(operator$1) && !(match$2.loc.loc_ghost && operator$1 === "^")) {
                        var precParent = Res_parsetree_viewer.operatorPrecedence(parentOperator);
                        var precChild = Res_parsetree_viewer.operatorPrecedence(operator$1);
                        if (precParent >= precChild) {
                          return true;
                        } else {
                          return rhs.pexp_attributes !== /* [] */0;
                        }
                      }
                      
                    }
                    
                  }
                  break;
              case /* Ldot */1 :
              case /* Lapply */2 :
                  break;
              
            }
          }
          break;
      case /* Pexp_constraint */19 :
          var tmp = match._0.pexp_desc;
          if (typeof tmp === "number") {
            return true;
          }
          if (tmp.TAG !== /* Pexp_pack */32) {
            return true;
          }
          var tmp$1 = match._1.ptyp_desc;
          if (typeof tmp$1 === "number" || tmp$1.TAG !== /* Ptyp_package */9) {
            return true;
          } else {
            return false;
          }
      case /* Pexp_setfield */13 :
      case /* Pexp_newtype */31 :
          return true;
      default:
        
    }
  }
  if (Res_parsetree_viewer.isTernaryExpr(rhs)) {
    return true;
  } else {
    return false;
  }
}

function lazyOrAssertExprRhs(expr) {
  var match = Res_parsetree_viewer.processBracesAttr(expr);
  var optBraces = match[0];
  if (optBraces !== undefined) {
    return /* Braced */{
            _0: optBraces[0].loc
          };
  }
  var match$1 = expr.pexp_desc;
  var match$2 = Res_parsetree_viewer.filterParsingAttrs(expr.pexp_attributes);
  if (match$2 ? true : false) {
    return /* Parenthesized */0;
  }
  if (Res_parsetree_viewer.isBinaryExpression(expr)) {
    return /* Parenthesized */0;
  }
  if (typeof match$1 === "number") {
    return /* Nothing */1;
  }
  switch (match$1.TAG | 0) {
    case /* Pexp_fun */4 :
        if (Res_parsetree_viewer.isUnderscoreApplySugar(expr)) {
          return /* Nothing */1;
        } else {
          return /* Parenthesized */0;
        }
    case /* Pexp_constraint */19 :
        var tmp = match$1._0.pexp_desc;
        if (typeof tmp === "number") {
          return /* Parenthesized */0;
        }
        if (tmp.TAG !== /* Pexp_pack */32) {
          return /* Parenthesized */0;
        }
        var tmp$1 = match$1._1.ptyp_desc;
        if (typeof tmp$1 === "number" || tmp$1.TAG !== /* Ptyp_package */9) {
          return /* Parenthesized */0;
        } else {
          return /* Nothing */1;
        }
    case /* Pexp_function */3 :
    case /* Pexp_match */6 :
    case /* Pexp_try */7 :
    case /* Pexp_setfield */13 :
    case /* Pexp_ifthenelse */15 :
    case /* Pexp_while */17 :
    case /* Pexp_for */18 :
    case /* Pexp_assert */27 :
    case /* Pexp_lazy */28 :
    case /* Pexp_newtype */31 :
        return /* Parenthesized */0;
    default:
      return /* Nothing */1;
  }
}

function isNegativeConstant(constant) {
  var isNeg = function (txt) {
    var len = txt.length;
    if (len > 0) {
      return Caml_string.get(txt, 0) === /* '-' */45;
    } else {
      return false;
    }
  };
  switch (constant.TAG | 0) {
    case /* Pconst_char */1 :
    case /* Pconst_string */2 :
        return false;
    case /* Pconst_integer */0 :
    case /* Pconst_float */3 :
        if (isNeg(constant._0)) {
          return true;
        } else {
          return false;
        }
    
  }
}

function fieldExpr(expr) {
  var match = Res_parsetree_viewer.processBracesAttr(expr);
  var optBraces = match[0];
  if (optBraces !== undefined) {
    return /* Braced */{
            _0: optBraces[0].loc
          };
  }
  var c = expr.pexp_desc;
  var match$1 = Res_parsetree_viewer.filterParsingAttrs(expr.pexp_attributes);
  if (match$1 ? true : false) {
    return /* Parenthesized */0;
  }
  if (Res_parsetree_viewer.isBinaryExpression(expr) || Res_parsetree_viewer.isUnaryExpression(expr)) {
    return /* Parenthesized */0;
  }
  if (typeof c === "number") {
    return /* Nothing */1;
  }
  switch (c.TAG | 0) {
    case /* Pexp_constant */1 :
        if (isNegativeConstant(c._0)) {
          return /* Parenthesized */0;
        } else {
          return /* Nothing */1;
        }
    case /* Pexp_fun */4 :
        if (Res_parsetree_viewer.isUnderscoreApplySugar(expr)) {
          return /* Nothing */1;
        } else {
          return /* Parenthesized */0;
        }
    case /* Pexp_constraint */19 :
        var tmp = c._0.pexp_desc;
        if (typeof tmp === "number") {
          return /* Parenthesized */0;
        }
        if (tmp.TAG !== /* Pexp_pack */32) {
          return /* Parenthesized */0;
        }
        var tmp$1 = c._1.ptyp_desc;
        if (typeof tmp$1 === "number" || tmp$1.TAG !== /* Ptyp_package */9) {
          return /* Parenthesized */0;
        } else {
          return /* Nothing */1;
        }
    case /* Pexp_function */3 :
    case /* Pexp_match */6 :
    case /* Pexp_try */7 :
    case /* Pexp_setfield */13 :
    case /* Pexp_ifthenelse */15 :
    case /* Pexp_while */17 :
    case /* Pexp_for */18 :
    case /* Pexp_assert */27 :
    case /* Pexp_lazy */28 :
    case /* Pexp_newtype */31 :
    case /* Pexp_extension */34 :
        return /* Parenthesized */0;
    default:
      return /* Nothing */1;
  }
}

function setFieldExprRhs(expr) {
  var match = Res_parsetree_viewer.processBracesAttr(expr);
  var optBraces = match[0];
  if (optBraces !== undefined) {
    return /* Braced */{
            _0: optBraces[0].loc
          };
  }
  var match$1 = expr.pexp_desc;
  if (typeof match$1 === "number") {
    return /* Nothing */1;
  }
  if (match$1.TAG !== /* Pexp_constraint */19) {
    return /* Nothing */1;
  }
  var tmp = match$1._0.pexp_desc;
  if (typeof tmp === "number") {
    return /* Parenthesized */0;
  }
  if (tmp.TAG !== /* Pexp_pack */32) {
    return /* Parenthesized */0;
  }
  var tmp$1 = match$1._1.ptyp_desc;
  if (typeof tmp$1 === "number" || tmp$1.TAG !== /* Ptyp_package */9) {
    return /* Parenthesized */0;
  } else {
    return /* Nothing */1;
  }
}

function ternaryOperand(expr) {
  var match = Res_parsetree_viewer.processBracesAttr(expr);
  var optBraces = match[0];
  if (optBraces !== undefined) {
    return /* Braced */{
            _0: optBraces[0].loc
          };
  }
  var match$1 = expr.pexp_desc;
  if (typeof match$1 === "number") {
    return /* Nothing */1;
  }
  switch (match$1.TAG | 0) {
    case /* Pexp_constraint */19 :
        var tmp = match$1._0.pexp_desc;
        if (typeof tmp === "number") {
          return /* Parenthesized */0;
        }
        if (tmp.TAG !== /* Pexp_pack */32) {
          return /* Parenthesized */0;
        }
        var tmp$1 = match$1._1.ptyp_desc;
        if (typeof tmp$1 === "number" || tmp$1.TAG !== /* Ptyp_package */9) {
          return /* Parenthesized */0;
        } else {
          return /* Nothing */1;
        }
    case /* Pexp_fun */4 :
    case /* Pexp_newtype */31 :
        break;
    default:
      return /* Nothing */1;
  }
  var match$2 = Res_parsetree_viewer.funExpr(expr);
  var match$3 = match$2[2].pexp_desc;
  if (typeof match$3 === "number" || match$3.TAG !== /* Pexp_constraint */19) {
    return /* Nothing */1;
  } else {
    return /* Parenthesized */0;
  }
}

function startsWithMinus(txt) {
  var len = txt.length;
  if (len === 0) {
    return false;
  }
  var s = Caml_string.get(txt, 0);
  return s === /* '-' */45;
}

function jsxPropExpr(expr) {
  var match = expr.pexp_desc;
  var exit = 0;
  if (typeof match === "number") {
    exit = 1;
  } else {
    switch (match.TAG | 0) {
      case /* Pexp_let */2 :
      case /* Pexp_sequence */16 :
      case /* Pexp_letmodule */25 :
      case /* Pexp_letexception */26 :
      case /* Pexp_open */33 :
          return /* Nothing */1;
      default:
        exit = 1;
    }
  }
  if (exit === 1) {
    var match$1 = Res_parsetree_viewer.processBracesAttr(expr);
    var optBraces = match$1[0];
    if (optBraces !== undefined) {
      return /* Braced */{
              _0: optBraces[0].loc
            };
    }
    var match$2 = expr.pexp_desc;
    var exit$1 = 0;
    if (typeof match$2 === "number") {
      return /* Parenthesized */0;
    }
    switch (match$2.TAG | 0) {
      case /* Pexp_constant */1 :
          var match$3 = match$2._0;
          var exit$2 = 0;
          switch (match$3.TAG | 0) {
            case /* Pconst_char */1 :
            case /* Pconst_string */2 :
                exit$1 = 2;
                break;
            case /* Pconst_integer */0 :
            case /* Pconst_float */3 :
                exit$2 = 3;
                break;
            
          }
          if (exit$2 === 3) {
            if (expr.pexp_attributes) {
              exit$1 = 2;
            } else {
              if (startsWithMinus(match$3._0)) {
                return /* Parenthesized */0;
              }
              exit$1 = 2;
            }
          }
          break;
      case /* Pexp_constraint */19 :
          var tmp = match$2._0.pexp_desc;
          if (typeof tmp === "number") {
            return /* Parenthesized */0;
          }
          if (tmp.TAG !== /* Pexp_pack */32) {
            return /* Parenthesized */0;
          }
          var tmp$1 = match$2._1.ptyp_desc;
          if (typeof tmp$1 === "number" || !(tmp$1.TAG === /* Ptyp_package */9 && !expr.pexp_attributes)) {
            return /* Parenthesized */0;
          } else {
            return /* Nothing */1;
          }
      case /* Pexp_ident */0 :
      case /* Pexp_let */2 :
      case /* Pexp_tuple */8 :
      case /* Pexp_construct */9 :
      case /* Pexp_variant */10 :
      case /* Pexp_record */11 :
      case /* Pexp_field */12 :
      case /* Pexp_array */14 :
      case /* Pexp_sequence */16 :
      case /* Pexp_letmodule */25 :
      case /* Pexp_letexception */26 :
      case /* Pexp_pack */32 :
      case /* Pexp_open */33 :
      case /* Pexp_extension */34 :
          exit$1 = 2;
          break;
      default:
        return /* Parenthesized */0;
    }
    if (exit$1 === 2) {
      if (expr.pexp_attributes) {
        return /* Parenthesized */0;
      } else {
        return /* Nothing */1;
      }
    }
    
  }
  
}

function jsxChildExpr(expr) {
  var match = expr.pexp_desc;
  var exit = 0;
  if (typeof match === "number") {
    exit = 1;
  } else {
    switch (match.TAG | 0) {
      case /* Pexp_let */2 :
      case /* Pexp_sequence */16 :
      case /* Pexp_letmodule */25 :
      case /* Pexp_letexception */26 :
      case /* Pexp_open */33 :
          return /* Nothing */1;
      default:
        exit = 1;
    }
  }
  if (exit === 1) {
    var match$1 = Res_parsetree_viewer.processBracesAttr(expr);
    var optBraces = match$1[0];
    if (optBraces !== undefined) {
      return /* Braced */{
              _0: optBraces[0].loc
            };
    }
    var match$2 = expr.pexp_desc;
    var exit$1 = 0;
    var exit$2 = 0;
    if (typeof match$2 === "number") {
      exit$1 = 2;
    } else {
      switch (match$2.TAG | 0) {
        case /* Pexp_constant */1 :
            var match$3 = match$2._0;
            var exit$3 = 0;
            switch (match$3.TAG | 0) {
              case /* Pconst_char */1 :
              case /* Pconst_string */2 :
                  exit$2 = 3;
                  break;
              case /* Pconst_integer */0 :
              case /* Pconst_float */3 :
                  exit$3 = 4;
                  break;
              
            }
            if (exit$3 === 4) {
              if (expr.pexp_attributes) {
                exit$2 = 3;
              } else {
                if (startsWithMinus(match$3._0)) {
                  return /* Parenthesized */0;
                }
                exit$2 = 3;
              }
            }
            break;
        case /* Pexp_constraint */19 :
            var tmp = match$2._0.pexp_desc;
            if (typeof tmp === "number" || tmp.TAG !== /* Pexp_pack */32) {
              exit$1 = 2;
            } else {
              var tmp$1 = match$2._1.ptyp_desc;
              if (typeof tmp$1 === "number" || tmp$1.TAG !== /* Ptyp_package */9) {
                exit$1 = 2;
              } else {
                if (!expr.pexp_attributes) {
                  return /* Nothing */1;
                }
                exit$1 = 2;
              }
            }
            break;
        case /* Pexp_ident */0 :
        case /* Pexp_let */2 :
        case /* Pexp_construct */9 :
        case /* Pexp_variant */10 :
        case /* Pexp_record */11 :
        case /* Pexp_field */12 :
        case /* Pexp_array */14 :
        case /* Pexp_sequence */16 :
        case /* Pexp_letmodule */25 :
        case /* Pexp_letexception */26 :
        case /* Pexp_pack */32 :
        case /* Pexp_open */33 :
        case /* Pexp_extension */34 :
            exit$2 = 3;
            break;
        default:
          exit$1 = 2;
      }
    }
    if (exit$2 === 3) {
      if (!expr.pexp_attributes) {
        return /* Nothing */1;
      }
      exit$1 = 2;
    }
    if (exit$1 === 2) {
      if (Res_parsetree_viewer.isJsxExpression(expr)) {
        return /* Nothing */1;
      } else {
        return /* Parenthesized */0;
      }
    }
    
  }
  
}

function binaryExpr(expr) {
  var match = Res_parsetree_viewer.processBracesAttr(expr);
  var optBraces = match[0];
  if (optBraces !== undefined) {
    return /* Braced */{
            _0: optBraces[0].loc
          };
  } else if (expr.pexp_attributes && Res_parsetree_viewer.isBinaryExpression(expr)) {
    return /* Parenthesized */0;
  } else {
    return /* Nothing */1;
  }
}

function modTypeFunctorReturn(modType) {
  if (modType.pmty_desc.TAG === /* Pmty_with */3) {
    return true;
  } else {
    return false;
  }
}

function modTypeWithOperand(modType) {
  switch (modType.pmty_desc.TAG | 0) {
    case /* Pmty_functor */2 :
    case /* Pmty_with */3 :
        return true;
    default:
      return false;
  }
}

function modExprFunctorConstraint(modType) {
  switch (modType.pmty_desc.TAG | 0) {
    case /* Pmty_functor */2 :
    case /* Pmty_with */3 :
        return true;
    default:
      return false;
  }
}

function bracedExpr(expr) {
  var match = expr.pexp_desc;
  if (typeof match === "number") {
    return false;
  }
  if (match.TAG !== /* Pexp_constraint */19) {
    return false;
  }
  var tmp = match._0.pexp_desc;
  if (typeof tmp === "number") {
    return true;
  }
  if (tmp.TAG !== /* Pexp_pack */32) {
    return true;
  }
  var tmp$1 = match._1.ptyp_desc;
  if (typeof tmp$1 === "number" || tmp$1.TAG !== /* Ptyp_package */9) {
    return true;
  } else {
    return false;
  }
}

function includeModExpr(modExpr) {
  var match = modExpr.pmod_desc;
  if (match.TAG === /* Pmod_constraint */4) {
    return true;
  } else {
    return false;
  }
}

function arrowReturnTypExpr(typExpr) {
  var match = typExpr.ptyp_desc;
  if (typeof match === "number" || match.TAG !== /* Ptyp_arrow */1) {
    return false;
  } else {
    return true;
  }
}

function patternRecordRowRhs(pattern) {
  var match = pattern.ppat_desc;
  if (typeof match === "number") {
    return false;
  }
  if (match.TAG !== /* Ppat_constraint */10) {
    return false;
  }
  var tmp = match._0.ppat_desc;
  if (typeof tmp === "number") {
    return true;
  }
  if (tmp.TAG !== /* Ppat_unpack */13) {
    return true;
  }
  var tmp$1 = match._1.ptyp_desc;
  if (typeof tmp$1 === "number" || tmp$1.TAG !== /* Ptyp_package */9) {
    return true;
  } else {
    return false;
  }
}

var ParsetreeViewer;

export {
  ParsetreeViewer ,
  expr ,
  callExpr ,
  structureExpr ,
  unaryExprOperand ,
  binaryExprOperand ,
  subBinaryExprOperand ,
  rhsBinaryExprOperand ,
  flattenOperandRhs ,
  lazyOrAssertExprRhs ,
  isNegativeConstant ,
  fieldExpr ,
  setFieldExprRhs ,
  ternaryOperand ,
  startsWithMinus ,
  jsxPropExpr ,
  jsxChildExpr ,
  binaryExpr ,
  modTypeFunctorReturn ,
  modTypeWithOperand ,
  modExprFunctorConstraint ,
  bracedExpr ,
  includeModExpr ,
  arrowReturnTypExpr ,
  patternRecordRowRhs ,
  
}
/* No side effect */
