summaryrefslogtreecommitdiffstats
path: root/Parser/Python.asdl
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-01-25 23:40:57 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-01-25 23:40:57 (GMT)
commitf2c1aa1661edb3e14ff8b7b9995f93e303c8acbb (patch)
tree2b05f347dd55b86059d70197ce3d21210a668f91 /Parser/Python.asdl
parent0dceb918668399bdcbe27d1c59d01c4c9228c1a6 (diff)
downloadcpython-f2c1aa1661edb3e14ff8b7b9995f93e303c8acbb.zip
cpython-f2c1aa1661edb3e14ff8b7b9995f93e303c8acbb.tar.gz
cpython-f2c1aa1661edb3e14ff8b7b9995f93e303c8acbb.tar.bz2
Add ast.Constant
Issue #26146: Add a new kind of AST node: ast.Constant. It can be used by external AST optimizers, but the compiler does not emit directly such node. An optimizer can replace the following AST nodes with ast.Constant: * ast.NameConstant: None, False, True * ast.Num: int, float, complex * ast.Str: str * ast.Bytes: bytes * ast.Tuple if items are constants too: tuple * frozenset Update code to accept ast.Constant instead of ast.Num and/or ast.Str: * compiler * docstrings * ast.literal_eval() * Tools/parser/unparse.py
Diffstat (limited to 'Parser/Python.asdl')
-rw-r--r--Parser/Python.asdl7
1 files changed, 6 insertions, 1 deletions
diff --git a/Parser/Python.asdl b/Parser/Python.asdl
index 22775c6..aaddf61 100644
--- a/Parser/Python.asdl
+++ b/Parser/Python.asdl
@@ -1,4 +1,8 @@
--- ASDL's six builtin types are identifier, int, string, bytes, object, singleton
+-- ASDL's 7 builtin types are:
+-- identifier, int, string, bytes, object, singleton, constant
+--
+-- singleton: None, True or False
+-- constant can be None, whereas None means "no value" for object.
module Python
{
@@ -76,6 +80,7 @@ module Python
| Bytes(bytes s)
| NameConstant(singleton value)
| Ellipsis
+ | Constant(constant value)
-- the following expression can appear in assignment context
| Attribute(expr value, identifier attr, expr_context ctx)