# Copyright (c) 2017-2026 Juancarlo Añez (apalala@gmail.com)
# SPDX-License-Identifier: BSD-4-Clause
from __future__ import annotations

from collections.abc import Callable
from typing import cast

from ..infos import RuleLike


def leftrec(impl: Callable) -> Callable:
    over: RuleLike = cast(RuleLike, impl)
    over.is_lrec = True
    over.is_memo = False
    return impl


def nomemo(impl: Callable) -> Callable:
    over: RuleLike = cast(RuleLike, impl)
    over.no_memo = True
    return impl


def nostak(impl: Callable) -> Callable:
    over: RuleLike = cast(RuleLike, impl)
    over.no_stak = True
    return impl


def isname(impl: Callable) -> Callable:
    over: RuleLike = cast(RuleLike, impl)
    over.is_name = True
    return impl


def name(impl: Callable) -> Callable:
    over: RuleLike = cast(RuleLike, impl)
    over.is_name = True
    return impl


def token(impl: Callable) -> Callable:
    over: RuleLike = cast(RuleLike, impl)
    over.is_tokn = True
    return impl
