arithmeticExpr function
Arithmetic expression: term (arithmeticOp term)? Note: Single operation only for now (no chaining like a + b + c)
Implementation
Parser arithmeticExpr() {
return (ref0(primaryTerm).trim() &
(ref0(arithmeticOperator) & ref0(primaryTerm).trim()).optional())
.map((values) {
final left = values[0];
final opAndRight = values[1];
if (opAndRight == null) {
return left;
}
final op = opAndRight[0];
final right = opAndRight[1];
return BinaryOperation(left, op, right);
})
.labeled('arithmeticExpr');
}