Ejemplo n.º 1
0
    def partial_eval(self):
        value = self.value.partial_eval()

        start_index = self.lang[CaseOp([
            WhenOp(self.prefix.missing(), **{"then": ZERO}),
            WhenOp(IsNumberOp(self.prefix),
                   **{"then": MaxOp([ZERO, self.prefix])}),
            FindOp([value, self.prefix], start=self.start),
        ])].partial_eval()

        len_prefix = self.lang[CaseOp([
            WhenOp(self.prefix.missing(), **{"then": ZERO}),
            WhenOp(IsNumberOp(self.prefix), **{"then": ZERO}),
            LengthOp(self.prefix),
        ])].partial_eval()

        end_index = self.lang[CaseOp([
            WhenOp(start_index.missing(), **{"then": NULL}),
            WhenOp(self.suffix.missing(), **{"then": LengthOp(value)}),
            WhenOp(IsNumberOp(self.suffix),
                   **{"then": MinOp([self.suffix, LengthOp(value)])}),
            FindOp([value, self.suffix],
                   start=AddOp([start_index, len_prefix])),
        ])].partial_eval()

        start_index = AddOp([start_index, len_prefix]).partial_eval()
        substring = BasicSubstringOp([value, start_index,
                                      end_index]).partial_eval()

        between = self.lang[WhenOp(end_index.missing(), **{
            "then": self.default,
            "else": substring
        })].partial_eval()

        return between
Ejemplo n.º 2
0
    def partial_eval(self):
        value = self.lang[self.value].partial_eval()
        length = self.lang[self.length].partial_eval()
        max_length = LengthOp(value)

        return self.lang[WhenOp(
            self.missing(), **{
                "else":
                BasicSubstringOp(
                    [value, ZERO,
                     MaxOp([ZERO, MinOp([length, max_length])])])
            })].partial_eval()
Ejemplo n.º 3
0
    def partial_eval(self, lang):
        value = (self.value).partial_eval(lang)
        length = (self.length).partial_eval(lang)
        max_length = LengthOp(value)

        return WhenOp(
            self.missing(lang),
            **{"else": BasicSubstringOp([
                value,
                MaxOp([ZERO, MinOp([max_length, SubOp([max_length, length])])]),
                max_length,
            ])}
        ).partial_eval(lang)
Ejemplo n.º 4
0
    def partial_eval(self):
        value = self.lang[self.value].partial_eval()
        length = self.length.partial_eval()

        if length is ZERO:
            return value

        max_length = LengthOp(value)
        part = BasicSubstringOp([
            value,
            ZERO,
            MaxOp([ZERO,
                   MinOp([max_length, SubOp([max_length, length])])]),
        ])
        return self.lang[WhenOp(self.missing(), **{"else":
                                                   part})].partial_eval()
Ejemplo n.º 5
0
    def partial_eval(self, lang):
        value = (self.value).partial_eval(lang)
        length = self.length.partial_eval(lang)

        if length is ZERO:
            return value

        max_length = LengthOp(value)
        part = BasicSubstringOp([
            value,
            ZERO,
            MaxOp([ZERO,
                   MinOp([max_length, SubOp([max_length, length])])]),
        ])
        return (WhenOp(self.missing(lang), **{"else":
                                              part})).partial_eval(lang)
Ejemplo n.º 6
0
    def partial_eval(self, lang):
        value = (self.value).partial_eval(lang)
        length = self.length.partial_eval(lang)

        if length is ZERO:
            return value

        max_length = LengthOp(value)
        output = WhenOp(
            self.missing(lang),
            **{"else": BasicSubstringOp([
                value,
                MaxOp([ZERO, MinOp([length, max_length])]),
                max_length,
            ])}
        ).partial_eval(lang)
        return output
Ejemplo n.º 7
0
    def partial_eval(self):
        value = self.lang[self.value].partial_eval()
        length = self.length.partial_eval()

        if length is ZERO:
            return value

        max_length = LengthOp(value)
        output = self.lang[WhenOp(
            self.missing(), **{
                "else":
                BasicSubstringOp([
                    value,
                    MaxOp([ZERO, MinOp([length, max_length])]), max_length
                ])
            })].partial_eval()
        return output