]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
* compile.[ch]: support for lambda()
authorGuido van Rossum <guido@python.org>
Tue, 26 Oct 1993 17:58:25 +0000 (17:58 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 26 Oct 1993 17:58:25 +0000 (17:58 +0000)
* PROTO.h, mymalloc.h: added #ifdefs for TURBOC and GNUC.
* allobjects.h: added #include "rangeobject.h"
* Grammar: added lambda_input; relaxed syntax for exec.
* bltinmodule.c: added bagof, map, reduce, lambda, xrange.
* tupleobject.[ch]: added resizetuple().
* rangeobject.[ch]: new object type to speed up range operations (not
  convinced this is needed!!!)

12 files changed:
Grammar/Grammar
Include/allobjects.h
Include/compile.h
Include/graminit.h
Include/mymalloc.h
Include/rangeobject.h [new file with mode: 0644]
Include/tupleobject.h
Objects/rangeobject.c [new file with mode: 0644]
Objects/tupleobject.c
Python/bltinmodule.c
Python/compile.c
Python/graminit.c

index 1ba6b5c0646247cfc29cb24e2225e01ae74329b4..22a48f7a0f7099d2c5b05b604f8d110c584a61a3 100644 (file)
@@ -2,6 +2,9 @@
 
 # Change log:
 
+# 25-Oct-93:
+#      Added lambda_input
+
 # 18-Oct-93:
 #      Use testlist instead of exprlist in expr_stmt
 #      Add exec statement
 #      single_input is a single interactive statement;
 #      file_input is a module or sequence of commands read from an input file;
 #      expr_input is the input for the input() function;
-#      eval_input is the input for the eval() function.
+#      eval_input is the input for the eval() function;
+#      lambda_input is the input for the proposed lambda() function.
 
 # NB: compound_stmt in single_input is followed by extra NEWLINE!
 single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE
 file_input: (NEWLINE | stmt)* ENDMARKER
-expr_input: testlist NEWLINE
 eval_input: testlist NEWLINE* ENDMARKER
+lambda_input: varargslist ':' testlist NEWLINE* ENDMARKER
 
 funcdef: 'def' NAME parameters ':' suite
 parameters: '(' [varargslist] ')'
@@ -108,7 +112,7 @@ access_stmt: 'access' ('*' | NAME (',' NAME)*) ':' accesstype (',' accesstype)*
 accesstype: NAME+
 # accesstype should be ('public' | 'protected' | 'private') ['read'] ['write']
 # but can't be because that would create undesirable reserved words!
-exec_stmt: 'exec' expr ['in' expr [',' expr]]
+exec_stmt: 'exec' expr ['in' test [',' test]]
 
 compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef
 if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite]
index 8f9091ad486941b3c266298bb13349cf846c1245..17d6dd29f64dac8c11912ac29f663a29883d49c7 100644 (file)
@@ -46,6 +46,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "intobject.h"
 #include "longobject.h"
 #include "floatobject.h"
+#include "rangeobject.h"
 #include "stringobject.h"
 #include "tupleobject.h"
 #include "listobject.h"
index a23fea18fff42baa3c0187b68c689ed1c5508bf5..2b0b29e27e0767d9f54e75e2f136121eece2fb01 100644 (file)
@@ -54,10 +54,12 @@ extern typeobject Codetype;
 
 /* Public interface */
 struct _node; /* Declare the existence of this type */
-codeobject *compile PROTO((struct _node *, char *));
+codeobject *_compile PROTO((struct _node *, char *, int));
 codeobject *newcodeobject
        PROTO((object *, object *, object *, object *, object *));
 
+#define compile(n,f)   (_compile((n),(f),0))
+
 #ifdef __cplusplus
 }
 #endif
index 288e333630fa4122d250c1d7a6a5f8670d744204..735838c4f6ef1fe459169a95d3b1bea4745315f7 100644 (file)
@@ -1,7 +1,7 @@
 #define single_input 256
 #define file_input 257
-#define expr_input 258
-#define eval_input 259
+#define eval_input 258
+#define lambda_input 259
 #define funcdef 260
 #define parameters 261
 #define varargslist 262
index 959f29641ddae71c9c48e011a2aceda32ec9eb27..24e212539ca8aafe7b085df60982dfc8d349d1da 100644 (file)
@@ -51,6 +51,16 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #define HAVE_STDLIB
 #endif
 
+#ifdef __TURBOC__
+#define ANY void
+#define HAVE_STDLIB
+#endif
+
+#ifdef __GNUC__
+#define ANY void
+#define HAVE_STDLIB
+#endif
+
 #ifndef ANY
 #define ANY char
 #endif
diff --git a/Include/rangeobject.h b/Include/rangeobject.h
new file mode 100644 (file)
index 0000000..39d20c6
--- /dev/null
@@ -0,0 +1,41 @@
+/***********************************************************
+Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Amsterdam, The Netherlands.
+
+                        All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its 
+documentation for any purpose and without fee is hereby granted, 
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in 
+supporting documentation, and that the names of Stichting Mathematisch
+Centrum or CWI not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior permission.
+
+STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
+THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
+FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+******************************************************************/
+
+/* Range object interface */
+
+/*
+123456789-123456789-123456789-123456789-123456789-123456789-123456789-12
+
+rangeobject represents an integer range.  This is an immutable object;
+a range cannot change its value after creation.
+
+Range objects behave like the corresponding tuple objects except that
+they are represented by a start, stop, and step datamembers.
+*/
+
+extern typeobject Rangetype;
+
+#define is_rangeobject(op) ((op)->ob_type == &Rangetype)
+
+extern object *newrangeobject PROTO((long, long, long, int));
index b5f22306041f524eefcbe5b8a841982a4bd27854..8fe28a2394cdc7cdf6c7cb434e23b7b2605baf3f 100644 (file)
@@ -58,6 +58,7 @@ extern int gettuplesize PROTO((object *));
 extern object *gettupleitem PROTO((object *, int));
 extern int settupleitem PROTO((object *, int, object *));
 extern object *gettupleslice PROTO((object *, int, int));
+extern int resizetuple PROTO((object **, int));
 
 /* Macro, trading safety for speed */
 #define GETTUPLEITEM(op, i) ((op)->ob_item[i])
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c
new file mode 100644 (file)
index 0000000..a68d317
--- /dev/null
@@ -0,0 +1,205 @@
+/***********************************************************
+Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Amsterdam, The Netherlands.
+
+                        All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its 
+documentation for any purpose and without fee is hereby granted, 
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in 
+supporting documentation, and that the names of Stichting Mathematisch
+Centrum or CWI not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior permission.
+
+STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
+THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
+FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+******************************************************************/
+
+/* Range object implementation */
+
+#include "allobjects.h"
+
+typedef struct {
+       OB_HEAD
+       long    start;
+       long    step;
+       long    len;
+       int     reps;
+} rangeobject;
+
+
+object *
+newrangeobject(start, len, step, reps)
+       long start, len, step;
+       int reps;
+{
+       rangeobject *obj = (rangeobject *) newobject(&Rangetype);
+
+       obj->start = start;
+       obj->len   = len;
+       obj->step  = step;
+       obj->reps  = reps;
+
+       return (object *) obj;
+}
+
+static void
+range_dealloc(r)
+       rangeobject *r;
+{
+       DEL(r);
+}
+
+static object *
+range_item(r, i)
+       rangeobject *r;
+       int i;
+{
+       if (i < 0 || i >= r->len * r->reps) {
+               err_setstr(IndexError, "range object index out of range");
+               return NULL;
+       }
+
+       return newintobject(r->start + (i % r->len) * r->step);
+}
+
+static int
+range_length(r)
+       rangeobject *r;
+{
+       return r->len * r->reps;
+}
+
+static object *
+range_repr(r)
+       rangeobject *r;
+{
+       char buf[80];
+       if (r->reps != 1)
+               sprintf(buf, "(xrange(%ld, %ld, %ld) * %d)",
+                       r->start,
+                       r->start + r->len * r->step,
+                       r->step,
+                       r->reps);
+       else
+               sprintf(buf, "xrange(%ld, %ld, %ld)",
+                       r->start,
+                       r->start + r->len * r->step,
+                       r->step);
+       return newstringobject(buf);
+}
+
+object *
+range_concat(r, obj)
+       rangeobject *r;
+       object *obj;
+{
+       if (is_rangeobject(obj)) {
+               rangeobject *s = (rangeobject *)obj;
+               if (r->start == s->start && r->len == s->len &&
+                   r->step == s->step)
+                       return newrangeobject(r->start, r->len, r->step,
+                                             r->reps + s->reps);
+       }
+       err_setstr(TypeError, "cannot concatenate different range objects");
+       return NULL;
+}
+
+object *
+range_repeat(r, n)
+       rangeobject *r;
+       int n;
+{
+       if (n < 0)
+               return (object *) newrangeobject(0, 0, 1, 1);
+
+       else if (n == 1) {
+               INCREF(r);
+               return (object *) r;
+       }
+
+       else
+               return (object *) newrangeobject(
+                                               r->start,
+                                               r->len,
+                                               r->step,
+                                               r->reps * n);
+}
+
+static int
+range_compare(r1, r2)
+       rangeobject *r1, *r2;
+{
+       if (r1->start != r2->start)
+               return r1->start - r2->start;
+
+       else if (r1->step != r2->step)
+               return r1->step - r2->step;
+
+       else if (r1->len != r2->len)
+               return r1->len - r2->len;
+
+       else
+               return r1->reps - r2->reps;
+}
+
+static object *
+range_slice(r, low, high)
+       rangeobject *r;
+       int low, high;
+{
+       if (r->reps != 1) {
+               err_setstr(TypeError, "cannot slice a replicated range");
+               return NULL;
+       }
+       if (low < 0)
+               low = 0;
+       else if (low > r->len)
+               low = r->len;
+       if (high < 0)
+               high = 0;
+       if (high < low)
+               high = low;
+       else if (high > r->len)
+               high = r->len;
+
+       return (object *) newrangeobject(
+                               low * r->step + r->start,
+                               high - low,
+                               r->step,
+                               1);
+}
+
+static sequence_methods range_as_sequence = {
+       range_length,   /*sq_length*/
+       range_concat,   /*sq_concat*/
+       range_repeat,   /*sq_repeat*/
+       range_item,     /*sq_item*/
+       range_slice,    /*sq_slice*/
+       0,              /*sq_ass_item*/
+       0,              /*sq_ass_slice*/
+};
+
+typeobject Rangetype = {
+       OB_HEAD_INIT(&Typetype)
+       0,                      /* Number of items for varobject */
+       "range",                /* Name of this type */
+       sizeof(rangeobject),    /* Basic object size */
+       0,                      /* Item size for varobject */
+       range_dealloc,          /*tp_dealloc*/
+       0,                      /*tp_print*/
+       0,                      /*tp_getattr*/
+       0,                      /*tp_setattr*/
+       range_compare,          /*tp_compare*/
+       range_repr,             /*tp_repr*/
+       0,                      /*tp_as_number*/
+       &range_as_sequence,     /*tp_as_sequence*/
+       0,                      /*tp_as_mapping*/
+};
index bc6874445d642848d8719850a49a62645ef436e4..0047a09c7e838bdc79872a927b24b9d68e07aba2 100644 (file)
@@ -123,21 +123,18 @@ settupleitem(op, i, newitem)
 {
        register object *olditem;
        if (!is_tupleobject(op)) {
-               if (newitem != NULL)
-                       DECREF(newitem);
+               XDECREF(newitem);
                err_badcall();
                return -1;
        }
        if (i < 0 || i >= ((tupleobject *)op) -> ob_size) {
-               if (newitem != NULL)
-                       DECREF(newitem);
+               XDECREF(newitem);
                err_setstr(IndexError, "tuple assignment index out of range");
                return -1;
        }
        olditem = ((tupleobject *)op) -> ob_item[i];
        ((tupleobject *)op) -> ob_item[i] = newitem;
-       if (olditem != NULL)
-               DECREF(olditem);
+       XDECREF(olditem);
        return 0;
 }
 
