コード例 #1
0
ファイル: expressions.py プロジェクト: pillmuncher/hornet
def mcompose(*mfuncs):
    return compose(unit, bind_compose(*mfuncs))
コード例 #2
0
ファイル: operators.py プロジェクト: pillmuncher/hornet
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):
コード例 #3
0
ファイル: expressions.py プロジェクト: pillmuncher/hornet
def lift(func):
    return compose(func, unit)