Esempio n. 1
0
def mcompose(*mfuncs):
    return compose(unit, bind_compose(*mfuncs))
Esempio n. 2
0
import ast
import collections
import operator

from hornet.util import pairwise, identity, const, decrement
from hornet.util import compose2 as compose
from hornet.expressions import is_name, is_operator, is_tuple, is_astwrapper
from hornet.expressions import lift, promote


class ParseError(Exception):
    pass


parse_error = compose('Precedence conflict: ({}) {} ({})'.format, ParseError)


class Token(collections.namedtuple('BaseToken', 'lbp rbp node')):

    __slots__ = ()

    def __lt__(self, other):
        return self.rbp < other.lbp

    def __gt__(self, other):
        return self.rbp > other.lbp

    @classmethod
    def fixity(cls, left, right):
Esempio n. 3
0
def lift(func):
    return compose(func, unit)