@@ -148,10 +145,8 @@ tupledealloc(op)
        register tupleobject *op;
 {
        register int i;
-       for (i = 0; i < op->ob_size; i++) {
-               if (op->ob_item[i] != NULL)
-                       DECREF(op->ob_item[i]);
-       }
+       for (i = 0; i < op->ob_size; i++)
+               XDECREF(op->ob_item[i]);
 #if MAXSAVESIZE > 0
        if (0 < op->ob_size && op->ob_size < MAXSAVESIZE) {
                op->ob_item[0] = (object *) free_list[op->ob_size];
@@ -194,8 +189,7 @@ tuplerepr(v)
                        joinstring(&s, comma);
                t = reprobject(v->ob_item[i]);
                joinstring(&s, t);
-               if (t != NULL)
-                       DECREF(t);
+               XDECREF(t);
        }
        DECREF(comma);
        if (v->ob_size == 1) {
@@ -397,3 +391,42 @@ typeobject Tupletype = {
        0,              /*tp_as_mapping*/
        tuplehash,      /*tp_hash*/
 };
+
+/* The following function breaks the notion that tuples are immutable:
+   it changes the size of a tuple.  We get away with this only if there
+   is only one module referencing the object.  You can also think of it
+   as creating a new tuple object and destroying the old one, only
+   more efficiently.  In any case, don't use this if the tuple may
+   already be known to some other part of the code... */
+
+int
+resizetuple(pv, newsize)
+       object **pv;
+       int newsize;
+{
+       register object *v;
+       register tupleobject *sv;
+       v = *pv;
+       if (!is_tupleobject(v) || v->ob_refcnt != 1) {
+               *pv = 0;
+               DECREF(v);
+               err_badcall();
+               return -1;
+       }
+       /* XXX UNREF/NEWREF interface should be more symmetrical */
+#ifdef REF_DEBUG
+       --ref_total;
+#endif
+       UNREF(v);
+       *pv = (object *)
+               realloc((char *)v,
+                       sizeof(tupleobject) + newsize * sizeof(object *));
+       if (*pv == NULL) {
+               DEL(v);
+               err_nomem();
+               return -1;
+       }
+       NEWREF(*pv);
+       ((tupleobject *) *pv)->ob_size = newsize;
+       return 0;
+}
index 60208a0d47c49f01e6dd5e5c6766d1ca692c79c3..b95c351ba08eefaafa93717e9d7cb5c8cfc54cf2 100644 (file)
@@ -37,6 +37,11 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "compile.h"
 #include "eval.h"
 
+/* Forward */
+static object *filterstring PROTO((object *, object *));
+static object *filtertuple  PROTO((object *, object *));
+static object *exec_eval PROTO((object *v, int start));
+
 static object *
 builtin_abs(self, v)
        object *self;
@@ -61,6 +66,132 @@ builtin_apply(self, args)
        return call_object(func, arglist);
 }
 
+static object *
+builtin_bagof(self, args)
+       object *self;
+       object *args;
+{
+       object *func, *seq, *arg, *result;
+       sequence_methods *sqf;
+       int len, newfunc = 0;
+       register int i,j;
+       static char bagof_err[] = "bagof() requires 1 or 2 args";
+
+       if (args == NULL) {
+               err_setstr(TypeError, bagof_err);
+               return NULL;
+       }
+
+       if (is_tupleobject(args)) {
+               if (gettuplesize(args) != 2) {
+                       err_setstr(TypeError, bagof_err);
+                       return NULL;
+               }
+
+               func = gettupleitem(args, 0);
+               seq  = gettupleitem(args, 1);
+
+               if (is_stringobject(func)) {
+                       if ((func = exec_eval(func, lambda_input)) == NULL)
+                               return NULL;
+                       newfunc = 1;
+               }
+       }
+       else {
+               func = None;
+               seq  = args;
+       }
+
+       /* check for special cases; strings and tuples are returned as same */
+       if (is_stringobject(seq)) {
+               object *r = filterstring(func, seq);
+               if (newfunc)
+                       DECREF(func);
+               return r;
+       }
+
+       else if (is_tupleobject(seq)) {
+               object *r = filtertuple(func, seq);
+               if (newfunc)
+                       DECREF(func);
+               return r;
+       }
+
+       if (! (sqf = seq->ob_type->tp_as_sequence)) {
+               err_setstr(TypeError,
+                          "argument to bagof() must be a sequence type");
+               goto Fail_2;
+       }
+
+       if ((len = (*sqf->sq_length)(seq)) < 0)
+               goto Fail_2;
+
+       if (is_listobject(seq) && seq->ob_refcnt == 1) {
+               INCREF(seq);
+               result = seq;
+       }
+       else
+               if ((result = newlistobject(len)) == NULL)
+                       goto Fail_2;
+
+       if ((arg = newtupleobject(1)) == NULL)
+               goto Fail_1;
+
+       for (i = j = 0; i < len; ++i) {
+               object *ele, *value;
+
+               if (arg->ob_refcnt > 1) {
+                       DECREF(arg);
+                       if ((arg = newtupleobject(1)) == NULL)
+                               goto Fail_1;
+               }
+
+               if ((ele = (*sqf->sq_item)(seq, i)) == NULL)
+                       goto Fail_0;
+
+               if (func == None)
+                       value = ele;
+               else {
+                       if (settupleitem(arg, 0, ele) < 0)
+                               goto Fail_0;
+
+                       if ((value = call_object(func, arg)) == NULL)
+                               goto Fail_0;
+               }
+
+               if (testbool(value)) {
+                       INCREF(ele);
+                       if (setlistitem(result, j++, ele) < 0)
+                               goto Fail_0;
+               }
+
+               DECREF(value);
+       }
+
+       /* list_ass_slice() expects the rest of the list to be non-null */
+       for (i = j; i < len; ++i) {
+               INCREF(None);
+               if (setlistitem(result, i, None) < 0)
+                       goto Fail_0;
+       }
+
+       DECREF(arg);
+       if (newfunc)
+               DECREF(func);
+
+       (*result->ob_type->tp_as_sequence->sq_ass_slice)(result, j, len, NULL);
+       return result;
+
+Fail_0:
+       DECREF(arg);
+Fail_1:
+       DECREF(result);
+Fail_2:
+       if (newfunc)
+               DECREF(func);
+       return NULL;
+}
+
 static object *
 builtin_chr(self, args)
        object *self;
@@ -191,6 +322,7 @@ exec_eval(v, start)
        object *str = NULL, *globals = NULL, *locals = NULL;
        char *s;
        int n;
+       /* XXX This is a bit of a mess.  Should make it varargs */
        if (v != NULL) {
                if (is_tupleobject(v) &&
                                ((n = gettuplesize(v)) == 2 || n == 3)) {
@@ -206,9 +338,10 @@ exec_eval(v, start)
                        globals != NULL && !is_dictobject(globals) ||
                        locals != NULL && !is_dictobject(locals)) {
                err_setstr(TypeError,
-                   "exec/eval arguments must be (string|code)[,dict[,dict]]");
+                 "eval/lambda arguments must be (string|code)[,dict[,dict]]");
                return NULL;
        }
+       /* XXX The following is only correct for eval(), not for lambda() */
        if (is_codeobject(str))
                return eval_code((codeobject *) str, globals, locals,
                                 (object *)NULL, (object *)NULL);
@@ -217,7 +350,7 @@ exec_eval(v, start)
                err_setstr(ValueError, "embedded '\\0' in string arg");
                return NULL;
        }
-       if (start == eval_input) {
+       if (start == eval_input || start == lambda_input) {
                while (*s == ' ' || *s == '\t')
                        s++;
        }
@@ -335,6 +468,136 @@ builtin_id(self, args)
        return newintobject((long)v);
 }
 
+static object *
+builtin_map(self, args)
+       object *self;
+       object *args;
+{
+       typedef struct {
+               object *seq;
+               sequence_methods *sqf;
+               int len;
+       } sequence;
+
+       object *func, *result;
+       sequence *seqs = NULL, *sqp;
+       int n, len, newfunc = 0;
+       register int i, j;
+
+       if (args == NULL || !is_tupleobject(args)) {
+               err_setstr(TypeError, "map() requires at least two args");
+               return NULL;
+       }
+
+       func = gettupleitem(args, 0);
+       n    = gettuplesize(args) - 1;
+
+       if (is_stringobject(func)) {
+               if ((func = exec_eval(func, lambda_input)) == NULL)
+                       return NULL;
+               newfunc = 1;
+       }
+
+       if ((seqs = (sequence *) malloc(n * sizeof(sequence))) == NULL)
+               return err_nomem();
+
+       for (len = -1, i = 0, sqp = seqs; i < n; ++i, ++sqp) {
+               int curlen;
+       
+               if ((sqp->seq = gettupleitem(args, i + 1)) == NULL)
+                       goto Fail_2;
+
+               if (! (sqp->sqf = sqp->seq->ob_type->tp_as_sequence)) {
+                       static char errmsg[] =
+                           "argument %d to map() must be a sequence object";
+                       char errbuf[sizeof(errmsg) + 3];
+
+                       sprintf(errbuf, errmsg, i+2);
+                       err_setstr(TypeError, errbuf);
+                       goto Fail_2;
+               }
+
+               if ((curlen = sqp->len = (*sqp->sqf->sq_length)(sqp->seq)) < 0)
+                       goto Fail_2;
+
+               if (curlen > len)
+                       len = curlen;
+       }
+
+       if ((result = (object *) newlistobject(len)) == NULL)
+               goto Fail_2;
+
+       if ((args = newtupleobject(n)) == NULL)
+               goto Fail_1;
+
+       for (i = 0; i < len; ++i) {
+               object *arg, *value;
+
+               if (args->ob_refcnt > 1) {
+                       DECREF(args);
+                       if ((args = newtupleobject(n)) == NULL)
+                               goto Fail_1;
+               }
+
+               for (j = 0, sqp = seqs; j < n; ++j, ++sqp) {
+                       if (i >= sqp->len) {
+                               INCREF(None);
+                               if (settupleitem(args, j, None) < 0)
+                                       goto Fail_0;
+                               arg = None;
+                       }
+
+                       else {
+                               if ((arg = (*sqp->sqf->sq_item)(sqp->seq, i)) == NULL)
+                                       goto Fail_0;
+
+                               if (settupleitem(args, j, arg) < 0)
+                                       goto Fail_0;
+                       }
+               }
+
+               if (func == None) {
+                       if (n == 1)     { /* avoid creating singleton */
+                               INCREF(arg);
+                               if (setlistitem(result, i, arg) < 0)
+                                       goto Fail_0;
+                       }
+                       else {
+                               INCREF(args);
+                               if (setlistitem(result, i, args) < 0)
+                                       goto Fail_0;
+                       }
+               }
+               else {
+                       if ((value = call_object(func, args)) == NULL)
+                               goto Fail_0;
+
+                       if (setlistitem((object *) result, i, value) < 0)
+                               goto Fail_0;
+               }
+       }
+
+       if (seqs) free(seqs);
+
+       DECREF(args);
+       if (newfunc)
+               DECREF(func);
+
+       return result;
+
+Fail_0:
+       DECREF(args);
+Fail_1:
+       DECREF(result);
+Fail_2:
+       if (newfunc)
+               DECREF(func);
+
+       if (seqs) free(seqs);
+
+       return NULL;
+}
+
 static object *
 builtin_setattr(self, args)
        object *self;
@@ -413,6 +676,14 @@ builtin_int(self, v)
        return (*nb->nb_int)(v);
 }
 
