]> granicus.if.org Git - python/commitdiff
PEP-0318, @decorator-style. In Guido's words:
authorAnthony Baxter <anthonybaxter@gmail.com>
Mon, 2 Aug 2004 06:10:11 +0000 (06:10 +0000)
committerAnthony Baxter <anthonybaxter@gmail.com>
Mon, 2 Aug 2004 06:10:11 +0000 (06:10 +0000)
"@ seems the syntax that everybody can hate equally"
Implementation by Mark Russell, from SF #979728.

28 files changed:
Doc/lib/asttable.tex
Doc/lib/libfuncs.tex
Doc/ref/ref7.tex
Grammar/Grammar
Include/graminit.h
Include/node.h
Include/token.h
Lib/compiler/ast.py
Lib/compiler/pycodegen.py
Lib/compiler/symbols.py
Lib/compiler/transformer.py
Lib/pyclbr.py
Lib/symbol.py
Lib/test/output/test_tokenize
Lib/test/pyclbr_input.py [new file with mode: 0644]
Lib/test/test_decorators.py [new file with mode: 0644]
Lib/test/test_parser.py
Lib/test/test_pyclbr.py
Lib/test/tokenize_tests.txt
Lib/token.py
Lib/tokenize.py
Modules/parsermodule.c
Parser/tokenizer.c
Python/compile.c
Python/graminit.c
Tools/compiler/ast.txt
Tools/compiler/astgen.py
Tools/compiler/regrtest.py

index 7f6ba9f7b4acf4b78ea9ff07e02a81a6625e542a..8a93abf70e1b8581077e59f5e47f5c64a59ab13b 100644 (file)
@@ -73,6 +73,9 @@
 \lineiii{Continue}{}{}
 \hline 
 
+\lineiii{Decorators}{\member{nodes}}{List of function decorator expressions}
+\hline 
+
 \lineiii{Dict}{\member{items}}{}
 \hline 
 
 \lineiii{}{\member{names}}{}
 \hline 
 
-\lineiii{Function}{\member{name}}{name used in def, a string}
+\lineiii{Function}{\member{decorators}}{\class{Decorators} or \code{None}}
+\lineiii{}{\member{name}}{name used in def, a string}
 \lineiii{}{\member{argnames}}{list of argument names, as strings}
 \lineiii{}{\member{defaults}}{list of default values}
 \lineiii{}{\member{flags}}{xxx}
index ff922d40f9a8d9abffd3ad66bc1357e7ea69d43a..b3d3d30b458ccc96f3f196612f0c7f719600d0be 100644 (file)
@@ -109,10 +109,14 @@ def my_import(name):
 
 \begin{verbatim}
 class C:
+    @classmethod
     def f(cls, arg1, arg2, ...): ...
-    f = classmethod(f)
 \end{verbatim}
 
+  The \code{@classmethod} form is a function decorator -- see the description
+  of function definitions in chapter 7 of the
+  \citetitle[../ref/ref.html]{Python Reference Manual} for details.
+
   It can be called either on the class (such as \code{C.f()}) or on an
   instance (such as \code{C().f()}).  The instance is ignored except for
   its class.
@@ -122,6 +126,7 @@ class C:
   Class methods are different than \Cpp{} or Java static methods.
   If you want those, see \function{staticmethod()} in this section.
   \versionadded{2.2}
+  Function decorator syntax added in version 2.4.
 \end{funcdesc}
 
 \begin{funcdesc}{cmp}{x, y}
@@ -936,10 +941,14 @@ except NameError:
 
 \begin{verbatim}
 class C:
+    @staticmethod
     def f(arg1, arg2, ...): ...
-    f = staticmethod(f)
 \end{verbatim}
 
+  The \code{@staticmethod} form is a function decorator -- see the description
+  of function definitions in chapter 7 of the
+  \citetitle[../ref/ref.html]{Python Reference Manual} for details.
+
   It can be called either on the class (such as \code{C.f()}) or on an
   instance (such as \code{C().f()}).  The instance is ignored except
   for its class.
index 80ddc3394385dbb7a0f74086e3fd26788fd06386..1d7b8604b6cfe3f169023664a79d2f40d83291ed 100644 (file)
@@ -315,8 +315,12 @@ section~\ref{types}):
 
 \begin{productionlist}
   \production{funcdef}
