summaryrefslogtreecommitdiff
path: root/Cython/Compiler/Parsing.py
Commit message (Collapse)AuthorAgeFilesLines
* Keep 'extern' visibility in context of struct/union to properly infer ↵Matus Valo2023-05-031-1/+1
| | | | 'noexcept' for function pointer fields (GH-5386)
* Fix parsing of bracketed then called context managers (GH-5404)da-woods2023-04-281-0/+4
| | | | | | | Require the bracketed multiple context managers to be followed by a colon, so that the bracketed called context manager is identified as regular parentheses in old-style syntax. Fixes https://github.com/cython/cython/issues/5403
* Add compiler directive to disable the default exception propagation for ↵Matus Valo2022-12-061-0/+6
| | | | legacy code (GH-5094)
* Remove "from x cimport class C" (#4904)da-woods2022-10-111-15/+8
| | | | | | | | | | | | | | | | | | | | | | | (and "struct S"/"union U") This appears to be an old Pyrex feature introduced in https://github.com/cython/cython/commit/9bac9c2e014ed63c2ac435e9b431fae124fba668 to provide a way of "forward cimporting" a class. I originally tried to make a test for it, but couldn't actually come up with a useful way of using it in the intended way, where the name would be unavailable initially but avaialble later. It looks to be completely untested, and responsible for some missing coverage in Nodes.py (https://github.com/cython/cython/issues/4163). The large section containing ``` if kind == 'struct' or kind == 'union': # 8479 ↛ 8480 ``` I propose to fix the missing coverage by killing off the feature. The only people I could find using this syntax were H5Py, who look to have removed their sole use of it 3 years ago https://github.com/h5py/h5py/commit/8d2498c7f5e3fec884ff56e9aca905c325d82484 Therefore it seems a good candidate to go in Cython 3
* PEP614 decorators (#4991)da-woods2022-10-011-8/+1
| | | Relaxes the grammar restrictions on decorators
* [ENH] Propagate exceptions from `cdef` functions by default (#4670)Ashwin Srinath2022-09-101-8/+57
| | | | | Change the default behavior to always check for exceptions after a call to a cdef function defined in Cython. Calls to extern cdef functions are not checked by default.
* Remove `p_lambdef_nocond` from the parser, following Python 3.9+. (GH-4992)da-woods2022-09-051-20/+8
| | | | | | | | | | | | | | | | | | Note that it wasn't correct before since it didn't pass the correct flag to `p_lambdef` and thus was equivalent to just using `p_lambdef`. Note also that there's a difference in behaviour between Python3.9+ and before. Python <3.9 allowed `[i for i in range(10) if lambda: i]` while Python >=3.9 disallows this. Arguably it's pointless because the lambda always evaluates to True. See https://github.com/python/cpython/issues/86014 for the Python issue. With this change Cython will follow the Python 3.9 behaviour at the cost of potentially breaking some code that does use the pattern above. Part of the cleanup in https://github.com/cython/cython/issues/4595
* Allow C code assertions in tests by defining regular expressions in module ↵scoder2022-07-301-0/+3
| | | | directives. (GH-4938)
* Remove unused function "looking_at_call" from parser (GH-4922)da-woods2022-07-261-10/+0
|
* Refactor "with" parsing code to reduce code duplication.Stefan Behnel2022-07-171-19/+18
|
* Enable parenthesized context managers (GH-4814)da-woods2022-07-171-13/+49
| | | | | | | As described in https://docs.python.org/3/whatsnew/3.10.html#parenthesized-context-managers The approach to parsing is largely copied from the CPython parser (with comments to support it) - closer to the PEG approach of "try the bracketed case first, and let it fail silently then try the unbracketed case".
* Make it easier to restore scanner state during parsing phase (GH-4813)da-woods2022-07-161-13/+18
| | | | | | | | | Things like match-case (essentially anything that uses Python's new PEG parser capacities) are going to have to be implemented by trying to parse something, failing, then going back and trying to parse something else. This commit gets the initial work done to make this easier to do. Several error positions change in this effort, but this seems to improve the error reporting overall.
* Refactor parsing of named expressions to bring it closer to CPython's LL ↵da-woods2022-07-161-36/+66
| | | | | | | | parser (GH-4846) I've tried to rewrite it to largely follow the rules from the most recent version of the Python LL parser, so avoiding conditional parameters. See https://github.com/cython/cython/issues/4595
* Reject invalid spellings of Ellipsis (GH-4868)0dminnimda2022-07-041-9/+7
|
* Also add a deprecation warning for the compile time DEF statement.Stefan Behnel2022-02-251-0/+4
| | | | See https://github.com/cython/cython/issues/4310
* Add a deprecation warning to usages of the compile time "IF" statement.Stefan Behnel2022-02-241-0/+4
| | | | See https://github.com/cython/cython/issues/4310
* Remove unused imports (GH-4643)Matus Valo2022-02-151-1/+1
|
* Implement PEP 572: Named/Assignment Expressions (GH-3691)da-woods2022-01-271-18/+35
| | | Closes https://github.com/cython/cython/issues/2636
* Fix type declaration in parser.Stefan Behnel2021-07-261-2/+2
|
* Fix the type of the 'self' argument in a cdef staticmethod declared in a pxd ↵da-woods2021-07-261-9/+6
| | | | | | | | | | file (GH-4085) Fixes https://github.com/cython/cython/issues/3174 Closes https://github.com/cython/cython/pull/3175 I've removed all identification of is_self_arg from the parser, since I think it's better dealt with when analysing the declarations. Original test copied from https://github.com/cython/cython/pull/3175
* Assume that any assignment to a variable that has a PEP-526 type annotation ↵Stefan Behnel2021-05-221-1/+5
| | | | | | is the first assignment to that variable. This makes literal list assignments to declared pointers work.
* Avoid string concatenation where we can just compare characters separately.Stefan Behnel2021-05-031-7/+4
|
* Self documenting f-strings (GH-3939)davfsa2021-05-031-11/+38
| | | Closes https://github.com/cython/cython/issues/3796
* Modernise code: use set literals/comprehensions where possible, frozenset ↵Stefan Behnel2021-04-131-19/+23
| | | | where appropriate.
* Allow const declarations in nested template arguments (GH-3886)Ashwin Srinath2020-11-051-1/+1
| | | Closes https://github.com/cython/cython/issues/1355
* Improve error reporting when users mistakenly write "&&" or "||" instead of ↵scoder2020-10-211-6/+13
| | | | Python's "and" and "or" operators. (GH-3858)
* Add support for forwarding references (GH-3821)Ashwin Srinath2020-10-031-5/+6
| | | | | See, for example, https://isocpp.org/blog/2012/11/universal-references-in-c11-scott-meyers Closes #3814
* Declare "scanner.sy" as "unicode" string to optimise its usage.Stefan Behnel2020-09-301-9/+9
|
* Join '*' and '**' parsing in declarators to avoid differences for 'const' ↵Stefan Behnel2020-09-301-23/+16
| | | | parsing etc.
* Add doc support for cpdef enum (GH-3813)matham2020-09-101-1/+3
|
* Allow cast to ctuple (GH-3812)da-woods2020-09-051-3/+6
|
* Add support for C++ scoped enums with "enum class" and "enum struct" (GH-3640)Ashwin Srinath2020-06-181-7/+42
| | | Closes #1603.
* Remove dead code.Stefan Behnel2020-06-171-1/+0
|
* Fix many indentation and whitespace issues throughout the code base (GH-3673)scoder2020-06-101-14/+14
| | | … and enforce them with pycodestyle.
* Merge branch '0.29.x'Stefan Behnel2020-06-101-14/+26
|\
| * Correct the positions reported for errors in f-strings.Stefan Behnel2020-06-101-14/+26
| | | | | | | | Closes https://github.com/cython/cython/issues/3674
* | Merge branch '0.29.x'Stefan Behnel2020-05-151-1/+1
|\ \ | |/
| * Allow decorators on nested async-def functions.Stefan Behnel2020-05-151-1/+1
| | | | | | | | Closes https://github.com/cython/cython/issues/1462
* | Reimplement the "assert" statement by delegating the exception raising to a ↵Stefan Behnel2020-04-291-1/+1
| | | | | | | | | | | | RaiseStatNode. This allows taking advantage of the automatic "with gil" block handling for raising exceptions, allows proper control flow analysis, etc.
* | Minor code simplification.Stefan Behnel2020-04-291-5/+1
| |
* | Implement PEP-563, annotations as strings (GH-3285)da-woods2020-01-041-4/+15
| | | | | | | | | | | | | | | | Annotations are now dealt with according to PEP-563 - they are saved as strings, rather than evaluated as Python objects. They can/are still be used by Cython for typing. Previous behaviour for evaluating them as Python objects was convoluted and has been removed entirely, which hopefully doesn't break too much.
* | Allow docstrings in c++ classes (GH-3183)samaingw2019-10-181-0/+4
| |
* | Adds positional only args support (PEP 570)Josh Tobin2019-04-271-1/+15
| |
* | Merge branch '0.29.x'Stefan Behnel2019-04-231-1/+2
|\ \ | |/
| * Fix a compiler crash when non-ASCII characters appear in unprefixed strings ↵Stefan Behnel2019-04-231-1/+2
| | | | | | | | in "3str" parsing mode.
* | Merge pull request #2860 from noamher/conditional-gilstatnodeStefan Behnel2019-02-261-1/+9
|\ \ | | | | | | Allow condition in GILStatNode
| * | Allow condition in GILStatNodeNoam Hershtig2019-02-231-1/+9
| | |
* | | Merge branch 'master' into faster_absolute_reimportsStefan Behnel2019-02-221-2/+2
|\ \ \ | |/ /
| * | Intern all identifier strings in the parser.Stefan Behnel2019-02-221-2/+2
| | |
* | | GH-2854: Reimplement absolute module imports to speed them up, especially ↵Stefan Behnel2019-02-221-6/+2
|/ / | | | | | | | | | | under Py3.7. Cython used to be 3x slower than CPython here. Also enable absolute imports automatically in top-level (non-package) modules.