summaryrefslogtreecommitdiffstats
path: root/Tools/compiler/ast.txt
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-08-29 18:08:02 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2001-08-29 18:08:02 (GMT)
commit5477f529d6f3b25e51ac6b321a6fe7b28fafe1f4 (patch)
treeb9b16d67a12f72d359d44f2a5ae231d1e922af1b /Tools/compiler/ast.txt
parent96d68d57bebd8e9d7d1f5bcd00e63df5a0cbc915 (diff)
downloadcpython-5477f529d6f3b25e51ac6b321a6fe7b28fafe1f4.zip
cpython-5477f529d6f3b25e51ac6b321a6fe7b28fafe1f4.tar.gz
cpython-5477f529d6f3b25e51ac6b321a6fe7b28fafe1f4.tar.bz2
Revise implementations of getChildren() and getChildNodes().
Add support for floor division (// and //=) The implementation of getChildren() and getChildNodes() is intended to be faster, because it avoids calling flatten() on every return value. But it's not clear that it is a lot faster, because constructing a tuple with just the right values ends up being slow. (Too many attribute lookups probably.) The ast.txt file is much more complicated, with funny characters at the ends of names (*, &, !) to indicate the types of each child node. The astgen script is also much more complex, making me wonder if it's still useful.
Diffstat (limited to 'Tools/compiler/ast.txt')
-rw-r--r--Tools/compiler/ast.txt91
1 files changed, 50 insertions, 41 deletions
diff --git a/Tools/compiler/ast.txt b/Tools/compiler/ast.txt
index 21203d2..3e2a82d 100644
--- a/Tools/compiler/ast.txt
+++ b/Tools/compiler/ast.txt
@@ -1,56 +1,64 @@
-Module: doc, node
-Stmt: nodes
-Function: name, argnames, defaults, flags, doc, code
-Lambda: argnames, defaults, flags, code
-Class: name, bases, doc, code
+# This file describes the nodes of the AST in ast.py. The module is
+# generated by astgen.py.
+# The descriptions use the following special notation to describe
+# properties of the children:
+# * this child is not a node
+# ! this child is a sequence that contains nodes in it
+# & this child may be set to None
+# = ... a default value for the node constructor (optional args)
+Module: doc*, node
+Stmt: nodes!
+Function: name*, argnames*, defaults!, flags*, doc*, code
+Lambda: argnames*, defaults!, flags*, code
+Class: name*, bases!, doc*, code
Pass:
Break:
Continue:
-For: assign, list, body, else_
-While: test, body, else_
-If: tests, else_
-Exec: expr, locals, globals
-From: modname, names
-Import: names
-Raise: expr1, expr2, expr3
+For: assign, list, body, else_&
+While: test, body, else_&
+If: tests!, else_&
+Exec: expr, locals&, globals&
+From: modname*, names*
+Import: names*
+Raise: expr1&, expr2&, expr3&
TryFinally: body, final
-TryExcept: body, handlers, else_
+TryExcept: body, handlers!, else_&
Return: value
Yield: value
-Const: value
-Print: nodes, dest
-Printnl: nodes, dest
+Const: value*
+Print: nodes!, dest&
+Printnl: nodes!, dest&
Discard: expr
-AugAssign: node, op, expr
-Assign: nodes, expr
-AssTuple: nodes
-AssList: nodes
-AssName: name, flags
-AssAttr: expr, attrname, flags
-ListComp: expr, quals
-ListCompFor: assign, list, ifs
+AugAssign: node, op*, expr
+Assign: nodes!, expr
+AssTuple: nodes!
+AssList: nodes!
+AssName: name*, flags*
+AssAttr: expr, attrname*, flags*
+ListComp: expr, quals!
+ListCompFor: assign, list, ifs!
ListCompIf: test
-List: nodes
-Dict: items
+List: nodes!
+Dict: items!
Not: expr
-Compare: expr, ops
-Name: name
+Compare: expr, ops!
+Name: name*
Global: names
Backquote: expr
-Getattr: expr, attrname
-CallFunc: node, args, star_args = None, dstar_args = None
-Keyword: name, expr
-Subscript: expr, flags, subs
+Getattr: expr, attrname*
+CallFunc: node, args!, star_args& = None, dstar_args& = None
+Keyword: name*, expr
+Subscript: expr, flags*, subs!
Ellipsis:
-Sliceobj: nodes
-Slice: expr, flags, lower, upper
-Assert: test, fail
-Tuple: nodes
-Or: nodes
-And: nodes
-Bitor: nodes
-Bitxor: nodes
-Bitand: nodes
+Sliceobj: nodes!
+Slice: expr, flags*, lower&, upper&
+Assert: test, fail&
+Tuple: nodes!
+Or: nodes!
+And: nodes!
+Bitor: nodes!
+Bitxor: nodes!
+Bitand: nodes!
LeftShift: (left, right)
RightShift: (left, right)
Add: (left, right)
@@ -59,6 +67,7 @@ Mul: (left, right)
Div: (left, right)
Mod: (left, right)
Power: (left, right)
+FloorDiv: (left, right)
UnaryAdd: expr
UnarySub: expr
Invert: expr