-             {"def" \token{funcname} "(" [\token{parameter_list}] ")"
+             {[\token{decorators}] "def" \token{funcname} "(" [\token{parameter_list}] ")"
               ":" \token{suite}}
+  \production{decorators}
+             {\token{decorator} ([NEWLINE] \token{decorator})* NEWLINE}
+  \production{decorator}
+             {"@" \token{dotted_name} ["(" [\token{argument_list} [","]] ")"]}
   \production{parameter_list}
              {(\token{defparameter} ",")*}
   \productioncont{("*" \token{identifier} [, "**" \token{identifier}]}
@@ -343,6 +347,27 @@ as the global namespace to be used when the function is called.
 The function definition does not execute the function body; this gets
 executed only when the function is called.
 
+A function definition may be wrapped by one or more decorator expressions.
+Decorator expressions are evaluated when the function is defined, in the scope
+that contains the function definition.  The result must be a callable,
+which is invoked with the function object as the only argument.
+The returned value is bound to the function name instead of the function
+object.  If there are multiple decorators, they are applied in reverse
+order.  For example, the following code:
+
+\begin{verbatim}
+@f1
+@f2
+def func(): pass
+\end{verbatim}
+
+is equivalent to:
+
+\begin{verbatim}
+def func(): pass
+func = f2(f1(func))
+\end{verbatim}
+
 When one or more top-level parameters have the form \var{parameter}
 \code{=} \var{expression}, the function is said to have ``default
 parameter values.''  For a parameter with a
index ce75ba8014b0ca8eaffc46767910f3373b9758b8..111ebe04ad5ad07b8ba6058b2a798a911c0a7c27 100644 (file)
@@ -28,7 +28,9 @@ single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE
 file_input: (NEWLINE | stmt)* ENDMARKER
 eval_input: testlist NEWLINE* ENDMARKER
 
-funcdef: 'def' NAME parameters ':' suite
+decorator: '@' dotted_name [ '(' [arglist] ')' ]
+decorators: decorator ([NEWLINE] decorator)* NEWLINE
+funcdef: [decorators] 'def' NAME parameters ':' suite
 parameters: '(' [varargslist] ')'
 varargslist: (fpdef ['=' test] ',')* ('*' NAME [',' '**' NAME] | '**' NAME) | fpdef ['=' test] (',' fpdef ['=' test])* [',']
 fpdef: NAME | '(' fplist ')'
index 7d4a97a7946ac23848bcac82d51784cc621dd6c1..ac351be4365d3666441919502039a64a9004d1f0 100644 (file)
@@ -1,72 +1,74 @@
 #define single_input 256
 #define file_input 257
 #define eval_input 258
-#define funcdef 259
-#define parameters 260
-#define varargslist 261
-#define fpdef 262
-#define fplist 263
-#define stmt 264
-#define simple_stmt 265
-#define small_stmt 266
-#define expr_stmt 267
-#define augassign 268
-#define print_stmt 269
-#define del_stmt 270
-#define pass_stmt 271
-#define flow_stmt 272
-#define break_stmt 273
-#define continue_stmt 274
-#define return_stmt 275
-#define yield_stmt 276
-#define raise_stmt 277
-#define import_stmt 278
-#define import_as_name 279
-#define dotted_as_name 280
-#define dotted_name 281
-#define global_stmt 282
-#define exec_stmt 283
-#define assert_stmt 284
-#define compound_stmt 285
-#define if_stmt 286
-#define while_stmt 287
-#define for_stmt 288
-#define try_stmt 289
-#define except_clause 290
-#define suite 291
-#define test 292
-#define and_test 293
-#define not_test 294
-#define comparison 295
-#define comp_op 296
-#define expr 297
-#define xor_expr 298
-#define and_expr 299
-#define shift_expr 300
-#define arith_expr 301
-#define term 302
-#define factor 303
-#define power 304
-#define atom 305
-#define listmaker 306
-#define testlist_gexp 307
-#define lambdef 308
-#define trailer 309
-#define subscriptlist 310
-#define subscript 311
-#define sliceop 312
-#define exprlist 313
-#define testlist 314
-#define testlist_safe 315
-#define dictmaker 316
-#define classdef 317
-#define arglist 318
-#define argument 319
-#define list_iter 320
-#define list_for 321
-#define list_if 322
-#define gen_iter 323
-#define gen_for 324
-#define gen_if 325
-#define testlist1 326
-#define encoding_decl 327
+#define decorator 259
+#define decorators 260
+#define funcdef 261
+#define parameters 262
+#define varargslist 263
+#define fpdef 264
+#define fplist 265
+#define stmt 266
+#define simple_stmt 267
+#define small_stmt 268
+#define expr_stmt 269
+#define augassign 270
+#define print_stmt 271
+#define del_stmt 272
+#define pass_stmt 273
+#define flow_stmt 274
+#define break_stmt 275
+#define continue_stmt 276
+#define return_stmt 277
+#define yield_stmt 278
+#define raise_stmt 279
+#define import_stmt 280
+#define import_as_name 281
+#define dotted_as_name 282
+#define dotted_name 283
+#define global_stmt 284
+#define exec_stmt 285
+#define assert_stmt 286
+#define compound_stmt 287
+#define if_stmt 288
+#define while_stmt 289
+#define for_stmt 290
+#define try_stmt 291
+#define except_clause 292
+#define suite 293
+#define test 294
+#define and_test 295
+#define not_test 296
+#define comparison 297
+#define comp_op 298
+#define expr 299
+#define xor_expr 300
+#define and_expr 301
+#define shift_expr 302
+#define arith_expr 303
+#define term 304
+#define factor 305
+#define power 306
+#define atom 307
+#define listmaker 308
+#define testlist_gexp 309
+#define lambdef 310
+#define trailer 311
+#define subscriptlist 312
+#define subscript 313
+#define sliceop 314
+#define exprlist 315
+#define testlist 316
+#define testlist_safe 317
+#define dictmaker 318
+#define classdef 319
+#define arglist 320
+#define argument 321
+#define list_iter 322
+#define list_for 323
+#define list_if 324
+#define gen_iter 325
+#define gen_for 326
+#define gen_if 327
+#define testlist1 328
+#define encoding_decl 329
index 8f5ef236aa8de6107556a67ef57a4fdf57f3494d..4c647080a00a4891562e8e4a89fb364bb9f9f989 100644 (file)
@@ -22,7 +22,9 @@ PyAPI_FUNC(void) PyNode_Free(node *n);
 
 /* Node access functions */
 #define NCH(n)         ((n)->n_nchildren)
+       
 #define CHILD(n, i)    (&(n)->n_child[i])
+#define RCHILD(n, i)   (CHILD(n, NCH(n) + i))
 #define TYPE(n)                ((n)->n_type)
 #define STR(n)         ((n)->n_str)
 
index 4e2ec06b68685be75a1dd16eb228cb70d8bf4760..4250000d135103bf40c61229aa6018f583ac4ec6 100644 (file)
@@ -57,10 +57,11 @@ extern "C" {
 #define DOUBLESTAREQUAL        47
 #define DOUBLESLASH    48
 #define DOUBLESLASHEQUAL 49
+#define AT              50     
 /* Don't forget to update the table _PyParser_TokenNames in tokenizer.c! */
-#define OP             50
-#define ERRORTOKEN     51
-#define N_TOKENS       52
+#define OP             51
+#define ERRORTOKEN     52
+#define N_TOKENS       53
 
 /* Special definitions for cooperation with parser */
 
index 064df50ed5b822670caea843e4c3c6347a665eaa..a81937f850b4951abf7688dd5382ac8d078edf2d 100644 (file)
@@ -48,99 +48,72 @@ class Node: # an abstract base class
 class EmptyNode(Node):
     pass
 
-class Slice(Node):
-    nodes["slice"] = "Slice"
-    def __init__(self, expr, flags, lower, upper):
-        self.expr = expr
-        self.flags = flags
-        self.lower = lower
-        self.upper = upper
+class Expression(Node):
+    # Expression is an artificial node class to support "eval"
+    nodes["expression"] = "Expression"
+    def __init__(self, node):
+        self.node = node
 
     def getChildren(self):
-        children = []
-        children.append(self.expr)
-        children.append(self.flags)
-        children.append(self.lower)
-        children.append(self.upper)
-        return tuple(children)
+        return self.node,
 
     def getChildNodes(self):
-        nodelist = []
-        nodelist.append(self.expr)
-        if self.lower is not None:            nodelist.append(self.lower)
-        if self.upper is not None:            nodelist.append(self.upper)
-        return tuple(nodelist)
+        return self.node,
 
     def __repr__(self):
-        return "Slice(%s, %s, %s, %s)" % (repr(self.expr), repr(self.flags), repr(self.lower), repr(self.upper))
+        return "Expression(%s)" % (repr(self.node))
 
-class Const(Node):
-    nodes["const"] = "Const"
-    def __init__(self, value):
-        self.value = value
+class Add(Node):
+    nodes["add"] = "Add"
+    def __init__(self, (left, right)):
+        self.left = left
+        self.right = right
 
     def getChildren(self):
-        return self.value,
+        return self.left, self.right
 
     def getChildNodes(self):
-        return ()
+        return self.left, self.right
 
     def __repr__(self):
-        return "Const(%s)" % (repr(self.value),)
+        return "Add((%s, %s))" % (repr(self.left), repr(self.right))
 
-class Raise(Node):
-    nodes["raise"] = "Raise"
-    def __init__(self, expr1, expr2, expr3):
-        self.expr1 = expr1
-        self.expr2 = expr2
-        self.expr3 = expr3
+class And(Node):
+    nodes["and"] = "And"
+    def __init__(self, nodes):
+        self.nodes = nodes
 
     def getChildren(self):
         children = []
-        children.append(self.expr1)
-        children.append(self.expr2)
-        children.append(self.expr3)
+        children.extend(flatten(self.nodes))
         return tuple(children)
 
     def getChildNodes(self):
         nodelist = []
-        if self.expr1 is not None:            nodelist.append(self.expr1)
-        if self.expr2 is not None:            nodelist.append(self.expr2)
-        if self.expr3 is not None:            nodelist.append(self.expr3)
+        nodelist.extend(flatten_nodes(self.nodes))
         return tuple(nodelist)
 
     def __repr__(self):
-        return "Raise(%s, %s, %s)" % (repr(self.expr1), repr(self.expr2), repr(self.expr3))
+        return "And(%s)" % (repr(self.nodes),)
 
-class For(Node):
-    nodes["for"] = "For"
-    def __init__(self, assign, list, body, else_):
-        self.assign = assign
-        self.list = list
-        self.body = body
-        self.else_ = else_
+class AssAttr(Node):
+    nodes["assattr"] = "AssAttr"
+    def __init__(self, expr, attrname, flags):
+        self.expr = expr
+        self.attrname = attrname
+        self.flags = flags
 
     def getChildren(self):
-        children = []
-        children.append(self.assign)
-        children.append(self.list)
-        children.append(self.body)
-        children.append(self.else_)
-        return tuple(children)
+        return self.expr, self.attrname, self.flags
 
     def getChildNodes(self):
-        nodelist = []
-        nodelist.append(self.assign)
-        nodelist.append(self.list)
-        nodelist.append(self.body)
-        if self.else_ is not None:            nodelist.append(self.else_)
-        return tuple(nodelist)
+        return self.expr,
 
     def __repr__(self):
-        return "For(%s, %s, %s, %s)" % (repr(self.assign), repr(self.list), repr(self.body), repr(self.else_))
+        return "AssAttr(%s, %s, %s)" % (repr(self.expr), repr(self.attrname), repr(self.flags))
 
-class AssTuple(Node):
-    nodes["asstuple"] = "AssTuple"
+class AssList(Node):
+    nodes["asslist"] = "AssList"
     def __init__(self, nodes):
         self.nodes = nodes
 
@@ -155,363 +128,330 @@ class AssTuple(Node):
         return tuple(nodelist)
 
     def __repr__(self):
-        return "AssTuple(%s)" % (repr(self.nodes),)
+        return "AssList(%s)" % (repr(self.nodes),)
 
-class Mul(Node):
-    nodes["mul"] = "Mul"
-    def __init__(self, (left, right)):
-        self.left = left
-        self.right = right
+class AssName(Node):
+    nodes["assname"] = "AssName"
+    def __init__(self, name, flags):
+        self.name = name
+        self.flags = flags
 
     def getChildren(self):
-        return self.left, self.right
+        return self.name, self.flags
 
     def getChildNodes(self):
-        return self.left, self.right
+        return ()
 
     def __repr__(self):
-        return "Mul((%s, %s))" % (repr(self.left), repr(self.right))
+        return "AssName(%s, %s)" % (repr(self.name), repr(self.flags))
 
-class Invert(Node):
-    nodes["invert"] = "Invert"
-    def __init__(self, expr):
-        self.expr = expr
+class AssTuple(Node):
+    nodes["asstuple"] = "AssTuple"
+    def __init__(self, nodes):
+        self.nodes = nodes
 
     def getChildren(self):
-        return self.expr,
+        children = []
+        children.extend(flatten(self.nodes))
+        return tuple(children)
 
     def getChildNodes(self):
-        return self.expr,
+        nodelist = []
+        nodelist.extend(flatten_nodes(self.nodes))
+        return tuple(nodelist)
 
     def __repr__(self):
-        return "Invert(%s)" % (repr(self.expr),)
+        return "AssTuple(%s)" % (repr(self.nodes),)
 
-class RightShift(Node):
-    nodes["rightshift"] = "RightShift"
-    def __init__(self, (left, right)):
-        self.left = left
-        self.right = right
+class Assert(Node):
+    nodes["assert"] = "Assert"
+    def __init__(self, test, fail):
+        self.test = test
+        self.fail = fail
 
     def getChildren(self):
-        return self.left, self.right
+        children = []
+        children.append(self.test)
+        children.append(self.fail)
+        return tuple(children)
 
     def getChildNodes(self):
-        return self.left, self.right
+        nodelist = []
+        nodelist.append(self.test)
+        if self.fail is not None:            nodelist.append(self.fail)
+        return tuple(nodelist)
 
     def __repr__(self):
-        return "RightShift((%s, %s))" % (repr(self.left), repr(self.right))
+        return "Assert(%s, %s)" % (repr(self.test), repr(self.fail))
 
-class AssList(Node):
-    nodes["asslist"] = "AssList"
-    def __init__(self, nodes):
+class Assign(Node):
+    nodes["assign"] = "Assign"
+    def __init__(self, nodes, expr):
         self.nodes = nodes
+        self.expr = expr
 
     def getChildren(self):
         children = []
         children.extend(flatten(self.nodes))
+        children.append(self.expr)
         return tuple(children)
 
     def getChildNodes(self):
         nodelist = []
         nodelist.extend(flatten_nodes(self.nodes))
+        nodelist.append(self.expr)
         return tuple(nodelist)
 
     def __repr__(self):
-        return "AssList(%s)" % (repr(self.nodes),)
+        return "Assign(%s, %s)" % (repr(self.nodes), repr(self.expr))
 
-class From(Node):
-    nodes["from"] = "From"
-    def __init__(self, modname, names):
-        self.modname = modname
-        self.names = names
+class AugAssign(Node):
+    nodes["augassign"] = "AugAssign"
+    def __init__(self, node, op, expr):
+        self.node = node
+        self.op = op
+        self.expr = expr
 
     def getChildren(self):
-        return self.modname, self.names
+        return self.node, self.op, self.expr
 
     def getChildNodes(self):
-        return ()
+        return self.node, self.expr
 
     def __repr__(self):
-        return "From(%s, %s)" % (repr(self.modname), repr(self.names))
+        return "AugAssign(%s, %s, %s)" % (repr(self.node), repr(self.op), repr(self.expr))
 
-class Getattr(Node):
-    nodes["getattr"] = "Getattr"
-    def __init__(self, expr, attrname):
+class Backquote(Node):
+    nodes["backquote"] = "Backquote"
+    def __init__(self, expr):
         self.expr = expr
-        self.attrname = attrname
 
     def getChildren(self):
-        return self.expr, self.attrname
+        return self.expr,
 
     def getChildNodes(self):
         return self.expr,
 
     def __repr__(self):
-        return "Getattr(%s, %s)" % (repr(self.expr), repr(self.attrname))
+        return "Backquote(%s)" % (repr(self.expr),)
 
-class Dict(Node):
-    nodes["dict"] = "Dict"
-    def __init__(self, items):
-        self.items = items
+class Bitand(Node):
+    nodes["bitand"] = "Bitand"
+    def __init__(self, nodes):
+        self.nodes = nodes
 
     def getChildren(self):
         children = []
-        children.extend(flatten(self.items))
+        children.extend(flatten(self.nodes))
         return tuple(children)
 
     def getChildNodes(self):
         nodelist = []
-        nodelist.extend(flatten_nodes(self.items))
+        nodelist.extend(flatten_nodes(self.nodes))
         return tuple(nodelist)
 
     def __repr__(self):
-        return "Dict(%s)" % (repr(self.items),)
+        return "Bitand(%s)" % (repr(self.nodes),)
 
-class Module(Node):
-    nodes["module"] = "Module"
-    def __init__(self, doc, node):
-        self.doc = doc
-        self.node = node
+class Bitor(Node):
+    nodes["bitor"] = "Bitor"
+    def __init__(self, nodes):
+        self.nodes = nodes
 
     def getChildren(self):
-        return self.doc, self.node
+        children = []
+        children.extend(flatten(self.nodes))
+        return tuple(children)
 
     def getChildNodes(self):
-        return self.node,
+        nodelist = []
+        nodelist.extend(flatten_nodes(self.nodes))
+        return tuple(nodelist)
 
     def __repr__(self):
-        return "Module(%s, %s)" % (repr(self.doc), repr(self.node))
+        return "Bitor(%s)" % (repr(self.nodes),)
 
-class Expression(Node):
-    # Expression is an artificial node class to support "eval"
-    nodes["expression"] = "Expression"
-    def __init__(self, node):
-        self.node = node
+class Bitxor(Node):
+    nodes["bitxor"] = "Bitxor"
+    def __init__(self, nodes):
+        self.nodes = nodes
 
     def getChildren(self):
-        return self.node,
+        children = []
+        children.extend(flatten(self.nodes))
+        return tuple(children)
 
     def getChildNodes(self):
-        return self.node,
+        nodelist = []
+        nodelist.extend(flatten_nodes(self.nodes))
+        return tuple(nodelist)
 
     def __repr__(self):
-        return "Expression(%s)" % (repr(self.node))
+        return "Bitxor(%s)" % (repr(self.nodes),)
 
-class UnaryAdd(Node):
-    nodes["unaryadd"] = "UnaryAdd"
-    def __init__(self, expr):
-        self.expr = expr
+class Break(Node):
+    nodes["break"] = "Break"
+    def __init__(self, ):
+        pass
 
     def getChildren(self):
-        return self.expr,
+        return ()
 
     def getChildNodes(self):
-        return self.expr,
+        return ()
 
     def __repr__(self):
-        return "UnaryAdd(%s)" % (repr(self.expr),)
-
-class Ellipsis(Node):
-    nodes["ellipsis"] = "Ellipsis"
-    def __init__(self, ):
-        pass
-
-    def getChildren(self):
-        return ()
-
-    def getChildNodes(self):
-        return ()
-
-    def __repr__(self):
-        return "Ellipsis()"
+        return "Break()"
 
-class Print(Node):
-    nodes["print"] = "Print"
-    def __init__(self, nodes, dest):
-        self.nodes = nodes
-        self.dest = dest
+class CallFunc(Node):
+    nodes["callfunc"] = "CallFunc"
+    def __init__(self, node, args, star_args = None, dstar_args = None):
+        self.node = node
+        self.args = args
+        self.star_args = star_args
+        self.dstar_args = dstar_args
 
     def getChildren(self):
         children = []
-        children.extend(flatten(self.nodes))
-        children.append(self.dest)
+        children.append(self.node)
+        children.extend(flatten(self.args))
+        children.append(self.star_args)
+        children.append(self.dstar_args)
         return tuple(children)
 
     def getChildNodes(self):
         nodelist = []
-        nodelist.extend(flatten_nodes(self.nodes))
-        if self.dest is not None:            nodelist.append(self.dest)
+        nodelist.append(self.node)
+        nodelist.extend(flatten_nodes(self.args))
+        if self.star_args is not None:            nodelist.append(self.star_args)
+        if self.dstar_args is not None:            nodelist.append(self.dstar_args)
         return tuple(nodelist)
 
     def __repr__(self):
-        return "Print(%s, %s)" % (repr(self.nodes), repr(self.dest))
-
-class Import(Node):
-    nodes["import"] = "Import"
-    def __init__(self, names):
-        self.names = names
-
-    def getChildren(self):
-        return self.names,
-
-    def getChildNodes(self):
-        return ()
-
-    def __repr__(self):
-        return "Import(%s)" % (repr(self.names),)
+        return "CallFunc(%s, %s, %s, %s)" % (repr(self.node), repr(self.args), repr(self.star_args), repr(self.dstar_args))
 
-class Subscript(Node):
-    nodes["subscript"] = "Subscript"
-    def __init__(self, expr, flags, subs):
-        self.expr = expr
-        self.flags = flags
-        self.subs = subs
+class Class(Node):
+    nodes["class"] = "Class"
+    def __init__(self, name, bases, doc, code):
+        self.name = name
+        self.bases = bases
+        self.doc = doc
+        self.code = code
 
     def getChildren(self):
         children = []
-        children.append(self.expr)
-        children.append(self.flags)
-        children.extend(flatten(self.subs))
+        children.append(self.name)
+        children.extend(flatten(self.bases))
+        children.append(self.doc)
+        children.append(self.code)
         return tuple(children)
 
     def getChildNodes(self):
         nodelist = []
-        nodelist.append(self.expr)
-        nodelist.extend(flatten_nodes(self.subs))
+        nodelist.extend(flatten_nodes(self.bases))
+        nodelist.append(self.code)
         return tuple(nodelist)
 
     def __repr__(self):
-        return "Subscript(%s, %s, %s)" % (repr(self.expr), repr(self.flags), repr(self.subs))
+        return "Class(%s, %s, %s, %s)" % (repr(self.name), repr(self.bases), repr(self.doc), repr(self.code))
 
-class TryExcept(Node):
-    nodes["tryexcept"] = "TryExcept"
-    def __init__(self, body, handlers, else_):
-        self.body = body
-        self.handlers = handlers
-        self.else_ = else_
+class Compare(Node):
+    nodes["compare"] = "Compare"
+    def __init__(self, expr, ops):
+        self.expr = expr
+        self.ops = ops
 
     def getChildren(self):
         children = []
-        children.append(self.body)
-        children.extend(flatten(self.handlers))
-        children.append(self.else_)
+        children.append(self.expr)
+        children.extend(flatten(self.ops))
         return tuple(children)
 
     def getChildNodes(self):
         nodelist = []
-        nodelist.append(self.body)
-        nodelist.extend(flatten_nodes(self.handlers))
-        if self.else_ is not None:            nodelist.append(self.else_)
+        nodelist.append(self.expr)
+        nodelist.extend(flatten_nodes(self.ops))
         return tuple(nodelist)
 
     def __repr__(self):
-        return "TryExcept(%s, %s, %s)" % (repr(self.body), repr(self.handlers), repr(self.else_))
+        return "Compare(%s, %s)" % (repr(self.expr), repr(self.ops))
 
-class Or(Node):
-    nodes["or"] = "Or"
-    def __init__(self, nodes):
-        self.nodes = nodes
+class Const(Node):
+    nodes["const"] = "Const"
+    def __init__(self, value):
+        self.value = value
 
     def getChildren(self):
-        children = []
-        children.extend(flatten(self.nodes))
-        return tuple(children)
+        return self.value,
 
     def getChildNodes(self):
-        nodelist = []
-        nodelist.extend(flatten_nodes(self.nodes))
-        return tuple(nodelist)
+        return ()
 
     def __repr__(self):
-        return "Or(%s)" % (repr(self.nodes),)
+        return "Const(%s)" % (repr(self.value),)
 
-class Name(Node):
-    nodes["name"] = "Name"
-    def __init__(self, name):
-        self.name = name
+class Continue(Node):
+    nodes["continue"] = "Continue"
+    def __init__(self, ):
+        pass
 
     def getChildren(self):
-        return self.name,
+        return ()
 
     def getChildNodes(self):
         return ()
 
     def __repr__(self):
-        return "Name(%s)" % (repr(self.name),)
-
-class Function(Node):
-    nodes["function"] = "Function"
-    def __init__(self, name, argnames, defaults, flags, doc, code):
-        self.name = name
-        self.argnames = argnames
-        self.defaults = defaults
-        self.flags = flags
-        self.doc = doc
-        self.code = code
-        self.varargs = self.kwargs = None
-        if flags & CO_VARARGS:
-            self.varargs = 1
-        if flags & CO_VARKEYWORDS:
-            self.kwargs = 1
-
+        return "Continue()"
 
+class Decorators(Node):
+    nodes["decorators"] = "Decorators"
+    def __init__(self, nodes):
+        self.nodes = nodes
 
     def getChildren(self):
-        children = []
-        children.append(self.name)
-        children.append(self.argnames)
-        children.extend(flatten(self.defaults))
-        children.append(self.flags)
-        children.append(self.doc)
-        children.append(self.code)
-        return tuple(children)
+        return tuple(flatten(self.nodes))
 
     def getChildNodes(self):
-        nodelist = []
-        nodelist.extend(flatten_nodes(self.defaults))
-        nodelist.append(self.code)
-        return tuple(nodelist)
+        return flatten_nodes(self.nodes)
 
     def __repr__(self):
-        return "Function(%s, %s, %s, %s, %s, %s)" % (repr(self.name), repr(self.argnames), repr(self.defaults), repr(self.flags), repr(self.doc), repr(self.code))
+        return "Decorators(%s)" % (repr(self.nodes),)
 
-class Assert(Node):
-    nodes["assert"] = "Assert"
-    def __init__(self, test, fail):
-        self.test = test
-        self.fail = fail
+class Dict(Node):
+    nodes["dict"] = "Dict"
+    def __init__(self, items):
+        self.items = items
 
     def getChildren(self):
         children = []
-        children.append(self.test)
-        children.append(self.fail)
+        children.extend(flatten(self.items))
         return tuple(children)
 
     def getChildNodes(self):
         nodelist = []
-        nodelist.append(self.test)
-        if self.fail is not None:            nodelist.append(self.fail)
+        nodelist.extend(flatten_nodes(self.items))
         return tuple(nodelist)
 
     def __repr__(self):
-        return "Assert(%s, %s)" % (repr(self.test), repr(self.fail))
+        return "Dict(%s)" % (repr(self.items),)
 
-class Return(Node):
-    nodes["return"] = "Return"
-    def __init__(self, value):
-        self.value = value
+class Discard(Node):
+    nodes["discard"] = "Discard"
+    def __init__(self, expr):
+        self.expr = expr
 
     def getChildren(self):
-        return self.value,
+        return self.expr,
 
     def getChildNodes(self):
-        return self.value,
+        return self.expr,
 
     def __repr__(self):
-        return "Return(%s)" % (repr(self.value),)
+        return "Discard(%s)" % (repr(self.expr),)
 
-class Power(Node):
-    nodes["power"] = "Power"
+class Div(Node):
+    nodes["div"] = "Div"
     def __init__(self, (left, right)):
         self.left = left
         self.right = right
@@ -523,7 +463,21 @@ class Power(Node):
         return self.left, self.right
 
     def __repr__(self):
-        return "Power((%s, %s))" % (repr(self.left), repr(self.right))
+        return "Div((%s, %s))" % (repr(self.left), repr(self.right))
+
+class Ellipsis(Node):
+    nodes["ellipsis"] = "Ellipsis"
+    def __init__(self, ):
+        pass
+
+    def getChildren(self):
+        return ()
+
+    def getChildNodes(self):
+        return ()
+
+    def __repr__(self):
+        return "Ellipsis()"
 
 class Exec(Node):
     nodes["exec"] = "Exec"
@@ -549,212 +503,260 @@ class Exec(Node):
     def __repr__(self):
         return "Exec(%s, %s, %s)" % (repr(self.expr), repr(self.locals), repr(self.globals))
 
-class Stmt(Node):
-    nodes["stmt"] = "Stmt"
-    def __init__(self, nodes):
-        self.nodes = nodes
+class FloorDiv(Node):
+    nodes["floordiv"] = "FloorDiv"
+    def __init__(self, (left, right)):
+        self.left = left
+        self.right = right
 
     def getChildren(self):
-        children = []
-        children.extend(flatten(self.nodes))
-        return tuple(children)
+        return self.left, self.right
 
     def getChildNodes(self):
-        nodelist = []
-        nodelist.extend(flatten_nodes(self.nodes))
-        return tuple(nodelist)
+        return self.left, self.right
 
     def __repr__(self):
-        return "Stmt(%s)" % (repr(self.nodes),)
+        return "FloorDiv((%s, %s))" % (repr(self.left), repr(self.right))
 
-class Sliceobj(Node):
-    nodes["sliceobj"] = "Sliceobj"
-    def __init__(self, nodes):
-        self.nodes = nodes
+class For(Node):
+    nodes["for"] = "For"
+    def __init__(self, assign, list, body, else_):
+        self.assign = assign
+        self.list = list
+        self.body = body
+        self.else_ = else_
 
     def getChildren(self):
         children = []
-        children.extend(flatten(self.nodes))
+        children.append(self.assign)
+        children.append(self.list)
+        children.append(self.body)
+        children.append(self.else_)
         return tuple(children)
 
     def getChildNodes(self):
         nodelist = []
-        nodelist.extend(flatten_nodes(self.nodes))
+        nodelist.append(self.assign)
+        nodelist.append(self.list)
+        nodelist.append(self.body)
+        if self.else_ is not None:            nodelist.append(self.else_)
         return tuple(nodelist)
 
     def __repr__(self):
-        return "Sliceobj(%s)" % (repr(self.nodes),)
+        return "For(%s, %s, %s, %s)" % (repr(self.assign), repr(self.list), repr(self.body), repr(self.else_))
 
-class Break(Node):
-    nodes["break"] = "Break"
-    def __init__(self, ):
-        pass
+class From(Node):
+    nodes["from"] = "From"
+    def __init__(self, modname, names):
+        self.modname = modname
+        self.names = names
 
     def getChildren(self):
-        return ()
+        return self.modname, self.names
 
     def getChildNodes(self):
         return ()
 
     def __repr__(self):
-        return "Break()"
+        return "From(%s, %s)" % (repr(self.modname), repr(self.names))
+
+class Function(Node):
+    nodes["function"] = "Function"
+    def __init__(self, decorators, name, argnames, defaults, flags, doc, code):
+        self.decorators = decorators
+        self.name = name
+        self.argnames = argnames
+        self.defaults = defaults
+        self.flags = flags
+        self.doc = doc
+        self.code = code
+        self.varargs = self.kwargs = None
+        if flags & CO_VARARGS:
+            self.varargs = 1
+        if flags & CO_VARKEYWORDS:
+            self.kwargs = 1
+
 
-class Bitand(Node):
-    nodes["bitand"] = "Bitand"
-    def __init__(self, nodes):
-        self.nodes = nodes
 
     def getChildren(self):
         children = []
-        children.extend(flatten(self.nodes))
+        if self.decorators:
+            children.append(flatten(self.decorators.nodes))
+        children.append(self.name)
+        children.append(self.argnames)
+        children.extend(flatten(self.defaults))
+        children.append(self.flags)
+        children.append(self.doc)
+        children.append(self.code)
         return tuple(children)
 
     def getChildNodes(self):
         nodelist = []
-        nodelist.extend(flatten_nodes(self.nodes))
+        if self.decorators:
+            nodelist.extend(flatten_nodes(self.decorators.nodes))
+        nodelist.extend(flatten_nodes(self.defaults))
+        nodelist.append(self.code)
         return tuple(nodelist)
 
     def __repr__(self):
-        return "Bitand(%s)" % (repr(self.nodes),)
+        return "Function(%s, %s, %s, %s, %s, %s, %s)" % (repr(self.decorators), repr(self.name), repr(self.argnames), repr(self.defaults), repr(self.flags), repr(self.doc), repr(self.code))
+
+class GenExpr(Node):
+    nodes["genexpr"] = "GenExpr"
+    def __init__(self, code):
+        self.code = code
+        self.argnames = ['[outmost-iterable]']
+        self.varargs = self.kwargs = None
+    
 
-class FloorDiv(Node):
-    nodes["floordiv"] = "FloorDiv"
-    def __init__(self, (left, right)):
-        self.left = left
-        self.right = right
 
     def getChildren(self):
-        return self.left, self.right
+        return self.code,
 
     def getChildNodes(self):
-        return self.left, self.right
+        return self.code,
 
     def __repr__(self):
-        return "FloorDiv((%s, %s))" % (repr(self.left), repr(self.right))
+        return "GenExpr(%s)" % (repr(self.code),)
+
+class GenExprFor(Node):
+    nodes["genexprfor"] = "GenExprFor"
+    def __init__(self, assign, iter, ifs):
+        self.assign = assign
+        self.iter = iter
+        self.ifs = ifs
+        self.is_outmost = False
 
-class TryFinally(Node):
-    nodes["tryfinally"] = "TryFinally"
-    def __init__(self, body, final):
-        self.body = body
-        self.final = final
 
     def getChildren(self):
-        return self.body, self.final
+        children = []
+        children.append(self.assign)
+        children.append(self.iter)
+        children.extend(flatten(self.ifs))
+        return tuple(children)
 
     def getChildNodes(self):
-        return self.body, self.final
+        nodelist = []
+        nodelist.append(self.assign)
+        nodelist.append(self.iter)
+        nodelist.extend(flatten_nodes(self.ifs))
+        return tuple(nodelist)
 
     def __repr__(self):
-        return "TryFinally(%s, %s)" % (repr(self.body), repr(self.final))
+        return "GenExprFor(%s, %s, %s)" % (repr(self.assign), repr(self.iter), repr(self.ifs))
 
-class Not(Node):
-    nodes["not"] = "Not"
-    def __init__(self, expr):
-        self.expr = expr
+class GenExprIf(Node):
+    nodes["genexprif"] = "GenExprIf"
+    def __init__(self, test):
+        self.test = test
 
     def getChildren(self):
-        return self.expr,
+        return self.test,
 
     def getChildNodes(self):
-        return self.expr,
+        return self.test,
 
     def __repr__(self):
-        return "Not(%s)" % (repr(self.expr),)
+        return "GenExprIf(%s)" % (repr(self.test),)
 
-class Class(Node):
-    nodes["class"] = "Class"
-    def __init__(self, name, bases, doc, code):
-        self.name = name
-        self.bases = bases
-        self.doc = doc
-        self.code = code
+class GenExprInner(Node):
+    nodes["genexprinner"] = "GenExprInner"
+    def __init__(self, expr, quals):
+        self.expr = expr
+        self.quals = quals
 
     def getChildren(self):
         children = []
-        children.append(self.name)
-        children.extend(flatten(self.bases))
-        children.append(self.doc)
-        children.append(self.code)
+        children.append(self.expr)
+        children.extend(flatten(self.quals))
         return tuple(children)
 
     def getChildNodes(self):
         nodelist = []
-        nodelist.extend(flatten_nodes(self.bases))
-        nodelist.append(self.code)
+        nodelist.append(self.expr)
+        nodelist.extend(flatten_nodes(self.quals))
         return tuple(nodelist)
 
     def __repr__(self):
-        return "Class(%s, %s, %s, %s)" % (repr(self.name), repr(self.bases), repr(self.doc), repr(self.code))
+        return "GenExprInner(%s, %s)" % (repr(self.expr), repr(self.quals))
 
-class Mod(Node):
-    nodes["mod"] = "Mod"
-    def __init__(self, (left, right)):
-        self.left = left
-        self.right = right
+class Getattr(Node):
+    nodes["getattr"] = "Getattr"
+    def __init__(self, expr, attrname):
+        self.expr = expr
+        self.attrname = attrname
 
     def getChildren(self):
-        return self.left, self.right
+        return self.expr, self.attrname
 
     def getChildNodes(self):
-        return self.left, self.right
+        return self.expr,
 
     def __repr__(self):
-        return "Mod((%s, %s))" % (repr(self.left), repr(self.right))
+        return "Getattr(%s, %s)" % (repr(self.expr), repr(self.attrname))
 
-class Printnl(Node):
-    nodes["printnl"] = "Printnl"
-    def __init__(self, nodes, dest):
-        self.nodes = nodes
-        self.dest = dest
+class Global(Node):
+    nodes["global"] = "Global"
+    def __init__(self, names):
+        self.names = names
 
     def getChildren(self):
-        children = []
-        children.extend(flatten(self.nodes))
-        children.append(self.dest)
-        return tuple(children)
+        return self.names,
 
     def getChildNodes(self):
-        nodelist = []
-        nodelist.extend(flatten_nodes(self.nodes))
-        if self.dest is not None:            nodelist.append(self.dest)
-        return tuple(nodelist)
+        return ()
 
     def __repr__(self):
-        return "Printnl(%s, %s)" % (repr(self.nodes), repr(self.dest))
+        return "Global(%s)" % (repr(self.names),)
 
-class Tuple(Node):
-    nodes["tuple"] = "Tuple"
-    def __init__(self, nodes):
-        self.nodes = nodes
+class If(Node):
+    nodes["if"] = "If"
+    def __init__(self, tests, else_):
+        self.tests = tests
+        self.else_ = else_
 
     def getChildren(self):
         children = []
-        children.extend(flatten(self.nodes))
+        children.extend(flatten(self.tests))
+        children.append(self.else_)
         return tuple(children)
 
     def getChildNodes(self):
         nodelist = []
-        nodelist.extend(flatten_nodes(self.nodes))
+        nodelist.extend(flatten_nodes(self.tests))
+        if self.else_ is not None:            nodelist.append(self.else_)
         return tuple(nodelist)
 
     def __repr__(self):
-        return "Tuple(%s)" % (repr(self.nodes),)
+        return "If(%s, %s)" % (repr(self.tests), repr(self.else_))
 
-class AssAttr(Node):
-    nodes["assattr"] = "AssAttr"
-    def __init__(self, expr, attrname, flags):
+class Import(Node):
+    nodes["import"] = "Import"
+    def __init__(self, names):
+        self.names = names
+
+    def getChildren(self):
+        return self.names,
+
+    def getChildNodes(self):
+        return ()
+
+    def __repr__(self):
+        return "Import(%s)" % (repr(self.names),)
+
+class Invert(Node):
+    nodes["invert"] = "Invert"
+    def __init__(self, expr):
         self.expr = expr
-        self.attrname = attrname
-        self.flags = flags
 
     def getChildren(self):
-        return self.expr, self.attrname, self.flags
+        return self.expr,
 
     def getChildNodes(self):
         return self.expr,
 
     def __repr__(self):
-        return "AssAttr(%s, %s, %s)" % (repr(self.expr), repr(self.attrname), repr(self.flags))
+        return "Invert(%s)" % (repr(self.expr),)
 
 class Keyword(Node):
     nodes["keyword"] = "Keyword"
@@ -771,21 +773,52 @@ class Keyword(Node):
     def __repr__(self):
         return "Keyword(%s, %s)" % (repr(self.name), repr(self.expr))
 
-class AugAssign(Node):
-    nodes["augassign"] = "AugAssign"
-    def __init__(self, node, op, expr):
-        self.node = node
-        self.op = op
-        self.expr = expr
+class Lambda(Node):
+    nodes["lambda"] = "Lambda"
+    def __init__(self, argnames, defaults, flags, code):
+        self.argnames = argnames
+        self.defaults = defaults
+        self.flags = flags
+        self.code = code
+        self.varargs = self.kwargs = None
+        if flags & CO_VARARGS:
+            self.varargs = 1
+        if flags & CO_VARKEYWORDS:
+            self.kwargs = 1
+    
+
 
     def getChildren(self):
-        return self.node, self.op, self.expr
+        children = []
+        children.append(self.argnames)
+        children.extend(flatten(self.defaults))
+        children.append(self.flags)
+        children.append(self.code)
+        return tuple(children)
 
     def getChildNodes(self):
-        return self.node, self.expr
+        nodelist = []
+        nodelist.extend(flatten_nodes(self.defaults))
+        nodelist.append(self.code)
+        return tuple(nodelist)
 
     def __repr__(self):
-        return "AugAssign(%s, %s, %s)" % (repr(self.node), repr(self.op), repr(self.expr))
+        return "Lambda(%s, %s, %s, %s)" % (repr(self.argnames), repr(self.defaults), repr(self.flags), repr(self.code))
+
+class LeftShift(Node):
+    nodes["leftshift"] = "LeftShift"
+    def __init__(self, (left, right)):
+        self.left = left
+        self.right = right
+
+    def getChildren(self):
+        return self.left, self.right
+
+    def getChildNodes(self):
+        return self.left, self.right
+
+    def __repr__(self):
+        return "LeftShift((%s, %s))" % (repr(self.left), repr(self.right))
 
 class List(Node):
     nodes["list"] = "List"
@@ -805,22 +838,67 @@ class List(Node):
     def __repr__(self):
         return "List(%s)" % (repr(self.nodes),)
 
-class Yield(Node):
-    nodes["yield"] = "Yield"
-    def __init__(self, value):
-        self.value = value
+class ListComp(Node):
+    nodes["listcomp"] = "ListComp"
+    def __init__(self, expr, quals):
+        self.expr = expr
+        self.quals = quals
 
     def getChildren(self):
-        return self.value,
+        children = []
+        children.append(self.expr)
+        children.extend(flatten(self.quals))
+        return tuple(children)
 
     def getChildNodes(self):
-        return self.value,
+        nodelist = []
+        nodelist.append(self.expr)
+        nodelist.extend(flatten_nodes(self.quals))
+        return tuple(nodelist)
 
     def __repr__(self):
-        return "Yield(%s)" % (repr(self.value),)
+        return "ListComp(%s, %s)" % (repr(self.expr), repr(self.quals))
 
-class LeftShift(Node):
-    nodes["leftshift"] = "LeftShift"
+class ListCompFor(Node):
+    nodes["listcompfor"] = "ListCompFor"
+    def __init__(self, assign, list, ifs):
+        self.assign = assign
+        self.list = list
+        self.ifs = ifs
+
+    def getChildren(self):
+        children = []
+        children.append(self.assign)
+        children.append(self.list)
+        children.extend(flatten(self.ifs))
+        return tuple(children)
+
+    def getChildNodes(self):
+        nodelist = []
+        nodelist.append(self.assign)
+        nodelist.append(self.list)
+        nodelist.extend(flatten_nodes(self.ifs))
+        return tuple(nodelist)
+
+    def __repr__(self):
+        return "ListCompFor(%s, %s, %s)" % (repr(self.assign), repr(self.list), repr(self.ifs))
+
+class ListCompIf(Node):
+    nodes["listcompif"] = "ListCompIf"
+    def __init__(self, test):
+        self.test = test
+
+    def getChildren(self):
+        return self.test,
+
+    def getChildNodes(self):
+        return self.test,
+
+    def __repr__(self):
+        return "ListCompIf(%s)" % (repr(self.test),)
+
+class Mod(Node):
+    nodes["mod"] = "Mod"
     def __init__(self, (left, right)):
         self.left = left
         self.right = right
@@ -832,63 +910,54 @@ class LeftShift(Node):
         return self.left, self.right
 
     def __repr__(self):
-        return "LeftShift((%s, %s))" % (repr(self.left), repr(self.right))
+        return "Mod((%s, %s))" % (repr(self.left), repr(self.right))
 
-class AssName(Node):
-    nodes["assname"] = "AssName"
-    def __init__(self, name, flags):
-        self.name = name
-        self.flags = flags
+class Module(Node):
+    nodes["module"] = "Module"
+    def __init__(self, doc, node):
+        self.doc = doc
+        self.node = node
 
     def getChildren(self):
-        return self.name, self.flags
+        return self.doc, self.node
 
     def getChildNodes(self):
-        return ()
+        return self.node,
 
     def __repr__(self):
-        return "AssName(%s, %s)" % (repr(self.name), repr(self.flags))
+        return "Module(%s, %s)" % (repr(self.doc), repr(self.node))
 
-class While(Node):
-    nodes["while"] = "While"
-    def __init__(self, test, body, else_):
-        self.test = test
-        self.body = body
-        self.else_ = else_
+class Mul(Node):
+    nodes["mul"] = "Mul"
+    def __init__(self, (left, right)):
+        self.left = left
+        self.right = right
 
     def getChildren(self):
-        children = []
-        children.append(self.test)
-        children.append(self.body)
-        children.append(self.else_)
-        return tuple(children)
+        return self.left, self.right
 
     def getChildNodes(self):
-        nodelist = []
-        nodelist.append(self.test)
-        nodelist.append(self.body)
-        if self.else_ is not None:            nodelist.append(self.else_)
-        return tuple(nodelist)
+        return self.left, self.right
 
     def __repr__(self):
-        return "While(%s, %s, %s)" % (repr(self.test), repr(self.body), repr(self.else_))
+        return "Mul((%s, %s))" % (repr(self.left), repr(self.right))
 
-class Continue(Node):
-    nodes["continue"] = "Continue"
-    def __init__(self, ):
-        pass
+class Name(Node):
+    nodes["name"] = "Name"
+    def __init__(self, name):
+        self.name = name
 
     def getChildren(self):
-        return ()
+        return self.name,
 
     def getChildNodes(self):
         return ()
 
     def __repr__(self):
-        return "Continue()"
+        return "Name(%s)" % (repr(self.name),)
 
-class Backquote(Node):
-    nodes["backquote"] = "Backquote"
+class Not(Node):
+    nodes["not"] = "Not"
     def __init__(self, expr):
         self.expr = expr
 
@@ -899,24 +968,42 @@ class Backquote(Node):
         return self.expr,
 
     def __repr__(self):
-        return "Backquote(%s)" % (repr(self.expr),)
+        return "Not(%s)" % (repr(self.expr),)
 
-class Discard(Node):
-    nodes["discard"] = "Discard"
-    def __init__(self, expr):
-        self.expr = expr
+class Or(Node):
+    nodes["or"] = "Or"
+    def __init__(self, nodes):
+        self.nodes = nodes
 
     def getChildren(self):
-        return self.expr,
+        children = []
+        children.extend(flatten(self.nodes))
+        return tuple(children)
 
     def getChildNodes(self):
-        return self.expr,
+        nodelist = []
+        nodelist.extend(flatten_nodes(self.nodes))
+        return tuple(nodelist)
 
     def __repr__(self):
-        return "Discard(%s)" % (repr(self.expr),)
+        return "Or(%s)" % (repr(self.nodes),)
 
-class Div(Node):
-    nodes["div"] = "Div"
+class Pass(Node):
+    nodes["pass"] = "Pass"
+    def __init__(self, ):
+        pass
+
+    def getChildren(self):
+        return ()
+
+    def getChildNodes(self):
+        return ()
+
+    def __repr__(self):
+        return "Pass()"
+
+class Power(Node):
+    nodes["power"] = "Power"
     def __init__(self, (left, right)):
         self.left = left
         self.right = right
@@ -928,119 +1015,131 @@ class Div(Node):
         return self.left, self.right
 
     def __repr__(self):
-        return "Div((%s, %s))" % (repr(self.left), repr(self.right))
+        return "Power((%s, %s))" % (repr(self.left), repr(self.right))
 
-class Assign(Node):
-    nodes["assign"] = "Assign"
-    def __init__(self, nodes, expr):
+class Print(Node):
+    nodes["print"] = "Print"
+    def __init__(self, nodes, dest):
         self.nodes = nodes
-        self.expr = expr
+        self.dest = dest
 
     def getChildren(self):
         children = []
         children.extend(flatten(self.nodes))
-        children.append(self.expr)
+        children.append(self.dest)
         return tuple(children)
 
     def getChildNodes(self):
         nodelist = []
         nodelist.extend(flatten_nodes(self.nodes))
-        nodelist.append(self.expr)
+        if self.dest is not None:            nodelist.append(self.dest)
         return tuple(nodelist)
 
     def __repr__(self):
-        return "Assign(%s, %s)" % (repr(self.nodes), repr(self.expr))
-
-class Lambda(Node):
-    nodes["lambda"] = "Lambda"
-    def __init__(self, argnames, defaults, flags, code):
-        self.argnames = argnames
-        self.defaults = defaults
-        self.flags = flags
-        self.code = code
-        self.varargs = self.kwargs = None
-        if flags & CO_VARARGS:
-            self.varargs = 1
-        if flags & CO_VARKEYWORDS:
-            self.kwargs = 1
+        return "Print(%s, %s)" % (repr(self.nodes), repr(self.dest))
 
+class Printnl(Node):
+    nodes["printnl"] = "Printnl"
+    def __init__(self, nodes, dest):
+        self.nodes = nodes
+        self.dest = dest
 
     def getChildren(self):
         children = []
-        children.append(self.argnames)
-        children.extend(flatten(self.defaults))
-        children.append(self.flags)
-        children.append(self.code)
+        children.extend(flatten(self.nodes))
+        children.append(self.dest)
         return tuple(children)
 
     def getChildNodes(self):
         nodelist = []
-        nodelist.extend(flatten_nodes(self.defaults))
-        nodelist.append(self.code)
+        nodelist.extend(flatten_nodes(self.nodes))
+        if self.dest is not None:            nodelist.append(self.dest)
         return tuple(nodelist)
 
     def __repr__(self):
-        return "Lambda(%s, %s, %s, %s)" % (repr(self.argnames), repr(self.defaults), repr(self.flags), repr(self.code))
+        return "Printnl(%s, %s)" % (repr(self.nodes), repr(self.dest))
 
-class And(Node):
-    nodes["and"] = "And"
-    def __init__(self, nodes):
-        self.nodes = nodes
+class Raise(Node):
+    nodes["raise"] = "Raise"
+    def __init__(self, expr1, expr2, expr3):
+        self.expr1 = expr1
+        self.expr2 = expr2
+        self.expr3 = expr3
 
     def getChildren(self):
         children = []
-        children.extend(flatten(self.nodes))
+        children.append(self.expr1)
+        children.append(self.expr2)
+        children.append(self.expr3)
         return tuple(children)
 
     def getChildNodes(self):
         nodelist = []
-        nodelist.extend(flatten_nodes(self.nodes))
+        if self.expr1 is not None:            nodelist.append(self.expr1)
+        if self.expr2 is not None:            nodelist.append(self.expr2)
+        if self.expr3 is not None:            nodelist.append(self.expr3)
         return tuple(nodelist)
 
     def __repr__(self):
-        return "And(%s)" % (repr(self.nodes),)
+        return "Raise(%s, %s, %s)" % (repr(self.expr1), repr(self.expr2), repr(self.expr3))
 
-class Compare(Node):
-    nodes["compare"] = "Compare"
-    def __init__(self, expr, ops):
-        self.expr = expr
-        self.ops = ops
+class Return(Node):
+    nodes["return"] = "Return"
+    def __init__(self, value):
+        self.value = value
 
     def getChildren(self):
-        children = []
-        children.append(self.expr)
-        children.extend(flatten(self.ops))
-        return tuple(children)
+        return self.value,
 
     def getChildNodes(self):
-        nodelist = []
-        nodelist.append(self.expr)
-        nodelist.extend(flatten_nodes(self.ops))
-        return tuple(nodelist)
+        return self.value,
 
     def __repr__(self):
-        return "Compare(%s, %s)" % (repr(self.expr), repr(self.ops))
+        return "Return(%s)" % (repr(self.value),)
 
-class Bitor(Node):
-    nodes["bitor"] = "Bitor"
-    def __init__(self, nodes):
-        self.nodes = nodes
+class RightShift(Node):
+    nodes["rightshift"] = "RightShift"
+    def __init__(self, (left, right)):
+        self.left = left
+        self.right = right
+
+    def getChildren(self):
+        return self.left, self.right
+
+    def getChildNodes(self):
+        return self.left, self.right
+
+    def __repr__(self):
+        return "RightShift((%s, %s))" % (repr(self.left), repr(self.right))
+
+class Slice(Node):
+    nodes["slice"] = "Slice"
+    def __init__(self, expr, flags, lower, upper):
+        self.expr = expr
+        self.flags = flags
+        self.lower = lower
+        self.upper = upper
 
     def getChildren(self):
         children = []
-        children.extend(flatten(self.nodes))
+        children.append(self.expr)
+        children.append(self.flags)
+        children.append(self.lower)
+        children.append(self.upper)
         return tuple(children)
 
     def getChildNodes(self):
         nodelist = []
-        nodelist.extend(flatten_nodes(self.nodes))
+        nodelist.append(self.expr)
+        if self.lower is not None:            nodelist.append(self.lower)
+        if self.upper is not None:            nodelist.append(self.upper)
         return tuple(nodelist)
 
     def __repr__(self):
-        return "Bitor(%s)" % (repr(self.nodes),)
+        return "Slice(%s, %s, %s, %s)" % (repr(self.expr), repr(self.flags), repr(self.lower), repr(self.upper))
 
-class Bitxor(Node):
-    nodes["bitxor"] = "Bitxor"
+class Sliceobj(Node):
+    nodes["sliceobj"] = "Sliceobj"
     def __init__(self, nodes):
         self.nodes = nodes
 
@@ -1055,77 +1154,25 @@ class Bitxor(Node):
         return tuple(nodelist)
 
     def __repr__(self):
-        return "Bitxor(%s)" % (repr(self.nodes),)
+        return "Sliceobj(%s)" % (repr(self.nodes),)
 
-class CallFunc(Node):
-    nodes["callfunc"] = "CallFunc"
-    def __init__(self, node, args, star_args = None, dstar_args = None):
-        self.node = node
-        self.args = args
-        self.star_args = star_args
-        self.dstar_args = dstar_args
+class Stmt(Node):
+    nodes["stmt"] = "Stmt"
+    def __init__(self, nodes):
+        self.nodes = nodes
 
     def getChildren(self):
         children = []
-        children.append(self.node)
-        children.extend(flatten(self.args))
-        children.append(self.star_args)
-        children.append(self.dstar_args)
+        children.extend(flatten(self.nodes))
         return tuple(children)
 
     def getChildNodes(self):
         nodelist = []
-        nodelist.append(self.node)
-        nodelist.extend(flatten_nodes(self.args))
-        if self.star_args is not None:            nodelist.append(self.star_args)
-        if self.dstar_args is not None:            nodelist.append(self.dstar_args)
+        nodelist.extend(flatten_nodes(self.nodes))
         return tuple(nodelist)
 
     def __repr__(self):
-        return "CallFunc(%s, %s, %s, %s)" % (repr(self.node), repr(self.args), repr(self.star_args), repr(self.dstar_args))
-
-class Global(Node):
-    nodes["global"] = "Global"
-    def __init__(self, names):
-        self.names = names
-
-    def getChildren(self):
-        return self.names,
-
-    def getChildNodes(self):
-        return ()
-
-    def __repr__(self):
-        return "Global(%s)" % (repr(self.names),)
-
-class Add(Node):
-    nodes["add"] = "Add"
-    def __init__(self, (left, right)):
-        self.left = left
-        self.right = right
-
-    def getChildren(self):
-        return self.left, self.right
-
-    def getChildNodes(self):
-        return self.left, self.right
-
-    def __repr__(self):
-        return "Add((%s, %s))" % (repr(self.left), repr(self.right))
-
-class ListCompIf(Node):
-    nodes["listcompif"] = "ListCompIf"
-    def __init__(self, test):
-        self.test = test
-
-    def getChildren(self):
-        return self.test,
-
-    def getChildNodes(self):
-        return self.test,
-
-    def __repr__(self):
-        return "ListCompIf(%s)" % (repr(self.test),)
+        return "Stmt(%s)" % (repr(self.nodes),)
 
 class Sub(Node):
     nodes["sub"] = "Sub"
@@ -1142,175 +1189,151 @@ class Sub(Node):
     def __repr__(self):
         return "Sub((%s, %s))" % (repr(self.left), repr(self.right))
 
-class Pass(Node):
-    nodes["pass"] = "Pass"
-    def __init__(self, ):
-        pass
-
-    def getChildren(self):
-        return ()
-
-    def getChildNodes(self):
-        return ()
-
-    def __repr__(self):
-        return "Pass()"
-
-class UnarySub(Node):
-    nodes["unarysub"] = "UnarySub"
-    def __init__(self, expr):
+class Subscript(Node):
+    nodes["subscript"] = "Subscript"
+    def __init__(self, expr, flags, subs):
         self.expr = expr
+        self.flags = flags
+        self.subs = subs
 
     def getChildren(self):
-        return self.expr,
+        children = []
+        children.append(self.expr)
+        children.append(self.flags)
+        children.extend(flatten(self.subs))
+        return tuple(children)
 
     def getChildNodes(self):
-        return self.expr,
+        nodelist = []
+        nodelist.append(self.expr)
+        nodelist.extend(flatten_nodes(self.subs))
+        return tuple(nodelist)
 
     def __repr__(self):
-        return "UnarySub(%s)" % (repr(self.expr),)
+        return "Subscript(%s, %s, %s)" % (repr(self.expr), repr(self.flags), repr(self.subs))
 
-class If(Node):
-    nodes["if"] = "If"
-    def __init__(self, tests, else_):
-        self.tests = tests
+class TryExcept(Node):
+    nodes["tryexcept"] = "TryExcept"
+    def __init__(self, body, handlers, else_):
+        self.body = body
+        self.handlers = handlers
         self.else_ = else_
 
     def getChildren(self):
         children = []
-        children.extend(flatten(self.tests))
+        children.append(self.body)
+        children.extend(flatten(self.handlers))
         children.append(self.else_)
         return tuple(children)
 
     def getChildNodes(self):
         nodelist = []
-        nodelist.extend(flatten_nodes(self.tests))
+        nodelist.append(self.body)
+        nodelist.extend(flatten_nodes(self.handlers))
         if self.else_ is not None:            nodelist.append(self.else_)
         return tuple(nodelist)
 
     def __repr__(self):
-        return "If(%s, %s)" % (repr(self.tests), repr(self.else_))
+        return "TryExcept(%s, %s, %s)" % (repr(self.body), repr(self.handlers), repr(self.else_))
 
-class ListComp(Node):
-    nodes["listcomp"] = "ListComp"
-    def __init__(self, expr, quals):
-        self.expr = expr
-        self.quals = quals
+class TryFinally(Node):
+    nodes["tryfinally"] = "TryFinally"
+    def __init__(self, body, final):
+        self.body = body
+        self.final = final
 
     def getChildren(self):
-        children = []
-        children.append(self.expr)
-        children.extend(flatten(self.quals))
-        return tuple(children)
+        return self.body, self.final
 
     def getChildNodes(self):
-        nodelist = []
-        nodelist.append(self.expr)
-        nodelist.extend(flatten_nodes(self.quals))
-        return tuple(nodelist)
+        return self.body, self.final
 
     def __repr__(self):
-        return "ListComp(%s, %s)" % (repr(self.expr), repr(self.quals))
+        return "TryFinally(%s, %s)" % (repr(self.body), repr(self.final))
 
-class ListCompFor(Node):
-    nodes["listcompfor"] = "ListCompFor"
-    def __init__(self, assign, list, ifs):
-        self.assign = assign
-        self.list = list
-        self.ifs = ifs
+class Tuple(Node):
+    nodes["tuple"] = "Tuple"
+    def __init__(self, nodes):
+        self.nodes = nodes
 
     def getChildren(self):
         children = []
-        children.append(self.assign)
-        children.append(self.list)
-        children.extend(flatten(self.ifs))
+        children.extend(flatten(self.nodes))
         return tuple(children)
 
     def getChildNodes(self):
         nodelist = []
-        nodelist.append(self.assign)
-        nodelist.append(self.list)
-        nodelist.extend(flatten_nodes(self.ifs))
+        nodelist.extend(flatten_nodes(self.nodes))
         return tuple(nodelist)
 
     def __repr__(self):
-        return "ListCompFor(%s, %s, %s)" % (repr(self.assign), repr(self.list), repr(self.ifs))
+        return "Tuple(%s)" % (repr(self.nodes),)
 
-class GenExpr(Node):
-    nodes["genexpr"] = "GenExpr"
-    def __init__(self, code):
-        self.code = code
-        self.argnames = ['[outmost-iterable]']
-        self.varargs = self.kwargs = None
+class UnaryAdd(Node):
+    nodes["unaryadd"] = "UnaryAdd"
+    def __init__(self, expr):
+        self.expr = expr
 
     def getChildren(self):
-        return self.code,
+        return self.expr,
 
     def getChildNodes(self):
-        return self.code,
+        return self.expr,
 
     def __repr__(self):
-        return "GenExpr(%s)" % (repr(self.code),)
+        return "UnaryAdd(%s)" % (repr(self.expr),)
 
-class GenExprInner(Node):
-    nodes["genexprinner"] = "GenExprInner"
-    def __init__(self, expr, quals):
+class UnarySub(Node):
+    nodes["unarysub"] = "UnarySub"
+    def __init__(self, expr):
         self.expr = expr
-        self.quals = quals
 
     def getChildren(self):
-        children = []
-        children.append(self.expr)
-        children.extend(flatten(self.quals))
-        return tuple(children)
+        return self.expr,
 
     def getChildNodes(self):
-        nodelist = []
-        nodelist.append(self.expr)
-        nodelist.extend(flatten_nodes(self.quals))
-        return tuple(nodelist)
+        return self.expr,
 
     def __repr__(self):
-        return "GenExprInner(%s, %s)" % (repr(self.expr), repr(self.quals))
+        return "UnarySub(%s)" % (repr(self.expr),)
 
-class GenExprFor(Node):
-    nodes["genexprfor"] = "GenExprFor"
-    def __init__(self, assign, iter, ifs):
-        self.assign = assign
-        self.iter = iter
-        self.ifs = ifs
-        self.is_outmost = False
+class While(Node):
+    nodes["while"] = "While"
+    def __init__(self, test, body, else_):
+        self.test = test
+        self.body = body
+        self.else_ = else_
 
     def getChildren(self):
         children = []
-        children.append(self.assign)
-        children.append(self.iter)
-        children.extend(flatten(self.ifs))
+        children.append(self.test)
+        children.append(self.body)
+        children.append(self.else_)
         return tuple(children)
 
     def getChildNodes(self):
         nodelist = []
-        nodelist.append(self.assign)
-        nodelist.append(self.iter)
-        nodelist.extend(flatten_nodes(self.ifs))
+        nodelist.append(self.test)
+        nodelist.append(self.body)
+        if self.else_ is not None:            nodelist.append(self.else_)
         return tuple(nodelist)
 
     def __repr__(self):
-        return "GenExprFor(%s, %s, %s)" % (repr(self.assign), repr(self.iter), repr(self.ifs))
+        return "While(%s, %s, %s)" % (repr(self.test), repr(self.body), repr(self.else_))
 
-class GenExprIf(Node):
-    nodes["genexprif"] = "GenExprIf"
-    def __init__(self, test):
-        self.test = test
+class Yield(Node):
+    nodes["yield"] = "Yield"
+    def __init__(self, value):
+        self.value = value
 
     def getChildren(self):
-        return self.test,
+        return self.value,
 
     def getChildNodes(self):
-        return self.test,
+        return self.value,
 
     def __repr__(self):
-        return "GenExprIf(%s)" % (repr(self.test),)
+        return "Yield(%s)" % (repr(self.value),)
 
 klasses = globals()
 for k in nodes.keys():
index 4d5f728811266491cc21be6825c0d1a63ebf51ef..e859ac517e2502dfcc594e0a07c97536e9579e0b 100644 (file)
@@ -366,6 +366,13 @@ class CodeGenerator:
         self._visitFuncOrLambda(node, isLambda=1)
 
     def _visitFuncOrLambda(self, node, isLambda=0):
+        if not isLambda and node.decorators:
+            for decorator in reversed(node.decorators.nodes):
+                self.visit(decorator)
+            ndecorators = len(node.decorators.nodes)
+        else:
+            ndecorators = 0
+            
         gen = self.FunctionGen(node, self.scopes, isLambda,
                                self.class_name, self.get_module())
         walk(node.code, gen)
@@ -382,6 +389,9 @@ class CodeGenerator:
         else:
             self.emit('LOAD_CONST', gen)
             self.emit('MAKE_FUNCTION', len(node.defaults))
+            
+        for i in range(ndecorators):
+            self.emit('CALL_FUNCTION', 1)
 
     def visitClass(self, node):
         gen = self.ClassGen(node, self.scopes,
index e1581a46cf3bb0572b59d01aa22086826780c196..9d4605a821bdceedae6300b9b36e104b6cece669 100644 (file)
@@ -224,6 +224,8 @@ class SymbolVisitor:
     visitExpression = visitModule
 
     def visitFunction(self, node, parent):
+        if node.decorators:
+            self.visit(node.decorators, parent)
         parent.add_def(node.name)
         for n in node.defaults:
             self.visit(n, parent)
index aa5a28ba821721fae7e4e3b4bb9b90e638a29986..229657b4066589f2538e0a7e0ce31e72c6917127 100644 (file)
@@ -185,29 +185,81 @@ class Transformer:
         ### is this sufficient?
         return Expression(self.com_node(nodelist[0]))
 
+    def decorator_name(self, nodelist):
+        listlen = len(nodelist)
+        assert listlen >= 1 and listlen % 2 == 1
+
+        item = self.atom_name(nodelist)
+        i = 1
+        while i < listlen:
+            assert nodelist[i][0] == token.DOT
+            assert nodelist[i + 1][0] == token.NAME
+            item = Getattr(item, nodelist[i + 1][1])
+            i += 2
+
+        return item
+        
+    def decorator(self, nodelist):
+        # '@' dotted_name [ '(' [arglist] ')' ]
+        assert len(nodelist) in (2, 4, 5)
+        assert nodelist[0][0] == token.AT
+
+        assert nodelist[1][0] == symbol.dotted_name
+        funcname = self.decorator_name(nodelist[1][1:])
+
+        if len(nodelist) > 2:
+            assert nodelist[2][0] == token.LPAR
+            expr = self.com_call_function(funcname, nodelist[3])
+        else:
+            expr = funcname
+            
+        return expr
+    
+    def decorators(self, nodelist):
+        # decorators: decorator ([NEWLINE] decorator)* NEWLINE
+        listlen = len(nodelist)
+        i = 0
+        items = []
+        while i < listlen:
+            assert nodelist[i][0] == symbol.decorator
+            items.append(self.decorator(nodelist[i][1:]))
+            i += 1
+
+            if i < listlen and nodelist[i][0] == token.NEWLINE:
+                i += 1
+        return Decorators(items)
+    
     def funcdef(self, nodelist):
-        # funcdef: 'def' NAME parameters ':' suite
+        #                    -6   -5    -4         -3  -2    -1
+        # funcdef: [decorators] 'def' NAME parameters ':' suite
         # parameters: '(' [varargslist] ')'
 
-        lineno = nodelist[1][2]
-        name = nodelist[1][1]
-        args = nodelist[2][2]
+        if len(nodelist) == 6:
+            assert nodelist[0][0] == symbol.decorators
+            decorators = self.decorators(nodelist[0][1:])
+        else:
+            assert len(nodelist) == 5
+            decorators = None
+            
+        lineno = nodelist[-4][2]
+        name = nodelist[-4][1]
+        args = nodelist[-3][2]
 
         if args[0] == symbol.varargslist:
             names, defaults, flags = self.com_arglist(args[1:])
         else:
             names = defaults = ()
             flags = 0
-        doc = self.get_docstring(nodelist[4])
+        doc = self.get_docstring(nodelist[-1])
 
         # code for function
-        code = self.com_node(nodelist[4])
+        code = self.com_node(nodelist[-1])
 
         if doc is not None:
             assert isinstance(code, Stmt)
             assert isinstance(code.nodes[0], Discard)
             del code.nodes[0]
-        n = Function(name, names, defaults, flags, doc, code)
+        n = Function(decorators, name, names, defaults, flags, doc, code)
         n.lineno = lineno
         return n
 
index 9e6bcb09c586f83b12851b1b5561d7df7cef5833..0812e22ff4734ccbb4940064b186c2335ea5f314 100644 (file)
@@ -222,7 +222,7 @@ def _readmodule(module, path, inpackage=None):
                         else:
                             super.append(token)
                     inherit = names
-                cur_class = Class(module, class_name, inherit, file, lineno)
+                cur_class = Class(fullmodule, class_name, inherit, file, lineno)
                 if not stack:
                     dict[class_name] = cur_class
                 stack.append((cur_class, thisindent))
index c839e4ab46b65aec872be59dd84ed1c5ce30e00e..cb57208005e5272f17c9f09efcb1ab6125b2d862 100755 (executable)
 single_input = 256
 file_input = 257
 eval_input = 258
-funcdef = 259
-parameters = 260
-varargslist = 261
-fpdef = 262
-fplist = 263
-stmt = 264
-simple_stmt = 265
-small_stmt = 266
-expr_stmt = 267
-augassign = 268
-print_stmt = 269
-del_stmt = 270
-pass_stmt = 271
-flow_stmt = 272
-break_stmt = 273
-continue_stmt = 274
-return_stmt = 275
-yield_stmt = 276
-raise_stmt = 277
-import_stmt = 278
-import_as_name = 279
-dotted_as_name = 280
-dotted_name = 281
-global_stmt = 282
-exec_stmt = 283
-assert_stmt = 284
-compound_stmt = 285
-if_stmt = 286
-while_stmt = 287
-for_stmt = 288
-try_stmt = 289
-except_clause = 290
-suite = 291
-test = 292
-and_test = 293
-not_test = 294
-comparison = 295
-comp_op = 296
-expr = 297
-xor_expr = 298
-and_expr = 299
-shift_expr = 300
-arith_expr = 301
-term = 302
-factor = 303
-power = 304
-atom = 305
-listmaker = 306
-testlist_gexp = 307
-lambdef = 308
-trailer = 309
-subscriptlist = 310
-subscript = 311
-sliceop = 312
-exprlist = 313
-testlist = 314
-testlist_safe = 315
-dictmaker = 316
-classdef = 317
-arglist = 318
-argument = 319
-list_iter = 320
-list_for = 321
-list_if = 322
-gen_iter = 323
-gen_for = 324
-gen_if = 325
-testlist1 = 326
-encoding_decl = 327
+decorator = 259
+decorators = 260
+funcdef = 261
+parameters = 262
+varargslist = 263
+fpdef = 264
+fplist = 265
+stmt = 266
+simple_stmt = 267
+small_stmt = 268
+expr_stmt = 269
+augassign = 270
+print_stmt = 271
+del_stmt = 272
+pass_stmt = 273
+flow_stmt = 274
+break_stmt = 275
+continue_stmt = 276
+return_stmt = 277
+yield_stmt = 278
+raise_stmt = 279
+import_stmt = 280
+import_as_name = 281
+dotted_as_name = 282
+dotted_name = 283
+global_stmt = 284
+exec_stmt = 285
+assert_stmt = 286
+compound_stmt = 287
+if_stmt = 288
+while_stmt = 289
+for_stmt = 290
+try_stmt = 291
+except_clause = 292
+suite = 293
+test = 294
+and_test = 295
+not_test = 296
+comparison = 297
+comp_op = 298
+expr = 299
+xor_expr = 300
+and_expr = 301
+shift_expr = 302
+arith_expr = 303
+term = 304
+factor = 305
+power = 306
+atom = 307
+listmaker = 308
+testlist_gexp = 309
+lambdef = 310
+trailer = 311
+subscriptlist = 312
+subscript = 313
+sliceop = 314
+exprlist = 315
+testlist = 316
+testlist_safe = 317
+dictmaker = 318
+classdef = 319
+arglist = 320
+argument = 321
+list_iter = 322
+list_for = 323
+list_if = 324
+gen_iter = 325
+gen_for = 326
+gen_if = 327
+testlist1 = 328
+encoding_decl = 329
 #--end constants--
 
 sym_name = {}
index ea55181dc5157eb2adc01d2ccbe1c70a8bdfcb3b..b78a223475d02e4202458edc0b76323ad8598823 100644 (file)
@@ -645,4 +645,15 @@ test_tokenize
 174,29-174,30: OP      ')'
 174,30-174,31: NEWLINE '\n'
 175,0-175,1:   NL      '\n'
-176,0-176,0:   ENDMARKER       ''
+176,0-176,1:   OP      '@'
+176,1-176,13:  NAME    'staticmethod'
+176,13-176,14: NEWLINE '\n'
+177,0-177,3:   NAME    'def'
+177,4-177,7:   NAME    'foo'
+177,7-177,8:   OP      '('
+177,8-177,9:   OP      ')'
+177,9-177,10:  OP      ':'
+177,11-177,15: NAME    'pass'
+177,15-177,16: NEWLINE '\n'
+178,0-178,1:   NL      '\n'
+179,0-179,0:   ENDMARKER       ''
diff --git a/Lib/test/pyclbr_input.py b/Lib/test/pyclbr_input.py
new file mode 100644 (file)
index 0000000..b410fcc
--- /dev/null
@@ -0,0 +1,33 @@
+"""Test cases for test_pyclbr.py"""
+
+def f(): pass
+
+class Other(object):
+    @classmethod
+    def foo(c): pass
+
+    def om(self): pass
+
+class B (object):
+    def bm(self): pass
+    
+class C (B):
+    foo = Other().foo
+    om = Other.om
+    
+    d = 10
+
+    # XXX: This causes test_pyclbr.py to fail, but only because the
+    #      introspection-based is_method() code in the test can't
+    #      distinguish between this and a geniune method function like m().
+    #      The pyclbr.py module gets this right as it parses the text.
+    #
+    #f = f
+    
+    def m(self): pass
+    
+    @staticmethod
+    def sm(self): pass
+
+    @classmethod
+    def cm(self): pass
diff --git a/Lib/test/test_decorators.py b/Lib/test/test_decorators.py
new file mode 100644 (file)
index 0000000..98d5d3e
--- /dev/null
@@ -0,0 +1,194 @@
+import unittest
+from test import test_support
+
+def funcattrs(**kwds):
+    def decorate(func):
+        func.__dict__.update(kwds)
+        return func
+    return decorate
+
+class MiscDecorators (object):
+    @staticmethod
+    def author(name):
+        def decorate(func):
+            func.__dict__['author'] = name
+            return func
+        return decorate
+
+# -----------------------------------------------
+
+class DbcheckError (Exception):
+    def __init__(self, exprstr, func, args, kwds):
+        # A real version of this would set attributes here
+        Exception.__init__(self, "dbcheck %r failed (func=%s args=%s kwds=%s)" %
+                           (exprstr, func, args, kwds))
+    
+    
+def dbcheck(exprstr, globals=None, locals=None):
+    "Decorator to implement debugging assertions"
+    def decorate(func):
+        expr = compile(exprstr, "dbcheck-%s" % func.func_name, "eval")
+        def check(*args, **kwds):
+            if not eval(expr, globals, locals):
+                raise DbcheckError(exprstr, func, args, kwds)
+            return func(*args, **kwds)
+        return check
+    return decorate
+
+# -----------------------------------------------
+
+def countcalls(counts):
+    "Decorator to count calls to a function"
+    def decorate(func):
+        name = func.func_name
+        counts[name] = 0
+        def call(*args, **kwds):
+            counts[name] += 1
+            return func(*args, **kwds)
+        # XXX: Would like to say: call.func_name = func.func_name here
+        #      to make nested decorators work in any order, but func_name
+        #      is a readonly attribute
+        return call
+    return decorate
+
+# -----------------------------------------------
+
+def memoize(func):
+    saved = {}
+    def call(*args):
+        try:
+            return saved[args]
+        except KeyError:
+            res = func(*args)
+            saved[args] = res
+            return res
+        except TypeError:
+            # Unhashable argument
+            return func(*args)
+    return call
+            
+# -----------------------------------------------
+
+class TestDecorators(unittest.TestCase):
+
+    def test_single(self):
+        class C(object):
+            @staticmethod
+            def foo(): return 42
+        self.assertEqual(C.foo(), 42)
+        self.assertEqual(C().foo(), 42)
+
+    def test_dotted(self):
+        decorators = MiscDecorators()
+        @decorators.author('Cleese')
+        def foo(): return 42
+        self.assertEqual(foo(), 42)
+        self.assertEqual(foo.author, 'Cleese')
+
+    def test_argforms(self):
+        # A few tests of argument passing, as we use restricted form
+        # of expressions for decorators.
+        
+        def noteargs(*args, **kwds):
+            def decorate(func):
+                setattr(func, 'dbval', (args, kwds))
+                return func
+            return decorate
+
+        args = ( 'Now', 'is', 'the', 'time' )
+        kwds = dict(one=1, two=2)
+        @noteargs(*args, **kwds)
+        def f1(): return 42
+        self.assertEqual(f1(), 42)
+        self.assertEqual(f1.dbval, (args, kwds))
+
+        @noteargs('terry', 'gilliam', eric='idle', john='cleese')
+        def f2(): return 84
+        self.assertEqual(f2(), 84)
+        self.assertEqual(f2.dbval, (('terry', 'gilliam'),
+                                     dict(eric='idle', john='cleese')))
+
+        @noteargs(1, 2,)
+        def f3(): pass
+        self.assertEqual(f3.dbval, ((1, 2), {}))
+
+    def test_dbcheck(self):
+        @dbcheck('args[1] is not None')
+        def f(a, b):
+            return a + b
+        self.assertEqual(f(1, 2), 3)
+        self.assertRaises(DbcheckError, f, 1, None)
+
+    def test_memoize(self):
+        # XXX: This doesn't work unless memoize is the last decorator -
+        #      see the comment in countcalls.
+        counts = {}
+        @countcalls(counts) @memoize 
+        def double(x):
+            return x * 2
+
+        self.assertEqual(counts, dict(double=0))
+
+        # Only the first call with a given argument bumps the call count:
+        #
+        self.assertEqual(double(2), 4)
+        self.assertEqual(counts['double'], 1)
+        self.assertEqual(double(2), 4)
+        self.assertEqual(counts['double'], 1)
+        self.assertEqual(double(3), 6)
+        self.assertEqual(counts['double'], 2)
+
+        # Unhashable arguments do not get memoized:
+        #
+        self.assertEqual(double([10]), [10, 10])
+        self.assertEqual(counts['double'], 3)
+        self.assertEqual(double([10]), [10, 10])
+        self.assertEqual(counts['double'], 4)
+
+    def test_errors(self):
+        # Test syntax restrictions - these are all compile-time errors:
+        #
+        for expr in [ "1+2", "x[3]", "(1, 2)" ]:
+            # Sanity check: is expr is a valid expression by itself?
+            compile(expr, "testexpr", "exec")
+            
+            codestr = "@%s\ndef f(): pass" % expr
+            self.assertRaises(SyntaxError, compile, codestr, "test", "exec")
+
+        # Test runtime errors
+
+        def unimp(func):
+            raise NotImplementedError
+        context = dict(nullval=None, unimp=unimp)
+        
+        for expr, exc in [ ("undef", NameError),
+                           ("nullval", TypeError),
+                           ("nullval.attr", AttributeError),
+                           ("unimp", NotImplementedError)]:
+            codestr = "@%s\ndef f(): pass\nassert f() is None" % expr
+            code = compile(codestr, "test", "exec")
+            self.assertRaises(exc, eval, code, context)
+
+    def test_double(self):
+        class C(object):
+            @funcattrs(abc=1, xyz="haha")
+            @funcattrs(booh=42)
+            def foo(self): return 42
+        self.assertEqual(C().foo(), 42)
+        self.assertEqual(C.foo.abc, 1)
+        self.assertEqual(C.foo.xyz, "haha")
+        self.assertEqual(C.foo.booh, 42)
+
+    def test_order(self):
+        class C(object):
+            @funcattrs(abc=1) @staticmethod
+            def foo(): return 42
+        # This wouldn't work if staticmethod was called first
+        self.assertEqual(C.foo(), 42)
+        self.assertEqual(C().foo(), 42)
+
+def test_main():
+    test_support.run_unittest(TestDecorators)
+
+if __name__=="__main__":
+    test_main()
index 9652f6bd1dc9e211b1be578fa800ea2261be1090..978ce5712c4faa12b1647f9a1c015d26250dfea0 100644 (file)
@@ -15,8 +15,8 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
         t = st1.totuple()
         try:
             st2 = parser.sequence2st(t)
-        except parser.ParserError:
-            self.fail("could not roundtrip %r" % s)
+        except parser.ParserError, why:
+            self.fail("could not roundtrip %r: %s" % (s, why))
 
         self.assertEquals(t, st2.totuple(),
                           "could not re-generate syntax tree")
@@ -119,6 +119,14 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
         self.check_suite("def f(a, b, foo=bar, *args, **kw): pass")
         self.check_suite("def f(a, b, foo=bar, **kw): pass")
 
+        self.check_suite("@staticmethod\n"
+                         "def f(): pass")
+        self.check_suite("@staticmethod\n"
+                         "@funcattrs(x, y)\n"
+                         "def f(): pass")
+        self.check_suite("@funcattrs()\n"
+                         "def f(): pass")
+
     def test_import_from_statement(self):
         self.check_suite("from sys.path import *")
         self.check_suite("from sys.path import dirname")
index 48e8bf7d6352952849266a7a9f04249973bba20b..eddd593b21da40dcd9735d5d038e047a3c1a9cbc 100644 (file)
@@ -8,6 +8,9 @@ from types import ClassType, FunctionType, MethodType
 import pyclbr
 from unittest import TestCase
 
+StaticMethodType = type(staticmethod(lambda: None))
+ClassMethodType = type(classmethod(lambda c: None))
+
 # This next line triggers an error on old versions of pyclbr.
 
 from commands import getstatus
@@ -43,11 +46,10 @@ class PyclbrTest(TestCase):
             print >>sys.stderr, "***",key
         self.failUnless(obj.has_key(key))
 
-    def assertEquals(self, a, b, ignore=None):
+    def assertEqualsOrIgnored(self, a, b, ignore):
         ''' succeed iff a == b or a in ignore or b in ignore '''
-        if (ignore == None) or (a in ignore) or (b in ignore): return
-
-        unittest.TestCase.assertEquals(self, a, b)
+        if a not in ignore and b not in ignore:
+            self.assertEquals(a, b)
 
     def checkModule(self, moduleName, module=None, ignore=()):
         ''' succeed iff pyclbr.readmodule_ex(modulename) corresponds
@@ -62,11 +64,22 @@ class PyclbrTest(TestCase):
 
         dict = pyclbr.readmodule_ex(moduleName)
 
-        def ismethod(obj, name):
-            if not  isinstance(obj, MethodType):
-                return False
-            if obj.im_self is not None:
-                return False
+        def ismethod(oclass, obj, name):
+            classdict = oclass.__dict__
+            if isinstance(obj, FunctionType):
+                if not isinstance(classdict[name], StaticMethodType):
+                    return False
+            else:
+                if not  isinstance(obj, MethodType):
+                    return False
+                if obj.im_self is not None:
+                    if (not isinstance(classdict[name], ClassMethodType) or
+                        obj.im_self is not oclass):
+                        return False
+                else:
+                    if not isinstance(classdict[name], FunctionType):
+                        return False
+
             objname = obj.__name__
             if objname.startswith("__") and not objname.endswith("__"):
                 objname = "_%s%s" % (obj.im_class.__name__, objname)
@@ -81,7 +94,7 @@ class PyclbrTest(TestCase):
             if isinstance(value, pyclbr.Function):
                 self.assertEquals(type(py_item), FunctionType)
             else:
-                self.assertEquals(type(py_item), ClassType)
+                self.failUnless(isinstance(py_item, (ClassType, type)))
                 real_bases = [base.__name__ for base in py_item.__bases__]
                 pyclbr_bases = [ getattr(base, 'name', base)
                                  for base in value.super ]
@@ -94,7 +107,7 @@ class PyclbrTest(TestCase):
 
                 actualMethods = []
                 for m in py_item.__dict__.keys():
-                    if ismethod(getattr(py_item, m), m):
+                    if ismethod(py_item, getattr(py_item, m), m):
                         actualMethods.append(m)
                 foundMethods = []
                 for m in value.methods.keys():
@@ -107,7 +120,8 @@ class PyclbrTest(TestCase):
                     self.assertListEq(foundMethods, actualMethods, ignore)
                     self.assertEquals(py_item.__module__, value.module)
 
-                    self.assertEquals(py_item.__name__, value.name, ignore)
+                    self.assertEqualsOrIgnored(py_item.__name__, value.name,
+                                               ignore)
                     # can't check file or lineno
                 except:
                     print >>sys.stderr, "class=%s" % py_item
@@ -132,6 +146,12 @@ class PyclbrTest(TestCase):
         self.checkModule('rfc822')
         self.checkModule('difflib')
 
+    def test_decorators(self):
+        # XXX: See comment in pyclbr_input.py for a test that would fail
+        #      if it were not commented out.
+        #
+        self.checkModule('test.pyclbr_input')
+        
     def test_others(self):
         cm = self.checkModule
 
index e990a36069bd4002e4a788ae98f7cd7a46704062..4ef3bf134aa20adff50b9beb3723cfc80dbec05e 100644 (file)
@@ -173,3 +173,6 @@ x = -1*1/1 + 1*1 - ---1*1
 import sys, time
 x = sys.modules['time'].time()
 
+@staticmethod
+def foo(): pass
+
index f75412c7a6302f631b2068d615a4655fc0ac1deb..c4db6c511af0f490f1083de4dca2c39da665ae2c 100755 (executable)
@@ -60,9 +60,10 @@ RIGHTSHIFTEQUAL = 46
 DOUBLESTAREQUAL = 47
 DOUBLESLASH = 48
 DOUBLESLASHEQUAL = 49
-OP = 50
-ERRORTOKEN = 51
-N_TOKENS = 52
+AT = 50
+OP = 51
+ERRORTOKEN = 52
+N_TOKENS = 53
 NT_OFFSET = 256
 #--end constants--
 
index 7e6fa1219acfd78d3bacd27a874414c132645867..9087e84ca0e2a30277fe344482be8c43d7685412 100644 (file)
@@ -83,7 +83,7 @@ Operator = group(r"\*\*=?", r">>=?", r"<<=?", r"<>", r"!=",
                  r"~")
 
 Bracket = '[][(){}]'
-Special = group(r'\r?\n', r'[:;.,`]')
+Special = group(r'\r?\n', r'[:;.,`@]')
 Funny = group(Operator, Bracket, Special)
 
 PlainToken = group(Number, Funny, String, Name)
index 35c5dee01ad108c7d2ad4a14f59c3ae18a627b54..81d96e16a7953aef7847c5f64f58ba6f6c4239f4 100644 (file)
@@ -824,6 +824,7 @@ static int validate_terminal(node *terminal, int type, char *string);
 #define validate_vbar(ch)       validate_terminal(ch,       VBAR, "|")
 #define validate_doublestar(ch) validate_terminal(ch, DOUBLESTAR, "**")
 #define validate_dot(ch)        validate_terminal(ch,        DOT, ".")
+#define validate_at(ch)         validate_terminal(ch,         AT, "@")
 #define validate_name(ch, str)  validate_terminal(ch,       NAME, str)
 
 #define VALIDATER(n)    static int validate_##n(node *tree)
@@ -2362,20 +2363,72 @@ validate_testlist_gexp(node *tree)
     return ok;
 }
 
+/*  decorator:
+ *    '@' dotted_name [ '(' [arglist] ')' ]
+ */
+static int
+validate_decorator(node *tree)
+{
+    int ok;
+    int nch = NCH(tree);
+    ok = (validate_ntype(tree, decorator) &&
+         (nch == 2 || nch == 4 || nch == 5) &&
+         validate_at(CHILD(tree, 0)) &&
+         validate_dotted_name(CHILD(tree, 1)));
+
+    if (ok && nch != 2) {
+           ok = (validate_lparen(CHILD(tree, 2)) &&
+                 validate_rparen(RCHILD(tree, -1)));
+
+           if (ok && nch == 5)
+               ok = validate_arglist(CHILD(tree, 3));
+    }
+
+    return ok;
+}
+    
+/*  decorators:
+ *    decorator ([NEWLINE] decorator)* NEWLINE
+ */
+static int
+validate_decorators(node *tree)
+{
+    int i, nch, ok; 
+    nch = NCH(tree);
+    ok = validate_ntype(tree, decorators) && nch >= 2;
+
+    i = 0;
+    while (ok && i < nch - 1) {
+       ok = validate_decorator(CHILD(tree, i));
+       if (TYPE(CHILD(tree, i + 1)) == NEWLINE)
+           ++i;
+       ++i;
+    }
+
+    return ok;
+}                             
+
 /*  funcdef:
- *      'def' NAME parameters ':' suite
- *
+ *      
+ *            -6   -5    -4         -3  -2 -1
+ *  [decorators] 'def' NAME parameters ':' suite
  */
 static int
 validate_funcdef(node *tree)
 {
-    return (validate_ntype(tree, funcdef)
-            && validate_numnodes(tree, 5, "funcdef")
-            && validate_name(CHILD(tree, 0), "def")
-            && validate_ntype(CHILD(tree, 1), NAME)
-            && validate_colon(CHILD(tree, 3))
-            && validate_parameters(CHILD(tree, 2))
-            && validate_suite(CHILD(tree, 4)));
+    int nch = NCH(tree);
+    int ok = (validate_ntype(tree, funcdef)
+              && ((nch == 5) || (nch == 6))
+              && validate_name(RCHILD(tree, -5), "def")
+              && validate_ntype(RCHILD(tree, -4), NAME)
+              && validate_colon(RCHILD(tree, -2))
+              && validate_parameters(RCHILD(tree, -3))
+              && validate_suite(RCHILD(tree, -1)));
+
+    if (ok && (nch == 6))
+       ok = validate_decorators(CHILD(tree, 0));
+
+    return ok;
 }
 
 
index 0821bda3d796e0694c37f46bbb196129d0372766..4fdc2e672f33d2a42db44ee8b304d2ef31806a6f 100644 (file)
@@ -92,6 +92,7 @@ char *_PyParser_TokenNames[] = {
        "DOUBLESTAREQUAL",
        "DOUBLESLASH",
        "DOUBLESLASHEQUAL",
+       "AT",
        /* This table must match the #defines in token.h! */
        "OP",
        "<ERRORTOKEN>",
@@ -847,6 +848,7 @@ PyToken_OneChar(int c)
        case '}':       return RBRACE;
        case '^':       return CIRCUMFLEX;
        case '~':       return TILDE;
+       case '@':       return AT;
        default:        return OP;
        }
 }
index 771bc2fa8acf44ac28dfe579d085a8eb1351a49b..337cc2ef02c0f3da1f22ce422554709c04c0b07e 100644 (file)
@@ -1876,6 +1876,7 @@ com_testlist_gexp(struct compiling *c, node *n)
        else com_list(c, n, 0);
 }
 
+
 static void
 com_dictmaker(struct compiling *c, node *n)
 {
@@ -3963,8 +3964,9 @@ com_argdefs(struct compiling *c, node *n)
                n = CHILD(n, 1);
        }
        else {
-               REQ(n, funcdef); /* funcdef: 'def' NAME parameters ... */
-               n = CHILD(n, 2);
+               REQ(n, funcdef);
+               /* funcdef: [decorators] 'def' NAME parameters ':' suite */
+               n = RCHILD(n, -3);
                REQ(n, parameters); /* parameters: '(' [varargslist] ')' */
                n = CHILD(n, 1);
        }
@@ -4008,16 +4010,90 @@ com_argdefs(struct compiling *c, node *n)
        return ndefs;
 }
 
+static void
+com_decorator_name(struct compiling *c, node *n)
+{
+       /* dotted_name: NAME ('.' NAME)* */
+       
+       int i, nch;
+       node *varname;
+
+       REQ(n, dotted_name);
+       nch = NCH(n);
+       assert(nch >= 1 && nch % 2 == 1);
+
+       varname = CHILD(n, 0);
+       REQ(varname, NAME);
+       com_addop_varname(c, VAR_LOAD, STR(varname));
+               
+       for (i = 1; i < nch; i += 2) {
+               node *attrname;
+               
+               REQ(CHILD(n, i), DOT);
+
+               attrname = CHILD(n, i + 1);
+               REQ(attrname, NAME);
+               com_addop_name(c, LOAD_ATTR, STR(attrname));
+       }
+}
+
+static void
+com_decorator(struct compiling *c, node *n)
+{
+       /* decorator: '@' dotted_name [ '(' [arglist] ')' ] */
+       int nch = NCH(n);
+       assert(nch >= 2);
+       REQ(CHILD(n, 0), AT);
+       com_decorator_name(c, CHILD(n, 1));
+
+       if (nch > 2) {
+               assert(nch == 4 || nch == 5);
+               REQ(CHILD(n, 2), LPAR);
+               REQ(CHILD(n, nch - 1), RPAR);
+               com_call_function(c, CHILD(n, 3));
+       }
+}
+
+static int
+com_decorators(struct compiling *c, node *n)
+{
+       int i, nch, ndecorators;
+       
+       /* decorator ([NEWLINE] decorator)* NEWLINE */
+       nch = NCH(n);
+       assert(nch >= 2);
+       REQ(CHILD(n, nch - 1), NEWLINE);
+
+       ndecorators = 0;
+       for (i = NCH(n) - 1; i >= 0; --i) {
+               node *ch = CHILD(n, i);
+               if (TYPE(ch) != NEWLINE) {
+                       com_decorator(c, ch);
+                       ++ndecorators;
+               }
+       }
+
+       return ndecorators;
+}
+
 static void
 com_funcdef(struct compiling *c, node *n)
 {
        PyObject *co;
-       int ndefs;
-       REQ(n, funcdef); /* funcdef: 'def' NAME parameters ':' suite */
+       int ndefs, ndecorators;
+       REQ(n, funcdef);
+       /*          -6            -5   -4   -3         -2  -1
+          funcdef: [decorators] 'def' NAME parameters ':' suite */
+
+       if (NCH(n) == 6)
+               ndecorators = com_decorators(c, CHILD(n, 0));
+       else
+               ndecorators = 0;
+       
        ndefs = com_argdefs(c, n);
        if (ndefs < 0)
                return;
-       symtable_enter_scope(c->c_symtable, STR(CHILD(n, 1)), TYPE(n),
+       symtable_enter_scope(c->c_symtable, STR(RCHILD(n, -4)), TYPE(n),
                             n->n_lineno);
        co = (PyObject *)icompile(n, c);
        symtable_exit_scope(c->c_symtable);
@@ -4033,7 +4109,12 @@ com_funcdef(struct compiling *c, node *n)
                else
                        com_addoparg(c, MAKE_FUNCTION, ndefs);
                com_pop(c, ndefs);
-               com_addop_varname(c, VAR_STORE, STR(CHILD(n, 1)));
+               while (ndecorators > 0) {
+                       com_addoparg(c, CALL_FUNCTION, 1);
+                       com_pop(c, 1);
+                       ndecorators--;
+               }
+               com_addop_varname(c, VAR_STORE, STR(RCHILD(n, -4)));
                com_pop(c, 1);
                Py_DECREF(co);
        }
@@ -4112,7 +4193,7 @@ com_node(struct compiling *c, node *n)
        switch (TYPE(n)) {
        
        /* Definition nodes */
-       
+
        case funcdef:
                com_funcdef(c, n);
                break;
@@ -4377,21 +4458,23 @@ compile_funcdef(struct compiling *c, node *n)
 {
        PyObject *doc;
        node *ch;
-       REQ(n, funcdef); /* funcdef: 'def' NAME parameters ':' suite */
-       c->c_name = STR(CHILD(n, 1));
-       doc = get_docstring(c, CHILD(n, 4));
+       REQ(n, funcdef);
+       /*          -6            -5   -4   -3         -2  -1
+          funcdef: [decorators] 'def' NAME parameters ':' suite */
+       c->c_name = STR(RCHILD(n, -4));
+       doc = get_docstring(c, RCHILD(n, -1));
        if (doc != NULL) {
                (void) com_addconst(c, doc);
                Py_DECREF(doc);
        }
        else
                (void) com_addconst(c, Py_None); /* No docstring */
-       ch = CHILD(n, 2); /* parameters: '(' [varargslist] ')' */
+       ch = RCHILD(n, -3); /* parameters: '(' [varargslist] ')' */
        ch = CHILD(ch, 1); /* ')' | varargslist */
        if (TYPE(ch) == varargslist)
                com_arglist(c, ch);
        c->c_infunction = 1;
-       com_node(c, CHILD(n, 4));
+       com_node(c, RCHILD(n, -1));
        c->c_infunction = 0;
        com_strip_lnotab(c);
        com_addoparg(c, LOAD_CONST, com_addconst(c, Py_None));
@@ -5587,9 +5670,12 @@ symtable_node(struct symtable *st, node *n)
  loop:
        switch (TYPE(n)) {
        case funcdef: {
-               char *func_name = STR(CHILD(n, 1));
+               char *func_name;
+               if (NCH(n) == 6)
+                       symtable_node(st, CHILD(n, 0));
+               func_name = STR(RCHILD(n, -4));
                symtable_add_def(st, func_name, DEF_LOCAL);
-               symtable_default_args(st, CHILD(n, 2));
+               symtable_default_args(st, RCHILD(n, -3));
                symtable_enter_scope(st, func_name, TYPE(n), n->n_lineno);
                symtable_funcdef(st, n);
                symtable_exit_scope(st);
@@ -5734,6 +5820,17 @@ symtable_node(struct symtable *st, node *n)
           to be coded with great care, even though they look like
           rather innocuous.  Each case must double-check TYPE(n).
        */
+       case decorator:
+               if (TYPE(n) == decorator) {
+                       /* decorator: '@' dotted_name [ '(' [arglist] ')' ] */
+                       node *name, *varname;
+                       name = CHILD(n, 1);
+                       REQ(name, dotted_name);
+                       varname = CHILD(name, 0);
+                       REQ(varname, NAME);
+                       symtable_add_use(st, STR(varname));
+               }
+               /* fall through */
        case argument:
                if (TYPE(n) == argument && NCH(n) == 3) {
                        n = CHILD(n, 2);
@@ -5787,7 +5884,7 @@ symtable_funcdef(struct symtable *st, node *n)
                if (NCH(n) == 4)
                        symtable_params(st, CHILD(n, 1));
        } else
-               symtable_params(st, CHILD(n, 2));
+               symtable_params(st, RCHILD(n, -3));
        body = CHILD(n, NCH(n) - 1);
        symtable_node(st, body);
 }
index cd8240bac107c5721d912af3fa52e83e9df94b1d..171809658cf39f9ba50cfa4623a1339cf3fe40e9 100644 (file)
@@ -49,11 +49,13 @@ static arc arcs_3_0[1] = {
 static arc arcs_3_1[1] = {
        {12, 2},
 };
-static arc arcs_3_2[1] = {
+static arc arcs_3_2[2] = {
        {13, 3},
+       {0, 2},
 };
-static arc arcs_3_3[1] = {
+static arc arcs_3_3[2] = {
        {14, 4},
+       {15, 5},
 };
 static arc arcs_3_4[1] = {
        {15, 5},
@@ -64,300 +66,323 @@ static arc arcs_3_5[1] = {
 static state states_3[6] = {
        {1, arcs_3_0},
        {1, arcs_3_1},
-       {1, arcs_3_2},
-       {1, arcs_3_3},
+       {2, arcs_3_2},
+       {2, arcs_3_3},
        {1, arcs_3_4},
        {1, arcs_3_5},
 };
 static arc arcs_4_0[1] = {
-       {16, 1},
+       {10, 1},
 };
 static arc arcs_4_1[2] = {
-       {17, 2},
-       {18, 3},
-};
-static arc arcs_4_2[1] = {
-       {18, 3},
+       {2, 2},
+       {10, 1},
 };
-static arc arcs_4_3[1] = {
-       {0, 3},
+static arc arcs_4_2[2] = {
+       {10, 1},
+       {0, 2},
 };
-static state states_4[4] = {
+static state states_4[3] = {
        {1, arcs_4_0},
        {2, arcs_4_1},
-       {1, arcs_4_2},
-       {1, arcs_4_3},
+       {2, arcs_4_2},
 };
-static arc arcs_5_0[3] = {
-       {19, 1},
-       {23, 2},
-       {24, 3},
+static arc arcs_5_0[2] = {
+       {16, 1},
+       {18, 2},
 };
-static arc arcs_5_1[3] = {
-       {20, 4},
-       {22, 5},
-       {0, 1},
+static arc arcs_5_1[1] = {
+       {18, 2},
 };
 static arc arcs_5_2[1] = {
-       {12, 6},
+       {19, 3},
 };
 static arc arcs_5_3[1] = {
-       {12, 7},
+       {20, 4},
 };
 static arc arcs_5_4[1] = {
-       {21, 8},
+       {21, 5},
 };
-static arc arcs_5_5[4] = {
-       {19, 1},
-       {23, 2},
-       {24, 3},
-       {0, 5},
+static arc arcs_5_5[1] = {
+       {22, 6},
 };
-static arc arcs_5_6[2] = {
-       {22, 9},
+static arc arcs_5_6[1] = {
        {0, 6},
 };
-static arc arcs_5_7[1] = {
-       {0, 7},
-};
-static arc arcs_5_8[2] = {
-       {22, 5},
-       {0, 8},
-};
-static arc arcs_5_9[1] = {
-       {24, 3},
-};
-static state states_5[10] = {
-       {3, arcs_5_0},
-       {3, arcs_5_1},
+static state states_5[7] = {
+       {2, arcs_5_0},
+       {1, arcs_5_1},
        {1, arcs_5_2},
        {1, arcs_5_3},
        {1, arcs_5_4},
-       {4, arcs_5_5},
-       {2, arcs_5_6},
-       {1, arcs_5_7},
-       {2, arcs_5_8},
-       {1, arcs_5_9},
+       {1, arcs_5_5},
+       {1, arcs_5_6},
 };
-static arc arcs_6_0[2] = {
-       {12, 1},
-       {16, 2},
+static arc arcs_6_0[1] = {
+       {13, 1},
 };
-static arc arcs_6_1[1] = {
-       {0, 1},
+static arc arcs_6_1[2] = {
+       {23, 2},
+       {15, 3},
 };
 static arc arcs_6_2[1] = {
-       {25, 3},
+       {15, 3},
 };
 static arc arcs_6_3[1] = {
-       {18, 1},
+       {0, 3},
 };
 static state states_6[4] = {
-       {2, arcs_6_0},
-       {1, arcs_6_1},
+       {1, arcs_6_0},
+       {2, arcs_6_1},
        {1, arcs_6_2},
        {1, arcs_6_3},
 };
-static arc arcs_7_0[1] = {
-       {19, 1},
+static arc arcs_7_0[3] = {
+       {24, 1},
+       {28, 2},
+       {29, 3},
 };
-static arc arcs_7_1[2] = {
-       {22, 2},
+static arc arcs_7_1[3] = {
+       {25, 4},
+       {27, 5},
        {0, 1},
 };
-static arc arcs_7_2[2] = {
-       {19, 1},
-       {0, 2},
+static arc arcs_7_2[1] = {
+       {19, 6},
+};
+static arc arcs_7_3[1] = {
+       {19, 7},
+};
+static arc arcs_7_4[1] = {
+       {26, 8},
+};
+static arc arcs_7_5[4] = {
+       {24, 1},
+       {28, 2},
+       {29, 3},
+       {0, 5},
+};
+static arc arcs_7_6[2] = {
+       {27, 9},
+       {0, 6},
+};
+static arc arcs_7_7[1] = {
+       {0, 7},
+};
+static arc arcs_7_8[2] = {
+       {27, 5},
+       {0, 8},
 };
-static state states_7[3] = {
-       {1, arcs_7_0},
-       {2, arcs_7_1},
-       {2, arcs_7_2},
+static arc arcs_7_9[1] = {
+       {29, 3},
+};
+static state states_7[10] = {
+       {3, arcs_7_0},
+       {3, arcs_7_1},
+       {1, arcs_7_2},
+       {1, arcs_7_3},
+       {1, arcs_7_4},
+       {4, arcs_7_5},
+       {2, arcs_7_6},
+       {1, arcs_7_7},
+       {2, arcs_7_8},
+       {1, arcs_7_9},
 };
 static arc arcs_8_0[2] = {
-       {3, 1},
-       {4, 1},
+       {19, 1},
+       {13, 2},
 };
 static arc arcs_8_1[1] = {
        {0, 1},
 };
-static state states_8[2] = {
+static arc arcs_8_2[1] = {
+       {30, 3},
+};
+static arc arcs_8_3[1] = {
+       {15, 1},
+};
+static state states_8[4] = {
        {2, arcs_8_0},
        {1, arcs_8_1},
+       {1, arcs_8_2},
+       {1, arcs_8_3},
 };
 static arc arcs_9_0[1] = {
-       {26, 1},
+       {24, 1},
 };
 static arc arcs_9_1[2] = {
        {27, 2},
-       {2, 3},
+       {0, 1},
 };
 static arc arcs_9_2[2] = {
-       {26, 1},
-       {2, 3},
-};
-static arc arcs_9_3[1] = {
-       {0, 3},
+       {24, 1},
+       {0, 2},
 };
-static state states_9[4] = {
+static state states_9[3] = {
        {1, arcs_9_0},
        {2, arcs_9_1},
        {2, arcs_9_2},
-       {1, arcs_9_3},
 };
-static arc arcs_10_0[9] = {
-       {28, 1},
-       {29, 1},
-       {30, 1},
-       {31, 1},
-       {32, 1},
-       {33, 1},
-       {34, 1},
-       {35, 1},
-       {36, 1},
+static arc arcs_10_0[2] = {
+       {3, 1},
+       {4, 1},
 };
 static arc arcs_10_1[1] = {
        {0, 1},
 };
 static state states_10[2] = {
-       {9, arcs_10_0},
+       {2, arcs_10_0},
        {1, arcs_10_1},
 };
 static arc arcs_11_0[1] = {
-       {9, 1},
+       {31, 1},
 };
-static arc arcs_11_1[3] = {
-       {37, 2},
-       {20, 3},
-       {0, 1},
+static arc arcs_11_1[2] = {
+       {32, 2},
+       {2, 3},
 };
-static arc arcs_11_2[1] = {
-       {9, 4},
+static arc arcs_11_2[2] = {
+       {31, 1},
+       {2, 3},
 };
 static arc arcs_11_3[1] = {
-       {9, 5},
-};
-static arc arcs_11_4[1] = {
-       {0, 4},
-};
-static arc arcs_11_5[2] = {
-       {20, 3},
-       {0, 5},
+       {0, 3},
 };
-static state states_11[6] = {
+static state states_11[4] = {
        {1, arcs_11_0},
-       {3, arcs_11_1},
-       {1, arcs_11_2},
+       {2, arcs_11_1},
+       {2, arcs_11_2},
        {1, arcs_11_3},
-       {1, arcs_11_4},
-       {2, arcs_11_5},
 };
-static arc arcs_12_0[12] = {
+static arc arcs_12_0[9] = {
+       {33, 1},
+       {34, 1},
+       {35, 1},
+       {36, 1},
+       {37, 1},
        {38, 1},
        {39, 1},
        {40, 1},
        {41, 1},
-       {42, 1},
-       {43, 1},
-       {44, 1},
-       {45, 1},
-       {46, 1},
-       {47, 1},
-       {48, 1},
-       {49, 1},
 };
 static arc arcs_12_1[1] = {
        {0, 1},
 };
 static state states_12[2] = {
-       {12, arcs_12_0},
+       {9, arcs_12_0},
        {1, arcs_12_1},
 };
 static arc arcs_13_0[1] = {
-       {50, 1},
+       {9, 1},
 };
 static arc arcs_13_1[3] = {
-       {21, 2},
-       {51, 3},
+       {42, 2},
+       {25, 3},
        {0, 1},
 };
-static arc arcs_13_2[2] = {
-       {22, 4},
-       {0, 2},
+static arc arcs_13_2[1] = {
+       {9, 4},
 };
 static arc arcs_13_3[1] = {
-       {21, 5},
+       {9, 5},
 };
-static arc arcs_13_4[2] = {
-       {21, 2},
+static arc arcs_13_4[1] = {
        {0, 4},
 };
 static arc arcs_13_5[2] = {
-       {22, 6},
+       {25, 3},
        {0, 5},
 };
-static arc arcs_13_6[1] = {
-       {21, 7},
-};
-static arc arcs_13_7[2] = {
-       {22, 8},
-       {0, 7},
-};
-static arc arcs_13_8[2] = {
-       {21, 7},
-       {0, 8},
-};
-static state states_13[9] = {
+static state states_13[6] = {
        {1, arcs_13_0},
        {3, arcs_13_1},
-       {2, arcs_13_2},
+       {1, arcs_13_2},
        {1, arcs_13_3},
-       {2, arcs_13_4},
+       {1, arcs_13_4},
        {2, arcs_13_5},
-       {1, arcs_13_6},
-       {2, arcs_13_7},
-       {2, arcs_13_8},
 };
-static arc arcs_14_0[1] = {
+static arc arcs_14_0[12] = {
+       {43, 1},
+       {44, 1},
+       {45, 1},
+       {46, 1},
+       {47, 1},
+       {48, 1},
+       {49, 1},
+       {50, 1},
+       {51, 1},
        {52, 1},
+       {53, 1},
+       {54, 1},
 };
 static arc arcs_14_1[1] = {
-       {53, 2},
-};
-static arc arcs_14_2[1] = {
-       {0, 2},
+       {0, 1},
 };
-static state states_14[3] = {
-       {1, arcs_14_0},
+static state states_14[2] = {
+       {12, arcs_14_0},
        {1, arcs_14_1},
-       {1, arcs_14_2},
 };
 static arc arcs_15_0[1] = {
-       {54, 1},
+       {55, 1},
 };
-static arc arcs_15_1[1] = {
+static arc arcs_15_1[3] = {
+       {26, 2},
+       {56, 3},
        {0, 1},
 };
-static state states_15[2] = {
-       {1, arcs_15_0},
-       {1, arcs_15_1},
+static arc arcs_15_2[2] = {
+       {27, 4},
+       {0, 2},
 };
-static arc arcs_16_0[5] = {
-       {55, 1},
-       {56, 1},
+static arc arcs_15_3[1] = {
+       {26, 5},
+};
+static arc arcs_15_4[2] = {
+       {26, 2},
+       {0, 4},
+};
+static arc arcs_15_5[2] = {
+       {27, 6},
+       {0, 5},
+};
+static arc arcs_15_6[1] = {
+       {26, 7},
+};
+static arc arcs_15_7[2] = {
+       {27, 8},
+       {0, 7},
+};
+static arc arcs_15_8[2] = {
+       {26, 7},
+       {0, 8},
+};
+static state states_15[9] = {
+       {1, arcs_15_0},
+       {3, arcs_15_1},
+       {2, arcs_15_2},
+       {1, arcs_15_3},
+       {2, arcs_15_4},
+       {2, arcs_15_5},
+       {1, arcs_15_6},
+       {2, arcs_15_7},
+       {2, arcs_15_8},
+};
+static arc arcs_16_0[1] = {
        {57, 1},
-       {58, 1},
-       {59, 1},
 };
 static arc arcs_16_1[1] = {
-       {0, 1},
+       {58, 2},
+};
+static arc arcs_16_2[1] = {
+       {0, 2},
 };
-static state states_16[2] = {
-       {5, arcs_16_0},
+static state states_16[3] = {
+       {1, arcs_16_0},
        {1, arcs_16_1},
+       {1, arcs_16_2},
 };
 static arc arcs_17_0[1] = {
-       {60, 1},
+       {59, 1},
 };
 static arc arcs_17_1[1] = {
        {0, 1},
@@ -366,567 +391,569 @@ static state states_17[2] = {
        {1, arcs_17_0},
        {1, arcs_17_1},
 };
-static arc arcs_18_0[1] = {
+static arc arcs_18_0[5] = {
+       {60, 1},
        {61, 1},
+       {62, 1},
+       {63, 1},
+       {64, 1},
 };
 static arc arcs_18_1[1] = {
        {0, 1},
 };
 static state states_18[2] = {
-       {1, arcs_18_0},
+       {5, arcs_18_0},
        {1, arcs_18_1},
 };
 static arc arcs_19_0[1] = {
-       {62, 1},
+       {65, 1},
 };
-static arc arcs_19_1[2] = {
-       {9, 2},
+static arc arcs_19_1[1] = {
        {0, 1},
 };
-static arc arcs_19_2[1] = {
-       {0, 2},
-};
-static state states_19[3] = {
+static state states_19[2] = {
        {1, arcs_19_0},
-       {2, arcs_19_1},
-       {1, arcs_19_2},
+       {1, arcs_19_1},
 };
 static arc arcs_20_0[1] = {
-       {63, 1},
+       {66, 1},
 };
 static arc arcs_20_1[1] = {
-       {9, 2},
-};
-static arc arcs_20_2[1] = {
-       {0, 2},
+       {0, 1},
 };
-static state states_20[3] = {
+static state states_20[2] = {
        {1, arcs_20_0},
        {1, arcs_20_1},
-       {1, arcs_20_2},
 };
 static arc arcs_21_0[1] = {
-       {64, 1},
+       {67, 1},
 };
 static arc arcs_21_1[2] = {
-       {21, 2},
+       {9, 2},
        {0, 1},
 };
-static arc arcs_21_2[2] = {
-       {22, 3},
+static arc arcs_21_2[1] = {
        {0, 2},
 };
-static arc arcs_21_3[1] = {
-       {21, 4},
-};
-static arc arcs_21_4[2] = {
-       {22, 5},
-       {0, 4},
-};
-static arc arcs_21_5[1] = {
-       {21, 6},
-};
-static arc arcs_21_6[1] = {
-       {0, 6},
-};
-static state states_21[7] = {
+static state states_21[3] = {
        {1, arcs_21_0},
        {2, arcs_21_1},
-       {2, arcs_21_2},
-       {1, arcs_21_3},
-       {2, arcs_21_4},
-       {1, arcs_21_5},
-       {1, arcs_21_6},
+       {1, arcs_21_2},
 };
-static arc arcs_22_0[2] = {
-       {65, 1},
-       {67, 2},
+static arc arcs_22_0[1] = {
+       {68, 1},
 };
 static arc arcs_22_1[1] = {
-       {66, 3},
+       {9, 2},
 };
 static arc arcs_22_2[1] = {
-       {68, 4},
-};
-static arc arcs_22_3[2] = {
-       {22, 1},
-       {0, 3},
-};
-static arc arcs_22_4[1] = {
-       {65, 5},
-};
-static arc arcs_22_5[2] = {
-       {23, 6},
-       {69, 7},
-};
-static arc arcs_22_6[1] = {
-       {0, 6},
-};
-static arc arcs_22_7[2] = {
-       {22, 8},
-       {0, 7},
-};
-static arc arcs_22_8[1] = {
-       {69, 7},
+       {0, 2},
 };
-static state states_22[9] = {
-       {2, arcs_22_0},
+static state states_22[3] = {
+       {1, arcs_22_0},
        {1, arcs_22_1},
        {1, arcs_22_2},
-       {2, arcs_22_3},
-       {1, arcs_22_4},
-       {2, arcs_22_5},
-       {1, arcs_22_6},
-       {2, arcs_22_7},
-       {1, arcs_22_8},
 };
 static arc arcs_23_0[1] = {
-       {12, 1},
+       {69, 1},
 };
 static arc arcs_23_1[2] = {
-       {12, 2},
+       {26, 2},
        {0, 1},
 };
-static arc arcs_23_2[1] = {
-       {12, 3},
+static arc arcs_23_2[2] = {
+       {27, 3},
+       {0, 2},
 };
 static arc arcs_23_3[1] = {
-       {0, 3},
+       {26, 4},
+};
+static arc arcs_23_4[2] = {
+       {27, 5},
+       {0, 4},
 };
-static state states_23[4] = {
+static arc arcs_23_5[1] = {
+       {26, 6},
+};
+static arc arcs_23_6[1] = {
+       {0, 6},
+};
+static state states_23[7] = {
        {1, arcs_23_0},
        {2, arcs_23_1},
-       {1, arcs_23_2},
+       {2, arcs_23_2},
        {1, arcs_23_3},
+       {2, arcs_23_4},
+       {1, arcs_23_5},
+       {1, arcs_23_6},
 };
-static arc arcs_24_0[1] = {
-       {68, 1},
+static arc arcs_24_0[2] = {
+       {70, 1},
+       {72, 2},
 };
-static arc arcs_24_1[2] = {
-       {12, 2},
-       {0, 1},
+static arc arcs_24_1[1] = {
+       {71, 3},
 };
 static arc arcs_24_2[1] = {
-       {12, 3},
+       {12, 4},
 };
-static arc arcs_24_3[1] = {
+static arc arcs_24_3[2] = {
+       {27, 1},
        {0, 3},
 };
-static state states_24[4] = {
-       {1, arcs_24_0},
-       {2, arcs_24_1},
+static arc arcs_24_4[1] = {
+       {70, 5},
+};
+static arc arcs_24_5[2] = {
+       {28, 6},
+       {73, 7},
+};
+static arc arcs_24_6[1] = {
+       {0, 6},
+};
+static arc arcs_24_7[2] = {
+       {27, 8},
+       {0, 7},
+};
+static arc arcs_24_8[1] = {
+       {73, 7},
+};
+static state states_24[9] = {
+       {2, arcs_24_0},
+       {1, arcs_24_1},
        {1, arcs_24_2},
-       {1, arcs_24_3},
+       {2, arcs_24_3},
+       {1, arcs_24_4},
+       {2, arcs_24_5},
+       {1, arcs_24_6},
+       {2, arcs_24_7},
+       {1, arcs_24_8},
 };
 static arc arcs_25_0[1] = {
-       {12, 1},
+       {19, 1},
 };
 static arc arcs_25_1[2] = {
-       {70, 0},
+       {19, 2},
        {0, 1},
 };
-static state states_25[2] = {
+static arc arcs_25_2[1] = {
+       {19, 3},
+};
+static arc arcs_25_3[1] = {
+       {0, 3},
+};
+static state states_25[4] = {
        {1, arcs_25_0},
        {2, arcs_25_1},
+       {1, arcs_25_2},
+       {1, arcs_25_3},
 };
 static arc arcs_26_0[1] = {
-       {71, 1},
+       {12, 1},
 };
-static arc arcs_26_1[1] = {
-       {12, 2},
+static arc arcs_26_1[2] = {
+       {19, 2},
+       {0, 1},
 };
-static arc arcs_26_2[2] = {
-       {22, 1},
-       {0, 2},
+static arc arcs_26_2[1] = {
+       {19, 3},
+};
+static arc arcs_26_3[1] = {
+       {0, 3},
 };
-static state states_26[3] = {
+static state states_26[4] = {
        {1, arcs_26_0},
-       {1, arcs_26_1},
-       {2, arcs_26_2},
+       {2, arcs_26_1},
+       {1, arcs_26_2},
+       {1, arcs_26_3},
 };
 static arc arcs_27_0[1] = {
-       {72, 1},
-};
-static arc arcs_27_1[1] = {
-       {73, 2},
-};
-static arc arcs_27_2[2] = {
-       {74, 3},
-       {0, 2},
-};
-static arc arcs_27_3[1] = {
-       {21, 4},
-};
-static arc arcs_27_4[2] = {
-       {22, 5},
-       {0, 4},
-};
-static arc arcs_27_5[1] = {
-       {21, 6},
+       {19, 1},
 };
-static arc arcs_27_6[1] = {
-       {0, 6},
+static arc arcs_27_1[2] = {
+       {74, 0},
+       {0, 1},
 };
-static state states_27[7] = {
+static state states_27[2] = {
        {1, arcs_27_0},
-       {1, arcs_27_1},
-       {2, arcs_27_2},
-       {1, arcs_27_3},
-       {2, arcs_27_4},
-       {1, arcs_27_5},
-       {1, arcs_27_6},
+       {2, arcs_27_1},
 };
 static arc arcs_28_0[1] = {
        {75, 1},
 };
 static arc arcs_28_1[1] = {
-       {21, 2},
+       {19, 2},
 };
 static arc arcs_28_2[2] = {
-       {22, 3},
+       {27, 1},
        {0, 2},
 };
-static arc arcs_28_3[1] = {
-       {21, 4},
-};
-static arc arcs_28_4[1] = {
-       {0, 4},
-};
-static state states_28[5] = {
+static state states_28[3] = {
        {1, arcs_28_0},
        {1, arcs_28_1},
        {2, arcs_28_2},
-       {1, arcs_28_3},
-       {1, arcs_28_4},
 };
-static arc arcs_29_0[6] = {
+static arc arcs_29_0[1] = {
        {76, 1},
-       {77, 1},
-       {78, 1},
-       {79, 1},
-       {10, 1},
-       {80, 1},
 };
 static arc arcs_29_1[1] = {
-       {0, 1},
+       {77, 2},
+};
+static arc arcs_29_2[2] = {
+       {78, 3},
+       {0, 2},
+};
+static arc arcs_29_3[1] = {
+       {26, 4},
+};
+static arc arcs_29_4[2] = {
+       {27, 5},
+       {0, 4},
+};
+static arc arcs_29_5[1] = {
+       {26, 6},
 };
-static state states_29[2] = {
-       {6, arcs_29_0},
+static arc arcs_29_6[1] = {
+       {0, 6},
+};
+static state states_29[7] = {
+       {1, arcs_29_0},
        {1, arcs_29_1},
+       {2, arcs_29_2},
+       {1, arcs_29_3},
+       {2, arcs_29_4},
+       {1, arcs_29_5},
+       {1, arcs_29_6},
 };
 static arc arcs_30_0[1] = {
-       {81, 1},
+       {79, 1},
 };
 static arc arcs_30_1[1] = {
-       {21, 2},
+       {26, 2},
 };
-static arc arcs_30_2[1] = {
-       {14, 3},
+static arc arcs_30_2[2] = {
+       {27, 3},
+       {0, 2},
 };
 static arc arcs_30_3[1] = {
-       {15, 4},
+       {26, 4},
 };
-static arc arcs_30_4[3] = {
-       {82, 1},
-       {83, 5},
+static arc arcs_30_4[1] = {
        {0, 4},
 };
-static arc arcs_30_5[1] = {
-       {14, 6},
-};
-static arc arcs_30_6[1] = {
-       {15, 7},
-};
-static arc arcs_30_7[1] = {
-       {0, 7},
-};
-static state states_30[8] = {
+static state states_30[5] = {
        {1, arcs_30_0},
        {1, arcs_30_1},
-       {1, arcs_30_2},
+       {2, arcs_30_2},
        {1, arcs_30_3},
-       {3, arcs_30_4},
-       {1, arcs_30_5},
-       {1, arcs_30_6},
-       {1, arcs_30_7},
+       {1, arcs_30_4},
 };
-static arc arcs_31_0[1] = {
+static arc arcs_31_0[6] = {
+       {80, 1},
+       {81, 1},
+       {82, 1},
+       {83, 1},
+       {17, 1},
        {84, 1},
 };
 static arc arcs_31_1[1] = {
-       {21, 2},
-};
-static arc arcs_31_2[1] = {
-       {14, 3},
-};
-static arc arcs_31_3[1] = {
-       {15, 4},
-};
-static arc arcs_31_4[2] = {
-       {83, 5},
-       {0, 4},
-};
-static arc arcs_31_5[1] = {
-       {14, 6},
-};
-static arc arcs_31_6[1] = {
-       {15, 7},
-};
-static arc arcs_31_7[1] = {
-       {0, 7},
+       {0, 1},
 };
-static state states_31[8] = {
-       {1, arcs_31_0},
+static state states_31[2] = {
+       {6, arcs_31_0},
        {1, arcs_31_1},
-       {1, arcs_31_2},
-       {1, arcs_31_3},
-       {2, arcs_31_4},
-       {1, arcs_31_5},
-       {1, arcs_31_6},
-       {1, arcs_31_7},
 };
 static arc arcs_32_0[1] = {
        {85, 1},
 };
 static arc arcs_32_1[1] = {
-       {53, 2},
+       {26, 2},
 };
 static arc arcs_32_2[1] = {
-       {74, 3},
+       {21, 3},
 };
 static arc arcs_32_3[1] = {
-       {9, 4},
+       {22, 4},
 };
-static arc arcs_32_4[1] = {
-       {14, 5},
+static arc arcs_32_4[3] = {
+       {86, 1},
+       {87, 5},
+       {0, 4},
 };
 static arc arcs_32_5[1] = {
-       {15, 6},
+       {21, 6},
 };
-static arc arcs_32_6[2] = {
-       {83, 7},
-       {0, 6},
+static arc arcs_32_6[1] = {
+       {22, 7},
 };
 static arc arcs_32_7[1] = {
-       {14, 8},
-};
-static arc arcs_32_8[1] = {
-       {15, 9},
-};
-static arc arcs_32_9[1] = {
-       {0, 9},
+       {0, 7},
 };
-static state states_32[10] = {
+static state states_32[8] = {
        {1, arcs_32_0},
        {1, arcs_32_1},
        {1, arcs_32_2},
        {1, arcs_32_3},
-       {1, arcs_32_4},
+       {3, arcs_32_4},
        {1, arcs_32_5},
-       {2, arcs_32_6},
+       {1, arcs_32_6},
        {1, arcs_32_7},
-       {1, arcs_32_8},
-       {1, arcs_32_9},
 };
 static arc arcs_33_0[1] = {
-       {86, 1},
+       {88, 1},
 };
 static arc arcs_33_1[1] = {
-       {14, 2},
+       {26, 2},
 };
 static arc arcs_33_2[1] = {
-       {15, 3},
+       {21, 3},
 };
-static arc arcs_33_3[2] = {
-       {87, 4},
-       {88, 5},
+static arc arcs_33_3[1] = {
+       {22, 4},
 };
-static arc arcs_33_4[1] = {
-       {14, 6},
+static arc arcs_33_4[2] = {
+       {87, 5},
+       {0, 4},
 };
 static arc arcs_33_5[1] = {
-       {14, 7},
+       {21, 6},
 };
 static arc arcs_33_6[1] = {
-       {15, 8},
+       {22, 7},
 };
 static arc arcs_33_7[1] = {
-       {15, 9},
-};
-static arc arcs_33_8[3] = {
-       {87, 4},
-       {83, 5},
-       {0, 8},
-};
-static arc arcs_33_9[1] = {
-       {0, 9},
+       {0, 7},
 };
-static state states_33[10] = {
+static state states_33[8] = {
        {1, arcs_33_0},
        {1, arcs_33_1},
        {1, arcs_33_2},
-       {2, arcs_33_3},
-       {1, arcs_33_4},
+       {1, arcs_33_3},
+       {2, arcs_33_4},
        {1, arcs_33_5},
        {1, arcs_33_6},
        {1, arcs_33_7},
-       {3, arcs_33_8},
-       {1, arcs_33_9},
 };
 static arc arcs_34_0[1] = {
        {89, 1},
 };
-static arc arcs_34_1[2] = {
-       {21, 2},
-       {0, 1},
+static arc arcs_34_1[1] = {
+       {58, 2},
 };
-static arc arcs_34_2[2] = {
-       {22, 3},
-       {0, 2},
+static arc arcs_34_2[1] = {
+       {78, 3},
 };
 static arc arcs_34_3[1] = {
-       {21, 4},
+       {9, 4},
 };
 static arc arcs_34_4[1] = {
-       {0, 4},
+       {21, 5},
+};
+static arc arcs_34_5[1] = {
+       {22, 6},
+};
+static arc arcs_34_6[2] = {
+       {87, 7},
+       {0, 6},
+};
+static arc arcs_34_7[1] = {
+       {21, 8},
+};
+static arc arcs_34_8[1] = {
+       {22, 9},
+};
+static arc arcs_34_9[1] = {
+       {0, 9},
 };
-static state states_34[5] = {
+static state states_34[10] = {
        {1, arcs_34_0},
-       {2, arcs_34_1},
-       {2, arcs_34_2},
+       {1, arcs_34_1},
+       {1, arcs_34_2},
        {1, arcs_34_3},
        {1, arcs_34_4},
+       {1, arcs_34_5},
+       {2, arcs_34_6},
+       {1, arcs_34_7},
+       {1, arcs_34_8},
+       {1, arcs_34_9},
 };
-static arc arcs_35_0[2] = {
-       {3, 1},
-       {2, 2},
+static arc arcs_35_0[1] = {
+       {90, 1},
 };
 static arc arcs_35_1[1] = {
-       {0, 1},
+       {21, 2},
 };
 static arc arcs_35_2[1] = {
-       {90, 3},
+       {22, 3},
 };
-static arc arcs_35_3[1] = {
-       {6, 4},
+static arc arcs_35_3[2] = {
+       {91, 4},
+       {92, 5},
 };
-static arc arcs_35_4[2] = {
-       {6, 4},
-       {91, 1},
+static arc arcs_35_4[1] = {
+       {21, 6},
+};
+static arc arcs_35_5[1] = {
+       {21, 7},
+};
+static arc arcs_35_6[1] = {
+       {22, 8},
+};
+static arc arcs_35_7[1] = {
+       {22, 9},
+};
+static arc arcs_35_8[3] = {
+       {91, 4},
+       {87, 5},
+       {0, 8},
+};
+static arc arcs_35_9[1] = {
+       {0, 9},
 };
-static state states_35[5] = {
-       {2, arcs_35_0},
+static state states_35[10] = {
+       {1, arcs_35_0},
        {1, arcs_35_1},
        {1, arcs_35_2},
-       {1, arcs_35_3},
-       {2, arcs_35_4},
+       {2, arcs_35_3},
+       {1, arcs_35_4},
+       {1, arcs_35_5},
+       {1, arcs_35_6},
+       {1, arcs_35_7},
+       {3, arcs_35_8},
+       {1, arcs_35_9},
 };
-static arc arcs_36_0[2] = {
-       {92, 1},
-       {94, 2},
+static arc arcs_36_0[1] = {
+       {93, 1},
 };
 static arc arcs_36_1[2] = {
-       {93, 3},
+       {26, 2},
        {0, 1},
 };
-static arc arcs_36_2[1] = {
+static arc arcs_36_2[2] = {
+       {27, 3},
        {0, 2},
 };
 static arc arcs_36_3[1] = {
-       {92, 1},
+       {26, 4},
+};
+static arc arcs_36_4[1] = {
+       {0, 4},
 };
-static state states_36[4] = {
-       {2, arcs_36_0},
+static state states_36[5] = {
+       {1, arcs_36_0},
        {2, arcs_36_1},
-       {1, arcs_36_2},
+       {2, arcs_36_2},
        {1, arcs_36_3},
+       {1, arcs_36_4},
 };
-static arc arcs_37_0[1] = {
-       {95, 1},
+static arc arcs_37_0[2] = {
+       {3, 1},
+       {2, 2},
 };
-static arc arcs_37_1[2] = {
-       {96, 0},
+static arc arcs_37_1[1] = {
        {0, 1},
 };
-static state states_37[2] = {
-       {1, arcs_37_0},
-       {2, arcs_37_1},
+static arc arcs_37_2[1] = {
+       {94, 3},
+};
+static arc arcs_37_3[1] = {
+       {6, 4},
+};
+static arc arcs_37_4[2] = {
+       {6, 4},
+       {95, 1},
+};
+static state states_37[5] = {
+       {2, arcs_37_0},
+       {1, arcs_37_1},
+       {1, arcs_37_2},
+       {1, arcs_37_3},
+       {2, arcs_37_4},
 };
 static arc arcs_38_0[2] = {
-       {97, 1},
+       {96, 1},
        {98, 2},
 };
-static arc arcs_38_1[1] = {
-       {95, 2},
+static arc arcs_38_1[2] = {
+       {97, 3},
+       {0, 1},
 };
 static arc arcs_38_2[1] = {
        {0, 2},
 };
-static state states_38[3] = {
+static arc arcs_38_3[1] = {
+       {96, 1},
+};
+static state states_38[4] = {
        {2, arcs_38_0},
-       {1, arcs_38_1},
+       {2, arcs_38_1},
        {1, arcs_38_2},
+       {1, arcs_38_3},
 };
 static arc arcs_39_0[1] = {
-       {73, 1},
+       {99, 1},
 };
 static arc arcs_39_1[2] = {
-       {99, 0},
+       {100, 0},
        {0, 1},
 };
 static state states_39[2] = {
        {1, arcs_39_0},
        {2, arcs_39_1},
 };
-static arc arcs_40_0[10] = {
-       {100, 1},
+static arc arcs_40_0[2] = {
        {101, 1},
-       {102, 1},
-       {103, 1},
-       {104, 1},
-       {105, 1},
-       {106, 1},
-       {74, 1},
-       {97, 2},
-       {107, 3},
+       {102, 2},
 };
 static arc arcs_40_1[1] = {
-       {0, 1},
+       {99, 2},
 };
 static arc arcs_40_2[1] = {
-       {74, 1},
-};
-static arc arcs_40_3[2] = {
-       {97, 1},
-       {0, 3},
+       {0, 2},
 };
-static state states_40[4] = {
-       {10, arcs_40_0},
+static state states_40[3] = {
+       {2, arcs_40_0},
        {1, arcs_40_1},
        {1, arcs_40_2},
-       {2, arcs_40_3},
 };
 static arc arcs_41_0[1] = {
-       {108, 1},
+       {77, 1},
 };
 static arc arcs_41_1[2] = {
-       {109, 0},
+       {103, 0},
        {0, 1},
 };
 static state states_41[2] = {
        {1, arcs_41_0},
        {2, arcs_41_1},
 };
-static arc arcs_42_0[1] = {
+static arc arcs_42_0[10] = {
+       {104, 1},
+       {105, 1},
+       {106, 1},
+       {107, 1},
+       {108, 1},
+       {109, 1},
        {110, 1},
+       {78, 1},
+       {101, 2},
+       {111, 3},
 };
-static arc arcs_42_1[2] = {
-       {111, 0},
+static arc arcs_42_1[1] = {
        {0, 1},
 };
-static state states_42[2] = {
-       {1, arcs_42_0},
-       {2, arcs_42_1},
+static arc arcs_42_2[1] = {
+       {78, 1},
+};
+static arc arcs_42_3[2] = {
+       {101, 1},
+       {0, 3},
+};
+static state states_42[4] = {
+       {10, arcs_42_0},
+       {1, arcs_42_1},
+       {1, arcs_42_2},
+       {2, arcs_42_3},
 };
 static arc arcs_43_0[1] = {
        {112, 1},
@@ -942,811 +969,842 @@ static state states_43[2] = {
 static arc arcs_44_0[1] = {
        {114, 1},
 };
-static arc arcs_44_1[3] = {
+static arc arcs_44_1[2] = {
        {115, 0},
-       {51, 0},
        {0, 1},
 };
 static state states_44[2] = {
        {1, arcs_44_0},
-       {3, arcs_44_1},
+       {2, arcs_44_1},
 };
 static arc arcs_45_0[1] = {
        {116, 1},
 };
-static arc arcs_45_1[3] = {
+static arc arcs_45_1[2] = {
        {117, 0},
-       {118, 0},
        {0, 1},
 };
 static state states_45[2] = {
        {1, arcs_45_0},
-       {3, arcs_45_1},
+       {2, arcs_45_1},
 };
 static arc arcs_46_0[1] = {
-       {119, 1},
+       {118, 1},
 };
-static arc arcs_46_1[5] = {
-       {23, 0},
-       {120, 0},
-       {121, 0},
-       {122, 0},
+static arc arcs_46_1[3] = {
+       {119, 0},
+       {56, 0},
        {0, 1},
 };
 static state states_46[2] = {
        {1, arcs_46_0},
-       {5, arcs_46_1},
+       {3, arcs_46_1},
 };
-static arc arcs_47_0[4] = {
-       {117, 1},
-       {118, 1},
-       {123, 1},
-       {124, 2},
-};
-static arc arcs_47_1[1] = {
-       {119, 2},
+static arc arcs_47_0[1] = {
+       {120, 1},
 };
-static arc arcs_47_2[1] = {
-       {0, 2},
+static arc arcs_47_1[3] = {
+       {121, 0},
+       {122, 0},
+       {0, 1},
 };
-static state states_47[3] = {
-       {4, arcs_47_0},
-       {1, arcs_47_1},
-       {1, arcs_47_2},
+static state states_47[2] = {
+       {1, arcs_47_0},
+       {3, arcs_47_1},
 };
 static arc arcs_48_0[1] = {
-       {125, 1},
+       {123, 1},
 };
-static arc arcs_48_1[3] = {
-       {126, 1},
-       {24, 2},
+static arc arcs_48_1[5] = {
+       {28, 0},
+       {124, 0},
+       {125, 0},
+       {126, 0},
        {0, 1},
 };
-static arc arcs_48_2[1] = {
-       {119, 3},
-};
-static arc arcs_48_3[1] = {
-       {0, 3},
-};
-static state states_48[4] = {
+static state states_48[2] = {
        {1, arcs_48_0},
-       {3, arcs_48_1},
-       {1, arcs_48_2},
-       {1, arcs_48_3},
+       {5, arcs_48_1},
 };
-static arc arcs_49_0[7] = {
-       {16, 1},
+static arc arcs_49_0[4] = {
+       {121, 1},
+       {122, 1},
+       {127, 1},
        {128, 2},
-       {131, 3},
-       {134, 4},
-       {12, 5},
-       {136, 5},
-       {137, 6},
-};
-static arc arcs_49_1[2] = {
-       {127, 7},
-       {18, 5},
-};
-static arc arcs_49_2[2] = {
-       {129, 8},
-       {130, 5},
-};
-static arc arcs_49_3[2] = {
-       {132, 9},
-       {133, 5},
 };
-static arc arcs_49_4[1] = {
-       {135, 10},
-};
-static arc arcs_49_5[1] = {
-       {0, 5},
-};
-static arc arcs_49_6[2] = {
-       {137, 6},
-       {0, 6},
+static arc arcs_49_1[1] = {
+       {123, 2},
 };
-static arc arcs_49_7[1] = {
-       {18, 5},
-};
-static arc arcs_49_8[1] = {
-       {130, 5},
-};
-static arc arcs_49_9[1] = {
-       {133, 5},
-};
-static arc arcs_49_10[1] = {
-       {134, 5},
+static arc arcs_49_2[1] = {
+       {0, 2},
 };
-static state states_49[11] = {
-       {7, arcs_49_0},
-       {2, arcs_49_1},
-       {2, arcs_49_2},
-       {2, arcs_49_3},
-       {1, arcs_49_4},
-       {1, arcs_49_5},
-       {2, arcs_49_6},
-       {1, arcs_49_7},
-       {1, arcs_49_8},
-       {1, arcs_49_9},
-       {1, arcs_49_10},
+static state states_49[3] = {
+       {4, arcs_49_0},
+       {1, arcs_49_1},
+       {1, arcs_49_2},
 };
 static arc arcs_50_0[1] = {
-       {21, 1},
+       {129, 1},
 };
 static arc arcs_50_1[3] = {
-       {138, 2},
-       {22, 3},
+       {130, 1},
+       {29, 2},
        {0, 1},
 };
 static arc arcs_50_2[1] = {
-       {0, 2},
+       {123, 3},
 };
-static arc arcs_50_3[2] = {
-       {21, 4},
+static arc arcs_50_3[1] = {
        {0, 3},
 };
-static arc arcs_50_4[2] = {
-       {22, 3},
-       {0, 4},
-};
-static state states_50[5] = {
+static state states_50[4] = {
        {1, arcs_50_0},
        {3, arcs_50_1},
        {1, arcs_50_2},
-       {2, arcs_50_3},
-       {2, arcs_50_4},
+       {1, arcs_50_3},
+};
+static arc arcs_51_0[7] = {
+       {13, 1},
+       {132, 2},
+       {135, 3},
+       {138, 4},
+       {19, 5},
+       {140, 5},
+       {141, 6},
+};
+static arc arcs_51_1[2] = {
+       {131, 7},
+       {15, 5},
 };
-static arc arcs_51_0[1] = {
-       {21, 1},
+static arc arcs_51_2[2] = {
+       {133, 8},
+       {134, 5},
 };
-static arc arcs_51_1[3] = {
-       {139, 2},
-       {22, 3},
-       {0, 1},
+static arc arcs_51_3[2] = {
+       {136, 9},
+       {137, 5},
 };
-static arc arcs_51_2[1] = {
-       {0, 2},
+static arc arcs_51_4[1] = {
+       {139, 10},
 };
-static arc arcs_51_3[2] = {
-       {21, 4},
-       {0, 3},
+static arc arcs_51_5[1] = {
+       {0, 5},
 };
-static arc arcs_51_4[2] = {
-       {22, 3},
-       {0, 4},
+static arc arcs_51_6[2] = {
+       {141, 6},
+       {0, 6},
+};
+static arc arcs_51_7[1] = {
+       {15, 5},
+};
+static arc arcs_51_8[1] = {
+       {134, 5},
 };
-static state states_51[5] = {
-       {1, arcs_51_0},
-       {3, arcs_51_1},
-       {1, arcs_51_2},
+static arc arcs_51_9[1] = {
+       {137, 5},
+};
+static arc arcs_51_10[1] = {
+       {138, 5},
+};
+static state states_51[11] = {
+       {7, arcs_51_0},
+       {2, arcs_51_1},
+       {2, arcs_51_2},
        {2, arcs_51_3},
-       {2, arcs_51_4},
+       {1, arcs_51_4},
+       {1, arcs_51_5},
+       {2, arcs_51_6},
+       {1, arcs_51_7},
+       {1, arcs_51_8},
+       {1, arcs_51_9},
+       {1, arcs_51_10},
 };
 static arc arcs_52_0[1] = {
-       {140, 1},
+       {26, 1},
 };
-static arc arcs_52_1[2] = {
-       {17, 2},
-       {14, 3},
+static arc arcs_52_1[3] = {
+       {142, 2},
+       {27, 3},
+       {0, 1},
 };
 static arc arcs_52_2[1] = {
-       {14, 3},
+       {0, 2},
 };
-static arc arcs_52_3[1] = {
-       {21, 4},
+static arc arcs_52_3[2] = {
+       {26, 4},
+       {0, 3},
 };
-static arc arcs_52_4[1] = {
+static arc arcs_52_4[2] = {
+       {27, 3},
        {0, 4},
 };
 static state states_52[5] = {
        {1, arcs_52_0},
-       {2, arcs_52_1},
+       {3, arcs_52_1},
        {1, arcs_52_2},
-       {1, arcs_52_3},
-       {1, arcs_52_4},
+       {2, arcs_52_3},
+       {2, arcs_52_4},
 };
-static arc arcs_53_0[3] = {
-       {16, 1},
-       {128, 2},
-       {70, 3},
+static arc arcs_53_0[1] = {
+       {26, 1},
 };
-static arc arcs_53_1[2] = {
-       {141, 4},
-       {18, 5},
+static arc arcs_53_1[3] = {
+       {143, 2},
+       {27, 3},
+       {0, 1},
 };
 static arc arcs_53_2[1] = {
-       {142, 6},
-};
-static arc arcs_53_3[1] = {
-       {12, 5},
-};
-static arc arcs_53_4[1] = {
-       {18, 5},
+       {0, 2},
 };
-static arc arcs_53_5[1] = {
-       {0, 5},
+static arc arcs_53_3[2] = {
+       {26, 4},
+       {0, 3},
 };
-static arc arcs_53_6[1] = {
-       {130, 5},
+static arc arcs_53_4[2] = {
+       {27, 3},
+       {0, 4},
 };
-static state states_53[7] = {
-       {3, arcs_53_0},
-       {2, arcs_53_1},
+static state states_53[5] = {
+       {1, arcs_53_0},
+       {3, arcs_53_1},
        {1, arcs_53_2},
-       {1, arcs_53_3},
-       {1, arcs_53_4},
-       {1, arcs_53_5},
-       {1, arcs_53_6},
+       {2, arcs_53_3},
+       {2, arcs_53_4},
 };
 static arc arcs_54_0[1] = {
-       {143, 1},
+       {144, 1},
 };
 static arc arcs_54_1[2] = {
-       {22, 2},
-       {0, 1},
+       {23, 2},
+       {21, 3},
 };
-static arc arcs_54_2[2] = {
-       {143, 1},
-       {0, 2},
+static arc arcs_54_2[1] = {
+       {21, 3},
+};
+static arc arcs_54_3[1] = {
+       {26, 4},
+};
+static arc arcs_54_4[1] = {
+       {0, 4},
 };
-static state states_54[3] = {
+static state states_54[5] = {
        {1, arcs_54_0},
        {2, arcs_54_1},
-       {2, arcs_54_2},
+       {1, arcs_54_2},
+       {1, arcs_54_3},
+       {1, arcs_54_4},
 };
 static arc arcs_55_0[3] = {
-       {70, 1},
-       {21, 2},
-       {14, 3},
+       {13, 1},
+       {132, 2},
+       {74, 3},
 };
-static arc arcs_55_1[1] = {
-       {70, 4},
+static arc arcs_55_1[2] = {
+       {14, 4},
+       {15, 5},
 };
-static arc arcs_55_2[2] = {
-       {14, 3},
-       {0, 2},
+static arc arcs_55_2[1] = {
+       {145, 6},
 };
-static arc arcs_55_3[3] = {
-       {21, 5},
-       {144, 6},
-       {0, 3},
+static arc arcs_55_3[1] = {
+       {19, 5},
 };
 static arc arcs_55_4[1] = {
-       {70, 6},
+       {15, 5},
 };
-static arc arcs_55_5[2] = {
-       {144, 6},
+static arc arcs_55_5[1] = {
        {0, 5},
 };
 static arc arcs_55_6[1] = {
-       {0, 6},
+       {134, 5},
 };
 static state states_55[7] = {
        {3, arcs_55_0},
-       {1, arcs_55_1},
-       {2, arcs_55_2},
-       {3, arcs_55_3},
+       {2, arcs_55_1},
+       {1, arcs_55_2},
+       {1, arcs_55_3},
        {1, arcs_55_4},
-       {2, arcs_55_5},
+       {1, arcs_55_5},
        {1, arcs_55_6},
 };
 static arc arcs_56_0[1] = {
-       {14, 1},
+       {146, 1},
 };
 static arc arcs_56_1[2] = {
-       {21, 2},
+       {27, 2},
        {0, 1},
 };
-static arc arcs_56_2[1] = {
+static arc arcs_56_2[2] = {
+       {146, 1},
        {0, 2},
 };
 static state states_56[3] = {
        {1, arcs_56_0},
        {2, arcs_56_1},
-       {1, arcs_56_2},
+       {2, arcs_56_2},
 };
-static arc arcs_57_0[1] = {
-       {73, 1},
+static arc arcs_57_0[3] = {
+       {74, 1},
+       {26, 2},
+       {21, 3},
 };
-static arc arcs_57_1[2] = {
-       {22, 2},
-       {0, 1},
+static arc arcs_57_1[1] = {
+       {74, 4},
 };
 static arc arcs_57_2[2] = {
-       {73, 1},
+       {21, 3},
        {0, 2},
 };
-static state states_57[3] = {
-       {1, arcs_57_0},
-       {2, arcs_57_1},
+static arc arcs_57_3[3] = {
+       {26, 5},
+       {147, 6},
+       {0, 3},
+};
+static arc arcs_57_4[1] = {
+       {74, 6},
+};
+static arc arcs_57_5[2] = {
+       {147, 6},
+       {0, 5},
+};
+static arc arcs_57_6[1] = {
+       {0, 6},
+};
+static state states_57[7] = {
+       {3, arcs_57_0},
+       {1, arcs_57_1},
        {2, arcs_57_2},
+       {3, arcs_57_3},
+       {1, arcs_57_4},
+       {2, arcs_57_5},
+       {1, arcs_57_6},
 };
 static arc arcs_58_0[1] = {
        {21, 1},
 };
 static arc arcs_58_1[2] = {
-       {22, 2},
+       {26, 2},
        {0, 1},
 };
-static arc arcs_58_2[2] = {
-       {21, 1},
+static arc arcs_58_2[1] = {
        {0, 2},
 };
 static state states_58[3] = {
        {1, arcs_58_0},
        {2, arcs_58_1},
-       {2, arcs_58_2},
+       {1, arcs_58_2},
 };
 static arc arcs_59_0[1] = {
-       {21, 1},
+       {77, 1},
 };
 static arc arcs_59_1[2] = {
-       {22, 2},
+       {27, 2},
        {0, 1},
 };
-static arc arcs_59_2[1] = {
-       {21, 3},
-};
-static arc arcs_59_3[2] = {
-       {22, 4},
-       {0, 3},
-};
-static arc arcs_59_4[2] = {
-       {21, 3},
-       {0, 4},
+static arc arcs_59_2[2] = {
+       {77, 1},
+       {0, 2},
 };
-static state states_59[5] = {
+static state states_59[3] = {
        {1, arcs_59_0},
        {2, arcs_59_1},
-       {1, arcs_59_2},
-       {2, arcs_59_3},
-       {2, arcs_59_4},
+       {2, arcs_59_2},
 };
 static arc arcs_60_0[1] = {
-       {21, 1},
-};
-static arc arcs_60_1[1] = {
-       {14, 2},
-};
-static arc arcs_60_2[1] = {
-       {21, 3},
+       {26, 1},
 };
-static arc arcs_60_3[2] = {
-       {22, 4},
-       {0, 3},
+static arc arcs_60_1[2] = {
+       {27, 2},
+       {0, 1},
 };
-static arc arcs_60_4[2] = {
-       {21, 1},
-       {0, 4},
+static arc arcs_60_2[2] = {
+       {26, 1},
+       {0, 2},
 };
-static state states_60[5] = {
+static state states_60[3] = {
        {1, arcs_60_0},
-       {1, arcs_60_1},
-       {1, arcs_60_2},
-       {2, arcs_60_3},
-       {2, arcs_60_4},
+       {2, arcs_60_1},
+       {2, arcs_60_2},
 };
 static arc arcs_61_0[1] = {
-       {146, 1},
-};
-static arc arcs_61_1[1] = {
-       {12, 2},
-};
-static arc arcs_61_2[2] = {
-       {16, 3},
-       {14, 4},
-};
-static arc arcs_61_3[1] = {
-       {9, 5},
+       {26, 1},
 };
-static arc arcs_61_4[1] = {
-       {15, 6},
+static arc arcs_61_1[2] = {
+       {27, 2},
+       {0, 1},
 };
-static arc arcs_61_5[1] = {
-       {18, 7},
+static arc arcs_61_2[1] = {
+       {26, 3},
 };
-static arc arcs_61_6[1] = {
-       {0, 6},
+static arc arcs_61_3[2] = {
+       {27, 4},
+       {0, 3},
 };
-static arc arcs_61_7[1] = {
-       {14, 4},
+static arc arcs_61_4[2] = {
+       {26, 3},
+       {0, 4},
 };
-static state states_61[8] = {
+static state states_61[5] = {
        {1, arcs_61_0},
-       {1, arcs_61_1},
-       {2, arcs_61_2},
-       {1, arcs_61_3},
-       {1, arcs_61_4},
-       {1, arcs_61_5},
-       {1, arcs_61_6},
-       {1, arcs_61_7},
-};
-static arc arcs_62_0[3] = {
-       {147, 1},
-       {23, 2},
-       {24, 3},
+       {2, arcs_61_1},
+       {1, arcs_61_2},
+       {2, arcs_61_3},
+       {2, arcs_61_4},
 };
-static arc arcs_62_1[2] = {
-       {22, 4},
-       {0, 1},
+static arc arcs_62_0[1] = {
+       {26, 1},
+};
+static arc arcs_62_1[1] = {
+       {21, 2},
 };
 static arc arcs_62_2[1] = {
-       {21, 5},
+       {26, 3},
 };
-static arc arcs_62_3[1] = {
-       {21, 6},
+static arc arcs_62_3[2] = {
+       {27, 4},
+       {0, 3},
 };
-static arc arcs_62_4[4] = {
-       {147, 1},
-       {23, 2},
-       {24, 3},
+static arc arcs_62_4[2] = {
+       {26, 1},
        {0, 4},
 };
-static arc arcs_62_5[2] = {
-       {22, 7},
-       {0, 5},
-};
-static arc arcs_62_6[1] = {
-       {0, 6},
-};
-static arc arcs_62_7[1] = {
-       {24, 3},
-};
-static state states_62[8] = {
-       {3, arcs_62_0},
-       {2, arcs_62_1},
+static state states_62[5] = {
+       {1, arcs_62_0},
+       {1, arcs_62_1},
        {1, arcs_62_2},
-       {1, arcs_62_3},
-       {4, arcs_62_4},
-       {2, arcs_62_5},
-       {1, arcs_62_6},
-       {1, arcs_62_7},
+       {2, arcs_62_3},
+       {2, arcs_62_4},
 };
 static arc arcs_63_0[1] = {
-       {21, 1},
+       {149, 1},
 };
-static arc arcs_63_1[3] = {
-       {20, 2},
-       {139, 3},
-       {0, 1},
+static arc arcs_63_1[1] = {
+       {19, 2},
 };
-static arc arcs_63_2[1] = {
+static arc arcs_63_2[2] = {
+       {13, 3},
        {21, 4},
 };
 static arc arcs_63_3[1] = {
-       {0, 3},
+       {9, 5},
 };
-static arc arcs_63_4[2] = {
-       {139, 3},
-       {0, 4},
+static arc arcs_63_4[1] = {
+       {22, 6},
+};
+static arc arcs_63_5[1] = {
+       {15, 7},
+};
+static arc arcs_63_6[1] = {
+       {0, 6},
+};
+static arc arcs_63_7[1] = {
+       {21, 4},
 };
-static state states_63[5] = {
+static state states_63[8] = {
        {1, arcs_63_0},
-       {3, arcs_63_1},
-       {1, arcs_63_2},
+       {1, arcs_63_1},
+       {2, arcs_63_2},
        {1, arcs_63_3},
-       {2, arcs_63_4},
+       {1, arcs_63_4},
+       {1, arcs_63_5},
+       {1, arcs_63_6},
+       {1, arcs_63_7},
+};
+static arc arcs_64_0[3] = {
+       {150, 1},
+       {28, 2},
+       {29, 3},
+};
+static arc arcs_64_1[2] = {
+       {27, 4},
+       {0, 1},
 };
-static arc arcs_64_0[2] = {
-       {138, 1},
-       {149, 1},
+static arc arcs_64_2[1] = {
+       {26, 5},
 };
-static arc arcs_64_1[1] = {
-       {0, 1},
+static arc arcs_64_3[1] = {
+       {26, 6},
 };
-static state states_64[2] = {
-       {2, arcs_64_0},
-       {1, arcs_64_1},
+static arc arcs_64_4[4] = {
+       {150, 1},
+       {28, 2},
+       {29, 3},
+       {0, 4},
+};
+static arc arcs_64_5[2] = {
+       {27, 7},
+       {0, 5},
+};
+static arc arcs_64_6[1] = {
+       {0, 6},
+};
+static arc arcs_64_7[1] = {
+       {29, 3},
+};
+static state states_64[8] = {
+       {3, arcs_64_0},
+       {2, arcs_64_1},
+       {1, arcs_64_2},
+       {1, arcs_64_3},
+       {4, arcs_64_4},
+       {2, arcs_64_5},
+       {1, arcs_64_6},
+       {1, arcs_64_7},
 };
 static arc arcs_65_0[1] = {
-       {85, 1},
+       {26, 1},
 };
-static arc arcs_65_1[1] = {
-       {53, 2},
+static arc arcs_65_1[3] = {
+       {25, 2},
+       {143, 3},
+       {0, 1},
 };
 static arc arcs_65_2[1] = {
-       {74, 3},
+       {26, 4},
 };
 static arc arcs_65_3[1] = {
-       {145, 4},
+       {0, 3},
 };
 static arc arcs_65_4[2] = {
-       {148, 5},
+       {143, 3},
        {0, 4},
 };
-static arc arcs_65_5[1] = {
-       {0, 5},
-};
-static state states_65[6] = {
+static state states_65[5] = {
        {1, arcs_65_0},
-       {1, arcs_65_1},
+       {3, arcs_65_1},
        {1, arcs_65_2},
        {1, arcs_65_3},
        {2, arcs_65_4},
-       {1, arcs_65_5},
 };
-static arc arcs_66_0[1] = {
-       {81, 1},
+static arc arcs_66_0[2] = {
+       {142, 1},
+       {152, 1},
 };
 static arc arcs_66_1[1] = {
-       {21, 2},
-};
-static arc arcs_66_2[2] = {
-       {148, 3},
-       {0, 2},
-};
-static arc arcs_66_3[1] = {
-       {0, 3},
+       {0, 1},
 };
-static state states_66[4] = {
-       {1, arcs_66_0},
+static state states_66[2] = {
+       {2, arcs_66_0},
        {1, arcs_66_1},
-       {2, arcs_66_2},
-       {1, arcs_66_3},
 };
-static arc arcs_67_0[2] = {
-       {139, 1},
-       {151, 1},
+static arc arcs_67_0[1] = {
+       {89, 1},
 };
 static arc arcs_67_1[1] = {
-       {0, 1},
+       {58, 2},
+};
+static arc arcs_67_2[1] = {
+       {78, 3},
 };
-static state states_67[2] = {
-       {2, arcs_67_0},
+static arc arcs_67_3[1] = {
+       {148, 4},
+};
+static arc arcs_67_4[2] = {
+       {151, 5},
+       {0, 4},
+};
+static arc arcs_67_5[1] = {
+       {0, 5},
+};
+static state states_67[6] = {
+       {1, arcs_67_0},
        {1, arcs_67_1},
+       {1, arcs_67_2},
+       {1, arcs_67_3},
+       {2, arcs_67_4},
+       {1, arcs_67_5},
 };
 static arc arcs_68_0[1] = {
        {85, 1},
 };
 static arc arcs_68_1[1] = {
-       {53, 2},
+       {26, 2},
 };
-static arc arcs_68_2[1] = {
-       {74, 3},
+static arc arcs_68_2[2] = {
+       {151, 3},
+       {0, 2},
 };
 static arc arcs_68_3[1] = {
-       {21, 4},
-};
-static arc arcs_68_4[2] = {
-       {150, 5},
-       {0, 4},
-};
-static arc arcs_68_5[1] = {
-       {0, 5},
+       {0, 3},
 };
-static state states_68[6] = {
+static state states_68[4] = {
        {1, arcs_68_0},
        {1, arcs_68_1},
-       {1, arcs_68_2},
+       {2, arcs_68_2},
        {1, arcs_68_3},
-       {2, arcs_68_4},
-       {1, arcs_68_5},
 };
-static arc arcs_69_0[1] = {
-       {81, 1},
+static arc arcs_69_0[2] = {
+       {143, 1},
+       {154, 1},
 };
 static arc arcs_69_1[1] = {
-       {21, 2},
-};
-static arc arcs_69_2[2] = {
-       {150, 3},
-       {0, 2},
-};
-static arc arcs_69_3[1] = {
-       {0, 3},
+       {0, 1},
 };
-static state states_69[4] = {
-       {1, arcs_69_0},
+static state states_69[2] = {
+       {2, arcs_69_0},
        {1, arcs_69_1},
-       {2, arcs_69_2},
-       {1, arcs_69_3},
 };
 static arc arcs_70_0[1] = {
-       {21, 1},
+       {89, 1},
 };
-static arc arcs_70_1[2] = {
-       {22, 0},
-       {0, 1},
+static arc arcs_70_1[1] = {
+       {58, 2},
+};
+static arc arcs_70_2[1] = {
+       {78, 3},
+};
+static arc arcs_70_3[1] = {
+       {26, 4},
+};
+static arc arcs_70_4[2] = {
+       {153, 5},
+       {0, 4},
+};
+static arc arcs_70_5[1] = {
+       {0, 5},
 };
-static state states_70[2] = {
+static state states_70[6] = {
        {1, arcs_70_0},
-       {2, arcs_70_1},
+       {1, arcs_70_1},
+       {1, arcs_70_2},
+       {1, arcs_70_3},
+       {2, arcs_70_4},
+       {1, arcs_70_5},
 };
 static arc arcs_71_0[1] = {
-       {12, 1},
+       {85, 1},
 };
 static arc arcs_71_1[1] = {
-       {0, 1},
+       {26, 2},
+};
+static arc arcs_71_2[2] = {
+       {153, 3},
+       {0, 2},
+};
+static arc arcs_71_3[1] = {
+       {0, 3},
 };
-static state states_71[2] = {
+static state states_71[4] = {
        {1, arcs_71_0},
        {1, arcs_71_1},
+       {2, arcs_71_2},
+       {1, arcs_71_3},
 };
-static dfa dfas[72] = {
+static arc arcs_72_0[1] = {
+       {26, 1},
+};
+static arc arcs_72_1[2] = {
+       {27, 0},
+       {0, 1},
+};
+static state states_72[2] = {
+       {1, arcs_72_0},
+       {2, arcs_72_1},
+};
+static arc arcs_73_0[1] = {
+       {19, 1},
+};
+static arc arcs_73_1[1] = {
+       {0, 1},
+};
+static state states_73[2] = {
+       {1, arcs_73_0},
+       {1, arcs_73_1},
+};
+static dfa dfas[74] = {
        {256, "single_input", 0, 3, states_0,
-        "\004\030\001\000\000\000\124\360\213\011\162\000\002\000\140\010\111\023\004\000"},
+        "\004\050\014\000\000\000\200\012\176\231\040\007\040\000\000\206\220\064\041\000"},
        {257, "file_input", 0, 2, states_1,
-        "\204\030\001\000\000\000\124\360\213\011\162\000\002\000\140\010\111\023\004\000"},
+        "\204\050\014\000\000\000\200\012\176\231\040\007\040\000\000\206\220\064\041\000"},
        {258, "eval_input", 0, 3, states_2,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000\000"},
-       {259, "funcdef", 0, 6, states_3,
+        "\000\040\010\000\000\000\000\000\000\000\000\000\040\000\000\206\220\064\001\000"},
+       {259, "decorator", 0, 6, states_3,
         "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-       {260, "parameters", 0, 4, states_4,
-        "\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-       {261, "varargslist", 0, 10, states_5,
-        "\000\020\201\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-       {262, "fpdef", 0, 4, states_6,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-       {263, "fplist", 0, 3, states_7,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-       {264, "stmt", 0, 2, states_8,
-        "\000\030\001\000\000\000\124\360\213\011\162\000\002\000\140\010\111\023\004\000"},
-       {265, "simple_stmt", 0, 4, states_9,
-        "\000\020\001\000\000\000\124\360\213\011\000\000\002\000\140\010\111\023\000\000"},
-       {266, "small_stmt", 0, 2, states_10,
-        "\000\020\001\000\000\000\124\360\213\011\000\000\002\000\140\010\111\023\000\000"},
-       {267, "expr_stmt", 0, 6, states_11,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000\000"},
-       {268, "augassign", 0, 2, states_12,
-        "\000\000\000\000\300\377\003\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-       {269, "print_stmt", 0, 9, states_13,
-        "\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-       {270, "del_stmt", 0, 3, states_14,
-        "\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-       {271, "pass_stmt", 0, 2, states_15,
-        "\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-       {272, "flow_stmt", 0, 2, states_16,
-        "\000\000\000\000\000\000\000\360\001\000\000\000\000\000\000\000\000\000\000\000"},
-       {273, "break_stmt", 0, 2, states_17,
-        "\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000\000"},
-       {274, "continue_stmt", 0, 2, states_18,
-        "\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000"},
-       {275, "return_stmt", 0, 3, states_19,
-        "\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000\000\000"},
-       {276, "yield_stmt", 0, 3, states_20,
-        "\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000"},
-       {277, "raise_stmt", 0, 7, states_21,
-        "\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000"},
-       {278, "import_stmt", 0, 9, states_22,
-        "\000\000\000\000\000\000\000\000\012\000\000\000\000\000\000\000\000\000\000\000"},
-       {279, "import_as_name", 0, 4, states_23,
-        "\000\020\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-       {280, "dotted_as_name", 0, 4, states_24,
-        "\000\020\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-       {281, "dotted_name", 0, 2, states_25,
-        "\000\020\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-       {282, "global_stmt", 0, 3, states_26,
-        "\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000"},
-       {283, "exec_stmt", 0, 7, states_27,
-        "\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000"},
-       {284, "assert_stmt", 0, 5, states_28,
+       {260, "decorators", 0, 3, states_4,
+        "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+       {261, "funcdef", 0, 7, states_5,
+        "\000\010\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+       {262, "parameters", 0, 4, states_6,
+        "\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+       {263, "varargslist", 0, 10, states_7,
+        "\000\040\010\060\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+       {264, "fpdef", 0, 4, states_8,
+        "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+       {265, "fplist", 0, 3, states_9,
+        "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+       {266, "stmt", 0, 2, states_10,
+        "\000\050\014\000\000\000\200\012\176\231\040\007\040\000\000\206\220\064\041\000"},
+       {267, "simple_stmt", 0, 4, states_11,
+        "\000\040\010\000\000\000\200\012\176\231\000\000\040\000\000\206\220\064\001\000"},
+       {268, "small_stmt", 0, 2, states_12,
+        "\000\040\010\000\000\000\200\012\176\231\000\000\040\000\000\206\220\064\001\000"},
+       {269, "expr_stmt", 0, 6, states_13,
+        "\000\040\010\000\000\000\000\000\000\000\000\000\040\000\000\206\220\064\001\000"},
+       {270, "augassign", 0, 2, states_14,
+        "\000\000\000\000\000\370\177\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+       {271, "print_stmt", 0, 9, states_15,
+        "\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+       {272, "del_stmt", 0, 3, states_16,
+        "\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000"},
+       {273, "pass_stmt", 0, 2, states_17,
+        "\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000"},
+       {274, "flow_stmt", 0, 2, states_18,
+        "\000\000\000\000\000\000\000\000\076\000\000\000\000\000\000\000\000\000\000\000"},
+       {275, "break_stmt", 0, 2, states_19,
+        "\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000"},
+       {276, "continue_stmt", 0, 2, states_20,
+        "\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000"},
+       {277, "return_stmt", 0, 3, states_21,
+        "\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000"},
+       {278, "yield_stmt", 0, 3, states_22,
+        "\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000"},
+       {279, "raise_stmt", 0, 7, states_23,
+        "\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000"},
+       {280, "import_stmt", 0, 9, states_24,
+        "\000\000\000\000\000\000\000\000\100\001\000\000\000\000\000\000\000\000\000\000"},
+       {281, "import_as_name", 0, 4, states_25,
+        "\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+       {282, "dotted_as_name", 0, 4, states_26,
+        "\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+       {283, "dotted_name", 0, 2, states_27,
+        "\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+       {284, "global_stmt", 0, 3, states_28,
         "\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000"},
-       {285, "compound_stmt", 0, 2, states_29,
-        "\000\010\000\000\000\000\000\000\000\000\162\000\000\000\000\000\000\000\004\000"},
-       {286, "if_stmt", 0, 8, states_30,
-        "\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000"},
-       {287, "while_stmt", 0, 8, states_31,
-        "\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000"},
-       {288, "for_stmt", 0, 10, states_32,
+       {285, "exec_stmt", 0, 7, states_29,
+        "\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000"},
+       {286, "assert_stmt", 0, 5, states_30,
+        "\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000"},
+       {287, "compound_stmt", 0, 2, states_31,
+        "\000\010\004\000\000\000\000\000\000\000\040\007\000\000\000\000\000\000\040\000"},
+       {288, "if_stmt", 0, 8, states_32,
         "\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000"},
-       {289, "try_stmt", 0, 10, states_33,
-        "\000\000\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000"},
-       {290, "except_clause", 0, 5, states_34,
+       {289, "while_stmt", 0, 8, states_33,
+        "\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000"},
+       {290, "for_stmt", 0, 10, states_34,
+        "\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000"},
+       {291, "try_stmt", 0, 10, states_35,
+        "\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000"},
+       {292, "except_clause", 0, 5, states_36,
+        "\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000"},
+       {293, "suite", 0, 5, states_37,
+        "\004\040\010\000\000\000\200\012\176\231\000\000\040\000\000\206\220\064\001\000"},
+       {294, "test", 0, 4, states_38,
+        "\000\040\010\000\000\000\000\000\000\000\000\000\040\000\000\206\220\064\001\000"},
+       {295, "and_test", 0, 2, states_39,
+        "\000\040\010\000\000\000\000\000\000\000\000\000\040\000\000\206\220\064\000\000"},
+       {296, "not_test", 0, 3, states_40,
+        "\000\040\010\000\000\000\000\000\000\000\000\000\040\000\000\206\220\064\000\000"},
+       {297, "comparison", 0, 2, states_41,
+        "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\206\220\064\000\000"},
+       {298, "comp_op", 0, 4, states_42,
+        "\000\000\000\000\000\000\000\000\000\100\000\000\040\377\000\000\000\000\000\000"},
+       {299, "expr", 0, 2, states_43,
+        "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\206\220\064\000\000"},
+       {300, "xor_expr", 0, 2, states_44,
+        "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\206\220\064\000\000"},
+       {301, "and_expr", 0, 2, states_45,
+        "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\206\220\064\000\000"},
+       {302, "shift_expr", 0, 2, states_46,
+        "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\206\220\064\000\000"},
+       {303, "arith_expr", 0, 2, states_47,
+        "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\206\220\064\000\000"},
+       {304, "term", 0, 2, states_48,
+        "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\206\220\064\000\000"},
+       {305, "factor", 0, 3, states_49,
+        "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\206\220\064\000\000"},
+       {306, "power", 0, 4, states_50,
+        "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\220\064\000\000"},
+       {307, "atom", 0, 11, states_51,
+        "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\220\064\000\000"},
+       {308, "listmaker", 0, 5, states_52,
+        "\000\040\010\000\000\000\000\000\000\000\000\000\040\000\000\206\220\064\001\000"},
+       {309, "testlist_gexp", 0, 5, states_53,
+        "\000\040\010\000\000\000\000\000\000\000\000\000\040\000\000\206\220\064\001\000"},
+       {310, "lambdef", 0, 5, states_54,
+        "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000"},
+       {311, "trailer", 0, 7, states_55,
+        "\000\040\000\000\000\000\000\000\000\004\000\000\000\000\000\000\020\000\000\000"},
+       {312, "subscriptlist", 0, 3, states_56,
+        "\000\040\050\000\000\000\000\000\000\004\000\000\040\000\000\206\220\064\001\000"},
+       {313, "subscript", 0, 7, states_57,
+        "\000\040\050\000\000\000\000\000\000\004\000\000\040\000\000\206\220\064\001\000"},
+       {314, "sliceop", 0, 3, states_58,
+        "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+       {315, "exprlist", 0, 3, states_59,
+        "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\206\220\064\000\000"},
+       {316, "testlist", 0, 3, states_60,
+        "\000\040\010\000\000\000\000\000\000\000\000\000\040\000\000\206\220\064\001\000"},
+       {317, "testlist_safe", 0, 5, states_61,
+        "\000\040\010\000\000\000\000\000\000\000\000\000\040\000\000\206\220\064\001\000"},
+       {318, "dictmaker", 0, 5, states_62,
+        "\000\040\010\000\000\000\000\000\000\000\000\000\040\000\000\206\220\064\001\000"},
+       {319, "classdef", 0, 8, states_63,
+        "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\040\000"},
+       {320, "arglist", 0, 8, states_64,
+        "\000\040\010\060\000\000\000\000\000\000\000\000\040\000\000\206\220\064\001\000"},
+       {321, "argument", 0, 5, states_65,
+        "\000\040\010\000\000\000\000\000\000\000\000\000\040\000\000\206\220\064\001\000"},
+       {322, "list_iter", 0, 2, states_66,
+        "\000\000\000\000\000\000\000\000\000\000\040\002\000\000\000\000\000\000\000\000"},
+       {323, "list_for", 0, 6, states_67,
         "\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000"},
-       {291, "suite", 0, 5, states_35,
-        "\004\020\001\000\000\000\124\360\213\011\000\000\002\000\140\010\111\023\000\000"},
-       {292, "test", 0, 4, states_36,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000\000"},
-       {293, "and_test", 0, 2, states_37,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\010\111\003\000\000"},
-       {294, "not_test", 0, 3, states_38,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\010\111\003\000\000"},
-       {295, "comparison", 0, 2, states_39,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\140\010\111\003\000\000"},
-       {296, "comp_op", 0, 4, states_40,
-        "\000\000\000\000\000\000\000\000\000\004\000\000\362\017\000\000\000\000\000\000"},
-       {297, "expr", 0, 2, states_41,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\140\010\111\003\000\000"},
-       {298, "xor_expr", 0, 2, states_42,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\140\010\111\003\000\000"},
-       {299, "and_expr", 0, 2, states_43,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\140\010\111\003\000\000"},
-       {300, "shift_expr", 0, 2, states_44,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\140\010\111\003\000\000"},
-       {301, "arith_expr", 0, 2, states_45,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\140\010\111\003\000\000"},
-       {302, "term", 0, 2, states_46,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\140\010\111\003\000\000"},
-       {303, "factor", 0, 3, states_47,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\140\010\111\003\000\000"},
-       {304, "power", 0, 4, states_48,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\000\000\111\003\000\000"},
-       {305, "atom", 0, 11, states_49,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\000\000\111\003\000\000"},
-       {306, "listmaker", 0, 5, states_50,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000\000"},
-       {307, "testlist_gexp", 0, 5, states_51,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000\000"},
-       {308, "lambdef", 0, 5, states_52,
-        "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000"},
-       {309, "trailer", 0, 7, states_53,
-        "\000\000\001\000\000\000\000\000\100\000\000\000\000\000\000\000\001\000\000\000"},
-       {310, "subscriptlist", 0, 3, states_54,
-        "\000\120\001\000\000\000\000\000\100\000\000\000\002\000\140\010\111\023\000\000"},
-       {311, "subscript", 0, 7, states_55,
-        "\000\120\001\000\000\000\000\000\100\000\000\000\002\000\140\010\111\023\000\000"},
-       {312, "sliceop", 0, 3, states_56,
-        "\000\100\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-       {313, "exprlist", 0, 3, states_57,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\140\010\111\003\000\000"},
-       {314, "testlist", 0, 3, states_58,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000\000"},
-       {315, "testlist_safe", 0, 5, states_59,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000\000"},
-       {316, "dictmaker", 0, 5, states_60,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000\000"},
-       {317, "classdef", 0, 8, states_61,
-        "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\004\000"},
-       {318, "arglist", 0, 8, states_62,
-        "\000\020\201\001\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000\000"},
-       {319, "argument", 0, 5, states_63,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000\000"},
-       {320, "list_iter", 0, 2, states_64,
-        "\000\000\000\000\000\000\000\000\000\000\042\000\000\000\000\000\000\000\000\000"},
-       {321, "list_for", 0, 6, states_65,
+       {324, "list_if", 0, 4, states_68,
         "\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000"},
-       {322, "list_if", 0, 4, states_66,
-        "\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000"},
-       {323, "gen_iter", 0, 2, states_67,
-        "\000\000\000\000\000\000\000\000\000\000\042\000\000\000\000\000\000\000\000\000"},
-       {324, "gen_for", 0, 6, states_68,
+       {325, "gen_iter", 0, 2, states_69,
+        "\000\000\000\000\000\000\000\000\000\000\040\002\000\000\000\000\000\000\000\000"},
+       {326, "gen_for", 0, 6, states_70,
+        "\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000"},
+       {327, "gen_if", 0, 4, states_71,
         "\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000"},
-       {325, "gen_if", 0, 4, states_69,
-        "\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000"},
-       {326, "testlist1", 0, 2, states_70,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000\000"},
-       {327, "encoding_decl", 0, 2, states_71,
-        "\000\020\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-};
-static label labels[153] = {
+       {328, "testlist1", 0, 2, states_72,
+        "\000\040\010\000\000\000\000\000\000\000\000\000\040\000\000\206\220\064\001\000"},
+       {329, "encoding_decl", 0, 2, states_73,
+        "\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+};
+static label labels[156] = {
        {0, "EMPTY"},
        {256, 0},
        {4, 0},
-       {265, 0},
-       {285, 0},
+       {267, 0},
+       {287, 0},
        {257, 0},
-       {264, 0},
+       {266, 0},
        {0, 0},
        {258, 0},
-       {314, 0},
+       {316, 0},
        {259, 0},
-       {1, "def"},
-       {1, 0},
-       {260, 0},
-       {11, 0},
-       {291, 0},
+       {50, 0},
+       {283, 0},
        {7, 0},
-       {261, 0},
+       {320, 0},
        {8, 0},
+       {260, 0},
+       {261, 0},
+       {1, "def"},
+       {1, 0},
        {262, 0},
+       {11, 0},
+       {293, 0},
+       {263, 0},
+       {264, 0},
        {22, 0},
-       {292, 0},
+       {294, 0},
        {12, 0},
        {16, 0},
        {36, 0},
-       {263, 0},
-       {266, 0},
+       {265, 0},
+       {268, 0},
        {13, 0},
-       {267, 0},
        {269, 0},
-       {270, 0},
        {271, 0},
        {272, 0},
-       {278, 0},
-       {282, 0},
-       {283, 0},
+       {273, 0},
+       {274, 0},
+       {280, 0},
        {284, 0},
-       {268, 0},
+       {285, 0},
+       {286, 0},
+       {270, 0},
        {37, 0},
        {38, 0},
        {39, 0},
@@ -1762,53 +1820,52 @@ static label labels[153] = {
        {1, "print"},
        {35, 0},
        {1, "del"},
-       {313, 0},
+       {315, 0},
        {1, "pass"},
-       {273, 0},
-       {274, 0},
        {275, 0},
-       {277, 0},
        {276, 0},
+       {277, 0},
+       {279, 0},
+       {278, 0},
        {1, "break"},
        {1, "continue"},
        {1, "return"},
        {1, "yield"},
        {1, "raise"},
        {1, "import"},
-       {280, 0},
+       {282, 0},
        {1, "from"},
        {281, 0},
-       {279, 0},
        {23, 0},
        {1, "global"},
        {1, "exec"},
-       {297, 0},
+       {299, 0},
        {1, "in"},
        {1, "assert"},
-       {286, 0},
-       {287, 0},
        {288, 0},
        {289, 0},
-       {317, 0},
+       {290, 0},
+       {291, 0},
+       {319, 0},
        {1, "if"},
        {1, "elif"},
        {1, "else"},
        {1, "while"},
        {1, "for"},
        {1, "try"},
-       {290, 0},
+       {292, 0},
        {1, "finally"},
        {1, "except"},
        {5, 0},
        {6, 0},
-       {293, 0},
+       {295, 0},
        {1, "or"},
-       {308, 0},
-       {294, 0},
+       {310, 0},
+       {296, 0},
        {1, "and"},
        {1, "not"},
-       {295, 0},
-       {296, 0},
+       {297, 0},
+       {298, 0},
        {20, 0},
        {21, 0},
        {28, 0},
@@ -1817,55 +1874,54 @@ static label labels[153] = {
        {29, 0},
        {29, 0},
        {1, "is"},
-       {298, 0},
+       {300, 0},
        {18, 0},
-       {299, 0},
+       {301, 0},
        {33, 0},
-       {300, 0},
+       {302, 0},
        {19, 0},
-       {301, 0},
+       {303, 0},
        {34, 0},
-       {302, 0},
+       {304, 0},
        {14, 0},
        {15, 0},
-       {303, 0},
+       {305, 0},
        {17, 0},
        {24, 0},
        {48, 0},
        {32, 0},
-       {304, 0},
-       {305, 0},
-       {309, 0},
+       {306, 0},
        {307, 0},
+       {311, 0},
+       {309, 0},
        {9, 0},
-       {306, 0},
+       {308, 0},
        {10, 0},
        {26, 0},
-       {316, 0},
+       {318, 0},
        {27, 0},
        {25, 0},
-       {326, 0},
+       {328, 0},
        {2, 0},
        {3, 0},
-       {321, 0},
-       {324, 0},
+       {323, 0},
+       {326, 0},
        {1, "lambda"},
-       {318, 0},
-       {310, 0},
-       {311, 0},
        {312, 0},
-       {315, 0},
+       {313, 0},
+       {314, 0},
+       {317, 0},
        {1, "class"},
-       {319, 0},
-       {320, 0},
+       {321, 0},
        {322, 0},
-       {323, 0},
+       {324, 0},
        {325, 0},
        {327, 0},
+       {329, 0},
 };
 grammar _PyParser_Grammar = {
-       72,
+       74,
        dfas,
-       {153, labels},
+       {156, labels},
        256
 };
index 6a990d4cc5c09fb36d433f68bda4774bb158d99d..a235b99d6429b8e7b591cf4409cd9bce03ee080b 100644 (file)
@@ -8,7 +8,8 @@
 #  = ... a default value for the node constructor (optional args)
 Module: doc*, node
 Stmt: nodes!
-Function: name*, argnames*, defaults!, flags*, doc*, code
+Decorators: nodes!
+Function: decorators&, name*, argnames*, defaults!, flags*, doc*, code
 Lambda: argnames*, defaults!, flags*, code
 Class: name*, bases!, doc*, code
 Pass: 
index 08d501bc3ce997a95de07e0a4b0df837a56c1920..4fe4bbeff46709ebb6221773019e595a81988307 100644 (file)
@@ -154,19 +154,19 @@ class NodeInfo:
                 else:
                     print >> buf, "        return %s" % COMMA.join(clist)
             else:
-                print >> buf, "        nodes = []"
-                template = "        nodes.%s(%sself.%s%s)"
+                print >> buf, "        nodelist = []"
+                template = "        nodelist.%s(%sself.%s%s)"
                 for name in self.argnames:
                     if self.argprops[name] == P_NONE:
                         tmp = ("        if self.%s is not None:"
-                               "            nodes.append(self.%s)")
+                               "            nodelist.append(self.%s)")
                         print >> buf, tmp % (name, name)
                     elif self.argprops[name] == P_NESTED:
                         print >> buf, template % ("extend", "flatten_nodes(",
                                                   name, ")")
                     elif self.argprops[name] == P_NODE:
                         print >> buf, template % ("append", "", name, "")
-                print >> buf, "        return tuple(nodes)"
+                print >> buf, "        return tuple(nodelist)"
 
     def _gen_repr(self, buf):
         print >> buf, "    def __repr__(self):"
@@ -208,7 +208,7 @@ def parse_spec(file):
             # some extra code for a Node's __init__ method
             name = mo.group(1)
             cur = classes[name]
-    return classes.values()
+    return sorted(classes.values(), key=lambda n: n.name)
 
 def main():
     prologue, epilogue = load_boilerplate(sys.argv[-1])
@@ -245,9 +245,9 @@ def flatten(list):
 def flatten_nodes(list):
     return [n for n in flatten(list) if isinstance(n, Node)]
 
-def asList(nodes):
+def asList(nodearg):
     l = []
-    for item in nodes:
+    for item in nodearg:
         if hasattr(item, "asList"):
             l.append(item.asList())
         else:
@@ -274,6 +274,21 @@ class Node: # an abstract base class
 class EmptyNode(Node):
     pass
 
+class Expression(Node):
+    # Expression is an artificial node class to support "eval"
+    nodes["expression"] = "Expression"
+    def __init__(self, node):
+        self.node = node
+
+    def getChildren(self):
+        return self.node,
+
+    def getChildNodes(self):
+        return self.node,
+
+    def __repr__(self):
+        return "Expression(%s)" % (repr(self.node))
+
 ### EPILOGUE
 klasses = globals()
 for k in nodes.keys():
index def07c2faab6c659da10e97812eec750564dc2ec..50d06e71f3b6203742c22e075576e61b25aafdfe 100644 (file)
@@ -47,6 +47,8 @@ def compile_files(dir):
                 continue
             # make sure the .pyc file is not over-written
             os.chmod(source + "c", 444)
+        elif file == 'CVS':
+            pass
         else:
             path = os.path.join(dir, file)
             if os.path.isdir(path):