Parse a series of C definitions, returns a tuple of two type mappings, one for variable
    definitions and one for type definitions.
434528
def parse_file(defn, preprocess=True):
    
    if pycparser is None:
        raise ImportError("Please install pycparser in order to parse C definitions")

    defn = '\n'.join(x for x in defn.split('\n') if _include_re.match(x) is None)

    if preprocess:
        defn = do_preprocess(defn)

    preamble, ignoreme = make_preamble()
    node = pycparser.c_parser.CParser().parse(preamble + defn)
    if not isinstance(node, pycparser.c_ast.FileAST):
        raise ValueError("Something went horribly wrong using pycparser")
    out = {}
    extra_types = {}
    for piece in node.ext:
        if isinstance(piece, pycparser.c_ast.FuncDef):
            out[piece.decl.name] = _decl_to_type(piece.decl.type, extra_types)
        elif isinstance(piece, pycparser.c_ast.Decl):
            ty = _decl_to_type(piece.type, extra_types)
            if piece.name is not None:
                out[piece.name] = ty
        elif isinstance(piece, pycparser.c_ast.Typedef):
            extra_types[piece.name] = _decl_to_type(piece.type, extra_types)

    for ty in ignoreme:
        del extra_types[ty]
    return out, extra_types
1039044
def parse_definition(self, definition):
        
        type = definition[0]
        alias = None
        attributes = {}
        for part in definition[1:]:
            if '=' in part:
                key, value = part.split('=', 1)
                attributes[key] = set(value.split(','))
            elif alias is None:
                alias = part
            else:
                raise ValueError('entity name already defined: {}'.format(part))
        return type, alias, attributes
950817
private static Map<TypeVariable<?>, Type> getTypeVariableMap(Class<?> type) {
        return getTypeVariableMap(type, new HashSet<Type>());
    }
89372
def parse_nested(
    bels: list, char_locs: CharLocs, parsed: Parsed, errors: Errors
) -> Tuple[Parsed, Errors]:
    

    for sp in char_locs[
        "nested_parens"
    ]:  # sp = start parenthesis, ep = end parenthesis
        ep, level = char_locs["nested_parens"][sp]
        if ep == -1:
            ep = len(bels) + 1
        parsed[(sp, ep)] = {"type": "Nested", "span": (sp, ep)}

    return parsed, errors
779149
def _parseDefinition(typeDef, name, len=1, reader=None, writer=None):
        
        if isinstance(typeDef, Structure):
            return (name, typeDef.fmt, typeDef)

        if len != 1:
            size = struct.calcsize(typeDef)
            if typeDef not in "xspP":
                typeDef = 's'
            typeDef = str(len * size) + typeDef

        fmtChar = typeDef[-1:]

        if fmtChar == 'x':
            typeObj = Structure.skipType
        else:
            typeObj = _TypeWriter(Structure.defaults[fmtChar], reader, writer)

        return (name, typeDef, typeObj)
371102
def parse_input_fields_definition(lexer: Lexer) -> List[InputValueDefinitionNode]:
    """"""
    return (
        cast(
            List[InputValueDefinitionNode],
            many_nodes(
                lexer, TokenKind.BRACE_L, parse_input_value_def, TokenKind.BRACE_R
            ),
        )
        if peek(lexer, TokenKind.BRACE_L)
        else []
    )
1131677
def fresh(t, non_generic):
    

    mappings = {}  # A mapping of TypeVariables to TypeVariables

    def freshrec(tp):
        p = prune(tp)
        if isinstance(p, TypeVariable):
            if is_generic(p, non_generic):
                if p not in mappings:
                    mappings[p] = TypeVariable()
                return mappings[p]
            else:
                return p
        elif isinstance(p, dict):
            return p  # module
        elif isinstance(p, Collection):
            return Collection(*[freshrec(x) for x in p.types])
        elif isinstance(p, Scalar):
            return Scalar([freshrec(x) for x in p.types])
        elif isinstance(p, TypeOperator):
            return TypeOperator(p.name, [freshrec(x) for x in p.types])
        elif isinstance(p, MultiType):
            return MultiType([freshrec(x) for x in p.types])
        else:
            assert False, "missing freshrec case {}".format(type(p))

    return freshrec(t)
