Initial import.

This commit is contained in:
Kenneth Reitz
2010-11-07 05:14:40 -05:00
commit 2357f0ba6d
133 changed files with 32578 additions and 0 deletions
@@ -0,0 +1,26 @@
import compiler
from compiler.visitor import ASTVisitor
class NodeVisitor(ASTVisitor):
def __init__(self, code, stats=None, description=None):
ASTVisitor.__init__(self)
ast = compiler.parse(code)
self.node_types = set()
self.visit_node(ast.node)
#for child in ast.getChildNodes():
#compiler.walk(child, self, walker=self)
all_types = set(line.strip()
for line
in file('python_ast_node_types.txt').readlines())
self.untouched_nodes = sorted(all_types - self.node_types)
def visit_node(self, node):
self.node_types.add(node.__class__.__name__)
for child in node.getChildNodes():
self.visit_node(child)
visitor = NodeVisitor(file('everything.py').read())
print 'Nodes not touched: %s' % visitor.untouched_nodes
@@ -0,0 +1,71 @@
# This file aims to contain every Python syntax node. It's almost there.
from __future__ import with_statement
a + a
a and b
a.x = a
assert a
a = a
a, a = a
[a, a] = a
'a'
a += a
`a`
a & a
a | a
a ^ a
break
a()
class a: pass
a < a
continue
@a
def a(): pass
a(a=a)
{}
a / a
a[...]
exec a
a // a
for a in a: pass
from a import a
(a for a in a if a)
a.a
global a
if a: pass
import a
lambda: a
a << a
[]
[a for a in a]
[a for a in a if a]
a % a
a * a
not a
a or a
a ** a
raise a
print a,
print a
return a
a >> a
a[a:a]
a[a:a:a]
a - a
try:
a
except:
a
finally:
a
()
+a
-a
while a: pass
with a as a:
pass
yield a
# Thankst to Josh Lee (jleedev) for pointing this missing node out.
~x
@@ -0,0 +1,72 @@
Add
And
AssAttr
AssList
AssName
AssTuple
Assert
Assign
AugAssign
Backquote
Bitand
Bitor
Bitxor
Break
CallFunc
Class
Compare
Const
Continue
Decorators
Dict
Discard
Div
Ellipsis
Expression
Exec
FloorDiv
For
From
Function
GenExpr
GenExprFor
GenExprIf
GenExprInner
Getattr
Global
If
Import
Invert
Keyword
Lambda
LeftShift
List
ListComp
ListCompFor
ListCompIf
Mod
Module
Mul
Name
Not
Or
Pass
Power
Print
Printnl
Raise
Return
RightShift
Slice
Sliceobj
Stmt
Sub
Subscript
TryExcept
TryFinally
Tuple
UnaryAdd
UnarySub
While
With
Yield