ast_translator.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:pseudo-python 作者: alehander42 项目源码 文件源码
def _translate_in(self, element, sequence, location):
        sequence_node = self._translate_node(sequence)
        element_node = self._translate_node(element)
        if not (
            sequence_node['pseudo_type'] == 'String' and element_node['pseudo_type'] == 'String' or\
            isinstance(sequence_node['pseudo_type'], list) and sequence_node['pseudo_type'][0] != 'Tuple' and sequence_node['pseudo_type'][1] == element_node['pseudo_type']):
            raise type_check_error('expected the left side of in to has the element type of the sequence, in supported for string and sequences which are not tuples',
                    location, self.lines[location[0]],
                    wrong_type=element_node['pseudo_type'])
        return {
            'type': 'standard_method_call',
            'receiver': sequence_node,
            'message': 'include?',
            'args': [element_node],
            'pseudo_type': 'Boolean'
        }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号