# multiplication method

Node multiplication ()

Search for:

``````operand operator operandN
operator is * | /
operandN is 0 | more operands
``````

Example:

``````@a
@a * 2
@a * @b / 2
``````

## Implementation

``````Node multiplication() {
Node a;
bool isSpaced;
Node m;
String op;
Operation operation;

m = operand();
if (m != null) {
isSpaced = parserInput.isWhitespacePrevPos();
while (true) {

parserInput.save();

op = parserInput.\$char('/') ??
parserInput.\$char('*') ??
parserInput.\$str('./');
if (op == null) {
parserInput.forget();
break;
}

a = operand();
if (a == null) {
parserInput.restore();
break;
}

parserInput.forget();
m.parensInOp = true;
a.parensInOp = true;
operation =
Operation(op, <Node>[operation ?? m, a], isSpaced: isSpaced);
isSpaced = parserInput.isWhitespacePrevPos();
}
return operation ?? m;
}
return null;

//3.0.4 20180625
//  multiplication: function () {
//      var m, a, op, operation, isSpaced;
//      m = this.operand();
//      if (m) {
//          isSpaced = parserInput.isWhitespace(-1);
//          while (true) {
//              if (parserInput.peek(/^\/[*\/]/)) {
//                  break;
//              }
//
//              parserInput.save();
//
//              op = parserInput.\$char('/') || parserInput.\$char('*') || parserInput.\$str('./');
//
//              if (!op) { parserInput.forget(); break; }
//
//              a = this.operand();
//
//              if (!a) { parserInput.restore(); break; }
//              parserInput.forget();
//
//              m.parensInOp = true;
//              a.parensInOp = true;
//              operation = new(tree.Operation)(op, [operation || m, a], isSpaced);
//              isSpaced = parserInput.isWhitespace(-1);
//          }
//          return operation || m;
//      }
//  },
}``````