processFunction method

dynamic processFunction(
  1. Identifier func
)

Implementation

dynamic processFunction(Identifier func) {
  var name = func.name;

  switch (name) {
    case 'rgb':
      var expr = processExpr();
      if (!_maybeEat(TokenKind.RPAREN)) {
        _error('problem parsing function expected ), ');
      }
      return 'rgb($expr)';
    case 'url':
      // URI term sucks up everything inside of quotes(' or ") or between
      // parens.
      var urlParam = processQuotedString(true);

      // TODO(terry): Better error message and checking for mismatched quotes.
      if (_peek() == TokenKind.END_OF_FILE) {
        _error('problem parsing URI');
      }

      if (_peek() == TokenKind.RPAREN) {
        _next();
      }

      return 'url($urlParam)';
    case 'var':
      // TODO(terry): Consider handling var in IE specific filter/progid.
      //              This will require parsing entire IE specific syntax
      //              e.g. `param = value` or `progid:com_id`, etc.
      //              for example:
      //
      //    var-blur: Blur(Add = 0, Direction = 225, Strength = 10);
      //    var-gradient: progid:DXImageTransform.Microsoft.gradient"
      //      (GradientType=0,StartColorStr='#9d8b83', EndColorStr='#847670');
      var expr = processExpr();
      if (!_maybeEat(TokenKind.RPAREN)) {
        _error('problem parsing var expected');
      }
      return expr;
    default:
      var expr = processExpr();
      if (!_maybeEat(TokenKind.RPAREN)) {
        _error('problem parsing function expected');
      }
      return expr;
  }
}