1223072
def _get_dtype_maps():
    
    
    # Define pairs
    tmp = [ (np.float32, 'MET_FLOAT'),  (np.float64, 'MET_DOUBLE'),
            (np.uint8, 'MET_UCHAR'),    (np.int8, 'MET_CHAR'),
            (np.uint16, 'MET_USHORT'),  (np.int16, 'MET_SHORT'),
            (np.uint32, 'MET_UINT'),    (np.int32, 'MET_INT'),
            (np.uint64, 'MET_ULONG'),   (np.int64, 'MET_LONG') ]
    
    # Create dictionaries
    map1, map2 = {}, {}
    for np_type, itk_type in tmp:
        map1[np_type.__name__] = itk_type
        map2[itk_type] = np_type.__name__
    
    # Done
    return map1, map2
1025057
def parse(v):
        

        parts = v.split(',')

        slices = []

        for part in parts:
            p = part.split(':')

            if len(p) == 1:
                slices.append(int(p[0]))
            elif len(p) == 2:
                slices.append(tuple(p))
            else:
                raise ValueError("Too many ':': {}".format(part))

        return slices
386433
def parse_type_reference(lexer: Lexer) -> TypeNode:
    """"""
    start = lexer.token
    if expect_optional_token(lexer, TokenKind.BRACKET_L):
        type_ = parse_type_reference(lexer)
        expect_token(lexer, TokenKind.BRACKET_R)
        type_ = ListTypeNode(type=type_, loc=loc(lexer, start))
    else:
        type_ = parse_named_type(lexer)
    if expect_optional_token(lexer, TokenKind.BANG):
        return NonNullTypeNode(type=type_, loc=loc(lexer, start))
    return type_
765597
function mergeTypings(typingNames) {
                if (!typingNames) {
                    return;
                }
                for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) {
                    var typing = typingNames_1[_i];
                    if (!(typing in inferredTypings)) {
                        inferredTypings[typing] = undefined;
                    }
                }
            }
727796
def _infer_all_types(self):
        '''
        
        '''
        self._initialize_graph_status_for_traversing()

        # Deliver user-specified types to root variables
        for raw_name, initial_type in self.initial_types:
            # Check all variables declared using raw_name in the whole graph
            for scope in self.scopes:
                # Skip scopes without having the considered variable name
                if raw_name not in scope.variable_name_mapping:
                    continue
                # Assign initial_type to all variables declared using raw_name
                for onnx_name in scope.variable_name_mapping[raw_name]:
                    variable = scope.variables[onnx_name]
                    if variable.is_root:
                        # Assign type to the root; existing type produced by parser may be overwritten
                        variable.type = initial_type

        # Traverse the graph from roots to leaves
        for operator in self.topological_operator_iterator():
            if operator.type in self.custom_shape_calculators:
                self.custom_shape_calculators[operator.type](operator)
            elif operator.type in self.custom_conversion_functions:
                pass  # in Keras converter, the shape calculator can be optional.
            else:
                operator.infer_types()
489830
def parse_type_signature(sig):
    
    match = TYPE_SIG_RE.match(sig.strip())
    if not match:
        raise RuntimeError('Type signature invalid, got ' + sig)
    groups = match.groups()
    typ = groups[0]
    generic_types = groups[1]
    if not generic_types:
        generic_types = []
    else:
        generic_types = split_sig(generic_types[1:-1])
    is_array = (groups[2] is not None)
    return typ, generic_types, is_array
471758
def complex_type(name=None):
    ''''''
    def wrapped(cls):
        ParseType.type_mapping[name or cls.__name__] = cls
        return cls
    return wrapped
324000
def parse_argument_defs(lexer: Lexer) -> List[InputValueDefinitionNode]:
    """"""
    return (
        cast(
            List[InputValueDefinitionNode],
            many_nodes(
                lexer, TokenKind.PAREN_L, parse_input_value_def, TokenKind.PAREN_R
            ),
        )
        if peek(lexer, TokenKind.PAREN_L)
        else []
    )
754247
function typeVarNames(t) {
    return Z.concat (
      t.type === VARIABLE ? [t.name] : [],
      Z.chain (function(k) { return typeVarNames (t.types[k]); }, t.keys)
    );
  }
587977
def parse_declaration_expressn_tupleliteral(self, values, es):
        
        es = es + '('
        for ast in values:
            es = es + self.parse_declaration_expressn(ast, es='') + ', '
        if es.endswith(', '):
            es = es[:-2]
        return es + ')'