def parse_type(string,capture_strings,settings):
typestr = '<STR_LIT>'<EOL>for vtype in settings['<STR_LIT>']:<EOL><INDENT>typestr = typestr + '<STR_LIT:|>' + vtype<EOL><DEDENT>var_type_re = re.compile(VAR_TYPE_STRING + typestr,re.IGNORECASE)<EOL>match = var_type_re.match(string)<EOL>if not match: raise Exception("<STR_LIT>".format(string))<EOL>vartype = match.group().lower()<EOL>if DOUBLE_PREC_RE.match(vartype): vartype = "<STR_LIT>"<EOL>rest = string[match.end():].strip()<EOL>kindstr = ford.utils.get_parens(rest)<EOL>rest = rest[len(kindstr):].strip()<EOL>if len(kindstr) < <NUM_LIT:3> and vartype != "<STR_LIT:type>" and vartype != "<STR_LIT:class>" and not kindstr.startswith('<STR_LIT:*>'):<EOL><INDENT>return (vartype, None, None, None, rest)<EOL><DEDENT>match = VARKIND_RE.search(kindstr)<EOL>if match:<EOL><INDENT>if match.group(<NUM_LIT:1>):<EOL><INDENT>star = False<EOL>args = match.group(<NUM_LIT:1>).strip()<EOL><DEDENT>else:<EOL><INDENT>star = True<EOL>args = match.group(<NUM_LIT:2>).strip()<EOL>if args.startswith('<STR_LIT:(>'):<EOL><INDENT>args = args[<NUM_LIT:1>:-<NUM_LIT:1>].strip()<EOL><DEDENT><DEDENT>args = re.sub("<STR_LIT>","<STR_LIT>",args)<EOL>if vartype == "<STR_LIT:type>" or vartype == "<STR_LIT:class>" or vartype == "<STR_LIT>":<EOL><INDENT>PROTO_RE = re.compile("<STR_LIT>")<EOL>try:<EOL><INDENT>proto = list(PROTO_RE.match(args).groups())<EOL>if not proto[<NUM_LIT:1>]: proto[<NUM_LIT:1>] = '<STR_LIT>'<EOL><DEDENT>except:<EOL><INDENT>raise Exception("<STR_LIT>".format(args))<EOL><DEDENT>return (vartype, None, None, proto, rest)<EOL><DEDENT>elif vartype == "<STR_LIT>":<EOL><INDENT>if star:<EOL><INDENT>return (vartype, None, args, None, rest)<EOL><DEDENT>else:<EOL><INDENT>kind = None<EOL>length = None<EOL>if KIND_RE.search(args):<EOL><INDENT>kind = KIND_RE.sub("<STR_LIT>",args)<EOL>try:<EOL><INDENT>match = QUOTES_RE.search(kind)<EOL>num = int(match.group()[<NUM_LIT:1>:-<NUM_LIT:1>])<EOL>kind = QUOTES_RE.sub(captured_strings[num],kind)<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>elif LEN_RE.search(args):<EOL><INDENT>length = LEN_RE.sub("<STR_LIT>",args)<EOL><DEDENT>else:<EOL><INDENT>length = args<EOL><DEDENT>return (vartype, kind, length, None, rest)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>kind = KIND_RE.sub("<STR_LIT>",args)<EOL>return (vartype, kind, None, None, rest)<EOL><DEDENT><DEDENT>raise Exception("<STR_LIT>".format(vartype,string))<EOL>
Gets variable type, kind, length, and/or derived-type attributes from a
variable declaration.