+static object *
+builtin_lambda(self, v)
+       object *self;
+       object *v;
+{
+       return exec_eval(v, lambda_input);
+}
+
 static object *
 builtin_len(self, v)
        object *self;
@@ -640,6 +911,58 @@ builtin_range(self, v)
        return v;
 }
 
+static object *
+builtin_xrange(self, v)
+       object *self;
+       object *v;
+{
+       static char *errmsg = "xrange() requires 1-3 int arguments";
+       int i, n;
+       long start, stop, step, len;
+       if (v != NULL && is_intobject(v))
+               start = 0, stop = getintvalue(v), step = 1;
+
+       else if (v == NULL || !is_tupleobject(v)) {
+               err_setstr(TypeError, errmsg);
+               return NULL;
+       }
+       else {
+               n = gettuplesize(v);
+               if (n < 1 || n > 3) {
+                       err_setstr(TypeError, errmsg);
+                       return NULL;
+               }
+               for (i = 0; i < n; i++) {
+                       if (!is_intobject(gettupleitem(v, i))) {
+                               err_setstr(TypeError, errmsg);
+                               return NULL;
+                       }
+               }
+               if (n == 3) {
+                       step = getintvalue(gettupleitem(v, 2));
+                       --n;
+               }
+               else
+                       step = 1;
+               stop = getintvalue(gettupleitem(v, --n));
+               if (n > 0)
+                       start = getintvalue(gettupleitem(v, 0));
+               else
+                       start = 0;
+       }
+
+       if (step == 0) {
+               err_setstr(ValueError, "zero step for xrange()");
+               return NULL;
+       }
+
+       len = (stop - start + step + ((step > 0) ? -1 : 1)) / step;
+       if (len < 0)
+               len = 0;
+
+       return newrangeobject(start, len, step, 1);
+}
+
 static object *
 builtin_raw_input(self, v)
        object *self;
@@ -658,6 +981,103 @@ builtin_raw_input(self, v)
        return filegetline(sysget("stdin"), -1);
 }
 
+static object *
+builtin_reduce(self, args)
+       object *self;
+       object *args;
+{
+       object *seq, *func, *result;
+       sequence_methods *sqf;
+       static char reduce_err[] = "reduce() requires 2 or 3 args";
+       register int i;
+       int start = 0, newfunc = 0;
+       int len;
+
+       if (args == NULL || !is_tupleobject(args)) {
+               err_setstr(TypeError, reduce_err);
+               return NULL;
+       }
+
+       switch (gettuplesize(args)) {
+       case 2:
+               start = 1;              /* fall through */
+       case 3:
+               func = gettupleitem(args, 0);
+               seq  = gettupleitem(args, 1);
+               break;
+       default:
+               err_setstr(TypeError, reduce_err);
+       }
+
+       if ((sqf = seq->ob_type->tp_as_sequence) == NULL) {
+               err_setstr(TypeError,
+                   "2nd argument to reduce() must be a sequence object");
+               return NULL;
+       }
+
+       if (is_stringobject(func)) {
+               if ((func = exec_eval(func, lambda_input)) == NULL)
+                       return NULL;
+               newfunc = 1;
+       }
+
+       if ((len = (*sqf->sq_length)(seq)) < 0)
+               goto Fail_2;
+
+       if (start == 1) {
+               if (len == 0) {
+                       err_setstr(TypeError,
+                           "reduce of empty sequence with no initial value");
+                       goto Fail_2;
+               }
+
+               if ((result = (*sqf->sq_item)(seq, 0)) == NULL)
+                       goto Fail_2;
+       }
+       else {
+               result = gettupleitem(args, 2);
+               INCREF(result);
+       }
+
+       if ((args = newtupleobject(2)) == NULL)
+               goto Fail_1;
+
+       for (i = start; i < len; ++i) {
+               object *op2;
+
+               if (args->ob_refcnt > 1) {
+                       DECREF(args);
+                       if ((args = newtupleobject(2)) == NULL)
+                               goto Fail_1;
+               }
+
+               if ((op2 = (*sqf->sq_item)(seq, i)) == NULL)
+                       goto Fail_2;
+
+               settupleitem(args, 0, result);
+               settupleitem(args, 1, op2);
+               if ((result = call_object(func, args)) == NULL)
+                       goto Fail_0;
+       }
+
+       DECREF(args);
+       if (newfunc)
+               DECREF(func);
+
+       return result;
+
+       /* XXX I hate goto's. I hate goto's. I hate goto's. I hate goto's. */
+Fail_0:
+       DECREF(args);
+       goto Fail_2;
+Fail_1:
+       DECREF(result);
+Fail_2:
+       if (newfunc)
+               DECREF(func);
+       return NULL;
+}
+
 static object *
 builtin_reload(self, v)
        object *self;
