Esempio n. 1
0
    def parse(self, left, token, right, parser):
        right_side = parser.expression(self.precedence)

        left = list.ensure_partial_list(left)
        right_side = list.ensure_partial_list(right_side)

        return PartialList(left.items + right_side.items)
Esempio n. 2
0
    def parse(self, left, token, right, parser):
        indent = right.next()
        if indent.purpose != "indent":
            raise ParseError(
                "Indentation expected: line %d, column %d" %
                (token.line, token.character))

        right_side = parser.expression(self.precedence)

        dedent = right.next()
        if dedent.purpose != "dedent":
            raise ParseError(
                "Dedentation expected: line %d, column %d." %
                (token.line, token.character))

        # ensure both are lists
        left = list.ensure_partial_list(left)
        right_side = list.ensure_partial_list(right_side)

        return PartialList(left.items + right_side.items)