processExpr method

String? processExpr([
  1. bool ieFilter = false
])

Implementation

String? processExpr([bool ieFilter = false]) {
  var start = _peekToken.span;
  FileSpan? end;

  bool hasSynaxError = false;

  var parenCount = 0;
  while (!_maybeEat(TokenKind.END_OF_FILE)) {
    if (_peek() == TokenKind.LPAREN) {
      parenCount++;
    }
    if (_peek() == TokenKind.RPAREN) {
      parenCount--;
    }
    if (parenCount <= 0 && (_peek() == TokenKind.SEMICOLON || _peek() == TokenKind.RBRACE)) {
      break;
    }
    if (_peek() == TokenKind.IMPORTANT) {
      if (parenCount == 0) {
        break;
      } else {
        // synax error
        hasSynaxError = true;
      }
    }
    end = _next().span;
  }
  if (hasSynaxError || parenCount < 0) {
    return null;
  }
  if (end != null) {
    return start.expand(end).text;
  }
  return _peekToken.text;
}