Parse a list of literals.
321770
def _parse_literal_list(self, indent):
        """"""
        if self._cur_token['type'] not in self._literals:
            raise Exception(
                "Parser failed, _parse_literal_list was called on non-literal"
                " {} on line {}.".format(
                    repr(self._cur_token['value']), self._cur_token['line']
                )
            )

        # find next token after whitespace without incrementing
        temp_position = self._cur_position
        while (
            temp_position < self.num_tokens-1 and (
                self.tokens[temp_position]['type'] is TT.ws or
                self.tokens[temp_position]['type'] in self._literals
            )
        ):
            temp_position += 1
        next_token = self.tokens[temp_position]

        # end of stream
        if next_token['type'] is TT.ws:
            return self._cur_token['value']
        elif next_token['type'] is TT.comma:
            return self._parse_comma_list()
        elif next_token['type'] is TT.lbreak:
            while (
                temp_position < self.num_tokens-1 and
                self.tokens[temp_position]['type'] in (TT.lbreak, TT.ws)
            ):
                temp_position += 1
            if self.tokens[temp_position]['type'] in self._literals:
                return self._parse_newline_list(indent)
            else:
                rval = self._cur_token['value']
                self._increment()
                return rval
        else:
            rval = self._cur_token['value']
            self._increment()
            return rval
815440
def _parse_comma_list(self):
        """"""
        if self._cur_token['type'] not in self._literals:
            raise Exception(
                "Parser failed, _parse_comma_list was called on non-literal"
                " {} on line {}.".format(
                    repr(self._cur_token['value']), self._cur_token['line']
                )
            )

        array = []
        while self._cur_token['type'] in self._literals and not self._finished:
            array.append(self._cur_token['value'])
            self._increment()
            self._skip_whitespace()
            if self._cur_token['type'] is TT.comma:
                self._increment()
                self._skip_whitespace()
            elif (
                not self._finished and
                self._cur_token['type'] not in (TT.ws, TT.lbreak)
            ):
                raise ParseError('comma or newline', self._cur_token)

        return array
360341
private void parseLiteral() {

        AtomicValue atomic;

        if (mToken.getType() == TokenType.VALUE || mToken.getType() == TokenType.POINT) {
            // is numeric literal
            atomic = parseIntegerLiteral();
        } else {
            // is string literal
            assert (mToken.getType() == TokenType.DBL_QUOTE || mToken.getType() == TokenType.SINGLE_QUOTE);
            atomic = parseStringLiteral();
        }

        mPipeBuilder.addLiteral(mRTX, atomic);

    }
653694
def parseCCUSysVar(self, data):
        """"""
        if data['type'] == 'LOGIC':
            return data['name'], data['value'] == 'true'
        elif data['type'] == 'NUMBER':
            return data['name'], float(data['value'])
        elif data['type'] == 'LIST':
            return data['name'], int(data['value'])
        else:
            return data['name'], data['value']
496917
def parse_array(raw_array):
    """"""
    array_strip_brackets = raw_array.replace('{', '').replace('}', '')
    array_strip_spaces = array_strip_brackets.replace('"', '').replace(' ', '')
    return array_strip_spaces.split(',')
934844
def parse_if(self):
        """"""
        node = result = nodes.If(lineno=self.stream.expect('name:if').lineno)
        while 1:
            node.test = self.parse_tuple(with_condexpr=False)
            node.body = self.parse_statements(('name:elif', 'name:else',
                                               'name:endif'))
            node.elif_ = []
            node.else_ = []
            token = next(self.stream)
            if token.test('name:elif'):
                node = nodes.If(lineno=self.stream.current.lineno)
                result.elif_.append(node)
                continue
            elif token.test('name:else'):
                result.else_ = self.parse_statements(('name:endif',),
                                                     drop_needle=True)
            break
        return result
1109
def read_str(delim=',', *lines):
    """"""

    data = []
    for line in lines:
        com = parse_line(line, delim)
        data.append(com)
    return data
12881
def _find_literal(s, start, level, parts, exprs):
    """"""
    i = start
    parse_expr = True

    while i < len(s):
        ch = s[i]

        if ch in ('{', '}'):
            if level == 0:
                if i + 1 < len(s) and s[i + 1] == ch:
                    i += 2
                    parse_expr = False
                    break
                elif ch == '}':
                    raise SyntaxError("f-string: single '}' is not allowed")
            break

        i += 1

    parts.append(s[start:i])
    return i, parse_expr and i < len(s)
