Source code for pudding.tokens.statements.skip

"""Skip statement."""

import re
from typing import Callable

from pudding.processor import PAction
from pudding.processor.context import Context

from .match import IMatch, Match


def skip_on_match(method: Callable[..., PAction]) -> Callable[..., PAction]:
    """Skip text when it matches."""

    def wrapper(self: "Skip | ISkip", context: Context) -> PAction:
        action = method(self, context)
        if action == PAction.ENTER:
            return PAction.RESTART
        return PAction.NEXT

    return wrapper






[docs] class ISkip(IMatch): """Class for `iskip` statement.""" match_re = re.compile(r"(iskip) (.*)$") execute = skip_on_match(IMatch.execute)