# Path: coconut/constants.py
# def fixpath(path):
# def str_to_bool(boolstr, default=False):
# WINDOWS = os.name == "nt"
# PYPY = platform.python_implementation() == "PyPy"
# CPYTHON = platform.python_implementation() == "CPython"
# PY32 = sys.version_info >= (3, 2)
# PY33 = sys.version_info >= (3, 3)
# PY34 = sys.version_info >= (3, 4)
# PY35 = sys.version_info >= (3, 5)
# PY36 = sys.version_info >= (3, 6)
# PY38 = sys.version_info >= (3, 8)
# PY310 = sys.version_info >= (3, 10)
# IPY = (
#     ((PY2 and not PY26) or PY35)
#     and not (PYPY and WINDOWS)
#     # necessary until jupyter-console fixes https://github.com/jupyter/jupyter_console/issues/245
#     and not PY310
# )
# MYPY = (
#     PY34
#     and not WINDOWS
#     and not PYPY
# )
# PURE_PYTHON = str_to_bool(os.environ.get(pure_python_env_var, ""))
# 
# Path: coconut/util.py
# def get_clock_time():
#     """Get a time to use for performance metrics."""
#     if PY2:
#         return time.clock()
#     else:
#         return time.process_time()
# 
# Path: coconut/util.py
# def ver_str_to_tuple(ver_str):
#     """Convert a version string into a version tuple."""
#     out = []
#     for x in ver_str.split("."):
#         try:
#             x = int(x)
#         except ValueError:
#             pass
#         out.append(x)
#     return tuple(out)
# 
# def ver_tuple_to_str(req_ver):
#     """Converts a requirement version tuple into a version string."""
#     return ".".join(str(x) for x in req_ver)
# 
# def get_next_version(req_ver, point_to_increment=-1):
#     """Get the next version after the given version."""
#     return req_ver[:point_to_increment] + (req_ver[point_to_increment] + 1,)


from coconut.root import *  # NOQA
from warnings import warn
from collections import defaultdict
from coconut.constants import (
    PURE_PYTHON,
    PYPY,
    use_fast_pyparsing_reprs,
    use_packrat_parser,
    packrat_cache_size,
    default_whitespace_chars,
    varchars,
    min_versions,
    pure_python_env_var,
    enable_pyparsing_warnings,
    use_left_recursion_if_available,
)
from coconut.util import get_clock_time  # NOQA
from coconut.util import (
    ver_str_to_tuple,
    ver_tuple_to_str,
    get_next_version,
)
    from cPyparsing import *  # NOQA
    from cPyparsing import __version__
        from pyparsing import *  # NOQA
        from pyparsing import __version__
    from coconut.terminal import internal_assert  # hide to avoid circular import
    from coconut.terminal import logger  # hide to avoid circular imports
import os
import sys
import traceback
import functools
import inspect
    import cPyparsing as _pyparsing
        import pyparsing as _pyparsing
if PY2:
    def fast_repr(cls):
        """A very simple, fast __repr__/__str__ implementation."""
        return "<" + cls.__name__ + ">"
else:
    fast_repr = object.__repr__


_old_pyparsing_reprs = []


def set_fast_pyparsing_reprs():
    """Make pyparsing much faster by preventing it from computing expensive nested string representations."""
    for obj in vars(_pyparsing).values():
        try:
            if issubclass(obj, ParserElement):
                _old_pyparsing_reprs.append((obj, (obj.__repr__, obj.__str__)))
                obj.__repr__ = functools.partial(fast_repr, obj)
                obj.__str__ = functools.partial(fast_repr, obj)
        except TypeError:
            pass


def unset_fast_pyparsing_reprs():
    """Restore pyparsing's default string representations for ease of debugging."""
    for obj, (repr_method, str_method) in _old_pyparsing_reprs:
        obj.__repr__ = repr_method
        obj.__str__ = str_method



