coconut-develop 3.0.2.post0.dev7__tar.gz → 3.0.2.post0.dev13__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/DOCS.md +2 -0
- coconut-develop-3.0.2.post0.dev13/PKG-INFO +140 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/_coconut/__init__.pyi +1 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/_pyparsing.py +81 -44
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/compiler/compiler.py +339 -219
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/compiler/grammar.py +93 -79
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/compiler/header.py +15 -14
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/compiler/templates/header.py_template +10 -8
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/compiler/util.py +65 -17
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/constants.py +28 -17
- coconut-develop-3.0.2.post0.dev13/coconut/icoconut/coconut/kernel.json +11 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/root.py +1 -1
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/terminal.py +5 -1
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/tests/constants_test.py +2 -2
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/tests/main_test.py +2 -1
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/tests/src/cocotest/agnostic/primary.coco +24 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/tests/src/cocotest/agnostic/suite.coco +2 -2
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/tests/src/cocotest/agnostic/util.coco +4 -3
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/tests/src/cocotest/non_strict/non_strict_test.coco +1 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/tests/src/cocotest/target_sys/target_sys_test.coco +4 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/tests/src/extras.coco +9 -1
- coconut-develop-3.0.2.post0.dev7/PKG-INFO +0 -137
- coconut-develop-3.0.2.post0.dev7/coconut/icoconut/coconut/kernel.json +0 -11
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/CONTRIBUTING.md +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/FAQ.md +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/HELP.md +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/LICENSE.txt +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/MANIFEST.in +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/README.rst +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/__coconut__/__init__.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/__coconut__/__init__.pyi +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/__coconut__/py.typed +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/_coconut/__init__.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/_coconut/py.typed +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/__coconut__.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/__coconut__.pyi +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/__init__.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/__init__.pyi +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/__main__.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/api.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/api.pyi +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/command/__init__.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/command/__init__.pyi +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/command/cli.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/command/command.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/command/command.pyi +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/command/mypy.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/command/resources/zcoconut.pth +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/command/util.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/command/watch.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/compiler/__init__.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/compiler/matching.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/convenience.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/convenience.pyi +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/exceptions.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/highlighter.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/icoconut/__init__.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/icoconut/__main__.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/icoconut/coconut_py/kernel.json +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/icoconut/coconut_py2/kernel.json +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/icoconut/coconut_py3/kernel.json +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/icoconut/embed.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/icoconut/root.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/integrations.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/main.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/py.typed +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/requirements.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/tests/__init__.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/tests/__main__.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/tests/src/cocotest/agnostic/__init__.coco +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/tests/src/cocotest/agnostic/main.coco +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/tests/src/cocotest/agnostic/specific.coco +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/tests/src/cocotest/agnostic/tutorial.coco +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/tests/src/cocotest/target_2/py2_test.coco +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/tests/src/cocotest/target_3/py3_test.coco +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/tests/src/cocotest/target_35/py35_test.coco +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/tests/src/cocotest/target_36/py36_test.coco +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/tests/src/cocotest/target_38/py38_test.coco +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/tests/src/runnable.coco +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/tests/src/runner.coco +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/util.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut_develop.egg-info/SOURCES.txt +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/conf.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/pyproject.toml +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/setup.cfg +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/setup.py +0 -0
- {coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/xontrib/coconut.py +0 -0
|
@@ -541,6 +541,8 @@ Additionally, Coconut also supports an implicit usage of the `->` operator of th
|
|
|
541
541
|
|
|
542
542
|
_Note: If normal lambda syntax is insufficient, Coconut also supports an extended lambda syntax in the form of [statement lambdas](#statement-lambdas). Statement lambdas support full statements rather than just expressions and allow for the use of [pattern-matching function definition](#pattern-matching-functions)._
|
|
543
543
|
|
|
544
|
+
_Note: `->`-based lambdas are disabled inside type annotations to avoid conflicting with Coconut's [enhanced type annotation syntax](#enhanced-type-annotation)._
|
|
545
|
+
|
|
544
546
|
##### Rationale
|
|
545
547
|
|
|
546
548
|
In Python, lambdas are ugly and bulky, requiring the entire word `lambda` to be written out every time one is constructed. This is fine if in-line functions are very rarely needed, but in functional programming in-line functions are an essential tool.
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: coconut-develop
|
|
3
|
+
Version: 3.0.2.post0.dev13
|
|
4
|
+
Summary: Simple, elegant, Pythonic functional programming.
|
|
5
|
+
Home-page: http://coconut-lang.org
|
|
6
|
+
Author: Evan Hubinger
|
|
7
|
+
Author-email: evanjhub@gmail.com
|
|
8
|
+
License: Apache 2.0
|
|
9
|
+
Keywords: functional,programming,language,compiler,pattern,pattern-matching,algebraic,data type,data types,lambda,lambdas,lazy,evaluation,lazy list,lazy lists,tail,recursion,call,recursive,infix,function,composition,compose,partial,application,currying,curry,pipeline,pipe,unicode,operator,operators,frozenset,literal,syntax,destructuring,assignment,fold,datamaker,prepattern,iterator,none,coalesce,coalescing,statement,lru_cache,memoization,backport,typing,embed,PEP 622,overrides,islice,itertools,functools,TYPE_CHECKING,Expected,breakpoint,help,reduce,takewhile,dropwhile,tee,count,makedata,consume,parallel_map,addpattern,recursive_iterator,concurrent_map,fmap,starmap,reiterable,scan,groupsof,memoize,zip_longest,override,flatten,ident,call,safe_call,flip,const,lift,all_equal,collectby,multi_enumerate,cartesian_product,multiset,cycle,windowsof,and_then,and_then_await,py_chr,py_dict,py_hex,py_input,py_int,py_map,py_object,py_oct,py_open,py_print,py_range,py_str,py_super,py_zip,py_filter,py_reversed,py_enumerate,py_raw_input,py_xrange,py_repr,py_breakpoint,_namedtuple_of,reveal_type,reveal_locals,MatchError,__fmap__,__iter_getitem__,data,match,case,cases,where,addpattern,then,operator,type,copyclosure,λ
|
|
10
|
+
Platform: UNKNOWN
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Topic :: Software Development
|
|
15
|
+
Classifier: Topic :: Software Development :: Code Generators
|
|
16
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
17
|
+
Classifier: Topic :: Software Development :: Interpreters
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
|
+
Classifier: Topic :: Utilities
|
|
20
|
+
Classifier: Environment :: Console
|
|
21
|
+
Classifier: Operating System :: OS Independent
|
|
22
|
+
Classifier: Programming Language :: Python
|
|
23
|
+
Classifier: Programming Language :: Python :: 2
|
|
24
|
+
Classifier: Programming Language :: Python :: 2.6
|
|
25
|
+
Classifier: Programming Language :: Python :: 2.7
|
|
26
|
+
Classifier: Programming Language :: Python :: 3
|
|
27
|
+
Classifier: Programming Language :: Python :: 3.2
|
|
28
|
+
Classifier: Programming Language :: Python :: 3.3
|
|
29
|
+
Classifier: Programming Language :: Python :: 3.4
|
|
30
|
+
Classifier: Programming Language :: Python :: 3.5
|
|
31
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
32
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
33
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
37
|
+
Classifier: Programming Language :: Other
|
|
38
|
+
Classifier: Programming Language :: Other Scripting Engines
|
|
39
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
40
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
41
|
+
Classifier: Framework :: IPython
|
|
42
|
+
Classifier: Framework :: Jupyter
|
|
43
|
+
Classifier: Typing :: Typed
|
|
44
|
+
Provides-Extra: kernel
|
|
45
|
+
Provides-Extra: watch
|
|
46
|
+
Provides-Extra: mypy
|
|
47
|
+
Provides-Extra: backports
|
|
48
|
+
Provides-Extra: xonsh
|
|
49
|
+
Provides-Extra: jupyter
|
|
50
|
+
Provides-Extra: all
|
|
51
|
+
Provides-Extra: ipython
|
|
52
|
+
Provides-Extra: docs
|
|
53
|
+
Provides-Extra: tests
|
|
54
|
+
Provides-Extra: dev
|
|
55
|
+
License-File: LICENSE.txt
|
|
56
|
+
|
|
57
|
+
|logo| Coconut
|
|
58
|
+
==============
|
|
59
|
+
|
|
60
|
+
..
|
|
61
|
+
<insert toctree here>
|
|
62
|
+
|
|
63
|
+
.. |logo| image:: https://github.com/evhub/coconut/raw/gh-pages/favicon-32x32.png
|
|
64
|
+
|
|
65
|
+
.. image:: https://opencollective.com/coconut/backers/badge.svg
|
|
66
|
+
:alt: Backers on Open Collective
|
|
67
|
+
:target: #backers
|
|
68
|
+
.. image:: https://opencollective.com/coconut/sponsors/badge.svg
|
|
69
|
+
:alt: Sponsors on Open Collective
|
|
70
|
+
:target: #sponsors
|
|
71
|
+
.. image:: https://badges.gitter.im/evhub/coconut.svg
|
|
72
|
+
:alt: Join the chat at https://gitter.im/evhub/coconut
|
|
73
|
+
:target: https://gitter.im/evhub/coconut?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
|
|
74
|
+
|
|
75
|
+
Coconut (`coconut-lang.org`__) is a variant of Python_ that **adds on top of Python syntax** new features for simple, elegant, Pythonic **functional programming**.
|
|
76
|
+
|
|
77
|
+
__ Coconut_
|
|
78
|
+
.. _Coconut: http://coconut-lang.org/
|
|
79
|
+
|
|
80
|
+
Coconut is developed on GitHub_ and hosted on PyPI_. Installing Coconut is as easy as opening a command prompt and entering::
|
|
81
|
+
|
|
82
|
+
pip install coconut
|
|
83
|
+
|
|
84
|
+
To help you get started, check out these links for more information about Coconut:
|
|
85
|
+
|
|
86
|
+
- Tutorial_: If you're new to Coconut, a good place to start is Coconut's **tutorial**.
|
|
87
|
+
- Documentation_: If you're looking for info about a specific feature, check out Coconut's **documentation**.
|
|
88
|
+
- `Online Interpreter`_: If you want to try Coconut in your browser, check out Coconut's **online interpreter**.
|
|
89
|
+
- FAQ_: If you have general questions about Coconut—like who Coconut is built for and whether or not you should use it—Coconut's frequently asked questions are often the best place to start.
|
|
90
|
+
- `Create a New Issue <https://github.com/evhub/coconut/issues/new>`_: If you're having a problem with Coconut, creating a new issue detailing the problem will allow it to be addressed as soon as possible.
|
|
91
|
+
- Gitter_: For any questions, concerns, or comments about anything Coconut-related, ask around at Coconut's Gitter, a GitHub-integrated chat room for Coconut developers.
|
|
92
|
+
- Releases_: Want to know what's been added in recent Coconut versions? Check out the release log for all the new features and fixes.
|
|
93
|
+
|
|
94
|
+
.. _Python: https://www.python.org/
|
|
95
|
+
.. _PyPI: https://pypi.python.org/pypi/coconut
|
|
96
|
+
.. _Tutorial: http://coconut.readthedocs.io/en/latest/HELP.html
|
|
97
|
+
.. _Documentation: http://coconut.readthedocs.io/en/latest/DOCS.html
|
|
98
|
+
.. _`Online Interpreter`: https://cs121-team-panda.github.io/coconut-interpreter
|
|
99
|
+
.. _FAQ: http://coconut.readthedocs.io/en/latest/FAQ.html
|
|
100
|
+
.. _GitHub: https://github.com/evhub/coconut
|
|
101
|
+
.. _Gitter: https://gitter.im/evhub/coconut
|
|
102
|
+
.. _Releases: https://github.com/evhub/coconut/releases
|
|
103
|
+
|
|
104
|
+
Credits
|
|
105
|
+
+++++++
|
|
106
|
+
|
|
107
|
+
Contributors
|
|
108
|
+
------------
|
|
109
|
+
|
|
110
|
+
This project exists thanks to all the people who contribute! `Become a contributor`__.
|
|
111
|
+
|
|
112
|
+
.. image:: https://opencollective.com/coconut/contributors.svg?width=890&button=false
|
|
113
|
+
:target: https://github.com/evhub/coconut/graphs/contributors
|
|
114
|
+
|
|
115
|
+
__ Contributor_
|
|
116
|
+
.. _Contributor: http://coconut.readthedocs.io/en/develop/CONTRIBUTING.html
|
|
117
|
+
|
|
118
|
+
Backers
|
|
119
|
+
-------
|
|
120
|
+
|
|
121
|
+
Thank you to all our backers! `Become a backer`__.
|
|
122
|
+
|
|
123
|
+
.. image:: https://opencollective.com/coconut/backers.svg?width=890
|
|
124
|
+
:target: https://opencollective.com/coconut#backers
|
|
125
|
+
|
|
126
|
+
__ Backer_
|
|
127
|
+
.. _Backer: https://opencollective.com/coconut#backer
|
|
128
|
+
|
|
129
|
+
Sponsors
|
|
130
|
+
--------
|
|
131
|
+
|
|
132
|
+
Support Coconut by becoming a sponsor. Your logo will show up here with a link to your website. `Become a sponsor`__.
|
|
133
|
+
|
|
134
|
+
.. image:: https://opencollective.com/XX/sponsor/0/avatar.svg
|
|
135
|
+
:target: https://opencollective.com/coconut/sponsor/0/website
|
|
136
|
+
|
|
137
|
+
__ Sponsor_
|
|
138
|
+
.. _Sponsor: https://opencollective.com/coconut#sponsor
|
|
139
|
+
|
|
140
|
+
|
{coconut-develop-3.0.2.post0.dev7 → coconut-develop-3.0.2.post0.dev13}/coconut/_pyparsing.py
RENAMED
|
@@ -41,6 +41,8 @@ from coconut.constants import (
|
|
|
41
41
|
use_left_recursion_if_available,
|
|
42
42
|
get_bool_env_var,
|
|
43
43
|
use_computation_graph_env_var,
|
|
44
|
+
use_incremental_if_available,
|
|
45
|
+
incremental_cache_size,
|
|
44
46
|
)
|
|
45
47
|
from coconut.util import get_clock_time # NOQA
|
|
46
48
|
from coconut.util import (
|
|
@@ -80,7 +82,7 @@ except ImportError:
|
|
|
80
82
|
|
|
81
83
|
|
|
82
84
|
# -----------------------------------------------------------------------------------------------------------------------
|
|
83
|
-
#
|
|
85
|
+
# VERSIONING:
|
|
84
86
|
# -----------------------------------------------------------------------------------------------------------------------
|
|
85
87
|
|
|
86
88
|
min_ver = min(min_versions["pyparsing"], min_versions["cPyparsing"][:3]) # inclusive
|
|
@@ -103,26 +105,82 @@ elif cur_ver >= max_ver:
|
|
|
103
105
|
+ " (run '{python} -m pip install {package}<{max_ver}' to fix)".format(python=sys.executable, package=PYPARSING_PACKAGE, max_ver=max_ver_str),
|
|
104
106
|
)
|
|
105
107
|
|
|
108
|
+
MODERN_PYPARSING = cur_ver >= (3,)
|
|
109
|
+
|
|
110
|
+
if MODERN_PYPARSING:
|
|
111
|
+
warn(
|
|
112
|
+
"This version of Coconut is not built for pyparsing v3; some syntax features WILL NOT WORK"
|
|
113
|
+
+ " (run either '{python} -m pip install cPyparsing<{max_ver}' or '{python} -m pip install pyparsing<{max_ver}' to fix)".format(python=sys.executable, max_ver=max_ver_str),
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
# -----------------------------------------------------------------------------------------------------------------------
|
|
118
|
+
# OVERRIDES:
|
|
119
|
+
# -----------------------------------------------------------------------------------------------------------------------
|
|
120
|
+
|
|
121
|
+
if PYPARSING_PACKAGE != "cPyparsing":
|
|
122
|
+
if not MODERN_PYPARSING:
|
|
123
|
+
HIT, MISS = 0, 1
|
|
124
|
+
|
|
125
|
+
def _parseCache(self, instring, loc, doActions=True, callPreParse=True):
|
|
126
|
+
# [CPYPARSING] include packrat_context
|
|
127
|
+
lookup = (self, instring, loc, callPreParse, doActions, tuple(self.packrat_context))
|
|
128
|
+
with ParserElement.packrat_cache_lock:
|
|
129
|
+
cache = ParserElement.packrat_cache
|
|
130
|
+
value = cache.get(lookup)
|
|
131
|
+
if value is cache.not_in_cache:
|
|
132
|
+
ParserElement.packrat_cache_stats[MISS] += 1
|
|
133
|
+
try:
|
|
134
|
+
value = self._parseNoCache(instring, loc, doActions, callPreParse)
|
|
135
|
+
except ParseBaseException as pe:
|
|
136
|
+
# cache a copy of the exception, without the traceback
|
|
137
|
+
cache.set(lookup, pe.__class__(*pe.args))
|
|
138
|
+
raise
|
|
139
|
+
else:
|
|
140
|
+
cache.set(lookup, (value[0], value[1].copy()))
|
|
141
|
+
return value
|
|
142
|
+
else:
|
|
143
|
+
ParserElement.packrat_cache_stats[HIT] += 1
|
|
144
|
+
if isinstance(value, Exception):
|
|
145
|
+
raise value
|
|
146
|
+
return value[0], value[1].copy()
|
|
147
|
+
ParserElement.packrat_context = []
|
|
148
|
+
ParserElement._parseCache = _parseCache
|
|
149
|
+
|
|
150
|
+
elif not hasattr(ParserElement, "packrat_context"):
|
|
151
|
+
raise ImportError(
|
|
152
|
+
"This version of Coconut requires cPyparsing>=" + ver_tuple_to_str(min_versions["cPyparsing"])
|
|
153
|
+
+ "; got cPyparsing==" + __version__
|
|
154
|
+
+ " (run '{python} -m pip install --upgrade cPyparsing' to fix)".format(python=sys.executable),
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
if hasattr(ParserElement, "enableIncremental"):
|
|
158
|
+
SUPPORTS_INCREMENTAL = True
|
|
159
|
+
else:
|
|
160
|
+
SUPPORTS_INCREMENTAL = False
|
|
161
|
+
ParserElement._incrementalEnabled = False
|
|
162
|
+
ParserElement._incrementalWithResets = False
|
|
163
|
+
|
|
164
|
+
def enableIncremental(*args, **kwargs):
|
|
165
|
+
"""Dummy version of enableIncremental that just raises an error."""
|
|
166
|
+
raise ImportError(
|
|
167
|
+
"incremental parsing only supported on cPyparsing>="
|
|
168
|
+
+ ver_tuple_to_str(min_versions["cPyparsing"])
|
|
169
|
+
+ " (run '{python} -m pip install --upgrade cPyparsing' to fix)".format(python=sys.executable)
|
|
170
|
+
)
|
|
171
|
+
|
|
106
172
|
|
|
107
173
|
# -----------------------------------------------------------------------------------------------------------------------
|
|
108
174
|
# SETUP:
|
|
109
175
|
# -----------------------------------------------------------------------------------------------------------------------
|
|
110
176
|
|
|
111
|
-
if
|
|
112
|
-
MODERN_PYPARSING = True
|
|
177
|
+
if MODERN_PYPARSING:
|
|
113
178
|
_trim_arity = _pyparsing.core._trim_arity
|
|
114
179
|
_ParseResultsWithOffset = _pyparsing.core._ParseResultsWithOffset
|
|
115
180
|
else:
|
|
116
|
-
MODERN_PYPARSING = False
|
|
117
181
|
_trim_arity = _pyparsing._trim_arity
|
|
118
182
|
_ParseResultsWithOffset = _pyparsing._ParseResultsWithOffset
|
|
119
183
|
|
|
120
|
-
if MODERN_PYPARSING:
|
|
121
|
-
warn(
|
|
122
|
-
"This version of Coconut is not built for pyparsing v3; some syntax features WILL NOT WORK"
|
|
123
|
-
+ " (run either '{python} -m pip install cPyparsing<{max_ver}' or '{python} -m pip install pyparsing<{max_ver}' to fix)".format(python=sys.executable, max_ver=max_ver_str),
|
|
124
|
-
)
|
|
125
|
-
|
|
126
184
|
USE_COMPUTATION_GRAPH = get_bool_env_var(
|
|
127
185
|
use_computation_graph_env_var,
|
|
128
186
|
default=(
|
|
@@ -140,6 +198,8 @@ if enable_pyparsing_warnings:
|
|
|
140
198
|
|
|
141
199
|
if MODERN_PYPARSING and use_left_recursion_if_available:
|
|
142
200
|
ParserElement.enable_left_recursion()
|
|
201
|
+
elif SUPPORTS_INCREMENTAL and use_incremental_if_available:
|
|
202
|
+
ParserElement.enableIncremental(incremental_cache_size, still_reset_cache=True)
|
|
143
203
|
elif use_packrat_parser:
|
|
144
204
|
ParserElement.enablePackrat(packrat_cache_size)
|
|
145
205
|
|
|
@@ -149,42 +209,18 @@ Keyword.setDefaultKeywordChars(varchars)
|
|
|
149
209
|
|
|
150
210
|
|
|
151
211
|
# -----------------------------------------------------------------------------------------------------------------------
|
|
152
|
-
#
|
|
212
|
+
# MISSING OBJECTS:
|
|
153
213
|
# -----------------------------------------------------------------------------------------------------------------------
|
|
154
214
|
|
|
155
|
-
if
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
)
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
HIT, MISS = 0, 1
|
|
165
|
-
# [CPYPARSING] include packrat_context
|
|
166
|
-
lookup = (self, instring, loc, callPreParse, doActions, tuple(self.packrat_context))
|
|
167
|
-
with ParserElement.packrat_cache_lock:
|
|
168
|
-
cache = ParserElement.packrat_cache
|
|
169
|
-
value = cache.get(lookup)
|
|
170
|
-
if value is cache.not_in_cache:
|
|
171
|
-
ParserElement.packrat_cache_stats[MISS] += 1
|
|
172
|
-
try:
|
|
173
|
-
value = self._parseNoCache(instring, loc, doActions, callPreParse)
|
|
174
|
-
except ParseBaseException as pe:
|
|
175
|
-
# cache a copy of the exception, without the traceback
|
|
176
|
-
cache.set(lookup, pe.__class__(*pe.args))
|
|
177
|
-
raise
|
|
178
|
-
else:
|
|
179
|
-
cache.set(lookup, (value[0], value[1].copy()))
|
|
180
|
-
return value
|
|
181
|
-
else:
|
|
182
|
-
ParserElement.packrat_cache_stats[HIT] += 1
|
|
183
|
-
if isinstance(value, Exception):
|
|
184
|
-
raise value
|
|
185
|
-
return value[0], value[1].copy()
|
|
186
|
-
ParserElement.packrat_context = []
|
|
187
|
-
ParserElement._parseCache = _parseCache
|
|
215
|
+
if not hasattr(_pyparsing, "python_quoted_string"):
|
|
216
|
+
import re as _re
|
|
217
|
+
python_quoted_string = _pyparsing.Combine(
|
|
218
|
+
(_pyparsing.Regex(r'"""(?:[^"\\]|""(?!")|"(?!"")|\\.)*', flags=_re.MULTILINE) + '"""').setName("multiline double quoted string")
|
|
219
|
+
^ (_pyparsing.Regex(r"'''(?:[^'\\]|''(?!')|'(?!'')|\\.)*", flags=_re.MULTILINE) + "'''").setName("multiline single quoted string")
|
|
220
|
+
^ (_pyparsing.Regex(r'"(?:[^"\n\r\\]|(?:\\")|(?:\\(?:[^x]|x[0-9a-fA-F]+)))*') + '"').setName("double quoted string")
|
|
221
|
+
^ (_pyparsing.Regex(r"'(?:[^'\n\r\\]|(?:\\')|(?:\\(?:[^x]|x[0-9a-fA-F]+)))*") + "'").setName("single quoted string")
|
|
222
|
+
).setName("Python quoted string")
|
|
223
|
+
_pyparsing.python_quoted_string = python_quoted_string
|
|
188
224
|
|
|
189
225
|
|
|
190
226
|
# -----------------------------------------------------------------------------------------------------------------------
|
|
@@ -335,6 +371,7 @@ def collect_timing_info():
|
|
|
335
371
|
"_ErrorStop",
|
|
336
372
|
"_UnboundedCache",
|
|
337
373
|
"enablePackrat",
|
|
374
|
+
"enableIncremental",
|
|
338
375
|
"inlineLiteralsUsing",
|
|
339
376
|
"setDefaultWhitespaceChars",
|
|
340
377
|
"setDefaultKeywordChars",
|