url method

URL url ()

Parse url() tokens

We use a specific rule for urls, because they don't really behave like standard function calls. The difference is that the argument doesn't have to be enclosed within a string, so it can't be parsed as an Expression.

Implementation

URL url() {
  final int index = parserInput.i;
  Node value;

  parserInput.autoCommentAbsorb = false;

  if (parserInput.$str('url(') == null) {
    parserInput.autoCommentAbsorb = true;
    return null;
  }

  value = quoted() ??
      variable() ??
      property() ??
      Anonymous(parserInput.$re(_urlRegExp) ?? '');

  parserInput
    ..autoCommentAbsorb = true
    ..expectChar(')');
  return URL(
      (value.value != null) || (value is Variable) || (value is Property)
          ? value
          : Anonymous(value, index: index),
      index: index,
      currentFileInfo: fileInfo);

//3.0.0 20160718
// url: function () {
//     var value, index = parserInput.i;
//
//     parserInput.autoCommentAbsorb = false;
//
//     if (!parserInput.$str("url(")) {
//         parserInput.autoCommentAbsorb = true;
//         return;
//     }
//
//     value = this.quoted() || this.variable() || this.property() ||
//             parserInput.$re(/^(?:(?:\\[\(\)'"])|[^\(\)'"])+/) || "";
//
//     parserInput.autoCommentAbsorb = true;
//
//     expectChar(')');
//
//     return new(tree.URL)((value.value != null ||
//         value instanceof tree.Variable ||
//         value instanceof tree.Property) ?
//         value : new(tree.Anonymous)(value, index), index, fileInfo);
// },
}