# Path: coconut/constants.py
# def fixpath(path):
# def str_to_bool(boolstr, default=False):
# WINDOWS = os.name == "nt"
# PYPY = platform.python_implementation() == "PyPy"
# CPYTHON = platform.python_implementation() == "CPython"
# PY32 = sys.version_info >= (3, 2)
# PY33 = sys.version_info >= (3, 3)
# PY34 = sys.version_info >= (3, 4)
# PY35 = sys.version_info >= (3, 5)
# PY36 = sys.version_info >= (3, 6)
# PY38 = sys.version_info >= (3, 8)
# PY310 = sys.version_info >= (3, 10)
# IPY = (
#     ((PY2 and not PY26) or PY35)
#     and not (PYPY and WINDOWS)
#     # necessary until jupyter-console fixes https://github.com/jupyter/jupyter_console/issues/245
#     and not PY310
# )
# MYPY = (
#     PY34
#     and not WINDOWS
#     and not PYPY
# )
# PURE_PYTHON = str_to_bool(os.environ.get(pure_python_env_var, ""))
# 
# Path: coconut/util.py
# def get_clock_time():
#     """Get a time to use for performance metrics."""
#     if PY2:
#         return time.clock()
#     else:
#         return time.process_time()
# 
# Path: coconut/util.py
# def ver_str_to_tuple(ver_str):
#     """Convert a version string into a version tuple."""
#     out = []
#     for x in ver_str.split("."):
#         try:
#             x = int(x)
#         except ValueError:
#             pass
#         out.append(x)
#     return tuple(out)
# 
# def ver_tuple_to_str(req_ver):
#     """Converts a requirement version tuple into a version string."""
#     return ".".join(str(x) for x in req_ver)
# 
# def get_next_version(req_ver, point_to_increment=-1):
#     """Get the next version after the given version."""
#     return req_ver[:point_to_increment] + (req_ver[point_to_increment] + 1,)


# Path: coconut/_pyparsing.py
from coconut.root import *  # NOQA
from warnings import warn
from collections import defaultdict
from coconut.constants import (
    PURE_PYTHON,
    PYPY,
    use_fast_pyparsing_reprs,
    use_packrat_parser,
    packrat_cache_size,
    default_whitespace_chars,
    varchars,
    min_versions,
    pure_python_env_var,
    enable_pyparsing_warnings,
    use_left_recursion_if_available,
)
from coconut.util import get_clock_time  # NOQA
from coconut.util import (
    ver_str_to_tuple,
    ver_tuple_to_str,
    get_next_version,
)
    from cPyparsing import *  # NOQA
    from cPyparsing import __version__
        from pyparsing import *  # NOQA
        from pyparsing import __version__
    from coconut.terminal import internal_assert  # hide to avoid circular import
    from coconut.terminal import logger  # hide to avoid circular imports
import os
import sys
import traceback
import functools
import inspect
    import cPyparsing as _pyparsing
        import pyparsing as _pyparsing

if PY2:
    def fast_repr(cls):
        """A very simple, fast __repr__/__str__ implementation."""
        return "<" + cls.__name__ + ">"
else:
    fast_repr = object.__repr__


_old_pyparsing_reprs = []


def set_fast_pyparsing_reprs():
    """Make pyparsing much faster by preventing it from computing expensive nested string representations."""
    for obj in vars(_pyparsing).values():
        try:
            if issubclass(obj, ParserElement):
                _old_pyparsing_reprs.append((obj, (obj.__repr__, obj.__str__)))
                obj.__repr__ = functools.partial(fast_repr, obj)
                obj.__str__ = functools.partial(fast_repr, obj)
        except TypeError:
            pass


def unset_fast_pyparsing_reprs():
    """Restore pyparsing's default string representations for ease of debugging."""
    for obj, (repr_method, str_method) in _old_pyparsing_reprs:
        obj.__repr__ = repr_method
        obj.__str__ = str_method



if use_fast_pyparsing_reprs: