summaryrefslogtreecommitdiffstats
path: root/Modules/parsermodule.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-15999: Clean up of handling boolean arguments. (GH-15610)Serhiy Storchaka2019-09-011-8/+3
| | | | | | * Use the 'p' format unit instead of manually called PyObject_IsTrue(). * Pass boolean value instead 0/1 integers to functions that needs boolean. * Convert some arguments to boolean only once.
* bpo-37268: Add deprecation notice and a DeprecationWarning for the parser ↵Pablo Galindo2019-07-301-0/+6
| | | | | | | | | | | | | | | module (GH-15017) Deprecate the parser module and add a deprecation warning triggered on import and a warning block in the documentation. https://bugs.python.org/issue37268 Automerge-Triggered-By: @pablogsal
* bpo-37253: Add _PyCompilerFlags_INIT macro (GH-14018)Victor Stinner2019-06-131-2/+1
| | | | | Add a new _PyCompilerFlags_INIT macro to initialize PyCompilerFlags variables, rather than initializing cf_flags and cf_feature_version explicitly in each variable.
* bpo-36974: tp_print -> tp_vectorcall_offset and tp_reserved -> tp_as_async ↵Jeroen Demeyer2019-05-311-2/+2
| | | | | | | | | (GH-13464) Automatically replace tp_print -> tp_vectorcall_offset tp_compare -> tp_as_async tp_reserved -> tp_as_async
* fix warnings by adding more const (GH-12924)Inada Naoki2019-04-231-2/+1
|
* bpo-36440: include node names in ParserError messages, instead of numeric ↵tyomitch2019-04-031-6/+11
| | | | | IDs (GH-12565) The error messages in the parser module are referring to numeric IDs for the nodes. To improve readability, use the node names when reporting errors.
* bpo-36256: Fix bug in parsermodule when parsing if statements (GH-12477)Pablo Galindo2019-03-211-5/+17
| | | | | | bpo-36256: Fix bug in parsermodule when parsing if statements In the parser module, when validating nodes before starting the parsing with to create a ST in "parser_newstobject" there is a problem that appears when two arcs in the same DFA state has transitions with labels with the same type. For example, the DFA for if_stmt has a state with two labels with the same type: "elif" and "else" (type NAME). The algorithm tries one by one the arcs until the label that starts the arc transition has a label with the same type of the current child label we are trying to accept. In this case, the arc for "elif" comes before the arc for "else"and passes this test (because the current child label is "else" and has the same type as "elif"). This lead to expecting a namedexpr_test (305) instead of a colon (11). The solution is to compare also the string representation (in case there is one) of the labels to see if the transition that we have is the correct one.
* Remove d_initial from the parser as it is unused (GH-12212)tyomitch2019-03-091-1/+1
| | | d_initial, the first state of a particular DFA in the parser has always been initialized to 0 in the old pgen as well as the new pgen. As this value is not used and the first state of each DFA is assumed to be the first element in the array representing it, remove d_initial from the parser to reduce complexity.
* bpo-35975: Support parsing earlier minor versions of Python 3 (GH-12086)Guido van Rossum2019-03-071-1/+4
| | | | | | | This adds a `feature_version` flag to `ast.parse()` (documented) and `compile()` (hidden) that allow tweaking the parser to support older versions of the grammar. In particular if `feature_version` is 5 or 6, the hacks for the `async` and `await` keyword from PEP 492 are reinstated. (For 7 or higher, these are unconditionally treated as keywords, but they are still special tokens rather than `NAME` tokens that the parser driver recognizes.) https://bugs.python.org/issue35975
* bpo-35766: Merge typed_ast back into CPython (GH-11645)Guido van Rossum2019-01-311-0/+6
|
* bpo-33416: Add end positions to Python AST (GH-11605)Ivan Levkivskyi2019-01-221-1/+1
| | | | | | | | | | | | | | | | | | The majority of this PR is tediously passing `end_lineno` and `end_col_offset` everywhere. Here are non-trivial points: * It is not possible to reconstruct end positions in AST "on the fly", some information is lost after an AST node is constructed, so we need two more attributes for every AST node `end_lineno` and `end_col_offset`. * I add end position information to both CST and AST. Although it may be technically possible to avoid adding end positions to CST, the code becomes more cumbersome and less efficient. * Since the end position is not known for non-leaf CST nodes while the next token is added, this requires a bit of extra care (see `_PyNode_FinalizeEndPos`). Unless I made some mistake, the algorithm should be linear. * For statements, I "trim" the end position of suites to not include the terminal newlines and dedent (this seems to be what people would expect), for example in ```python class C: pass pass ``` the end line and end column for the class definition is (2, 8). * For `end_col_offset` I use the common Python convention for indexing, for example for `pass` the `end_col_offset` is 4 (not 3), so that `[0:4]` gives one the source code that corresponds to the node. * I added a helper function `ast.get_source_segment()`, to get source text segment corresponding to a given AST node. It is also useful for testing. An (inevitable) downside of this PR is that AST now takes almost 25% more memory. I think however it is probably justified by the benefits.
* bpo-33012: Fix invalid function cast warnings with gcc 8. (GH-6749)Serhiy Storchaka2018-11-271-14/+14
| | | | | | Fix invalid function cast warnings with gcc 8 for method conventions different from METH_NOARGS, METH_O and METH_VARARGS excluding Argument Clinic generated code.
* bpo-35177, Python-ast.h: Fix "Yield" compiler warning (GH-10664)Victor Stinner2018-11-221-0/+1
| | | | | | | | Partially revert commit 5f2df88b63e50d23914e97ec778861a52abdeaad: add "#undef Yield" to .c files after including Python-ast.h. Fix the warning: winbase.h(102): warning C4005: 'Yield': macro redefinition
* bpo-35177: Add dependencies between header files (GH-10361)Victor Stinner2018-11-111-3/+2
| | | | | | | | | | | | | | * ast.h now includes Python-ast.h and node.h * parsetok.h now includes node.h and grammar.h * symtable.h now includes Python-ast.h * Modify asdl_c.py to enhance Python-ast.h: * Add #ifndef/#define Py_PYTHON_AST_H to be able to include the header twice * Add "extern { ... }" for C++ * Undefine "Yield" macro conflicting with winbase.h * Remove "#undef Yield" from C files, it's now done in Python-ast.h * Remove now useless includes in C files
* bpo-33308: Fix a crash in the parser module when convert an ST object. (#6519)Serhiy Storchaka2018-04-181-3/+3
| | | | Converting with line_info=False and col_info=True crashed before.
* bpo-23699: Use a macro to reduce boilerplate code in rich comparison ↵stratakis2017-11-021-32/+2
| | | | functions (GH-793)
* bpo-30070: Fixed leaks and crashes in errors handling in the parser module. ↵Serhiy Storchaka2017-04-191-52/+79
| | | | (#1131)
* Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE whereverSerhiy Storchaka2017-01-231-2/+1
| | | | possible. Patch is writen with Coccinelle.
* Replaced outdated macros _PyUnicode_AsString and _PyUnicode_AsStringAndSizeSerhiy Storchaka2016-11-201-2/+2
| | | | with PyUnicode_AsUTF8 and PyUnicode_AsUTF8AndSize.
* replace custom validation logic in the parse module with a simple DFA ↵Benjamin Peterson2016-06-021-2452/+93
| | | | | | validator (closes #26526) Patch from A. Skrobov.
* Issue #25923: Added more const qualifiers to signatures of static and ↵Serhiy Storchaka2015-12-251-5/+5
| | | | private functions.
* Issue #25923: Added the const qualifier to static constant arrays.Serhiy Storchaka2015-12-251-2/+2
|
* Issue #25421: __sizeof__ methods of builtin types now use dynamic basic size.Serhiy Storchaka2015-12-191-1/+1
| | | | | This allows sys.getsize() to work correctly with their subclasses with __slots__ defined.
* Issue #24791: Fix grammar regression for call syntax: 'g(*a or b)'.Yury Selivanov2015-08-051-3/+6
|
* allow test node after ** in calls (closes #24176)Benjamin Peterson2015-05-161-1/+1
|
* PEP 0492 -- Coroutines with async and await syntax. Issue #24017.Yury Selivanov2015-05-121-12/+103
|
* PEP 448: additional unpacking generalizations (closes #2292)Benjamin Peterson2015-05-061-124/+141
| | | | Patch by Neil Girdhar.
* Removed unintentional trailing spaces in non-external and non-generated C files.Serhiy Storchaka2015-03-181-1/+1
|
* (Merge 3.3) parser: fix usage of Py_BuildValue() to build a parser errorVictor Stinner2014-01-021-1/+1
|\ | | | | | | Fix typo: "os" format => "Os"
| * parser: fix usage of Py_BuildValue() to build a parser errorVictor Stinner2014-01-021-1/+1
| | | | | | | | Fix typo: "os" format => "Os"
| * Issue #15989: Fix several occurrences of integer overflowSerhiy Storchaka2013-01-191-5/+19
| |\ | | | | | | | | | | | | | | | when result of PyLong_AsLong() narrowed to int without checks. This is a backport of changesets 13e2e44db99d and 525407d89277.
* | | Close #11619: The parser and the import machinery do not encode UnicodeVictor Stinner2013-08-261-18/+31
| | | | | | | | | | | | filenames anymore on Windows.
* | | Issue #18408: Fix typo in build_node_tree() of the parser moduleVictor Stinner2013-07-161-1/+1
| | | | | | | | | | | | Type "o" format of Py_BuildValue() is invalid: it must be "O".
* | | Issue #18408: parser module: fix error handling in node2tuple()Victor Stinner2013-07-111-28/+52
| | | | | | | | | | | | Handle PyLong_FromLong() and PyUnicode_FromString() failures
* | | Issue #18408: Fix parser.sequence2st() and parser.tuple2st(): raise MemoryErrorVictor Stinner2013-07-111-4/+15
| | | | | | | | | | | | | | | | | | on memory allocation failure Instead of ignoring the memory allocation failure and create invalid objects.
* | | Issue #15989: Fix several occurrences of integer overflowSerhiy Storchaka2013-01-141-5/+19
|/ / | | | | | | when result of PyLong_AsLong() narrowed to int without checks.
* | Issue #16714: use 'raise' exceptions, don't 'throw'.Andrew Svetlov2012-12-181-3/+3
|\ \ | |/ | | | | Patch by Serhiy Storchaka.
| * Issue #16714: use 'raise' exceptions, don't 'throw'.Andrew Svetlov2012-12-181-3/+3
| | | | | | | | Patch by Serhiy Storchaka.
* | Issue #15604: Update uses of PyObject_IsTrue() to check for and handle ↵Antoine Pitrou2012-08-151-32/+16
|\ \ | |/ | | | | | | | | errors correctly. Patch by Serhiy Storchaka.
| * Issue #15604: Update uses of PyObject_IsTrue() to check for and handle ↵Antoine Pitrou2012-08-151-5/+13
| | | | | | | | | | | | errors correctly. Patch by Serhiy Storchaka.
* | MERGE: Closes #15512: Correct __sizeof__ support for parserJesus Cea2012-08-031-1/+12
|\ \ | |/
| * Closes #15512: Correct __sizeof__ support for parserJesus Cea2012-08-031-1/+12
| |
* | Issue #14741: Merge fix from 3.2.Mark Dickinson2012-05-071-5/+1
|\ \ | |/
| * Issue #14741: Fix missing support for ellipsis in parser module.Mark Dickinson2012-05-071-5/+1
| |
* | Issue #14697: Merge fix from 3.2.Mark Dickinson2012-05-071-21/+79
|\ \ | |/
| * Issue #14697: Fix missing parser module support for set displays and set ↵Mark Dickinson2012-05-071-21/+79
| | | | | | | | comprehensions.
* | Issue #14701: Merge fix from 3.2.Mark Dickinson2012-05-071-12/+11
|\ \ | |/
| * Issue #14701: Add missing support for 'raise ... from' in parser module.Mark Dickinson2012-05-071-12/+11
| |
* | Issue #14696: Merge from 3.2Mark Dickinson2012-04-291-5/+36
|\ \ | |/
| * Issue #14696: Fix parser module to understand 'nonlocal' declarations.Mark Dickinson2012-04-291-5/+36
| |