@@ -740,6 +1160,7 @@ builtin_type(self, v)
 static struct methodlist builtin_methods[] = {
        {"abs",         builtin_abs},
        {"apply",       builtin_apply},
+       {"bagof",       builtin_bagof},
        {"chr",         builtin_chr},
        {"cmp",         builtin_cmp},
        {"coerce",      builtin_coerce},
@@ -756,8 +1177,10 @@ static struct methodlist builtin_methods[] = {
        {"id",          builtin_id},
        {"input",       builtin_input},
        {"int",         builtin_int},
+       {"lambda",      builtin_lambda},
        {"len",         builtin_len},
        {"long",        builtin_long},
+       {"map",         builtin_map},
        {"max",         builtin_max},
        {"min",         builtin_min},
        {"oct",         builtin_oct},
@@ -766,12 +1189,14 @@ static struct methodlist builtin_methods[] = {
        {"pow",         builtin_pow},
        {"range",       builtin_range},
        {"raw_input",   builtin_raw_input},
+       {"reduce",      builtin_reduce},
        {"reload",      builtin_reload},
        {"repr",        builtin_repr},
        {"round",       builtin_round},
        {"setattr",     builtin_setattr},
        {"str",         builtin_str},
        {"type",        builtin_type},
+       {"xrange",      builtin_xrange},
        {NULL,          NULL},
 };
 
@@ -883,3 +1308,155 @@ coerce(pv, pw)
        err_setstr(TypeError, "number coercion failed");
        return -1;
 }
+
+
+/* Filter a tuple through a function */
+
+static object *
+filtertuple(func, tuple)
+       object *func;
+       object *tuple;
+{
+       object *arg, *result;
+       register int i, j;
+       int len = gettuplesize(tuple), shared = 0;
+
+       if (tuple->ob_refcnt == 1) {
+               result = tuple;
+               shared = 1;
+               /* defer INCREF (resizetuple wants it to be one) */
+       }
+       else
+               if ((result = newtupleobject(len)) == NULL)
+                       return NULL;
+
+       if ((arg = newtupleobject(1)) == NULL)
+               goto Fail_1;
+
+       for (i = j = 0; i < len; ++i) {
+               object *ele, *value;
+
+               if (arg->ob_refcnt > 1) {
+                       DECREF(arg);
+                       if ((arg = newtupleobject(1)) == NULL)
+                               goto Fail_1;
+               }
+
+               if ((ele = gettupleitem(tuple, i)) == NULL)
+                       goto Fail_0;
+               INCREF(ele);
+
+               if (func == None)
+                       value = ele;
+               else {
+                       if (settupleitem(arg, 0, ele) < 0)
+                               goto Fail_0;
+
+                       if ((value = call_object(func, arg)) == NULL)
+                               goto Fail_0;
+               }
+
+               if (testbool(value)) {
+                       INCREF(ele);
+                       if (settupleitem(result, j++, ele) < 0)
+                               goto Fail_0;
+               }
+
+               DECREF(value);
+       }
+
+       DECREF(arg);
+       if (resizetuple(&result, j) < 0)
+               return NULL;
+
+       if (shared)
+               INCREF(result);
+
+       return result;
+
+Fail_0:
+       DECREF(arg);
+Fail_1:
+       if (!shared)
+               DECREF(result);
+       return NULL;
+}
+
+
+/* Filter a string through a function */
+
+static object *
+filterstring(func, strobj)
+       object *func;
+       object *strobj;
+{
+       object *arg, *result;
+       register int i, j;
+       int len = getstringsize(strobj), shared = 0;
+
+       if (strobj->ob_refcnt == 1) {
+               result = strobj;
+               shared = 1;
+               /* defer INCREF (resizestring wants it to be one) */
+
+               if (func == None) {
+                       INCREF(result);
+                       return result;
+               }
+       }
+       else {
+               if ((result = newsizedstringobject(NULL, len)) == NULL)
+                       return NULL;
+
+               if (func == None) {
+                       strcpy(GETSTRINGVALUE((stringobject *)result),
+                              GETSTRINGVALUE((stringobject *)strobj));
+                       return result;
+               }
+       }
+
+       if ((arg = newtupleobject(1)) == NULL)
+               goto Fail_1;
+
+       for (i = j = 0; i < len; ++i) {
+               object *ele, *value;
+
+               if (arg->ob_refcnt > 1) {
+                       DECREF(arg);
+                       if ((arg = newtupleobject(1)) == NULL)
+                               goto Fail_1;
+               }
+
+               if ((ele = (*strobj->ob_type->tp_as_sequence->sq_item)
+                          (strobj, i)) == NULL)
+                       goto Fail_0;
+
+               if (settupleitem(arg, 0, ele) < 0)
+                       goto Fail_0;
+
+               if ((value = call_object(func, arg)) == NULL)
+                       goto Fail_0;
+
+               if (testbool(value))
+                       GETSTRINGVALUE((stringobject *)result)[j++] =
+                               GETSTRINGVALUE((stringobject *)ele)[0];
+
+               DECREF(value);
+       }
+
+       DECREF(arg);
+       if (resizestring(&result, j) < 0)
+               return NULL;
+
+       if (shared)
+               INCREF(result);
+
+       return result;
+
+Fail_0:
+       DECREF(arg);
+Fail_1:
+       if (!shared)
+               DECREF(result);
+       return NULL;
+}
index 685a806c74920aa70e744346bbe85ed444b78957..3a6d1819c05f0e266c547fd9a53f90b149f7e55b 100644 (file)
@@ -164,6 +164,7 @@ struct compiling {
        int c_nexti;            /* index into c_code */
        int c_errors;           /* counts errors occurred */
        int c_infunction;       /* set when compiling a function */
+       int c_inlambda;         /* set when compiling an expression */
        int c_loops;            /* counts nested loops */
        int c_begin;            /* begin of current loop, for 'continue' */
        int c_block[MAXBLOCKS]; /* stack of block types */
@@ -205,7 +206,7 @@ block_pop(c, type)
 
 /* Prototypes */
 
-static int com_init PROTO((struct compiling *, char *));
+static int com_init PROTO((struct compiling *, char *, int));
 static void com_free PROTO((struct compiling *));
 static void com_done PROTO((struct compiling *));
 static void com_node PROTO((struct compiling *, struct _node *));
@@ -221,9 +222,10 @@ static void com_addopname PROTO((struct compiling *, int, node *));
 static void com_list PROTO((struct compiling *, node *, int));
 
 static int
-com_init(c, filename)
+com_init(c, filename, inlambda)
        struct compiling *c;
        char *filename;
+       int inlambda;
 {
        if ((c->c_code = newsizedstringobject((char *)NULL, 1000)) == NULL)
                goto fail_3;
@@ -236,6 +238,7 @@ com_init(c, filename)
        c->c_nexti = 0;
        c->c_errors = 0;
        c->c_infunction = 0;
+       c->c_inlambda = inlambda;
        c->c_loops = 0;
        c->c_begin = 0;
        c->c_nblocks = 0;
@@ -1792,7 +1795,7 @@ com_funcdef(c, n)
 {
        object *v;
        REQ(n, funcdef); /* funcdef: 'def' NAME parameters ':' suite */
-       v = (object *)compile(n, c->c_filename);
+       v = (object *)_compile(n, c->c_filename, 0);
        if (v == NULL)
                c->c_errors++;
        else {
@@ -1804,6 +1807,25 @@ com_funcdef(c, n)
        }
 }
 
+static void
+com_lambda(c, n)
+       struct compiling *c;
+       node *n;
+{
+       object *v;
+       REQ(n, lambda_input);
+       v = (object *)_compile(n, c->c_filename, 1);
+       if (v == NULL)
+               c->c_errors++;
+       else {
+               int i = com_addconst(c, v);
+               DECREF(v);
+               com_addoparg(c, LOAD_CONST, i);
+               com_addbyte(c, BUILD_FUNCTION);
+               com_addbyte(c, RETURN_VALUE);
+       }
+}
+
 static void
 com_bases(c, n)
        struct compiling *c;
@@ -1839,7 +1861,7 @@ com_classdef(c, n)
                com_addoparg(c, BUILD_TUPLE, 0);
        else
                com_bases(c, CHILD(n, 3));
-       v = (object *)compile(n, c->c_filename);
+       v = (object *)_compile(n, c->c_filename, 0);
        if (v == NULL)
                c->c_errors++;
        else {
@@ -2096,6 +2118,17 @@ compile_funcdef(c, n)
        com_addbyte(c, RETURN_VALUE);
 }
 
+static void
+compile_lambda(c, n)
+       struct compiling *c;
+       node *n;
+{
+       REQ(n, lambda_input)
+       com_arglist(c, CHILD(n, 0));
+       com_node(c, CHILD(n, 2));
+       com_addbyte(c, RETURN_VALUE);
+}
+
 static void
 compile_node(c, n)
        struct compiling *c;
@@ -2120,12 +2153,11 @@ compile_node(c, n)
                com_addbyte(c, RETURN_VALUE);
                break;
        
-       case expr_input: /* Built-in function eval() */
-               com_node(c, CHILD(n, 0));
-               com_addbyte(c, RETURN_VALUE);
+       case lambda_input: /* Built-in function lambda() */
+               (c->c_inlambda ? compile_lambda : com_lambda)(c, n);
                break;
        
-       case eval_input: /* Built-in function input() */
+       case eval_input: /* Built-in functions eval() and input() */
                com_node(c, CHILD(n, 0));
                com_addbyte(c, RETURN_VALUE);
                break;
@@ -2285,13 +2317,14 @@ optimize(c)
 }
 
 codeobject *
-compile(n, filename)
+_compile(n, filename, inlambda)
        node *n;
        char *filename;
+       int inlambda;
 {
        struct compiling sc;
        codeobject *co;
-       if (!com_init(&sc, filename))
+       if (!com_init(&sc, filename, inlambda))
                return NULL;
        compile_node(&sc, n);
        com_done(&sc);
index bce702d71aefca24132f5afeb30c016c635a3dc7..b5af72bf611932c50dab0e74d2dc75a1004c9c4c 100644 (file)
@@ -64,138 +64,160 @@ static arc arcs_4_1[1] = {
        {13, 2},
 };
 static arc arcs_4_2[1] = {
-       {14, 3},
+       {9, 3},
 };
-static arc arcs_4_3[1] = {
-       {15, 4},
+static arc arcs_4_3[2] = {
+       {2, 3},
+       {7, 4},
 };
 static arc arcs_4_4[1] = {
-       {16, 5},
-};
-static arc arcs_4_5[1] = {
-       {0, 5},
+       {0, 4},
 };
-static state states_4[6] = {
+static state states_4[5] = {
        {1, arcs_4_0},
        {1, arcs_4_1},
        {1, arcs_4_2},
-       {1, arcs_4_3},
+       {2, arcs_4_3},
        {1, arcs_4_4},
-       {1, arcs_4_5},
 };
 static arc arcs_5_0[1] = {
-       {17, 1},
+       {15, 1},
 };
-static arc arcs_5_1[2] = {
-       {18, 2},
-       {19, 3},
+static arc arcs_5_1[1] = {
+       {16, 2},
 };
 static arc arcs_5_2[1] = {
-       {19, 3},
+       {17, 3},
 };
 static arc arcs_5_3[1] = {
-       {0, 3},
+       {13, 4},
+};
+static arc arcs_5_4[1] = {
+       {18, 5},
+};
+static arc arcs_5_5[1] = {
+       {0, 5},
 };
-static state states_5[4] = {
+static state states_5[6] = {
        {1, arcs_5_0},
-       {2, arcs_5_1},
+       {1, arcs_5_1},
        {1, arcs_5_2},
        {1, arcs_5_3},
+       {1, arcs_5_4},
+       {1, arcs_5_5},
 };
-static arc arcs_6_0[2] = {
-       {20, 1},
-       {22, 2},
+static arc arcs_6_0[1] = {
+       {19, 1},
 };
 static arc arcs_6_1[2] = {
-       {21, 3},
-       {0, 1},
+       {12, 2},
+       {20, 3},
 };
 static arc arcs_6_2[1] = {
-       {13, 4},
+       {20, 3},
 };
-static arc arcs_6_3[3] = {
-       {20, 1},
-       {22, 2},
+static arc arcs_6_3[1] = {
        {0, 3},
 };
-static arc arcs_6_4[1] = {
-       {0, 4},
-};
-static state states_6[5] = {
-       {2, arcs_6_0},
+static state states_6[4] = {
+       {1, arcs_6_0},
        {2, arcs_6_1},
        {1, arcs_6_2},
-       {3, arcs_6_3},
-       {1, arcs_6_4},
+       {1, arcs_6_3},
 };
 static arc arcs_7_0[2] = {
-       {13, 1},
-       {17, 2},
+       {21, 1},
+       {23, 2},
 };
-static arc arcs_7_1[1] = {
+static arc arcs_7_1[2] = {
+       {22, 3},
        {0, 1},
 };
 static arc arcs_7_2[1] = {
-       {23, 3},
+       {16, 4},
 };
-static arc arcs_7_3[1] = {
-       {19, 1},
+static arc arcs_7_3[3] = {
+       {21, 1},
+       {23, 2},
+       {0, 3},
 };
-static state states_7[4] = {
+static arc arcs_7_4[1] = {
+       {0, 4},
+};
+static state states_7[5] = {
        {2, arcs_7_0},
-       {1, arcs_7_1},
+       {2, arcs_7_1},
        {1, arcs_7_2},
-       {1, arcs_7_3},
+       {3, arcs_7_3},
+       {1, arcs_7_4},
 };
-static arc arcs_8_0[1] = {
-       {20, 1},
+static arc arcs_8_0[2] = {
+       {16, 1},
+       {19, 2},
 };
-static arc arcs_8_1[2] = {
-       {21, 2},
+static arc arcs_8_1[1] = {
        {0, 1},
 };
-static arc arcs_8_2[2] = {
+static arc arcs_8_2[1] = {
+       {24, 3},
+};
+static arc arcs_8_3[1] = {
        {20, 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] = {
+       {21, 1},
+};
+static arc arcs_9_1[2] = {
+       {22, 2},
+       {0, 1},
+};
+static arc arcs_9_2[2] = {
+       {21, 1},
        {0, 2},
 };
-static state states_8[3] = {
-       {1, arcs_8_0},
-       {2, arcs_8_1},
-       {2, arcs_8_2},
+static state states_9[3] = {
+       {1, arcs_9_0},
+       {2, arcs_9_1},
+       {2, arcs_9_2},
 };
-static arc arcs_9_0[2] = {
+static arc arcs_10_0[2] = {
        {3, 1},
        {4, 1},
 };
-static arc arcs_9_1[1] = {
+static arc arcs_10_1[1] = {
        {0, 1},
 };
-static state states_9[2] = {
-       {2, arcs_9_0},
-       {1, arcs_9_1},
+static state states_10[2] = {
+       {2, arcs_10_0},
+       {1, arcs_10_1},
 };
-static arc arcs_10_0[1] = {
-       {24, 1},
+static arc arcs_11_0[1] = {
+       {25, 1},
 };
-static arc arcs_10_1[2] = {
-       {25, 2},
+static arc arcs_11_1[2] = {
+       {26, 2},
        {2, 3},
 };
-static arc arcs_10_2[2] = {
-       {24, 1},
+static arc arcs_11_2[2] = {
+       {25, 1},
        {2, 3},
 };
-static arc arcs_10_3[1] = {
+static arc arcs_11_3[1] = {
        {0, 3},
 };
-static state states_10[4] = {
-       {1, arcs_10_0},
-       {2, arcs_10_1},
-       {2, arcs_10_2},
-       {1, arcs_10_3},
+static state states_11[4] = {
+       {1, arcs_11_0},
+       {2, arcs_11_1},
+       {2, arcs_11_2},
+       {1, arcs_11_3},
 };
-static arc arcs_11_0[9] = {
-       {26, 1},
+static arc arcs_12_0[9] = {
        {27, 1},
        {28, 1},
        {29, 1},
@@ -204,86 +226,77 @@ static arc arcs_11_0[9] = {
        {32, 1},
        {33, 1},
        {34, 1},
+       {35, 1},
 };
-static arc arcs_11_1[1] = {
-       {0, 1},
-};
-static state states_11[2] = {
-       {9, arcs_11_0},
-       {1, arcs_11_1},
-};
-static arc arcs_12_0[1] = {
-       {9, 1},
-};
-static arc arcs_12_1[2] = {
-       {35, 0},
+static arc arcs_12_1[1] = {
        {0, 1},
 };
 static state states_12[2] = {
-       {1, arcs_12_0},
-       {2, arcs_12_1},
+       {9, arcs_12_0},
+       {1, arcs_12_1},
 };
 static arc arcs_13_0[1] = {
-       {36, 1},
+       {9, 1},
 };
 static arc arcs_13_1[2] = {
-       {37, 2},
+       {36, 0},
        {0, 1},
 };
-static arc arcs_13_2[2] = {
-       {21, 1},
-       {0, 2},
-};
-static state states_13[3] = {
+static state states_13[2] = {
        {1, arcs_13_0},
        {2, arcs_13_1},
-       {2, arcs_13_2},
 };
 static arc arcs_14_0[1] = {
-       {38, 1},
+       {37, 1},
 };
-static arc arcs_14_1[1] = {
-       {39, 2},
+static arc arcs_14_1[2] = {
+       {38, 2},
+       {0, 1},
 };
-static arc arcs_14_2[1] = {
+static arc arcs_14_2[2] = {
+       {22, 1},
        {0, 2},
 };
 static state states_14[3] = {
        {1, arcs_14_0},
-       {1, arcs_14_1},
-       {1, arcs_14_2},
+       {2, arcs_14_1},
+       {2, arcs_14_2},
 };
 static arc arcs_15_0[1] = {
-       {40, 1},
+       {39, 1},
 };
 static arc arcs_15_1[1] = {
-       {0, 1},
+       {40, 2},
+};
+static arc arcs_15_2[1] = {
+       {0, 2},
 };
-static state states_15[2] = {
+static state states_15[3] = {
        {1, arcs_15_0},
        {1, arcs_15_1},
+       {1, arcs_15_2},
 };
-static arc arcs_16_0[4] = {
+static arc arcs_16_0[1] = {
        {41, 1},
-       {42, 1},
-       {43, 1},
-       {44, 1},
 };
 static arc arcs_16_1[1] = {
        {0, 1},
 };
 static state states_16[2] = {
-       {4, arcs_16_0},
+       {1, arcs_16_0},
        {1, arcs_16_1},
 };
-static arc arcs_17_0[1] = {
+static arc arcs_17_0[4] = {
+       {42, 1},
+       {43, 1},
+       {44, 1},
        {45, 1},
 };
 static arc arcs_17_1[1] = {
        {0, 1},
 };
 static state states_17[2] = {
-       {1, arcs_17_0},
+       {4, arcs_17_0},
        {1, arcs_17_1},
 };
 static arc arcs_18_0[1] = {
@@ -299,246 +312,221 @@ static state states_18[2] = {
 static arc arcs_19_0[1] = {
        {47, 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] = {
        {48, 1},
 };
-static arc arcs_20_1[1] = {
-       {37, 2},
+static arc arcs_20_1[2] = {
+       {9, 2},
+       {0, 1},
 };
-static arc arcs_20_2[2] = {
-       {21, 3},
+static arc arcs_20_2[1] = {
        {0, 2},
 };
-static arc arcs_20_3[1] = {
-       {37, 4},
-};
-static arc arcs_20_4[1] = {
-       {0, 4},
-};
-static state states_20[5] = {
+static state states_20[3] = {
        {1, arcs_20_0},
-       {1, arcs_20_1},
-       {2, arcs_20_2},
-       {1, arcs_20_3},
-       {1, arcs_20_4},
+       {2, arcs_20_1},
+       {1, arcs_20_2},
 };
-static arc arcs_21_0[2] = {
+static arc arcs_21_0[1] = {
        {49, 1},
-       {50, 2},
 };
 static arc arcs_21_1[1] = {
-       {13, 3},
+       {38, 2},
 };
-static arc arcs_21_2[1] = {
-       {13, 4},
+static arc arcs_21_2[2] = {
+       {22, 3},
+       {0, 2},
 };
-static arc arcs_21_3[2] = {
-       {21, 1},
-       {0, 3},
+static arc arcs_21_3[1] = {
+       {38, 4},
 };
 static arc arcs_21_4[1] = {
-       {49, 5},
+       {0, 4},
 };
-static arc arcs_21_5[2] = {
-       {22, 6},
-       {13, 7},
+static state states_21[5] = {
+       {1, arcs_21_0},
+       {1, arcs_21_1},
+       {2, arcs_21_2},
+       {1, arcs_21_3},
+       {1, arcs_21_4},
 };
-static arc arcs_21_6[1] = {
-       {0, 6},
+static arc arcs_22_0[2] = {
+       {50, 1},
+       {51, 2},
 };
-static arc arcs_21_7[2] = {
-       {21, 8},
-       {0, 7},
+static arc arcs_22_1[1] = {
+       {16, 3},
 };
-static arc arcs_21_8[1] = {
-       {13, 7},
+static arc arcs_22_2[1] = {
+       {16, 4},
 };
-static state states_21[9] = {
-       {2, arcs_21_0},
-       {1, arcs_21_1},
-       {1, arcs_21_2},
-       {2, arcs_21_3},
-       {1, arcs_21_4},
-       {2, arcs_21_5},
-       {1, arcs_21_6},
-       {2, arcs_21_7},
-       {1, arcs_21_8},
+static arc arcs_22_3[2] = {
+       {22, 1},
+       {0, 3},
 };
-static arc arcs_22_0[1] = {
-       {51, 1},
+static arc arcs_22_4[1] = {
+       {50, 5},
 };
-static arc arcs_22_1[1] = {
-       {13, 2},
+static arc arcs_22_5[2] = {
+       {23, 6},
+       {16, 7},
 };
-static arc arcs_22_2[2] = {
-       {21, 1},
-       {0, 2},
+static arc arcs_22_6[1] = {
+       {0, 6},
 };
-static state states_22[3] = {
-       {1, arcs_22_0},
+static arc arcs_22_7[2] = {
+       {22, 8},
+       {0, 7},
+};
+static arc arcs_22_8[1] = {
+       {16, 7},
+};
+static state states_22[9] = {
+       {2, arcs_22_0},
        {1, arcs_22_1},
-       {2, arcs_22_2},
+       {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] = {
        {52, 1},
 };
-static arc arcs_23_1[2] = {
-       {22, 2},
-       {13, 3},
+static arc arcs_23_1[1] = {
+       {16, 2},
 };
-static arc arcs_23_2[1] = {
-       {15, 4},
+static arc arcs_23_2[2] = {
+       {22, 1},
+       {0, 2},
 };
-static arc arcs_23_3[2] = {
-       {21, 5},
-       {15, 4},
+static state states_23[3] = {
+       {1, arcs_23_0},
+       {1, arcs_23_1},
+       {2, arcs_23_2},
 };
-static arc arcs_23_4[1] = {
-       {53, 6},
+static arc arcs_24_0[1] = {
+       {53, 1},
 };
-static arc arcs_23_5[1] = {
-       {13, 3},
+static arc arcs_24_1[2] = {
+       {23, 2},
+       {16, 3},
 };
-static arc arcs_23_6[2] = {
-       {21, 4},
-       {0, 6},
+static arc arcs_24_2[1] = {
+       {13, 4},
 };
-static state states_23[7] = {
-       {1, arcs_23_0},
-       {2, arcs_23_1},
-       {1, arcs_23_2},
-       {2, arcs_23_3},
-       {1, arcs_23_4},
-       {1, arcs_23_5},
-       {2, arcs_23_6},
+static arc arcs_24_3[2] = {
+       {22, 5},
+       {13, 4},
 };
-static arc arcs_24_0[1] = {
-       {13, 1},
+static arc arcs_24_4[1] = {
+       {54, 6},
 };
-static arc arcs_24_1[2] = {
-       {13, 1},
-       {0, 1},
+static arc arcs_24_5[1] = {
+       {16, 3},
+};
+static arc arcs_24_6[2] = {
+       {22, 4},
+       {0, 6},
 };
-static state states_24[2] = {
+static state states_24[7] = {
        {1, arcs_24_0},
        {2, arcs_24_1},
+       {1, arcs_24_2},
+       {2, arcs_24_3},
+       {1, arcs_24_4},
+       {1, arcs_24_5},
+       {2, arcs_24_6},
 };
 static arc arcs_25_0[1] = {
-       {54, 1},
+       {16, 1},
+};
+static arc arcs_25_1[2] = {
+       {16, 1},
+       {0, 1},
+};
+static state states_25[2] = {
+       {1, arcs_25_0},
+       {2, arcs_25_1},
+};
+static arc arcs_26_0[1] = {
+       {55, 1},
 };
-static arc arcs_25_1[1] = {
-       {37, 2},
+static arc arcs_26_1[1] = {
+       {56, 2},
 };
-static arc arcs_25_2[2] = {
-       {55, 3},
+static arc arcs_26_2[2] = {
+       {57, 3},
        {0, 2},
 };
-static arc arcs_25_3[1] = {
-       {37, 4},
+static arc arcs_26_3[1] = {
+       {38, 4},
 };
-static arc arcs_25_4[2] = {
-       {21, 5},
+static arc arcs_26_4[2] = {
+       {22, 5},
        {0, 4},
 };
-static arc arcs_25_5[1] = {
-       {37, 6},
+static arc arcs_26_5[1] = {
+       {38, 6},
 };
-static arc arcs_25_6[1] = {
+static arc arcs_26_6[1] = {
        {0, 6},
 };
-static state states_25[7] = {
-       {1, arcs_25_0},
-       {1, arcs_25_1},
-       {2, arcs_25_2},
-       {1, arcs_25_3},
-       {2, arcs_25_4},
-       {1, arcs_25_5},
-       {1, arcs_25_6},
-};
-static arc arcs_26_0[6] = {
-       {56, 1},
-       {57, 1},
+static state states_26[7] = {
+       {1, arcs_26_0},
+       {1, arcs_26_1},
+       {2, arcs_26_2},
+       {1, arcs_26_3},
+       {2, arcs_26_4},
+       {1, arcs_26_5},
+       {1, arcs_26_6},
+};
+static arc arcs_27_0[6] = {
        {58, 1},
        {59, 1},
-       {11, 1},
        {60, 1},
-};
-static arc arcs_26_1[1] = {
-       {0, 1},
-};
-static state states_26[2] = {
-       {6, arcs_26_0},
-       {1, arcs_26_1},
-};
-static arc arcs_27_0[1] = {
        {61, 1},
-};
-static arc arcs_27_1[1] = {
-       {37, 2},
-};
-static arc arcs_27_2[1] = {
-       {15, 3},
-};
-static arc arcs_27_3[1] = {
-       {16, 4},
-};
-static arc arcs_27_4[3] = {
+       {14, 1},
        {62, 1},
-       {63, 5},
-       {0, 4},
-};
-static arc arcs_27_5[1] = {
-       {15, 6},
 };
-static arc arcs_27_6[1] = {
-       {16, 7},
-};
-static arc arcs_27_7[1] = {
-       {0, 7},
+static arc arcs_27_1[1] = {
+       {0, 1},
 };
-static state states_27[8] = {
-       {1, arcs_27_0},
+static state states_27[2] = {
+       {6, arcs_27_0},
        {1, arcs_27_1},
-       {1, arcs_27_2},
-       {1, arcs_27_3},
-       {3, arcs_27_4},
-       {1, arcs_27_5},
-       {1, arcs_27_6},
-       {1, arcs_27_7},
 };
 static arc arcs_28_0[1] = {
-       {64, 1},
+       {63, 1},
 };
 static arc arcs_28_1[1] = {
-       {37, 2},
+       {38, 2},
 };
 static arc arcs_28_2[1] = {
-       {15, 3},
+       {13, 3},
 };
 static arc arcs_28_3[1] = {
-       {16, 4},
+       {18, 4},
 };
-static arc arcs_28_4[2] = {
-       {63, 5},
+static arc arcs_28_4[3] = {
+       {64, 1},
+       {65, 5},
        {0, 4},
 };
 static arc arcs_28_5[1] = {
-       {15, 6},
+       {13, 6},
 };
 static arc arcs_28_6[1] = {
-       {16, 7},
+       {18, 7},
 };
 static arc arcs_28_7[1] = {
        {0, 7},
@@ -548,82 +536,73 @@ static state states_28[8] = {
        {1, arcs_28_1},
        {1, arcs_28_2},
        {1, arcs_28_3},
-       {2, arcs_28_4},
+       {3, arcs_28_4},
        {1, arcs_28_5},
        {1, arcs_28_6},
        {1, arcs_28_7},
 };
 static arc arcs_29_0[1] = {
-       {65, 1},
+       {66, 1},
 };
 static arc arcs_29_1[1] = {
-       {39, 2},
+       {38, 2},
 };
 static arc arcs_29_2[1] = {
-       {55, 3},
+       {13, 3},
 };
 static arc arcs_29_3[1] = {
-       {9, 4},
+       {18, 4},
 };
-static arc arcs_29_4[1] = {
-       {15, 5},
+static arc arcs_29_4[2] = {
+       {65, 5},
+       {0, 4},
 };
 static arc arcs_29_5[1] = {
-       {16, 6},
+       {13, 6},
 };
-static arc arcs_29_6[2] = {
-       {63, 7},
-       {0, 6},
+static arc arcs_29_6[1] = {
+       {18, 7},
 };
 static arc arcs_29_7[1] = {
-       {15, 8},
-};
-static arc arcs_29_8[1] = {
-       {16, 9},
-};
-static arc arcs_29_9[1] = {
-       {0, 9},
+       {0, 7},
 };
-static state states_29[10] = {
+static state states_29[8] = {
        {1, arcs_29_0},
        {1, arcs_29_1},
        {1, arcs_29_2},
        {1, arcs_29_3},
-       {1, arcs_29_4},
+       {2, arcs_29_4},
        {1, arcs_29_5},
-       {2, arcs_29_6},
+       {1, arcs_29_6},
        {1, arcs_29_7},
-       {1, arcs_29_8},
-       {1, arcs_29_9},
 };
 static arc arcs_30_0[1] = {
-       {66, 1},
+       {67, 1},
 };
 static arc arcs_30_1[1] = {
-       {15, 2},
+       {40, 2},
 };
 static arc arcs_30_2[1] = {
-       {16, 3},
+       {57, 3},
 };
-static arc arcs_30_3[2] = {
-       {67, 4},
-       {68, 5},
+static arc arcs_30_3[1] = {
+       {9, 4},
 };
 static arc arcs_30_4[1] = {
-       {15, 6},
+       {13, 5},
 };
 static arc arcs_30_5[1] = {
-       {15, 7},
+       {18, 6},
 };
-static arc arcs_30_6[1] = {
-       {16, 8},
+static arc arcs_30_6[2] = {
+       {65, 7},
+       {0, 6},
 };
 static arc arcs_30_7[1] = {
-       {16, 9},
+       {13, 8},
 };
-static arc arcs_30_8[2] = {
-       {67, 4},
-       {0, 8},
+static arc arcs_30_8[1] = {
+       {18, 9},
 };
 static arc arcs_30_9[1] = {
        {0, 9},
@@ -632,72 +611,105 @@ static state states_30[10] = {
        {1, arcs_30_0},
        {1, arcs_30_1},
        {1, arcs_30_2},
-       {2, arcs_30_3},
+       {1, arcs_30_3},
        {1, arcs_30_4},
        {1, arcs_30_5},
-       {1, arcs_30_6},
+       {2, arcs_30_6},
        {1, arcs_30_7},
-       {2, arcs_30_8},
+       {1, arcs_30_8},
        {1, arcs_30_9},
 };
 static arc arcs_31_0[1] = {
-       {69, 1},
+       {68, 1},
 };
-static arc arcs_31_1[2] = {
-       {37, 2},
-       {0, 1},
+static arc arcs_31_1[1] = {
+       {13, 2},
 };
-static arc arcs_31_2[2] = {
-       {21, 3},
-       {0, 2},
+static arc arcs_31_2[1] = {
+       {18, 3},
 };
-static arc arcs_31_3[1] = {
-       {37, 4},
+static arc arcs_31_3[2] = {
+       {69, 4},
+       {70, 5},
 };
 static arc arcs_31_4[1] = {
-       {0, 4},
+       {13, 6},
+};
+static arc arcs_31_5[1] = {
+       {13, 7},
+};
+static arc arcs_31_6[1] = {
+       {18, 8},
+};
+static arc arcs_31_7[1] = {
+       {18, 9},
 };
-static state states_31[5] = {
+static arc arcs_31_8[2] = {
+       {69, 4},
+       {0, 8},
+};
+static arc arcs_31_9[1] = {
+       {0, 9},
+};
+static state states_31[10] = {
        {1, arcs_31_0},
-       {2, arcs_31_1},
-       {2, arcs_31_2},
-       {1, arcs_31_3},
+       {1, arcs_31_1},
+       {1, arcs_31_2},
+       {2, arcs_31_3},
        {1, arcs_31_4},
+       {1, arcs_31_5},
+       {1, arcs_31_6},
+       {1, arcs_31_7},
+       {2, arcs_31_8},
+       {1, arcs_31_9},
 };
-static arc arcs_32_0[2] = {
-       {3, 1},
-       {2, 2},
+static arc arcs_32_0[1] = {
+       {71, 1},
 };
-static arc arcs_32_1[1] = {
+static arc arcs_32_1[2] = {
+       {38, 2},
        {0, 1},
 };
-static arc arcs_32_2[1] = {
-       {70, 3},
+static arc arcs_32_2[2] = {
+       {22, 3},
+       {0, 2},
 };
 static arc arcs_32_3[1] = {
-       {6, 4},
+       {38, 4},
 };
-static arc arcs_32_4[2] = {
-       {6, 4},
-       {71, 1},
+static arc arcs_32_4[1] = {
+       {0, 4},
 };
 static state states_32[5] = {
-       {2, arcs_32_0},
-       {1, arcs_32_1},
-       {1, arcs_32_2},
+       {1, arcs_32_0},
+       {2, arcs_32_1},
+       {2, arcs_32_2},
        {1, arcs_32_3},
-       {2, arcs_32_4},
+       {1, arcs_32_4},
 };
-static arc arcs_33_0[1] = {
-       {72, 1},
+static arc arcs_33_0[2] = {
+       {3, 1},
+       {2, 2},
 };
-static arc arcs_33_1[2] = {
-       {73, 0},
+static arc arcs_33_1[1] = {
        {0, 1},
 };
-static state states_33[2] = {
-       {1, arcs_33_0},
-       {2, arcs_33_1},
+static arc arcs_33_2[1] = {
+       {72, 3},
+};
+static arc arcs_33_3[1] = {
+       {6, 4},
+};
+static arc arcs_33_4[2] = {
+       {6, 4},
+       {73, 1},
+};
+static state states_33[5] = {
+       {2, arcs_33_0},
+       {1, arcs_33_1},
+       {1, arcs_33_2},
+       {1, arcs_33_3},
+       {2, arcs_33_4},
 };
 static arc arcs_34_0[1] = {
        {74, 1},
@@ -710,76 +722,76 @@ static state states_34[2] = {
        {1, arcs_34_0},
        {2, arcs_34_1},
 };
-static arc arcs_35_0[2] = {
+static arc arcs_35_0[1] = {
        {76, 1},
-       {77, 2},
 };
-static arc arcs_35_1[1] = {
-       {74, 2},
+static arc arcs_35_1[2] = {
+       {77, 0},
+       {0, 1},
+};
+static state states_35[2] = {
+       {1, arcs_35_0},
+       {2, arcs_35_1},
+};
+static arc arcs_36_0[2] = {
+       {78, 1},
+       {79, 2},
+};
+static arc arcs_36_1[1] = {
+       {76, 2},
 };
-static arc arcs_35_2[1] = {
+static arc arcs_36_2[1] = {
        {0, 2},
 };
-static state states_35[3] = {
-       {2, arcs_35_0},
-       {1, arcs_35_1},
-       {1, arcs_35_2},
+static state states_36[3] = {
+       {2, arcs_36_0},
+       {1, arcs_36_1},
+       {1, arcs_36_2},
 };
-static arc arcs_36_0[1] = {
-       {78, 1},
+static arc arcs_37_0[1] = {
+       {56, 1},
 };
-static arc arcs_36_1[2] = {
-       {79, 0},
+static arc arcs_37_1[2] = {
+       {80, 0},
        {0, 1},
 };
-static state states_36[2] = {
-       {1, arcs_36_0},
-       {2, arcs_36_1},
+static state states_37[2] = {
+       {1, arcs_37_0},
+       {2, arcs_37_1},
 };
-static arc arcs_37_0[10] = {
-       {80, 1},
+static arc arcs_38_0[10] = {
        {81, 1},
        {82, 1},
        {83, 1},
        {84, 1},
        {85, 1},
        {86, 1},
-       {55, 1},
-       {76, 2},
-       {87, 3},
+       {87, 1},
+       {57, 1},
+       {78, 2},
+       {88, 3},
 };
-static arc arcs_37_1[1] = {
+static arc arcs_38_1[1] = {
        {0, 1},
 };
-static arc arcs_37_2[1] = {
-       {55, 1},
+static arc arcs_38_2[1] = {
+       {57, 1},
 };
-static arc arcs_37_3[2] = {
-       {76, 1},
+static arc arcs_38_3[2] = {
+       {78, 1},
        {0, 3},
 };
-static state states_37[4] = {
-       {10, arcs_37_0},
-       {1, arcs_37_1},
-       {1, arcs_37_2},
-       {2, arcs_37_3},
-};
-static arc arcs_38_0[1] = {
-       {88, 1},
-};
-static arc arcs_38_1[2] = {
-       {89, 0},
-       {0, 1},
-};
-static state states_38[2] = {
-       {1, arcs_38_0},
-       {2, arcs_38_1},
+static state states_38[4] = {
+       {10, arcs_38_0},
+       {1, arcs_38_1},
+       {1, arcs_38_2},
+       {2, arcs_38_3},
 };
 static arc arcs_39_0[1] = {
-       {90, 1},
+       {89, 1},
 };
 static arc arcs_39_1[2] = {
-       {91, 0},
+       {90, 0},
        {0, 1},
 };
 static state states_39[2] = {
@@ -787,10 +799,10 @@ static state states_39[2] = {
        {2, arcs_39_1},
 };
 static arc arcs_40_0[1] = {
-       {92, 1},
+       {91, 1},
 };
 static arc arcs_40_1[2] = {
-       {93, 0},
+       {92, 0},
        {0, 1},
 };
 static state states_40[2] = {
@@ -798,23 +810,22 @@ static state states_40[2] = {
        {2, arcs_40_1},
 };
 static arc arcs_41_0[1] = {
-       {94, 1},
+       {93, 1},
 };
-static arc arcs_41_1[3] = {
-       {95, 0},
-       {96, 0},
+static arc arcs_41_1[2] = {
+       {94, 0},
        {0, 1},
 };
 static state states_41[2] = {
        {1, arcs_41_0},
-       {3, arcs_41_1},
+       {2, arcs_41_1},
 };
 static arc arcs_42_0[1] = {
-       {97, 1},
+       {95, 1},
 };
 static arc arcs_42_1[3] = {
-       {98, 0},
-       {99, 0},
+       {96, 0},
+       {97, 0},
        {0, 1},
 };
 static state states_42[2] = {
@@ -822,170 +833,166 @@ static state states_42[2] = {
        {3, arcs_42_1},
 };
 static arc arcs_43_0[1] = {
-       {100, 1},
+       {98, 1},
 };
-static arc arcs_43_1[4] = {
-       {22, 0},
-       {101, 0},
-       {102, 0},
+static arc arcs_43_1[3] = {
+       {99, 0},
+       {100, 0},
        {0, 1},
 };
 static state states_43[2] = {
        {1, arcs_43_0},
-       {4, arcs_43_1},
+       {3, arcs_43_1},
 };
-static arc arcs_44_0[4] = {
-       {98, 1},
-       {99, 1},
-       {103, 1},
-       {104, 2},
+static arc arcs_44_0[1] = {
+       {101, 1},
+};
+static arc arcs_44_1[4] = {
+       {23, 0},
+       {102, 0},
+       {103, 0},
+       {0, 1},
 };
-static arc arcs_44_1[1] = {
-       {100, 3},
+static state states_44[2] = {
+       {1, arcs_44_0},
+       {4, arcs_44_1},
 };
-static arc arcs_44_2[2] = {
+static arc arcs_45_0[4] = {
+       {99, 1},
+       {100, 1},
+       {104, 1},
        {105, 2},
+};
+static arc arcs_45_1[1] = {
+       {101, 3},
+};
+static arc arcs_45_2[2] = {
+       {106, 2},
        {0, 2},
 };
-static arc arcs_44_3[1] = {
+static arc arcs_45_3[1] = {
        {0, 3},
 };
-static state states_44[4] = {
-       {4, arcs_44_0},
-       {1, arcs_44_1},
-       {2, arcs_44_2},
-       {1, arcs_44_3},
+static state states_45[4] = {
+       {4, arcs_45_0},
+       {1, arcs_45_1},
+       {2, arcs_45_2},
+       {1, arcs_45_3},
 };
-static arc arcs_45_0[7] = {
-       {17, 1},
-       {106, 2},
-       {108, 3},
-       {111, 4},
-       {13, 5},
-       {112, 5},
+static arc arcs_46_0[7] = {
+       {19, 1},
+       {107, 2},
+       {109, 3},
+       {112, 4},
+       {16, 5},
        {113, 5},
+       {114, 5},
 };
-static arc arcs_45_1[2] = {
+static arc arcs_46_1[2] = {
        {9, 6},
-       {19, 5},
+       {20, 5},
 };
-static arc arcs_45_2[2] = {
+static arc arcs_46_2[2] = {
        {9, 7},
-       {107, 5},
+       {108, 5},
 };
-static arc arcs_45_3[2] = {
-       {109, 8},
-       {110, 5},
+static arc arcs_46_3[2] = {
+       {110, 8},
+       {111, 5},
 };
-static arc arcs_45_4[1] = {
+static arc arcs_46_4[1] = {
        {9, 9},
 };
-static arc arcs_45_5[1] = {
+static arc arcs_46_5[1] = {
        {0, 5},
 };
-static arc arcs_45_6[1] = {
-       {19, 5},
-};
-static arc arcs_45_7[1] = {
-       {107, 5},
+static arc arcs_46_6[1] = {
+       {20, 5},
 };
-static arc arcs_45_8[1] = {
-       {110, 5},
+static arc arcs_46_7[1] = {
+       {108, 5},
 };
-static arc arcs_45_9[1] = {
+static arc arcs_46_8[1] = {
        {111, 5},
 };
-static state states_45[10] = {
-       {7, arcs_45_0},
-       {2, arcs_45_1},
-       {2, arcs_45_2},
-       {2, arcs_45_3},
-       {1, arcs_45_4},
-       {1, arcs_45_5},
-       {1, arcs_45_6},
-       {1, arcs_45_7},
-       {1, arcs_45_8},
-       {1, arcs_45_9},
-};
-static arc arcs_46_0[3] = {
-       {17, 1},
-       {106, 2},
-       {115, 3},
-};
-static arc arcs_46_1[2] = {
-       {9, 4},
-       {19, 5},
-};
-static arc arcs_46_2[1] = {
-       {114, 6},
-};
-static arc arcs_46_3[1] = {
-       {13, 5},
-};
-static arc arcs_46_4[1] = {
-       {19, 5},
-};
-static arc arcs_46_5[1] = {
-       {0, 5},
-};
-static arc arcs_46_6[1] = {
-       {107, 5},
+static arc arcs_46_9[1] = {
+       {112, 5},
 };
-static state states_46[7] = {
-       {3, arcs_46_0},
+static state states_46[10] = {
+       {7, arcs_46_0},
        {2, arcs_46_1},
-       {1, arcs_46_2},
-       {1, arcs_46_3},
+       {2, arcs_46_2},
+       {2, arcs_46_3},
        {1, arcs_46_4},
        {1, arcs_46_5},
        {1, arcs_46_6},
+       {1, arcs_46_7},
+       {1, arcs_46_8},
+       {1, arcs_46_9},
 };
-static arc arcs_47_0[2] = {
-       {37, 1},
-       {15, 2},
+static arc arcs_47_0[3] = {
+       {19, 1},
+       {107, 2},
+       {116, 3},
 };
 static arc arcs_47_1[2] = {
-       {15, 2},
-       {0, 1},
+       {9, 4},
+       {20, 5},
 };
-static arc arcs_47_2[2] = {
-       {37, 3},
-       {0, 2},
+static arc arcs_47_2[1] = {
+       {115, 6},
 };
 static arc arcs_47_3[1] = {
-       {0, 3},
+       {16, 5},
+};
+static arc arcs_47_4[1] = {
+       {20, 5},
 };
-static state states_47[4] = {
-       {2, arcs_47_0},
+static arc arcs_47_5[1] = {
+       {0, 5},
+};
+static arc arcs_47_6[1] = {
+       {108, 5},
+};
+static state states_47[7] = {
+       {3, arcs_47_0},
        {2, arcs_47_1},
-       {2, arcs_47_2},
+       {1, arcs_47_2},
        {1, arcs_47_3},
+       {1, arcs_47_4},
+       {1, arcs_47_5},
+       {1, arcs_47_6},
 };
-static arc arcs_48_0[1] = {
-       {78, 1},
+static arc arcs_48_0[2] = {
+       {38, 1},
+       {13, 2},
 };
 static arc arcs_48_1[2] = {
-       {21, 2},
+       {13, 2},
        {0, 1},
 };
 static arc arcs_48_2[2] = {
-       {78, 1},
+       {38, 3},
        {0, 2},
 };
-static state states_48[3] = {
-       {1, arcs_48_0},
+static arc arcs_48_3[1] = {
+       {0, 3},
+};
+static state states_48[4] = {
+       {2, arcs_48_0},
        {2, arcs_48_1},
        {2, arcs_48_2},
+       {1, arcs_48_3},
 };
 static arc arcs_49_0[1] = {
-       {37, 1},
+       {56, 1},
 };
 static arc arcs_49_1[2] = {
-       {21, 2},
+       {22, 2},
        {0, 1},
 };
 static arc arcs_49_2[2] = {
-       {37, 1},
+       {56, 1},
        {0, 2},
 };
 static state states_49[3] = {
@@ -994,216 +1001,235 @@ static state states_49[3] = {
        {2, arcs_49_2},
 };
 static arc arcs_50_0[1] = {
-       {37, 1},
-};
-static arc arcs_50_1[1] = {
-       {15, 2},
-};
-static arc arcs_50_2[1] = {
-       {37, 3},
+       {38, 1},
 };
-static arc arcs_50_3[2] = {
-       {21, 4},
-       {0, 3},
+static arc arcs_50_1[2] = {
+       {22, 2},
+       {0, 1},
 };
-static arc arcs_50_4[2] = {
-       {37, 1},
-       {0, 4},
+static arc arcs_50_2[2] = {
+       {38, 1},
+       {0, 2},
 };
-static state states_50[5] = {
+static state states_50[3] = {
        {1, arcs_50_0},
-       {1, arcs_50_1},
-       {1, arcs_50_2},
-       {2, arcs_50_3},
-       {2, arcs_50_4},
+       {2, arcs_50_1},
+       {2, arcs_50_2},
 };
 static arc arcs_51_0[1] = {
-       {116, 1},
+       {38, 1},
 };
 static arc arcs_51_1[1] = {
        {13, 2},
 };
-static arc arcs_51_2[2] = {
-       {17, 3},
-       {15, 4},
+static arc arcs_51_2[1] = {
+       {38, 3},
+};
+static arc arcs_51_3[2] = {
+       {22, 4},
+       {0, 3},
+};
+static arc arcs_51_4[2] = {
+       {38, 1},
+       {0, 4},
+};
+static state states_51[5] = {
+       {1, arcs_51_0},
+       {1, arcs_51_1},
+       {1, arcs_51_2},
+       {2, arcs_51_3},
+       {2, arcs_51_4},
+};
+static arc arcs_52_0[1] = {
+       {117, 1},
+};
+static arc arcs_52_1[1] = {
+       {16, 2},
+};
+static arc arcs_52_2[2] = {
+       {19, 3},
+       {13, 4},
 };
-static arc arcs_51_3[1] = {
+static arc arcs_52_3[1] = {
        {9, 5},
 };
-static arc arcs_51_4[1] = {
-       {16, 6},
+static arc arcs_52_4[1] = {
+       {18, 6},
 };
-static arc arcs_51_5[1] = {
-       {19, 7},
+static arc arcs_52_5[1] = {
+       {20, 7},
 };
-static arc arcs_51_6[1] = {
+static arc arcs_52_6[1] = {
        {0, 6},
 };
-static arc arcs_51_7[1] = {
-       {15, 4},
+static arc arcs_52_7[1] = {
+       {13, 4},
 };
-static state states_51[8] = {
-       {1, arcs_51_0},
-       {1, arcs_51_1},
-       {2, arcs_51_2},
-       {1, arcs_51_3},
-       {1, arcs_51_4},
-       {1, arcs_51_5},
-       {1, arcs_51_6},
-       {1, arcs_51_7},
-};
-static dfa dfas[52] = {
+static state states_52[8] = {
+       {1, arcs_52_0},
+       {1, arcs_52_1},
+       {2, arcs_52_2},
+       {1, arcs_52_3},
+       {1, arcs_52_4},
+       {1, arcs_52_5},
+       {1, arcs_52_6},
+       {1, arcs_52_7},
+};
+static dfa dfas[53] = {
        {256, "single_input", 0, 3, states_0,
-        "\004\060\002\000\120\341\137\040\007\020\000\000\214\224\023"},
+        "\004\200\011\000\240\302\277\200\034\100\000\000\030\051\047"},
        {257, "file_input", 0, 2, states_1,
-        "\204\060\002\000\120\341\137\040\007\020\000\000\214\224\023"},
+        "\204\200\011\000\240\302\277\200\034\100\000\000\030\051\047"},
        {258, "expr_input", 0, 3, states_2,
-        "\000\040\002\000\000\000\000\000\000\020\000\000\214\224\003"},
+        "\000\000\011\000\000\000\000\000\000\100\000\000\030\051\007"},
        {259, "eval_input", 0, 3, states_3,
-        "\000\040\002\000\000\000\000\000\000\020\000\000\214\224\003"},
-       {260, "funcdef", 0, 6, states_4,
-        "\000\020\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-       {261, "parameters", 0, 4, states_5,
-        "\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000"},
-       {262, "varargslist", 0, 5, states_6,
-        "\000\040\102\000\000\000\000\000\000\000\000\000\000\000\000"},
-       {263, "fpdef", 0, 4, states_7,
-        "\000\040\002\000\000\000\000\000\000\000\000\000\000\000\000"},
-       {264, "fplist", 0, 3, states_8,
-        "\000\040\002\000\000\000\000\000\000\000\000\000\000\000\000"},
-       {265, "stmt", 0, 2, states_9,
-        "\000\060\002\000\120\341\137\040\007\020\000\000\214\224\023"},
-       {266, "simple_stmt", 0, 4, states_10,
-        "\000\040\002\000\120\341\137\000\000\020\000\000\214\224\003"},
-       {267, "small_stmt", 0, 2, states_11,
-        "\000\040\002\000\120\341\137\000\000\020\000\000\214\224\003"},
-       {268, "expr_stmt", 0, 2, states_12,
-        "\000\040\002\000\000\000\000\000\000\020\000\000\214\224\003"},
-       {269, "print_stmt", 0, 3, states_13,
-        "\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000"},
-       {270, "del_stmt", 0, 3, states_14,
-        "\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000"},
-       {271, "pass_stmt", 0, 2, states_15,
-        "\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000"},
-       {272, "flow_stmt", 0, 2, states_16,
-        "\000\000\000\000\000\340\001\000\000\000\000\000\000\000\000"},
-       {273, "break_stmt", 0, 2, states_17,
-        "\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000"},
-       {274, "continue_stmt", 0, 2, states_18,
+        "\000\000\011\000\000\000\000\000\000\100\000\000\030\051\007"},
+       {260, "exprfunc_input", 0, 5, states_4,
+        "\000\000\211\000\000\000\000\000\000\000\000\000\000\000\000"},
+       {261, "funcdef", 0, 6, states_5,
+        "\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+       {262, "parameters", 0, 4, states_6,
+        "\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000"},
+       {263, "varargslist", 0, 5, states_7,
+        "\000\000\211\000\000\000\000\000\000\000\000\000\000\000\000"},
+       {264, "fpdef", 0, 4, states_8,
+        "\000\000\011\000\000\000\000\000\000\000\000\000\000\000\000"},
+       {265, "fplist", 0, 3, states_9,
+        "\000\000\011\000\000\000\000\000\000\000\000\000\000\000\000"},
+       {266, "stmt", 0, 2, states_10,
+        "\000\200\011\000\240\302\277\200\034\100\000\000\030\051\047"},
+       {267, "simple_stmt", 0, 4, states_11,
+        "\000\000\011\000\240\302\277\000\000\100\000\000\030\051\007"},
+       {268, "small_stmt", 0, 2, states_12,
+        "\000\000\011\000\240\302\277\000\000\100\000\000\030\051\007"},
+       {269, "expr_stmt", 0, 2, states_13,
+        "\000\000\011\000\000\000\000\000\000\100\000\000\030\051\007"},
+       {270, "print_stmt", 0, 3, states_14,
+        "\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000"},
+       {271, "del_stmt", 0, 3, states_15,
+        "\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000"},
+       {272, "pass_stmt", 0, 2, states_16,
+        "\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000"},
+       {273, "flow_stmt", 0, 2, states_17,
+        "\000\000\000\000\000\300\003\000\000\000\000\000\000\000\000"},
+       {274, "break_stmt", 0, 2, states_18,
         "\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000"},
-       {275, "return_stmt", 0, 3, states_19,
+       {275, "continue_stmt", 0, 2, states_19,
         "\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000"},
-       {276, "raise_stmt", 0, 5, states_20,
+       {276, "return_stmt", 0, 3, states_20,
         "\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000"},
-       {277, "import_stmt", 0, 9, states_21,
-        "\000\000\000\000\000\000\006\000\000\000\000\000\000\000\000"},
-       {278, "global_stmt", 0, 3, states_22,
-        "\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000"},
-       {279, "access_stmt", 0, 7, states_23,
+       {277, "raise_stmt", 0, 5, states_21,
+        "\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000"},
+       {278, "import_stmt", 0, 9, states_22,
+        "\000\000\000\000\000\000\014\000\000\000\000\000\000\000\000"},
+       {279, "global_stmt", 0, 3, states_23,
         "\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000"},
-       {280, "accesstype", 0, 2, states_24,
-        "\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-       {281, "exec_stmt", 0, 7, states_25,
-        "\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000"},
-       {282, "compound_stmt", 0, 2, states_26,
-        "\000\020\000\000\000\000\000\040\007\000\000\000\000\000\020"},
-       {283, "if_stmt", 0, 8, states_27,
-        "\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000"},
-       {284, "while_stmt", 0, 8, states_28,
-        "\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000"},
-       {285, "for_stmt", 0, 10, states_29,
-        "\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000"},
-       {286, "try_stmt", 0, 10, states_30,
+       {280, "access_stmt", 0, 7, states_24,
+        "\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000"},
+       {281, "accesstype", 0, 2, states_25,
+        "\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000"},
+       {282, "exec_stmt", 0, 7, states_26,
+        "\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000"},
+       {283, "compound_stmt", 0, 2, states_27,
+        "\000\200\000\000\000\000\000\200\034\000\000\000\000\000\040"},
+       {284, "if_stmt", 0, 8, states_28,
+        "\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000"},
+       {285, "while_stmt", 0, 8, states_29,
         "\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000"},
-       {287, "except_clause", 0, 5, states_31,
-        "\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000"},
-       {288, "suite", 0, 5, states_32,
-        "\004\040\002\000\120\341\137\000\000\020\000\000\214\224\003"},
-       {289, "test", 0, 2, states_33,
-        "\000\040\002\000\000\000\000\000\000\020\000\000\214\224\003"},
-       {290, "and_test", 0, 2, states_34,
-        "\000\040\002\000\000\000\000\000\000\020\000\000\214\224\003"},
-       {291, "not_test", 0, 3, states_35,
-        "\000\040\002\000\000\000\000\000\000\020\000\000\214\224\003"},
-       {292, "comparison", 0, 2, states_36,
-        "\000\040\002\000\000\000\000\000\000\000\000\000\214\224\003"},
-       {293, "comp_op", 0, 4, states_37,
-        "\000\000\000\000\000\000\200\000\000\020\377\000\000\000\000"},
-       {294, "expr", 0, 2, states_38,
-        "\000\040\002\000\000\000\000\000\000\000\000\000\214\224\003"},
-       {295, "xor_expr", 0, 2, states_39,
-        "\000\040\002\000\000\000\000\000\000\000\000\000\214\224\003"},
-       {296, "and_expr", 0, 2, states_40,
-        "\000\040\002\000\000\000\000\000\000\000\000\000\214\224\003"},
-       {297, "shift_expr", 0, 2, states_41,
-        "\000\040\002\000\000\000\000\000\000\000\000\000\214\224\003"},
-       {298, "arith_expr", 0, 2, states_42,
-        "\000\040\002\000\000\000\000\000\000\000\000\000\214\224\003"},
-       {299, "term", 0, 2, states_43,
-        "\000\040\002\000\000\000\000\000\000\000\000\000\214\224\003"},
-       {300, "factor", 0, 4, states_44,
-        "\000\040\002\000\000\000\000\000\000\000\000\000\214\224\003"},
-       {301, "atom", 0, 10, states_45,
-        "\000\040\002\000\000\000\000\000\000\000\000\000\000\224\003"},
-       {302, "trailer", 0, 7, states_46,
-        "\000\000\002\000\000\000\000\000\000\000\000\000\000\004\010"},
-       {303, "subscript", 0, 4, states_47,
-        "\000\240\002\000\000\000\000\000\000\020\000\000\214\224\003"},
-       {304, "exprlist", 0, 3, states_48,
-        "\000\040\002\000\000\000\000\000\000\000\000\000\214\224\003"},
-       {305, "testlist", 0, 3, states_49,
-        "\000\040\002\000\000\000\000\000\000\020\000\000\214\224\003"},
-       {306, "dictmaker", 0, 5, states_50,
-        "\000\040\002\000\000\000\000\000\000\020\000\000\214\224\003"},
-       {307, "classdef", 0, 8, states_51,
-        "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\020"},
-};
-static label labels[117] = {
+       {286, "for_stmt", 0, 10, states_30,
+        "\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000"},
+       {287, "try_stmt", 0, 10, states_31,
+        "\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000"},
+       {288, "except_clause", 0, 5, states_32,
+        "\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000"},
+       {289, "suite", 0, 5, states_33,
+        "\004\000\011\000\240\302\277\000\000\100\000\000\030\051\007"},
+       {290, "test", 0, 2, states_34,
+        "\000\000\011\000\000\000\000\000\000\100\000\000\030\051\007"},
+       {291, "and_test", 0, 2, states_35,
+        "\000\000\011\000\000\000\000\000\000\100\000\000\030\051\007"},
+       {292, "not_test", 0, 3, states_36,
+        "\000\000\011\000\000\000\000\000\000\100\000\000\030\051\007"},
+       {293, "comparison", 0, 2, states_37,
+        "\000\000\011\000\000\000\000\000\000\000\000\000\030\051\007"},
+       {294, "comp_op", 0, 4, states_38,
+        "\000\000\000\000\000\000\000\002\000\100\376\001\000\000\000"},
+       {295, "expr", 0, 2, states_39,
+        "\000\000\011\000\000\000\000\000\000\000\000\000\030\051\007"},
+       {296, "xor_expr", 0, 2, states_40,
+        "\000\000\011\000\000\000\000\000\000\000\000\000\030\051\007"},
+       {297, "and_expr", 0, 2, states_41,
+        "\000\000\011\000\000\000\000\000\000\000\000\000\030\051\007"},
+       {298, "shift_expr", 0, 2, states_42,
+        "\000\000\011\000\000\000\000\000\000\000\000\000\030\051\007"},
+       {299, "arith_expr", 0, 2, states_43,
+        "\000\000\011\000\000\000\000\000\000\000\000\000\030\051\007"},
+       {300, "term", 0, 2, states_44,
+        "\000\000\011\000\000\000\000\000\000\000\000\000\030\051\007"},
+       {301, "factor", 0, 4, states_45,
+        "\000\000\011\000\000\000\000\000\000\000\000\000\030\051\007"},
+       {302, "atom", 0, 10, states_46,
+        "\000\000\011\000\000\000\000\000\000\000\000\000\000\050\007"},
+       {303, "trailer", 0, 7, states_47,
+        "\000\000\010\000\000\000\000\000\000\000\000\000\000\010\020"},
+       {304, "subscript", 0, 4, states_48,
+        "\000\040\011\000\000\000\000\000\000\100\000\000\030\051\007"},
+       {305, "exprlist", 0, 3, states_49,
+        "\000\000\011\000\000\000\000\000\000\000\000\000\030\051\007"},
+       {306, "testlist", 0, 3, states_50,
+        "\000\000\011\000\000\000\000\000\000\100\000\000\030\051\007"},
+       {307, "dictmaker", 0, 5, states_51,
+        "\000\000\011\000\000\000\000\000\000\100\000\000\030\051\007"},
+       {308, "classdef", 0, 8, states_52,
+        "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\040"},
+};
+static label labels[118] = {
        {0, "EMPTY"},
        {256, 0},
        {4, 0},
-       {266, 0},
-       {282, 0},
+       {267, 0},
+       {283, 0},
        {257, 0},
-       {265, 0},
+       {266, 0},
        {0, 0},
        {258, 0},
-       {305, 0},
+       {306, 0},
        {259, 0},
        {260, 0},
+       {263, 0},
+       {11, 0},
+       {261, 0},
        {1, "def"},
        {1, 0},
-       {261, 0},
-       {11, 0},
-       {288, 0},
-       {7, 0},
        {262, 0},
+       {289, 0},
+       {7, 0},
        {8, 0},
-       {263, 0},
+       {264, 0},
        {12, 0},
        {16, 0},
-       {264, 0},
-       {267, 0},
-       {13, 0},
+       {265, 0},
        {268, 0},
+       {13, 0},
        {269, 0},
        {270, 0},
        {271, 0},
        {272, 0},
-       {277, 0},
+       {273, 0},
        {278, 0},
        {279, 0},
-       {281, 0},
+       {280, 0},
+       {282, 0},
        {22, 0},
        {1, "print"},
-       {289, 0},
+       {290, 0},
        {1, "del"},
-       {304, 0},
+       {305, 0},
        {1, "pass"},
-       {273, 0},
        {274, 0},
        {275, 0},
        {276, 0},
+       {277, 0},
        {1, "break"},
        {1, "continue"},
        {1, "return"},
@@ -1212,33 +1238,33 @@ static label labels[117] = {
        {1, "from"},
        {1, "global"},
        {1, "access"},
-       {280, 0},
+       {281, 0},
        {1, "exec"},
+       {295, 0},
        {1, "in"},
-       {283, 0},
        {284, 0},
        {285, 0},
        {286, 0},
-       {307, 0},
+       {287, 0},
+       {308, 0},
        {1, "if"},
        {1, "elif"},
        {1, "else"},
        {1, "while"},
        {1, "for"},
        {1, "try"},
-       {287, 0},
+       {288, 0},
        {1, "finally"},
        {1, "except"},
        {5, 0},
        {6, 0},
-       {290, 0},
-       {1, "or"},
        {291, 0},
+       {1, "or"},
+       {292, 0},
        {1, "and"},
        {1, "not"},
-       {292, 0},
-       {294, 0},
        {293, 0},
+       {294, 0},
        {20, 0},
        {21, 0},
        {28, 0},
@@ -1247,39 +1273,39 @@ static label labels[117] = {
        {29, 0},
        {29, 0},
        {1, "is"},
-       {295, 0},
-       {18, 0},
        {296, 0},
-       {33, 0},
+       {18, 0},
        {297, 0},
-       {19, 0},
+       {33, 0},
        {298, 0},
+       {19, 0},
+       {299, 0},
        {34, 0},
        {35, 0},
-       {299, 0},
+       {300, 0},
        {14, 0},
        {15, 0},
-       {300, 0},
+       {301, 0},
        {17, 0},
        {24, 0},
        {32, 0},
-       {301, 0},
        {302, 0},
+       {303, 0},
        {9, 0},
        {10, 0},
        {26, 0},
-       {306, 0},
+       {307, 0},
        {27, 0},
        {25, 0},
        {2, 0},
        {3, 0},
-       {303, 0},
+       {304, 0},
        {23, 0},
        {1, "class"},
 };
 grammar gram = {
-       52,
+       53,
        dfas,
-       {117, labels},
+       {118, labels},
        256
 };