1002687
def _parse_list(self, text, i):
        """"""

        res = []
        end_match = self.end_list_re.match(text, i)
        old_current_type = self.current_type
        while not end_match:
            list_item, i = self._parse(text, i)
            res.append(list_item)

            end_match = self.end_list_re.match(text, i)

            if not end_match:
                m = self.list_delim_re.match(text, i)
                if not m:
                    self._fail("Missing delimiter in list before content", text, i)
                parsed = m.group(0)
                i += len(parsed)
            self.current_type = old_current_type

        parsed = end_match.group(0)
        i += len(parsed)
        return res, i
1373488
def _compile_list(self, data, indent_level):
        """"""
        if len(data) == 0:
            return '--'
        elif not any(isinstance(i, (dict, list)) for i in data):
            return ', '.join(self._compile_literal(value) for value in data)
        else:
            # 'ere be dragons,
            # granted there are fewer dragons than the parser,
            # but dragons nonetheless
            buffer = ''
            i = 0
            while i < len(data):
                if isinstance(data[i], dict):
                    buffer += '\n'
                    buffer += self._indent * indent_level
                    while i < len(data) and isinstance(data[i], dict):
                        buffer += '-\n'
                        buffer += self._compile_key_val(data[i], indent_level)
                        buffer += self._indent * indent_level + '-'
                        i += 1
                    buffer += '\n'
                elif (
                    isinstance(data[i], list) and
                    any(isinstance(item, (dict, list)) for item in data[i])
                ):
                    buffer += self._compile_list(data[i], indent_level+1)
                elif isinstance(data[i], list):
                    buffer += '\n'
                    buffer += self._indent * indent_level
                    buffer += self._compile_list(data[i], indent_level+1)
                else:
                    buffer += '\n'
                    buffer += self._indent * indent_level
                    buffer += self._compile_literal(data[i])

                i += 1

            return buffer
1227164
def process_literal_param(self, value: Optional[List[int]],
                              dialect: Dialect) -> str:
        """"""
        retval = self._intlist_to_dbstr(value)
        return retval
676469
def _parse_value(self):
        """"""
        indent = 0
        while self._cur_token['type'] is TT.ws:
            indent = self._skip_whitespace()
            self._skip_newlines()

        if self._cur_token['type'] is TT.id:
            return self._parse_key(indent)
        elif self._cur_token['type'] is TT.hyphen:
            self._increment()
            if self._cur_token['type'] is TT.hyphen:
                self._increment()
                return []
            else:
                return self._parse_object_list()
        else:
            # TODO: single comma gives empty list
            return self._parse_literal_list(indent)
592982
def parse_list(self):
        """"""
        try:
            return List([self.parse() for _ in
                         self.collect_tokens_until('CLOSE_BRACKET')])
        except IncompatibleItemType as exc:
            raise self.error(f'Item {str(exc.item)!r} is not a '
                             f'{exc.subtype.__name__} tag') from None
137654
def p_string_literal(self, p):
        """"""
        p[0] = self.asttypes.String(p[1])
        p[0].setpos(p)
319639
def to_literal(self):
    
    if not self.nodes:
        return (self.tag, self.attrib, self.text, [])
    else:
        return (self.tag, self.attrib, self.text,
                list(map(to_literal, self.nodes)))
787622
def parse_nbt(literal):
    """"""
    parser = Parser(tokenize(literal))
    tag = parser.parse()

    cursor = parser.token_span[1]
    leftover = literal[cursor:]
    if leftover.strip():
        parser.token_span = cursor, cursor + len(leftover)
        raise parser.error(f'Expected end of string but got {leftover!r}')

    return tag
462263
def transform_literals(rdf, literalmap):
    """"""

    affected_types = (SKOS.Concept, SKOS.Collection,
                      SKOSEXT.DeprecatedConcept)

    props = set()
    for t in affected_types:
        for conc in rdf.subjects(RDF.type, t):
            for p, o in rdf.predicate_objects(conc):
                if isinstance(o, Literal) \
                   and (p in literalmap or not in_general_ns(p)):
                    props.add(p)

    for p in props:
        if mapping_match(p, literalmap):
            newval = mapping_get(p, literalmap)
            newuris = [v[0] for v in newval]
            logging.debug("transform literal %s -> %s", p, str(newuris))
            replace_predicate(
                rdf, p, newuris, subjecttypes=affected_types)
        else:
            logging.info("Don't know what to do with literal %s", p)