Parse a string containing an type definition.
171059
public static AbstractType<?> parse(String str) throws SyntaxException, ConfigurationException
    {
        if (str == null)
            return BytesType.instance;

        AbstractType<?> type = cache.get(str);

        if (type != null)
            return type;

        // This could be simplier (i.e. new TypeParser(str).parse()) but we avoid creating a TypeParser object if not really necessary.
        int i = 0;
        i = skipBlank(str, i);
        int j = i;
        while (!isEOS(str, i) && isIdentifierChar(str.charAt(i)))
            ++i;

        if (i == j)
            return BytesType.instance;

        String name = str.substring(j, i);
        i = skipBlank(str, i);

        if (!isEOS(str, i) && str.charAt(i) == '(')
            type = getAbstractType(name, new TypeParser(str, i));
        else
            type = getAbstractType(name);

        // We don't really care about concurrency here. Worst case scenario, we do some parsing unnecessarily
        cache.put(str, type);
        return type;
    }
399390
def from_string(value):
        
        if value == None or len(value) == 0:
            return None
                
        tokens = value.split(",")
        if len(tokens) == 1:
            return TypeDescriptor(tokens[0].strip(), None)
        elif len(tokens) == 2:
            return TypeDescriptor(tokens[0].strip(), tokens[1].strip())
        else:
            raise ConfigException(
                None, "BAD_DESCRIPTOR", "Type descriptor " + value + " is in wrong format"
            ).with_details("descriptor", value)
868727
def from_string(cls, string):
    """"""
    # Note: There is some ambiguity as to whether the string passed is intended
    # to become a unit looked up by name or suffix, or a Dimension descriptor.
    if string in units.UNITS_BY_ALL:
      return cls(description=string, unit=units.Unit(string))
    else:
      return cls(description=string)
253293
def parse_def(self, text):
        """"""
        self.__init__()

        if not is_start_of_function(text):
            return

        self.func_indent = get_indent(text)

        text = text.strip()
        text = text.replace('\r\n', '')
        text = text.replace('\n', '')

        return_type_re = re.search(r'->[ ]*([a-zA-Z0-9_,()\[\] ]*):$', text)
        if return_type_re:
            self.return_type_annotated = return_type_re.group(1)
            text_end = text.rfind(return_type_re.group(0))
        else:
            self.return_type_annotated = None
            text_end = len(text)

        pos_args_start = text.find('(') + 1
        pos_args_end = text.rfind(')', pos_args_start, text_end)

        self.args_text = text[pos_args_start:pos_args_end]

        args_list = self.split_args_text_to_list(self.args_text)
        if args_list is not None:
            self.has_info = True
            self.split_arg_to_name_type_value(args_list)
201972
def parse_input_object_type_definition(lexer: Lexer) -> Node:
    """"""
    start = lexer.token
    description = parse_description(lexer)
    expect_keyword(lexer, "input")
    name = parse_name(lexer)
    directives = parse_directives(lexer, True)
    fields = parse_input_fields_definition(lexer)
    return Node(
        description=description,
        name=name,
        directives=directives,
        fields=fields,
        loc=loc(lexer, start),
    )
1268416
def _string_parser(strip_whitespace):
    """"""
    def _parse_string_value(element_text, _state):
        if element_text is None:
            value = ''
        elif strip_whitespace:
            value = element_text.strip()
        else:
            value = element_text

        return value

    return _parse_string_value
809704
def type_string(self):
        """"""
        if self.is_tuple:
            subtypes = [item.type_string for item in self.children]
            return '{}({})'.format(
                '' if self.val_guaranteed else '*',
                ', '.join(subtypes))
        elif self.is_list:
            return '{}[{}]'.format(
                '' if self.val_guaranteed else '*',
                self.children[0].type_string)
        else:
            return '{}{}'.format(
                '' if self.val_guaranteed else '*',
                self.type_.__name__)
839136
def parse_value(self, value):
        """"""
        if not isinstance(value, dict):
            return value

        embed_type = self._get_embed_type()
        return embed_type(**value)
1317013
public static Node parseTypeString(String typeString) {
    JsDocInfoParser parser = getParser(typeString);
    return parser.parseTopLevelTypeExpression(parser.next());
  }
590079
def _parse_value(value):
    ''''''
    if isinstance(value, bool):
        return 'true' if value else 'false'
    elif isinstance(value, six.string_types):
        # parse compacted notation to dict
        listparser = re.compile(r'''((?:[^,"']|"[^"]*"|'[^']*')+)''')

        value = value.strip()
        if value.startswith('[') and value.endswith(']'):
            return listparser.split(value[1:-1])[1::2]
        elif value.startswith('(') and value.endswith(')'):
            rval = {}
            for pair in listparser.split(value[1:-1])[1::2]:
                pair = pair.split('=')
                if '"' in pair[1]:
                    pair[1] = pair[1].replace('"', '')
                if pair[1].isdigit():
                    rval[pair[0]] = int(pair[1])
                elif pair[1] == 'true':
                    rval[pair[0]] = True
                elif pair[1] == 'false':
                    rval[pair[0]] = False
                else:
                    rval[pair[0]] = pair[1]
            return rval
        else:
            if '"' in value:
                value = value.replace('"', '')
            if value.isdigit():
                return int(value)
            elif value == 'true':
                return True
            elif value == 'false':
                return False
            else:
                return value
    else:
        return value
885427
def parse(fmt, stri):
    """"""
    convdef = get_convert_dict(fmt)
    keyvals = regex_formatter.extract_values(fmt, stri)
    for key in convdef.keys():
        keyvals[key] = _convert(convdef[key], keyvals[key])

    return keyvals
227967
def parseString(string, uri=None):
    """"""
    return etree.fromstring(string, parser=_get_xmlparser(), base_url=uri)
259462
def _parse_string_el(el):
    """"""
    value = str(el)
    el_type = el.attributes().get('xsi:type')
    if el_type and el_type.value == 'xsd:base64Binary':
        value = base64.b64decode(value)
        if not PY2:
            value = value.decode('utf-8', errors='replace')
    value = _uc(value)
    return value
32833
def _get_string_type_from_token(token_type):
    """"""
    return_value = None
    if token_type in [TokenType.BeginSingleQuotedLiteral,
                      TokenType.EndSingleQuotedLiteral]:
        return_value = "Single"
    elif token_type in [TokenType.BeginDoubleQuotedLiteral,
                        TokenType.EndDoubleQuotedLiteral]:
        return_value = "Double"

    assert return_value is not None
    return return_value
837137
def string(s):
    ''''''
    @Parser
    def string_parser(text, index=0):
        slen, tlen = len(s), len(text)
        if text[index:index + slen] == s:
            return Value.success(index + slen, s)
        else:
            matched = 0
            while matched < slen and index + matched < tlen and text[index + matched] == s[matched]:
                matched = matched + 1
            return Value.failure(index + matched, s)
    return string_parser
681696
def from_string(cls, string):
        
        cls.TYPE.setParseAction(cls.make)
        try:
            return cls.TYPE.parseString(string, parseAll=True)[0]
        except ParseException:
            log.error("Failed to parse '{0}'".format(string))
            raise
646429
def _parse_type(value, type_func):
        
        default = type_func(0)
        if value is None:
            return default
        try:
            return type_func(value)
        except ValueError:
            return default