processCalcExpression method

String processCalcExpression()

Implementation

String processCalcExpression() {
  var inString = tokenizer._inString;
  tokenizer._inString = false;

  // Gobble up everything until we hit our stop token.
  var stringValue = StringBuffer();
  var left = 1;
  var matchingParens = false;
  while (_peek() != TokenKind.END_OF_FILE && !matchingParens) {
    var token = _peek();
    if (token == TokenKind.LPAREN) {
      left++;
    } else if (token == TokenKind.RPAREN) {
      left--;
    }

    matchingParens = left == 0;
    if (!matchingParens) stringValue.write(_next().text);
  }

  if (!matchingParens) {
    _error('problem parsing function expected ), ');
  }

  tokenizer._inString = inString;

  return stringValue.toString();
}