<commit_before># coding: utf-8
import re

from collections import deque
from functools import wraps

from stacker.errors import StackerSyntaxError
from stacker.scope import Scope

__all__ = ['Stacker', 'Procedure']


class Procedure (object):
    def __init__(self, inp, name, scope):
        self.inp = inp
        self.name = name
        self.scope = scope

    def expression_list(self):
        return  [exp for exp in self.inp[1:-1].split(';') if exp]


class Stacker (object):

    def __init__(self):
        self.STACK = deque()
        self.scope = self.env()

    def stack_head(self):
        try:
            value = self.STACK[0]
        except IndexError:
            value = None
        return value

    def env(self, **kwargs):

        def _call(*args):
            proc = self.STACK.popleft()
            for exp in proc.expression_list():
                self.eval(exp, proc.scope)

        def _if(*args):
            proc = self.STACK.popleft()
            cond = self.STACK.popleft()
            if cond is False:
                return None
            for exp in proc.expression_list():
                self.eval(exp, proc.scope)

        def _not(*args):
            value = self.STACK.popleft()
            if value is False:
                self.STACK.appendleft(True)
            else:
                self.STACK.appendleft(False)
            return self.STACK

        def _or (*args):
            value1 = self.STACK.popleft()
            value2 = self.STACK.popleft()
            if value1 is False and value2 is False:
                self.STACK.appendleft(False)
            else:
                self.STACK.appendleft(True)
            return self.STACK

        def _eq(*args):
            other = args[0]
            value = self.STACK.popleft()
            out = other == value
            self.STACK.appendleft(out)
            return self.STACK

        def rot(*args):
            value = self.STACK.popleft()
            self.STACK.append(value)
            return self.STACK

        def over(*args):
            value = self.stack_head()
            self.STACK.append(value)
            return self.STACK

        def drop(*args):
            self.STACK.popleft()
            return self.STACK

        def swap(*args):
            value1 = self.STACK.popleft()
            value2 = self.STACK.popleft()
            self.STACK.appendleft(value1)
            self.STACK.appendleft(value2)
            return self.STACK

        def dup(*args):
            value = self.stack_head()
            self.STACK.appendleft(value)
            return self.STACK

        def push(*args):
            self.STACK.appendleft(args[0])
            return self.STACK

        base = {
            'push': push,
            'drop': drop,
            'dup': dup,
            'swap': swap,
            'over': over,
            'rot': rot,
            'eq': _eq,
            'or': _or,
            'not': _not,
            'if': _if,
            'call': _call,
        }

        scope = Scope(None, **base)

        if kwargs:
            scope.update(kwargs)

        return scope
<commit_msg>Add more comparison operators<commit_after># coding: utf-8
import re

from collections import deque
from functools import wraps

from stacker.errors import StackerSyntaxError
from stacker.scope import Scope

__all__ = ['Stacker', 'Procedure']


class Procedure (object):
    def __init__(self, inp, name, scope):
        self.inp = inp
        self.name = name
        self.scope = scope

    def expression_list(self):
        return  [exp for exp in self.inp[1:-1].split(';') if exp]


class Stacker (object):

    def __init__(self):
        self.STACK = deque()
        self.scope = self.env()

    def stack_head(self):
        try:
            value = self.STACK[0]
        except IndexError:
            value = None
        return value

    def env(self, **kwargs):

        def gte(*args):
            other = args[0]
            value = self.STACK.popleft()
            out = value >= other
            self.STACK.appendleft(out)
            return self.STACK

        def gt(*args):
            other = args[0]
            value = self.STACK.popleft()
            out = value > other
            self.STACK.appendleft(out)
            return self.STACK

        def lte(*args):
            other = args[0]
            value = self.STACK.popleft()
            out = value <= other
            self.STACK.appendleft(out)
            return self.STACK

        def lt(*args):
            other = args[0]
            value = self.STACK.popleft()
            out = value < other
            self.STACK.appendleft(out)
            return self.STACK

        def _call(*args):
            proc = self.STACK.popleft()
            for exp in proc.expression_list():
                self.eval(exp, proc.scope)

        def _if(*args):
            proc = self.STACK.popleft()
            cond = self.STACK.popleft()
            if cond is False:
                return None
            for exp in proc.expression_list():
                self.eval(exp, proc.scope)

        def _not(*args):
            value = self.STACK.popleft()
            if value is False:
                self.STACK.appendleft(True)
            else:
                self.STACK.appendleft(False)
            return self.STACK

        def _or (*args):
            value1 = self.STACK.popleft()
            value2 = self.STACK.popleft()
            if value1 is False and value2 is False:
                self.STACK.appendleft(False)
            else:
                self.STACK.appendleft(True)
            return self.STACK

        def _eq(*args):
            other = args[0]
            value = self.STACK.popleft()
            out = other == value
            self.STACK.appendleft(out)
            return self.STACK

        def rot(*args):
            value = self.STACK.popleft()
            self.STACK.append(value)
            return self.STACK

        def over(*args):
            value = self.stack_head()
            self.STACK.append(value)
            return self.STACK

        def drop(*args):
            self.STACK.popleft()
            return self.STACK

        def swap(*args):
            value1 = self.STACK.popleft()
            value2 = self.STACK.popleft()
            self.STACK.appendleft(value1)
            self.STACK.appendleft(value2)
            return self.STACK

        def dup(*args):
            value = self.stack_head()
            self.STACK.appendleft(value)
            return self.STACK

        def push(*args):
            self.STACK.appendleft(args[0])
            return self.STACK

        base = {
            'push': push,
            'drop': drop,
            'dup': dup,
            'swap': swap,
            'over': over,
            'rot': rot,
            'eq': _eq,
            'or': _or,
            'not': _not,
            'if': _if,
            'call': _call,
            'gte': gte,
            'lte': lte,
            'gt': gt,
            'lt': lt,
        }

        scope = Scope(None, **base)

        if kwargs:
            scope.update(kwargs)

        return scope

{'fraction_non_alphanumeric': 0.10431856421761077, 'fraction_numerical': 0.00448681996634885, 'mean_word_length': 1.3603573792190602, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2830686', 'n_tokens_mistral': 2109, 'n_tokens_neox': 2047, 'n_words': 491}