condition method

Condition condition ({bool needsParens: false })

Inside a MixinDefinition, conditions such as when, and, or, not, ...

Example:

when ((@1) and (@2) or (@3))

.light (@a) when (lightness(@a) > 50%) {
  color: white;
}

Implementation

Condition condition({bool needsParens = false}) {
  String or() => parserInput.$str('or');

  Condition result = conditionAnd(needsParens: needsParens);
  if (result == null) return null;

  final String logical = or();
  if (logical != null) {
    final Condition next = condition(needsParens: needsParens);
    if (next != null) {
      result = Condition(logical, result, next);
    } else {
      return null;
    }
  }
  return result;

// 3.5.3 20180708
//  condition: function (needsParens) {
//      var result, logical, next;
//      function or() {
//          return parserInput.$str('or');
//      }
//
//      result = this.conditionAnd(needsParens);
//      if (!result) {
//          return ;
//      }
//      logical = or();
//      if (logical) {
//          next = this.condition(needsParens);
//          if (next) {
//              result = new(tree.Condition)(logical, result, next);
//          } else {
//              return ;
//          }
//      }
//      return result;
//  },
}