parse spec

@param {any} spec
@returns
7644
function parseSwitch (spec) {
  const select = spec.select
  const defaultStatement = parseDefaultStatement(spec.id, select)
  return {
    cases: parseCaseStatements(select),
    default: createReducer(defaultStatement)
  }
}
528663
private URI _getSpecURI(String spec) {
        URI specURI = URI.create(spec);

        if (_scheme.indexOf(':') == -1) {
            return specURI;
        }
        
        String schemeSpecificPart = specURI.getSchemeSpecificPart();
        return URI.create(schemeSpecificPart);
    }
1122082
public function parse(Fixture $fixture, array $fixtures, $spec)
    {
        preg_match(self::REGEX, $spec, $matches);
        if (empty($matches)) {
            return $fixtures;
        }

        $list = $matches[0];
        $name = substr($spec, 0, strpos($spec, $list));

        preg_match_all('/[^,{}]+/', $list, $keys);
        if (empty($keys)) {
            return $fixtures;
        }

        $keys = array_map(function ($key) {
            return trim($key);
        }, $keys[0]);
        foreach ($keys as $item) {
            $newFixture = clone $fixture;
            $newFixture->setName($name . $item);
            $newFixture->setSpec($item);
            $fixtures[$name . $item] = $newFixture;
        }

        return $fixtures;
    }
415567
function spec(node, body, objId, initProps, file) {
  // add a simple assignment for all Symbol member expressions due to symbol polyfill limitations
  // otherwise use Object.defineProperty

  var _arr2 = node.properties;
  for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
    var prop = _arr2[_i2];
    // this wont work with Object.defineProperty
    if (t.isLiteral(t.toComputedKey(prop), { value: "__proto__" })) {
      initProps.push(prop);
      continue;
    }

    var key = prop.key;
    if (t.isIdentifier(key) && !prop.computed) {
      key = t.literal(key.name);
    }

    var bodyNode = t.callExpression(file.addHelper("define-property"), [objId, key, prop.value]);

    body.push(t.expressionStatement(bodyNode));
  }

  // only one node and it's a Object.defineProperty that returns the object

  if (body.length === 1) {
    var first = body[0].expression;

    if (t.isCallExpression(first)) {
      first.arguments[0] = t.objectExpression(initProps);
      return first;
    }
  }
}
329107
public static String toWindows(String spec) {
      if (spec == null) {
         return StringUtils.EMPTY;
      }
      return spec.replaceAll("/+", "\\\\");
   }
342179
def cpp_spec():
    """"""
    return {
        INDENTATION    : '\t',
        BEG_BLOCK      : '{',
        END_BLOCK      : '}',
        BEG_LINE       : '',
        END_LINE       : '\n',
        BEG_ACTION     : '',
        END_ACTION     : ';',
        BEG_CONDITION  : 'if(',
        END_CONDITION  : ')',
        LOGICAL_AND    : ' && ',
        LOGICAL_OR     : ' || '
    }
343734
function getSpec(spec) {
            __specs[spec.id] = extend(__specs[spec.id] || {}, spec);
            return __specs[spec.id];
        }
1174716
static Tree parse(String spec) throws IllegalArgumentException {
        Reader r = new Reader(spec);
        Tree t = new Tree();
        list(r, t);
        r.expect(Token.EOF);
        return t;
    }
847660
function parseTagSpec(specString) {
    if (!specString || !specString.match) throw new ParseError(specString)
    if (specCache[specString]) return specCache[specString]

    // Parse tagName, and optional type attribute
    var tagMatch = specString.match(tagNameRegex)
    if (!tagMatch) {
        if (specString.match(propsRegex)) tagMatch = ['div', 'div'] // create <div> if tagname omitted
        else throw new ParseError(specString)
    }
    var tagName = tagMatch[1]
    var props = {}
    var classes = []

    if (specString.match(autoKeyGenRegex)) props.key = specString
    if (tagMatch[2]) props.type = tagMatch[2]
    else if (tagName === 'button') props.type = 'button' // Saner default for <button>

    var matches = specString.match(propsRegex)
    matches && matches.forEach(function getRegexMatches(str) {
        if (!str) return
        else if (str[0] === '#') props.id = str.slice(1)
        else if (str[0] === '@') props.ref = str.slice(1)
        else if (str[0] === '.') classes.push(str.slice(1))
        else if (str[0] === '[') {
            var match = str.match(attrRegex)
            if (match) props[match[1]] = match[2] || true    // If no attr value given, use true
        }
    })
    if (classes.length) props.className = classes.join(' ')

    var spec = {
        tagName: tagName,
        props: props
    }

    specCache[specString] = spec
    return spec
}
24799
public static Pattern parseFilter( final String spec )
    {
        StringBuffer sb = new StringBuffer();
        for( int j = 0; j < spec.length(); j++ )
        {
            char c = spec.charAt( j );
            switch( c )
            {
                case '.':
                    sb.append( "\\." );
                    break;

                case '*':
                    // test for ** (all directories)
                    if( j < spec.length() - 1 && spec.charAt( j + 1 ) == '*' )
                    {
                        sb.append( ".*" );
                        j++;
                    }
                    else
                    {
                        sb.append( "[^/]*" );
                    }
                    break;
                default:
                    sb.append( c );
                    break;
            }
        }
        String s = sb.toString();
        try
        {
            return Pattern.compile( s );
        }
        catch( Exception e )
        {
            throw new IllegalArgumentException( "Invalid character used in the filter name", e );
        }
    }
