'Transforms meter names in the expression into valid identifiers.
:param expr: unescaped expression
:return: A tuple of the escaped expression and a dict representing
the translation of meter names into Python identifiers'

@classmethod
def parse_expr(cls, expr):

    class Replacer(object, ):
        "Replaces    matched    meter    names    with    escaped    names.\n\n                                                If    the    meter    name    is    not    followed    by    parameter    access    in    the\n                                                expression,    it    defaults    to    accessing    the    'volume'    parameter.\n                                                "
        def __init__(self, original_expr):
            self.original_expr = original_expr
            self.escaped_map = {}
        def __call__(self, match):
            meter_name = match.group(1)
            escaped_name = self.escape(meter_name)
            self.escaped_map[meter_name] = escaped_name
            if ((match.end(0) == len(self.original_expr)) or (self.original_expr[match.end(0)] != '.')):
                escaped_name += '.volume'
            return escaped_name
        @staticmethod
        def escape(name):
            has_dot = ('.' in name)
            if has_dot:
                name = name.replace('.', '_')
            if (has_dot or name.endswith('ESC') or (name in keyword.kwlist)):
                name = (('_' + name) + '_ESC')
            return name
    replacer = Replacer(expr)
    expr = re.sub(cls.meter_name_re, replacer, expr)
    return (expr, replacer.escaped_map)
