expression.py 文件源码

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

项目:monasca-analytics 作者: openstack 项目源码 文件源码
def __init__(self):
        """
        Create a parser that parse arithmetic expressions. They can
        contains variable identifiers or raw numbers. The meaning
        for the identifiers is left to the
        """
        number = p.Regex(r'\d+(\.\d*)?([eE]\d+)?')
        identifier = p.Word(p.alphas)
        terminal = identifier | number
        self._expr = p.infixNotation(terminal, [
            (p.oneOf('* /'), 2, p.opAssoc.LEFT),
            (p.oneOf('+ -'), 2, p.opAssoc.LEFT)
        ]) + p.stringEnd()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号