690042
public static String getPartitionSpecString(Map<String, String> spec) {
    StringBuilder sb = new StringBuilder();
    for (Map.Entry<String, String> entry : spec.entrySet()) {
      if (!sb.toString().isEmpty()) {
        sb.append(",");
      }
      sb.append(entry.getKey());
      sb.append("=");
      sb.append(getQuotedString(entry.getValue()));
    }
    return sb.toString();
  }
862283
function (token) {
        token.consume("!");
        var ast = this.parse_spec(token); /*  RECURSION  */
        ast = { type: "not", op: ast };
        return ast;
    }
456092
function getParams(spec_c, details, method, parent) {
  var spec_js = {};
  _.each(spec_c, function(param) {
    try {
      var paramType = getType(getText(getChild(param, 'type'), 'type'), parent);
      var paramName = getText(getChild(param, 'declname'), 'name');
      spec_js[paramName] = { type: paramType };
    } catch(e) {
      if (paramType == '...') {
        spec_js['arguments'] = { type: paramType };
      } else {
        throw e;
      }
    }
  });
  _.each(details, function(param) {
    var getParamName = function(p) { return getText(getChild(getChild(p, 'parameternamelist'), 'parametername'), 'name'); }
    var paramName = getParamName(param);
    var paramDescription = getText(getChild(param, 'parameterdescription'), 'description');
    if (_.has(spec_js, paramName)) {
      spec_js[paramName].description = paramDescription;
    } else {
      var msg = ' has documentation for an unknown parameter: ' + paramName + '. ';
      var suggestions = _.difference(_.keys(spec_js), _.map(details, getParamName));
      var msgAddendum = (!_.isEmpty(suggestions) ? ('Did you mean ' + suggestions.join(', or ') + '?') : '');
      console.log('Warning: ' + (parent ? (parent + '.') : '') + method + msg + msgAddendum);
    }
  });
  return spec_js;
}
610935
function defaultValue(spec)
{
  if (util.isRegExp(spec)) return "";
	return ({
        "string": "",
        "id": null,
        "number": 0,
        "boolean": false,
        "date": new Date(),
        "regexp": new RegExp(),
        "function": function() { },
        "array": [],
        "object": {}
    })[spec];
}
330569
function conformDispatch (spec) {
  if ('schema' in spec) {
    return 'schema'
  } else if ('$ref' in spec) {
    return '$ref'
  } else if ('enum' in spec) {
    return 'enum'
  } else if ('allOf' in spec) {
    return 'allOf'
  } else if ('type' in spec) {
    return spec.type
  } else {
    throw Object.assign(Error('Could not determine type'), { spec })
  }
}
991502
function parse (packageName) {
  if (!packageName || !packageNameRegexp.test(packageName)) {
    return null
  }

  const slashIndex = packageName.indexOf('/')
  const atLastIndex = packageName.lastIndexOf('@')
  const hasScope = slashIndex !== -1
  const hasVersion = atLastIndex !== -1 && atLastIndex !== 0

  let scope = ''
  let name = ''
  let version = ''

  if (hasScope && hasVersion) {
    scope = packageName.slice(1, slashIndex)
    name = packageName.slice(slashIndex + 1, atLastIndex)
    version = packageName.slice(atLastIndex + 1)
  } else if (hasScope) {
    scope = packageName.slice(1, slashIndex)
    name = packageName.slice(slashIndex + 1)
  } else if (hasVersion) {
    name = packageName.slice(slashIndex + 1, atLastIndex)
    version = packageName.slice(atLastIndex + 1)
  } else {
    name = packageName
  }

  return {
    name: normalize(name),
    scope,
    version
  }
}
827762
function (spec) {
    spec.addMatchers({
      /**
       * Array contains all elements of another array
       * @param needles another array
       * @returns {Boolean} true/false
       */
      toContainAll: function(needles) {
        var haystack = this.actual;
        return needles.every(function (elem) {
          return haystack.some(function (sackElem) {
            return spec.env.equals_(elem, sackElem);
          });
        });
      }
    });
  }