attribute method

Attribute attribute ()

Attribute is a operation inside []:

[key operator value]

Example:

[type = "text"]

Implementation

Attribute attribute() {
  if (parserInput.$char('[') == null) return null;

  dynamic key; //String or Node
  String op;
  dynamic val; //String or Node

  key = entities.variableCurly() ?? parserInput.expect(_attributeRegExp4);

  op = parserInput.$re(_attributeRegExp1);
  if (op != null) {
    val = entities.quoted() ??
        parserInput.$re(_attributeRegExp2) ??
        parserInput.$re(_attributeRegExp3) ??
        entities.variableCurly();
  }

  parserInput.expectChar(']');
  return Attribute(key, op, val);

//2.2.0
//  attribute: function () {
//      if (! parserInput.$char('[')) { return; }
//
//      var entities = this.entities,
//          key, val, op;
//
//      if (!(key = entities.variableCurly())) {
//          key = expect(/^(?:[_A-Za-z0-9-\*]*\|)?(?:[_A-Za-z0-9-]|\\.)+/);
//      }
//
//      op = parserInput.$re(/^[|~*$^]?=/);
//      if (op) {
//          val = entities.quoted() || parserInput.$re(/^[0-9]+%/) || parserInput.$re(/^[\w-]+/) || entities.variableCurly();
//      }
//
//      expectChar(']');
//
//      return new(tree.Attribute)(key, op, val);
//  }
}