summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-06-18 22:08:13 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-06-18 22:08:13 (GMT)
commit5ca576ed0a0c697c7e7547adfd0b3af010fd2053 (patch)
tree0b0db361191363b3c168a6c105030f53e181d3e5 /Python
parent1dad6a86de55c38da5c356c2c6d81be8ff7884b1 (diff)
downloadcpython-5ca576ed0a0c697c7e7547adfd0b3af010fd2053.zip
cpython-5ca576ed0a0c697c7e7547adfd0b3af010fd2053.tar.gz
cpython-5ca576ed0a0c697c7e7547adfd0b3af010fd2053.tar.bz2
Merging the gen-branch into the main line, at Guido's direction. Yay!
Bugfix candidate in inspect.py: it was referencing "self" outside of a method.
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c676
-rw-r--r--Python/compile.c60
-rw-r--r--Python/graminit.c1335
-rw-r--r--Python/marshal.c8
-rw-r--r--Python/symtable.c1
5 files changed, 1156 insertions, 924 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index f9d0325..30554d5 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -40,6 +40,7 @@ static PyObject *eval_code2(PyCodeObject *,
PyObject **, int,
PyObject *);
+static PyObject *eval_frame(PyFrameObject *);
static char *get_func_name(PyObject *);
static char *get_func_desc(PyObject *);
static PyObject *call_object(PyObject *, PyObject *, PyObject *);
@@ -106,6 +107,124 @@ static PyObject *str_line = NULL;
static PyObject *str_return = NULL;
+staticforward PyTypeObject gentype;
+
+typedef struct {
+ PyObject_HEAD
+ PyFrameObject *frame;
+ int running; /* true if generator is being executed */
+} genobject;
+
+static PyObject *
+gen_new(PyFrameObject *f)
+{
+ genobject *gen = PyObject_New(genobject, &gentype);
+ if (gen == NULL) {
+ Py_DECREF(f);
+ return NULL;
+ }
+ gen->frame = f;
+ gen->running = 0;
+ return (PyObject *)gen;
+}
+
+static void
+gen_dealloc(genobject *gen)
+{
+ Py_DECREF(gen->frame);
+ PyObject_DEL(gen);
+}
+
+static PyObject *
+gen_iternext(genobject *gen)
+{
+ PyFrameObject *f = gen->frame;
+ PyObject *result;
+
+ if (gen->running) {
+ PyErr_SetString(PyExc_ValueError,
+ "generator already executing");
+ return NULL;
+ }
+ if (f->f_stackbottom == NULL) {
+ return NULL;
+ }
+ gen->running = 1;
+ result = eval_frame(f);
+ gen->running = 0;
+ return result;
+}
+
+static PyObject *
+gen_next(genobject *gen, PyObject *args)
+{
+ PyObject *result;
+
+ if (!PyArg_ParseTuple(args, ":next"))
+ return NULL;
+
+ result = gen_iternext(gen);
+
+ if (result == NULL && !PyErr_Occurred()) {
+ PyErr_SetObject(PyExc_StopIteration, Py_None);
+ return NULL;
+ }
+
+ return result;
+}
+
+static PyObject *
+gen_getiter(PyObject *gen)
+{
+ Py_INCREF(gen);
+ return gen;
+}
+
+static struct PyMethodDef gen_methods[] = {
+ {"next", (PyCFunction)gen_next, METH_VARARGS,
+ "next() -- get the next value, or raise StopIteration"},
+ {NULL, NULL} /* Sentinel */
+};
+
+static PyObject *
+gen_getattr(genobject *gen, char *name)
+{
+ return Py_FindMethod(gen_methods, (PyObject *)gen, name);
+}
+
+statichere PyTypeObject gentype = {
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0, /* ob_size */
+ "generator", /* tp_name */
+ sizeof(genobject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)gen_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ (getattrfunc)gen_getattr, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_compare */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ 0, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc)gen_getiter, /* tp_iter */
+ (iternextfunc)gen_iternext, /* tp_iternext */
+};
+
+
#ifdef WITH_THREAD
#ifndef DONT_HAVE_ERRNO_H
@@ -337,7 +456,8 @@ enum why_code {
WHY_RERAISE, /* Exception re-raised by 'finally' */
WHY_RETURN, /* 'return' statement */
WHY_BREAK, /* 'break' statement */
- WHY_CONTINUE /* 'continue' statement */
+ WHY_CONTINUE, /* 'continue' statement */
+ WHY_YIELD, /* 'yield' operator */
};
static enum why_code do_raise(PyObject *, PyObject *, PyObject *);
@@ -358,10 +478,8 @@ PyEval_EvalCode(PyCodeObject *co, PyObject *globals, PyObject *locals)
/* Interpreter main loop */
-static PyObject *
-eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
- PyObject **args, int argcount, PyObject **kws, int kwcount,
- PyObject **defs, int defcount, PyObject *closure)
+PyObject *
+eval_frame(PyFrameObject *f)
{
#ifdef DXPAIRS
int lastopcode = 0;
@@ -378,17 +496,17 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
register PyObject *u;
register PyObject *t;
register PyObject *stream = NULL; /* for PRINT opcodes */
- register PyFrameObject *f; /* Current frame */
register PyObject **fastlocals, **freevars;
PyObject *retval = NULL; /* Return value */
PyThreadState *tstate = PyThreadState_GET();
+ PyCodeObject *co;
unsigned char *first_instr;
#ifdef LLTRACE
int lltrace;
#endif
#if defined(Py_DEBUG) || defined(LLTRACE)
/* Make it easier to find out where we are with a debugger */
- char *filename = PyString_AsString(co->co_filename);
+ char *filename;
#endif
/* Code access macros */
@@ -426,6 +544,9 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
/* Start of code */
+ if (f == NULL)
+ return NULL;
+
#ifdef USE_STACKCHECK
if (tstate->recursion_depth%10 == 0 && PyOS_CheckStack()) {
PyErr_SetString(PyExc_MemoryError, "Stack overflow");
@@ -433,256 +554,32 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
}
#endif
- if (globals == NULL) {
- PyErr_SetString(PyExc_SystemError, "eval_code2: NULL globals");
- return NULL;
- }
-
-#ifdef LLTRACE
- lltrace = PyDict_GetItemString(globals, "__lltrace__") != NULL;
-#endif
-
- f = PyFrame_New(tstate, /*back*/
- co, /*code*/
- globals, locals);
- if (f == NULL)
- return NULL;
-
- tstate->frame = f;
- fastlocals = f->f_localsplus;
- freevars = f->f_localsplus + f->f_nlocals;
-
- if (co->co_argcount > 0 ||
- co->co_flags & (CO_VARARGS | CO_VARKEYWORDS)) {
- int i;
- int n = argcount;
- PyObject *kwdict = NULL;
- if (co->co_flags & CO_VARKEYWORDS) {
- kwdict = PyDict_New();
- if (kwdict == NULL)
- goto fail;
- i = co->co_argcount;
- if (co->co_flags & CO_VARARGS)
- i++;
- SETLOCAL(i, kwdict);
- }
- if (argcount > co->co_argcount) {
- if (!(co->co_flags & CO_VARARGS)) {
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes %s %d "
- "%sargument%s (%d given)",
- PyString_AsString(co->co_name),
- defcount ? "at most" : "exactly",
- co->co_argcount,
- kwcount ? "non-keyword " : "",
- co->co_argcount == 1 ? "" : "s",
- argcount);
- goto fail;
- }
- n = co->co_argcount;
- }
- for (i = 0; i < n; i++) {
- x = args[i];
- Py_INCREF(x);
- SETLOCAL(i, x);
- }
- if (co->co_flags & CO_VARARGS) {
- u = PyTuple_New(argcount - n);
- if (u == NULL)
- goto fail;
- SETLOCAL(co->co_argcount, u);
- for (i = n; i < argcount; i++) {
- x = args[i];
- Py_INCREF(x);
- PyTuple_SET_ITEM(u, i-n, x);
- }
- }
- for (i = 0; i < kwcount; i++) {
- PyObject *keyword = kws[2*i];
- PyObject *value = kws[2*i + 1];
- int j;
- if (keyword == NULL || !PyString_Check(keyword)) {
- PyErr_Format(PyExc_TypeError,
- "%.200s() keywords must be strings",
- PyString_AsString(co->co_name));
- goto fail;
- }
- /* XXX slow -- speed up using dictionary? */
- for (j = 0; j < co->co_argcount; j++) {
- PyObject *nm = PyTuple_GET_ITEM(
- co->co_varnames, j);
- int cmp = PyObject_RichCompareBool(
- keyword, nm, Py_EQ);
- if (cmp > 0)
- break;
- else if (cmp < 0)
- goto fail;
- }
- /* Check errors from Compare */
- if (PyErr_Occurred())
- goto fail;
- if (j >= co->co_argcount) {
- if (kwdict == NULL) {
- PyErr_Format(PyExc_TypeError,
- "%.200s() got an unexpected "
- "keyword argument '%.400s'",
- PyString_AsString(co->co_name),
- PyString_AsString(keyword));
- goto fail;
- }
- PyDict_SetItem(kwdict, keyword, value);
- }
- else {
- if (GETLOCAL(j) != NULL) {
- PyErr_Format(PyExc_TypeError,
- "%.200s() got multiple "
- "values for keyword "
- "argument '%.400s'",
- PyString_AsString(co->co_name),
- PyString_AsString(keyword));
- goto fail;
- }
- Py_INCREF(value);
- SETLOCAL(j, value);
- }
- }
- if (argcount < co->co_argcount) {
- int m = co->co_argcount - defcount;
- for (i = argcount; i < m; i++) {
- if (GETLOCAL(i) == NULL) {
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes %s %d "
- "%sargument%s (%d given)",
- PyString_AsString(co->co_name),
- ((co->co_flags & CO_VARARGS) ||
- defcount) ? "at least"
- : "exactly",
- m, kwcount ? "non-keyword " : "",
- m == 1 ? "" : "s", i);
- goto fail;
- }
- }
- if (n > m)
- i = n - m;
- else
- i = 0;
- for (; i < defcount; i++) {
- if (GETLOCAL(m+i) == NULL) {
- PyObject *def = defs[i];
- Py_INCREF(def);
- SETLOCAL(m+i, def);
- }
- }
- }
- }
- else {
- if (argcount > 0 || kwcount > 0) {
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes no arguments (%d given)",
- PyString_AsString(co->co_name),
- argcount + kwcount);
- goto fail;
- }
- }
- /* Allocate and initialize storage for cell vars, and copy free
- vars into frame. This isn't too efficient right now. */
- if (f->f_ncells) {
- int i = 0, j = 0, nargs, found;
- char *cellname, *argname;
- PyObject *c;
-
- nargs = co->co_argcount;
- if (co->co_flags & CO_VARARGS)
- nargs++;
- if (co->co_flags & CO_VARKEYWORDS)
- nargs++;
-
- /* Check for cells that shadow args */
- for (i = 0; i < f->f_ncells && j < nargs; ++i) {
- cellname = PyString_AS_STRING(
- PyTuple_GET_ITEM(co->co_cellvars, i));
- found = 0;
- while (j < nargs) {
- argname = PyString_AS_STRING(
- PyTuple_GET_ITEM(co->co_varnames, j));
- if (strcmp(cellname, argname) == 0) {
- c = PyCell_New(GETLOCAL(j));
- if (c == NULL)
- goto fail;
- GETLOCAL(f->f_nlocals + i) = c;
- found = 1;
- break;
- }
- j++;
- }
- if (found == 0) {
- c = PyCell_New(NULL);
- if (c == NULL)
- goto fail;
- SETLOCAL(f->f_nlocals + i, c);
- }
- }
- /* Initialize any that are left */
- while (i < f->f_ncells) {
- c = PyCell_New(NULL);
- if (c == NULL)
- goto fail;
- SETLOCAL(f->f_nlocals + i, c);
- i++;
- }
- }
- if (f->f_nfreevars) {
- int i;
- for (i = 0; i < f->f_nfreevars; ++i) {
- PyObject *o = PyTuple_GET_ITEM(closure, i);
- Py_INCREF(o);
- freevars[f->f_ncells + i] = o;
- }
- }
-
- if (tstate->sys_tracefunc != NULL) {
- /* tstate->sys_tracefunc, if defined, is a function that
- will be called on *every* entry to a code block.
- Its return value, if not None, is a function that
- will be called at the start of each executed line
- of code. (Actually, the function must return
- itself in order to continue tracing.)
- The trace functions are called with three arguments:
- a pointer to the current frame, a string indicating
- why the function is called, and an argument which
- depends on the situation. The global trace function
- (sys.trace) is also called whenever an exception
- is detected. */
- if (call_trace(&tstate->sys_tracefunc,
- &f->f_trace, f, str_call,
- Py_None/*XXX how to compute arguments now?*/)) {
- /* Trace function raised an error */
- goto fail;
- }
- }
-
- if (tstate->sys_profilefunc != NULL) {
- /* Similar for sys_profilefunc, except it needn't return
- itself and isn't called for "line" events */
- if (call_trace(&tstate->sys_profilefunc,
- (PyObject**)0, f, str_call,
- Py_None/*XXX*/)) {
- goto fail;
- }
- }
-
+ /* push frame */
if (++tstate->recursion_depth > recursion_limit) {
--tstate->recursion_depth;
PyErr_SetString(PyExc_RuntimeError,
"maximum recursion depth exceeded");
tstate->frame = f->f_back;
- Py_DECREF(f);
return NULL;
}
+ f->f_back = tstate->frame;
+ tstate->frame = f;
+
+ co = f->f_code;
+ fastlocals = f->f_localsplus;
+ freevars = f->f_localsplus + f->f_nlocals;
_PyCode_GETCODEPTR(co, &first_instr);
- next_instr = first_instr;
- stack_pointer = f->f_valuestack;
+ next_instr = first_instr + f->f_lasti;
+ stack_pointer = f->f_stackbottom;
+ f->f_stackbottom = NULL;
+
+#ifdef LLTRACE
+ lltrace = PyDict_GetItemString(f->f_globals,"__lltrace__") != NULL;
+#endif
+#if defined(Py_DEBUG) || defined(LLTRACE)
+ filename = PyString_AsString(co->co_filename);
+#endif
why = WHY_NOT;
err = 0;
@@ -1459,6 +1356,14 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
why = WHY_RETURN;
break;
+ case YIELD_VALUE:
+ retval = POP();
+ f->f_stackbottom = stack_pointer;
+ f->f_lasti = INSTR_OFFSET();
+ why = WHY_YIELD;
+ break;
+
+
case EXEC_STMT:
w = POP();
v = POP();
@@ -1484,6 +1389,7 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
if (PyInt_Check(v)) {
why = (enum why_code) PyInt_AsLong(v);
if (why == WHY_RETURN ||
+ why == WHY_YIELD ||
why == CONTINUE_LOOP)
retval = POP();
}
@@ -2225,7 +2131,7 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
/* Unwind stacks if a (pseudo) exception occurred */
- while (why != WHY_NOT && f->f_iblock > 0) {
+ while (why != WHY_NOT && why != WHY_YIELD && f->f_iblock > 0) {
PyTryBlock *b = PyFrame_BlockPop(f);
if (b->b_type == SETUP_LOOP && why == WHY_CONTINUE) {
@@ -2295,16 +2201,18 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
/* Pop remaining stack entries */
+ /*
while (!EMPTY()) {
v = POP();
Py_XDECREF(v);
}
+ */
- if (why != WHY_RETURN)
+ if (why != WHY_RETURN && why != WHY_YIELD)
retval = NULL;
if (f->f_trace) {
- if (why == WHY_RETURN) {
+ if (why == WHY_RETURN || why == WHY_YIELD) {
if (call_trace(&f->f_trace, &f->f_trace, f,
str_return, retval)) {
Py_XDECREF(retval);
@@ -2314,7 +2222,8 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
}
}
- if (tstate->sys_profilefunc && why == WHY_RETURN) {
+ if (tstate->sys_profilefunc &&
+ (why == WHY_RETURN || why == WHY_YIELD)) {
if (call_trace(&tstate->sys_profilefunc, (PyObject**)0,
f, str_return, retval)) {
Py_XDECREF(retval);
@@ -2325,18 +2234,272 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
reset_exc_info(tstate);
+ /* pop frame */
--tstate->recursion_depth;
+ tstate->frame = f->f_back;
- fail: /* Jump here from prelude on failure */
+ return retval;
+}
- /* Restore previous frame and release the current one */
+static PyObject *
+eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
+ PyObject **args, int argcount, PyObject **kws, int kwcount,
+ PyObject **defs, int defcount, PyObject *closure)
+{
+ register PyFrameObject *f;
+ register PyObject *retval = NULL;
+ register PyObject **fastlocals, **freevars;
+ PyThreadState *tstate = PyThreadState_GET();
+ PyObject *x, *u;
- tstate->frame = f->f_back;
- Py_DECREF(f);
+ if (globals == NULL) {
+ PyErr_SetString(PyExc_SystemError, "eval_code2: NULL globals");
+ return NULL;
+ }
+ f = PyFrame_New(tstate, /*back*/
+ co, /*code*/
+ globals, locals);
+ if (f == NULL)
+ return NULL;
+
+ fastlocals = f->f_localsplus;
+ freevars = f->f_localsplus + f->f_nlocals;
+
+ if (co->co_argcount > 0 ||
+ co->co_flags & (CO_VARARGS | CO_VARKEYWORDS)) {
+ int i;
+ int n = argcount;
+ PyObject *kwdict = NULL;
+ if (co->co_flags & CO_VARKEYWORDS) {
+ kwdict = PyDict_New();
+ if (kwdict == NULL)
+ goto fail;
+ i = co->co_argcount;
+ if (co->co_flags & CO_VARARGS)
+ i++;
+ SETLOCAL(i, kwdict);
+ }
+ if (argcount > co->co_argcount) {
+ if (!(co->co_flags & CO_VARARGS)) {
+ PyErr_Format(PyExc_TypeError,
+ "%.200s() takes %s %d "
+ "%sargument%s (%d given)",
+ PyString_AsString(co->co_name),
+ defcount ? "at most" : "exactly",
+ co->co_argcount,
+ kwcount ? "non-keyword " : "",
+ co->co_argcount == 1 ? "" : "s",
+ argcount);
+ goto fail;
+ }
+ n = co->co_argcount;
+ }
+ for (i = 0; i < n; i++) {
+ x = args[i];
+ Py_INCREF(x);
+ SETLOCAL(i, x);
+ }
+ if (co->co_flags & CO_VARARGS) {
+ u = PyTuple_New(argcount - n);
+ if (u == NULL)
+ goto fail;
+ SETLOCAL(co->co_argcount, u);
+ for (i = n; i < argcount; i++) {
+ x = args[i];
+ Py_INCREF(x);
+ PyTuple_SET_ITEM(u, i-n, x);
+ }
+ }
+ for (i = 0; i < kwcount; i++) {
+ PyObject *keyword = kws[2*i];
+ PyObject *value = kws[2*i + 1];
+ int j;
+ if (keyword == NULL || !PyString_Check(keyword)) {
+ PyErr_Format(PyExc_TypeError,
+ "%.200s() keywords must be strings",
+ PyString_AsString(co->co_name));
+ goto fail;
+ }
+ /* XXX slow -- speed up using dictionary? */
+ for (j = 0; j < co->co_argcount; j++) {
+ PyObject *nm = PyTuple_GET_ITEM(
+ co->co_varnames, j);
+ int cmp = PyObject_RichCompareBool(
+ keyword, nm, Py_EQ);
+ if (cmp > 0)
+ break;
+ else if (cmp < 0)
+ goto fail;
+ }
+ /* Check errors from Compare */
+ if (PyErr_Occurred())
+ goto fail;
+ if (j >= co->co_argcount) {
+ if (kwdict == NULL) {
+ PyErr_Format(PyExc_TypeError,
+ "%.200s() got an unexpected "
+ "keyword argument '%.400s'",
+ PyString_AsString(co->co_name),
+ PyString_AsString(keyword));
+ goto fail;
+ }
+ PyDict_SetItem(kwdict, keyword, value);
+ }
+ else {
+ if (GETLOCAL(j) != NULL) {
+ PyErr_Format(PyExc_TypeError,
+ "%.200s() got multiple "
+ "values for keyword "
+ "argument '%.400s'",
+ PyString_AsString(co->co_name),
+ PyString_AsString(keyword));
+ goto fail;
+ }
+ Py_INCREF(value);
+ SETLOCAL(j, value);
+ }
+ }
+ if (argcount < co->co_argcount) {
+ int m = co->co_argcount - defcount;
+ for (i = argcount; i < m; i++) {
+ if (GETLOCAL(i) == NULL) {
+ PyErr_Format(PyExc_TypeError,
+ "%.200s() takes %s %d "
+ "%sargument%s (%d given)",
+ PyString_AsString(co->co_name),
+ ((co->co_flags & CO_VARARGS) ||
+ defcount) ? "at least"
+ : "exactly",
+ m, kwcount ? "non-keyword " : "",
+ m == 1 ? "" : "s", i);
+ goto fail;
+ }
+ }
+ if (n > m)
+ i = n - m;
+ else
+ i = 0;
+ for (; i < defcount; i++) {
+ if (GETLOCAL(m+i) == NULL) {
+ PyObject *def = defs[i];
+ Py_INCREF(def);
+ SETLOCAL(m+i, def);
+ }
+ }
+ }
+ }
+ else {
+ if (argcount > 0 || kwcount > 0) {
+ PyErr_Format(PyExc_TypeError,
+ "%.200s() takes no arguments (%d given)",
+ PyString_AsString(co->co_name),
+ argcount + kwcount);
+ goto fail;
+ }
+ }
+ /* Allocate and initialize storage for cell vars, and copy free
+ vars into frame. This isn't too efficient right now. */
+ if (f->f_ncells) {
+ int i = 0, j = 0, nargs, found;
+ char *cellname, *argname;
+ PyObject *c;
+
+ nargs = co->co_argcount;
+ if (co->co_flags & CO_VARARGS)
+ nargs++;
+ if (co->co_flags & CO_VARKEYWORDS)
+ nargs++;
+
+ /* Check for cells that shadow args */
+ for (i = 0; i < f->f_ncells && j < nargs; ++i) {
+ cellname = PyString_AS_STRING(
+ PyTuple_GET_ITEM(co->co_cellvars, i));
+ found = 0;
+ while (j < nargs) {
+ argname = PyString_AS_STRING(
+ PyTuple_GET_ITEM(co->co_varnames, j));
+ if (strcmp(cellname, argname) == 0) {
+ c = PyCell_New(GETLOCAL(j));
+ if (c == NULL)
+ goto fail;
+ GETLOCAL(f->f_nlocals + i) = c;
+ found = 1;
+ break;
+ }
+ j++;
+ }
+ if (found == 0) {
+ c = PyCell_New(NULL);
+ if (c == NULL)
+ goto fail;
+ SETLOCAL(f->f_nlocals + i, c);
+ }
+ }
+ /* Initialize any that are left */
+ while (i < f->f_ncells) {
+ c = PyCell_New(NULL);
+ if (c == NULL)
+ goto fail;
+ SETLOCAL(f->f_nlocals + i, c);
+ i++;
+ }
+ }
+ if (f->f_nfreevars) {
+ int i;
+ for (i = 0; i < f->f_nfreevars; ++i) {
+ PyObject *o = PyTuple_GET_ITEM(closure, i);
+ Py_INCREF(o);
+ freevars[f->f_ncells + i] = o;
+ }
+ }
+
+ if (tstate->sys_tracefunc != NULL) {
+ /* tstate->sys_tracefunc, if defined, is a function that
+ will be called on *every* entry to a code block.
+ Its return value, if not None, is a function that
+ will be called at the start of each executed line
+ of code. (Actually, the function must return
+ itself in order to continue tracing.)
+ The trace functions are called with three arguments:
+ a pointer to the current frame, a string indicating
+ why the function is called, and an argument which
+ depends on the situation. The global trace function
+ (sys.trace) is also called whenever an exception
+ is detected. */
+ if (call_trace(&tstate->sys_tracefunc,
+ &f->f_trace, f, str_call,
+ Py_None/*XXX how to compute arguments now?*/)) {
+ /* Trace function raised an error */
+ goto fail;
+ }
+ }
+
+ if (tstate->sys_profilefunc != NULL) {
+ /* Similar for sys_profilefunc, except it needn't return
+ itself and isn't called for "line" events */
+ if (call_trace(&tstate->sys_profilefunc,
+ (PyObject**)0, f, str_call,
+ Py_None/*XXX*/)) {
+ goto fail;
+ }
+ }
+
+ if (co->co_flags & CO_GENERATOR) {
+ /* create a new generator that owns the ready to run frame
+ * and return that as the value */
+ return gen_new(f);
+ }
+
+ retval = eval_frame(f);
+
+ fail: /* Jump here from prelude on failure */
+
+ Py_DECREF(f);
return retval;
}
+
static void
set_exc_info(PyThreadState *tstate,
PyObject *type, PyObject *value, PyObject *tb)
@@ -2701,7 +2864,6 @@ _PyTrace_Init(void)
return 0;
}
-
PyObject *
PyEval_GetBuiltins(void)
{
diff --git a/Python/compile.c b/Python/compile.c
index b9ba0fc..6c13bb9 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -2634,13 +2634,37 @@ com_return_stmt(struct compiling *c, node *n)
if (!c->c_infunction) {
com_error(c, PyExc_SyntaxError, "'return' outside function");
}
- if (NCH(n) < 2) {
- com_addoparg(c, LOAD_CONST, com_addconst(c, Py_None));
+ if (c->c_flags & CO_GENERATOR) {
+ if (NCH(n) > 1) {
+ com_error(c, PyExc_SyntaxError,
+ "'return' with argument inside generator");
+ }
+ com_addoparg(c, LOAD_CONST,
+ com_addconst(c, PyExc_StopIteration));
com_push(c, 1);
+ com_addoparg(c, RAISE_VARARGS, 1);
+ }
+ else {
+ if (NCH(n) < 2) {
+ com_addoparg(c, LOAD_CONST, com_addconst(c, Py_None));
+ com_push(c, 1);
+ }
+ else
+ com_node(c, CHILD(n, 1));
+ com_addbyte(c, RETURN_VALUE);
}
- else
- com_node(c, CHILD(n, 1));
- com_addbyte(c, RETURN_VALUE);
+ com_pop(c, 1);
+}
+
+static void
+com_yield_stmt(struct compiling *c, node *n)
+{
+ REQ(n, yield_stmt); /* 'yield' testlist */
+ if (!c->c_infunction) {
+ com_error(c, PyExc_SyntaxError, "'yield' outside function");
+ }
+ com_node(c, CHILD(n, 1));
+ com_addbyte(c, YIELD_VALUE);
com_pop(c, 1);
}
@@ -3455,6 +3479,9 @@ com_node(struct compiling *c, node *n)
case return_stmt:
com_return_stmt(c, n);
break;
+ case yield_stmt:
+ com_yield_stmt(c, n);
+ break;
case raise_stmt:
com_raise_stmt(c, n);
break;
@@ -3674,10 +3701,19 @@ compile_funcdef(struct compiling *c, node *n)
c->c_infunction = 1;
com_node(c, CHILD(n, 4));
c->c_infunction = 0;
- com_addoparg(c, LOAD_CONST, com_addconst(c, Py_None));
- com_push(c, 1);
- com_addbyte(c, RETURN_VALUE);
- com_pop(c, 1);
+ if (c->c_flags & CO_GENERATOR) {
+ com_addoparg(c, LOAD_CONST,
+ com_addconst(c, PyExc_StopIteration));
+ com_push(c, 1);
+ com_addoparg(c, RAISE_VARARGS, 1);
+ com_pop(c, 1);
+ }
+ else {
+ com_addoparg(c, LOAD_CONST, com_addconst(c, Py_None));
+ com_push(c, 1);
+ com_addbyte(c, RETURN_VALUE);
+ com_pop(c, 1);
+ }
}
static void
@@ -4342,6 +4378,8 @@ symtable_update_flags(struct compiling *c, PySymtableEntryObject *ste,
{
if (c->c_future && c->c_future->ff_nested_scopes)
c->c_flags |= CO_NESTED;
+ if (ste->ste_generator)
+ c->c_flags |= CO_GENERATOR;
if (ste->ste_type != TYPE_MODULE)
c->c_flags |= CO_NEWLOCALS;
if (ste->ste_type == TYPE_FUNCTION) {
@@ -4900,6 +4938,10 @@ symtable_node(struct symtable *st, node *n)
case del_stmt:
symtable_assign(st, CHILD(n, 1), 0);
break;
+ case yield_stmt:
+ st->st_cur->ste_generator = 1;
+ n = CHILD(n, 1);
+ goto loop;
case expr_stmt:
if (NCH(n) == 1)
n = CHILD(n, 0);
diff --git a/Python/graminit.c b/Python/graminit.c
index efe7c94..a960730 100644
--- a/Python/graminit.c
+++ b/Python/graminit.c
@@ -341,21 +341,22 @@ static state states_15[2] = {
{1, arcs_15_0},
{1, arcs_15_1},
};
-static arc arcs_16_0[4] = {
+static arc arcs_16_0[5] = {
{54, 1},
{55, 1},
{56, 1},
{57, 1},
+ {58, 1},
};
static arc arcs_16_1[1] = {
{0, 1},
};
static state states_16[2] = {
- {4, arcs_16_0},
+ {5, arcs_16_0},
{1, arcs_16_1},
};
static arc arcs_17_0[1] = {
- {58, 1},
+ {59, 1},
};
static arc arcs_17_1[1] = {
{0, 1},
@@ -365,7 +366,7 @@ static state states_17[2] = {
{1, arcs_17_1},
};
static arc arcs_18_0[1] = {
- {59, 1},
+ {60, 1},
};
static arc arcs_18_1[1] = {
{0, 1},
@@ -375,7 +376,7 @@ static state states_18[2] = {
{1, arcs_18_1},
};
static arc arcs_19_0[1] = {
- {60, 1},
+ {61, 1},
};
static arc arcs_19_1[2] = {
{9, 2},
@@ -390,101 +391,96 @@ static state states_19[3] = {
{1, arcs_19_2},
};
static arc arcs_20_0[1] = {
- {61, 1},
+ {62, 1},
+};
+static arc arcs_20_1[1] = {
+ {9, 2},
};
-static arc arcs_20_1[2] = {
+static arc arcs_20_2[1] = {
+ {0, 2},
+};
+static state states_20[3] = {
+ {1, arcs_20_0},
+ {1, arcs_20_1},
+ {1, arcs_20_2},
+};
+static arc arcs_21_0[1] = {
+ {63, 1},
+};
+static arc arcs_21_1[2] = {
{21, 2},
{0, 1},
};
-static arc arcs_20_2[2] = {
+static arc arcs_21_2[2] = {
{22, 3},
{0, 2},
};
-static arc arcs_20_3[1] = {
+static arc arcs_21_3[1] = {
{21, 4},
};
-static arc arcs_20_4[2] = {
+static arc arcs_21_4[2] = {
{22, 5},
{0, 4},
};
-static arc arcs_20_5[1] = {
+static arc arcs_21_5[1] = {
{21, 6},
};
-static arc arcs_20_6[1] = {
+static arc arcs_21_6[1] = {
{0, 6},
};
-static state states_20[7] = {
- {1, arcs_20_0},
- {2, arcs_20_1},
- {2, arcs_20_2},
- {1, arcs_20_3},
- {2, arcs_20_4},
- {1, arcs_20_5},
- {1, arcs_20_6},
-};
-static arc arcs_21_0[2] = {
- {62, 1},
- {64, 2},
+static state states_21[7] = {
+ {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},
};
-static arc arcs_21_1[1] = {
- {63, 3},
+static arc arcs_22_0[2] = {
+ {64, 1},
+ {66, 2},
};
-static arc arcs_21_2[1] = {
- {65, 4},
+static arc arcs_22_1[1] = {
+ {65, 3},
};
-static arc arcs_21_3[2] = {
+static arc arcs_22_2[1] = {
+ {67, 4},
+};
+static arc arcs_22_3[2] = {
{22, 1},
{0, 3},
};
-static arc arcs_21_4[1] = {
- {62, 5},
+static arc arcs_22_4[1] = {
+ {64, 5},
};
-static arc arcs_21_5[2] = {
+static arc arcs_22_5[2] = {
{23, 6},
- {66, 7},
+ {68, 7},
};
-static arc arcs_21_6[1] = {
+static arc arcs_22_6[1] = {
{0, 6},
};
-static arc arcs_21_7[2] = {
+static arc arcs_22_7[2] = {
{22, 8},
{0, 7},
};
-static arc arcs_21_8[1] = {
- {66, 7},
+static arc arcs_22_8[1] = {
+ {68, 7},
};
-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_0[1] = {
- {12, 1},
-};
-static arc arcs_22_1[2] = {
- {12, 2},
- {0, 1},
-};
-static arc arcs_22_2[1] = {
- {12, 3},
-};
-static arc arcs_22_3[1] = {
- {0, 3},
-};
-static state states_22[4] = {
- {1, arcs_22_0},
- {2, arcs_22_1},
+static state states_22[9] = {
+ {2, arcs_22_0},
+ {1, arcs_22_1},
{1, arcs_22_2},
- {1, arcs_22_3},
+ {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] = {
- {65, 1},
+ {12, 1},
};
static arc arcs_23_1[2] = {
{12, 2},
@@ -503,139 +499,122 @@ static state states_23[4] = {
{1, arcs_23_3},
};
static arc arcs_24_0[1] = {
- {12, 1},
+ {67, 1},
};
static arc arcs_24_1[2] = {
- {67, 0},
+ {12, 2},
{0, 1},
};
-static state states_24[2] = {
+static arc arcs_24_2[1] = {
+ {12, 3},
+};
+static arc arcs_24_3[1] = {
+ {0, 3},
+};
+static state states_24[4] = {
{1, arcs_24_0},
{2, arcs_24_1},
+ {1, arcs_24_2},
+ {1, arcs_24_3},
};
static arc arcs_25_0[1] = {
- {68, 1},
-};
-static arc arcs_25_1[1] = {
- {12, 2},
+ {12, 1},
};
-static arc arcs_25_2[2] = {
- {22, 1},
- {0, 2},
+static arc arcs_25_1[2] = {
+ {69, 0},
+ {0, 1},
};
-static state states_25[3] = {
+static state states_25[2] = {
{1, arcs_25_0},
- {1, arcs_25_1},
- {2, arcs_25_2},
+ {2, arcs_25_1},
};
static arc arcs_26_0[1] = {
- {69, 1},
+ {70, 1},
};
static arc arcs_26_1[1] = {
- {70, 2},
+ {12, 2},
};
static arc arcs_26_2[2] = {
- {71, 3},
+ {22, 1},
{0, 2},
};
-static arc arcs_26_3[1] = {
- {21, 4},
-};
-static arc arcs_26_4[2] = {
- {22, 5},
- {0, 4},
-};
-static arc arcs_26_5[1] = {
- {21, 6},
-};
-static arc arcs_26_6[1] = {
- {0, 6},
-};
-static state states_26[7] = {
+static state states_26[3] = {
{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[1] = {
- {72, 1},
+ {71, 1},
};
static arc arcs_27_1[1] = {
- {21, 2},
+ {72, 2},
};
static arc arcs_27_2[2] = {
- {22, 3},
+ {73, 3},
{0, 2},
};
static arc arcs_27_3[1] = {
{21, 4},
};
-static arc arcs_27_4[1] = {
+static arc arcs_27_4[2] = {
+ {22, 5},
{0, 4},
};
-static state states_27[5] = {
+static arc arcs_27_5[1] = {
+ {21, 6},
+};
+static arc arcs_27_6[1] = {
+ {0, 6},
+};
+static state states_27[7] = {
{1, arcs_27_0},
{1, arcs_27_1},
{2, arcs_27_2},
{1, arcs_27_3},
- {1, arcs_27_4},
+ {2, arcs_27_4},
+ {1, arcs_27_5},
+ {1, arcs_27_6},
};
-static arc arcs_28_0[6] = {
- {73, 1},
+static arc arcs_28_0[1] = {
{74, 1},
- {75, 1},
- {76, 1},
- {10, 1},
- {77, 1},
};
static arc arcs_28_1[1] = {
- {0, 1},
-};
-static state states_28[2] = {
- {6, arcs_28_0},
- {1, arcs_28_1},
-};
-static arc arcs_29_0[1] = {
- {78, 1},
-};
-static arc arcs_29_1[1] = {
{21, 2},
};
-static arc arcs_29_2[1] = {
- {14, 3},
+static arc arcs_28_2[2] = {
+ {22, 3},
+ {0, 2},
};
-static arc arcs_29_3[1] = {
- {15, 4},
+static arc arcs_28_3[1] = {
+ {21, 4},
};
-static arc arcs_29_4[3] = {
- {79, 1},
- {80, 5},
+static arc arcs_28_4[1] = {
{0, 4},
};
-static arc arcs_29_5[1] = {
- {14, 6},
+static state states_28[5] = {
+ {1, arcs_28_0},
+ {1, arcs_28_1},
+ {2, arcs_28_2},
+ {1, arcs_28_3},
+ {1, arcs_28_4},
};
-static arc arcs_29_6[1] = {
- {15, 7},
+static arc arcs_29_0[6] = {
+ {75, 1},
+ {76, 1},
+ {77, 1},
+ {78, 1},
+ {10, 1},
+ {79, 1},
};
-static arc arcs_29_7[1] = {
- {0, 7},
+static arc arcs_29_1[1] = {
+ {0, 1},
};
-static state states_29[8] = {
- {1, arcs_29_0},
+static state states_29[2] = {
+ {6, arcs_29_0},
{1, arcs_29_1},
- {1, arcs_29_2},
- {1, arcs_29_3},
- {3, arcs_29_4},
- {1, arcs_29_5},
- {1, arcs_29_6},
- {1, arcs_29_7},
};
static arc arcs_30_0[1] = {
- {81, 1},
+ {80, 1},
};
static arc arcs_30_1[1] = {
{21, 2},
@@ -646,8 +625,9 @@ static arc arcs_30_2[1] = {
static arc arcs_30_3[1] = {
{15, 4},
};
-static arc arcs_30_4[2] = {
- {80, 5},
+static arc arcs_30_4[3] = {
+ {81, 1},
+ {82, 5},
{0, 4},
};
static arc arcs_30_5[1] = {
@@ -664,83 +644,73 @@ static state states_30[8] = {
{1, arcs_30_1},
{1, arcs_30_2},
{1, arcs_30_3},
- {2, arcs_30_4},
+ {3, arcs_30_4},
{1, arcs_30_5},
{1, arcs_30_6},
{1, arcs_30_7},
};
static arc arcs_31_0[1] = {
- {82, 1},
+ {83, 1},
};
static arc arcs_31_1[1] = {
- {52, 2},
+ {21, 2},
};
static arc arcs_31_2[1] = {
- {71, 3},
+ {14, 3},
};
static arc arcs_31_3[1] = {
- {9, 4},
+ {15, 4},
};
-static arc arcs_31_4[1] = {
- {14, 5},
+static arc arcs_31_4[2] = {
+ {82, 5},
+ {0, 4},
};
static arc arcs_31_5[1] = {
- {15, 6},
+ {14, 6},
};
-static arc arcs_31_6[2] = {
- {80, 7},
- {0, 6},
+static arc arcs_31_6[1] = {
+ {15, 7},
};
static arc arcs_31_7[1] = {
- {14, 8},
-};
-static arc arcs_31_8[1] = {
- {15, 9},
-};
-static arc arcs_31_9[1] = {
- {0, 9},
+ {0, 7},
};
-static state states_31[10] = {
+static state states_31[8] = {
{1, arcs_31_0},
{1, arcs_31_1},
{1, arcs_31_2},
{1, arcs_31_3},
- {1, arcs_31_4},
+ {2, arcs_31_4},
{1, arcs_31_5},
- {2, arcs_31_6},
+ {1, arcs_31_6},
{1, arcs_31_7},
- {1, arcs_31_8},
- {1, arcs_31_9},
};
static arc arcs_32_0[1] = {
- {83, 1},
+ {84, 1},
};
static arc arcs_32_1[1] = {
- {14, 2},
+ {52, 2},
};
static arc arcs_32_2[1] = {
- {15, 3},
+ {73, 3},
};
-static arc arcs_32_3[2] = {
- {84, 4},
- {85, 5},
+static arc arcs_32_3[1] = {
+ {9, 4},
};
static arc arcs_32_4[1] = {
- {14, 6},
+ {14, 5},
};
static arc arcs_32_5[1] = {
- {14, 7},
+ {15, 6},
};
-static arc arcs_32_6[1] = {
- {15, 8},
+static arc arcs_32_6[2] = {
+ {82, 7},
+ {0, 6},
};
static arc arcs_32_7[1] = {
- {15, 9},
+ {14, 8},
};
-static arc arcs_32_8[3] = {
- {84, 4},
- {80, 5},
- {0, 8},
+static arc arcs_32_8[1] = {
+ {15, 9},
};
static arc arcs_32_9[1] = {
{0, 9},
@@ -749,157 +719,191 @@ static state states_32[10] = {
{1, arcs_32_0},
{1, arcs_32_1},
{1, arcs_32_2},
- {2, arcs_32_3},
+ {1, arcs_32_3},
{1, arcs_32_4},
{1, arcs_32_5},
- {1, arcs_32_6},
+ {2, arcs_32_6},
{1, arcs_32_7},
- {3, arcs_32_8},
+ {1, arcs_32_8},
{1, arcs_32_9},
};
static arc arcs_33_0[1] = {
- {86, 1},
+ {85, 1},
};
-static arc arcs_33_1[2] = {
- {21, 2},
- {0, 1},
+static arc arcs_33_1[1] = {
+ {14, 2},
};
-static arc arcs_33_2[2] = {
- {22, 3},
- {0, 2},
+static arc arcs_33_2[1] = {
+ {15, 3},
};
-static arc arcs_33_3[1] = {
- {21, 4},
+static arc arcs_33_3[2] = {
+ {86, 4},
+ {87, 5},
};
static arc arcs_33_4[1] = {
- {0, 4},
+ {14, 6},
};
-static state states_33[5] = {
+static arc arcs_33_5[1] = {
+ {14, 7},
+};
+static arc arcs_33_6[1] = {
+ {15, 8},
+};
+static arc arcs_33_7[1] = {
+ {15, 9},
+};
+static arc arcs_33_8[3] = {
+ {86, 4},
+ {82, 5},
+ {0, 8},
+};
+static arc arcs_33_9[1] = {
+ {0, 9},
+};
+static state states_33[10] = {
{1, arcs_33_0},
- {2, arcs_33_1},
- {2, arcs_33_2},
- {1, arcs_33_3},
+ {1, arcs_33_1},
+ {1, arcs_33_2},
+ {2, arcs_33_3},
{1, 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[2] = {
- {3, 1},
- {2, 2},
+static arc arcs_34_0[1] = {
+ {88, 1},
};
-static arc arcs_34_1[1] = {
+static arc arcs_34_1[2] = {
+ {21, 2},
{0, 1},
};
-static arc arcs_34_2[1] = {
- {87, 3},
+static arc arcs_34_2[2] = {
+ {22, 3},
+ {0, 2},
};
static arc arcs_34_3[1] = {
- {6, 4},
+ {21, 4},
};
-static arc arcs_34_4[2] = {
- {6, 4},
- {88, 1},
+static arc arcs_34_4[1] = {
+ {0, 4},
};
static state states_34[5] = {
- {2, arcs_34_0},
- {1, arcs_34_1},
- {1, arcs_34_2},
+ {1, arcs_34_0},
+ {2, arcs_34_1},
+ {2, arcs_34_2},
{1, arcs_34_3},
- {2, arcs_34_4},
+ {1, arcs_34_4},
};
static arc arcs_35_0[2] = {
- {89, 1},
- {91, 2},
+ {3, 1},
+ {2, 2},
};
-static arc arcs_35_1[2] = {
- {90, 3},
+static arc arcs_35_1[1] = {
{0, 1},
};
static arc arcs_35_2[1] = {
- {0, 2},
+ {89, 3},
};
static arc arcs_35_3[1] = {
- {89, 1},
+ {6, 4},
+};
+static arc arcs_35_4[2] = {
+ {6, 4},
+ {90, 1},
};
-static state states_35[4] = {
+static state states_35[5] = {
{2, arcs_35_0},
- {2, arcs_35_1},
+ {1, arcs_35_1},
{1, arcs_35_2},
{1, arcs_35_3},
+ {2, arcs_35_4},
};
-static arc arcs_36_0[1] = {
- {92, 1},
+static arc arcs_36_0[2] = {
+ {91, 1},
+ {93, 2},
};
static arc arcs_36_1[2] = {
- {93, 0},
+ {92, 3},
{0, 1},
};
-static state states_36[2] = {
- {1, arcs_36_0},
+static arc arcs_36_2[1] = {
+ {0, 2},
+};
+static arc arcs_36_3[1] = {
+ {91, 1},
+};
+static state states_36[4] = {
+ {2, arcs_36_0},
{2, arcs_36_1},
+ {1, arcs_36_2},
+ {1, arcs_36_3},
};
-static arc arcs_37_0[2] = {
+static arc arcs_37_0[1] = {
{94, 1},
- {95, 2},
};
-static arc arcs_37_1[1] = {
- {92, 2},
+static arc arcs_37_1[2] = {
+ {95, 0},
+ {0, 1},
+};
+static state states_37[2] = {
+ {1, arcs_37_0},
+ {2, arcs_37_1},
+};
+static arc arcs_38_0[2] = {
+ {96, 1},
+ {97, 2},
};
-static arc arcs_37_2[1] = {
+static arc arcs_38_1[1] = {
+ {94, 2},
+};
+static arc arcs_38_2[1] = {
{0, 2},
};
-static state states_37[3] = {
- {2, arcs_37_0},
- {1, arcs_37_1},
- {1, arcs_37_2},
+static state states_38[3] = {
+ {2, arcs_38_0},
+ {1, arcs_38_1},
+ {1, arcs_38_2},
};
-static arc arcs_38_0[1] = {
- {70, 1},
+static arc arcs_39_0[1] = {
+ {72, 1},
};
-static arc arcs_38_1[2] = {
- {96, 0},
+static arc arcs_39_1[2] = {
+ {98, 0},
{0, 1},
};
-static state states_38[2] = {
- {1, arcs_38_0},
- {2, arcs_38_1},
+static state states_39[2] = {
+ {1, arcs_39_0},
+ {2, arcs_39_1},
};
-static arc arcs_39_0[10] = {
- {97, 1},
- {98, 1},
+static arc arcs_40_0[10] = {
{99, 1},
{100, 1},
{101, 1},
{102, 1},
{103, 1},
- {71, 1},
- {94, 2},
- {104, 3},
+ {104, 1},
+ {105, 1},
+ {73, 1},
+ {96, 2},
+ {106, 3},
};
-static arc arcs_39_1[1] = {
+static arc arcs_40_1[1] = {
{0, 1},
};
-static arc arcs_39_2[1] = {
- {71, 1},
+static arc arcs_40_2[1] = {
+ {73, 1},
};
-static arc arcs_39_3[2] = {
- {94, 1},
+static arc arcs_40_3[2] = {
+ {96, 1},
{0, 3},
};
-static state states_39[4] = {
- {10, arcs_39_0},
- {1, arcs_39_1},
- {1, arcs_39_2},
- {2, arcs_39_3},
-};
-static arc arcs_40_0[1] = {
- {105, 1},
-};
-static arc arcs_40_1[2] = {
- {106, 0},
- {0, 1},
-};
-static state states_40[2] = {
- {1, arcs_40_0},
- {2, arcs_40_1},
+static state states_40[4] = {
+ {10, arcs_40_0},
+ {1, arcs_40_1},
+ {1, arcs_40_2},
+ {2, arcs_40_3},
};
static arc arcs_41_0[1] = {
{107, 1},
@@ -926,21 +930,20 @@ static state states_42[2] = {
static arc arcs_43_0[1] = {
{111, 1},
};
-static arc arcs_43_1[3] = {
+static arc arcs_43_1[2] = {
{112, 0},
- {50, 0},
{0, 1},
};
static state states_43[2] = {
{1, arcs_43_0},
- {3, arcs_43_1},
+ {2, arcs_43_1},
};
static arc arcs_44_0[1] = {
{113, 1},
};
static arc arcs_44_1[3] = {
{114, 0},
- {115, 0},
+ {50, 0},
{0, 1},
};
static state states_44[2] = {
@@ -948,286 +951,282 @@ static state states_44[2] = {
{3, arcs_44_1},
};
static arc arcs_45_0[1] = {
- {116, 1},
+ {115, 1},
};
-static arc arcs_45_1[4] = {
- {23, 0},
+static arc arcs_45_1[3] = {
+ {116, 0},
{117, 0},
- {118, 0},
{0, 1},
};
static state states_45[2] = {
{1, arcs_45_0},
- {4, arcs_45_1},
+ {3, arcs_45_1},
};
-static arc arcs_46_0[4] = {
- {114, 1},
- {115, 1},
- {119, 1},
- {120, 2},
+static arc arcs_46_0[1] = {
+ {118, 1},
};
-static arc arcs_46_1[1] = {
- {116, 2},
+static arc arcs_46_1[4] = {
+ {23, 0},
+ {119, 0},
+ {120, 0},
+ {0, 1},
+};
+static state states_46[2] = {
+ {1, arcs_46_0},
+ {4, arcs_46_1},
};
-static arc arcs_46_2[1] = {
+static arc arcs_47_0[4] = {
+ {116, 1},
+ {117, 1},
+ {121, 1},
+ {122, 2},
+};
+static arc arcs_47_1[1] = {
+ {118, 2},
+};
+static arc arcs_47_2[1] = {
{0, 2},
};
-static state states_46[3] = {
- {4, arcs_46_0},
- {1, arcs_46_1},
- {1, arcs_46_2},
+static state states_47[3] = {
+ {4, arcs_47_0},
+ {1, arcs_47_1},
+ {1, arcs_47_2},
};
-static arc arcs_47_0[1] = {
- {121, 1},
+static arc arcs_48_0[1] = {
+ {123, 1},
};
-static arc arcs_47_1[3] = {
- {122, 1},
+static arc arcs_48_1[3] = {
+ {124, 1},
{24, 2},
{0, 1},
};
-static arc arcs_47_2[1] = {
- {116, 3},
+static arc arcs_48_2[1] = {
+ {118, 3},
};
-static arc arcs_47_3[2] = {
+static arc arcs_48_3[2] = {
{24, 2},
{0, 3},
};
-static state states_47[4] = {
- {1, arcs_47_0},
- {3, arcs_47_1},
- {1, arcs_47_2},
- {2, arcs_47_3},
+static state states_48[4] = {
+ {1, arcs_48_0},
+ {3, arcs_48_1},
+ {1, arcs_48_2},
+ {2, arcs_48_3},
};
-static arc arcs_48_0[7] = {
+static arc arcs_49_0[7] = {
{16, 1},
- {123, 2},
- {126, 3},
- {129, 4},
+ {125, 2},
+ {128, 3},
+ {131, 4},
{12, 5},
- {130, 5},
- {131, 6},
+ {132, 5},
+ {133, 6},
};
-static arc arcs_48_1[2] = {
+static arc arcs_49_1[2] = {
{9, 7},
{18, 5},
};
-static arc arcs_48_2[2] = {
- {124, 8},
- {125, 5},
+static arc arcs_49_2[2] = {
+ {126, 8},
+ {127, 5},
};
-static arc arcs_48_3[2] = {
- {127, 9},
- {128, 5},
+static arc arcs_49_3[2] = {
+ {129, 9},
+ {130, 5},
};
-static arc arcs_48_4[1] = {
+static arc arcs_49_4[1] = {
{9, 10},
};
-static arc arcs_48_5[1] = {
+static arc arcs_49_5[1] = {
{0, 5},
};
-static arc arcs_48_6[2] = {
- {131, 6},
+static arc arcs_49_6[2] = {
+ {133, 6},
{0, 6},
};
-static arc arcs_48_7[1] = {
+static arc arcs_49_7[1] = {
{18, 5},
};
-static arc arcs_48_8[1] = {
- {125, 5},
+static arc arcs_49_8[1] = {
+ {127, 5},
};
-static arc arcs_48_9[1] = {
- {128, 5},
+static arc arcs_49_9[1] = {
+ {130, 5},
};
-static arc arcs_48_10[1] = {
- {129, 5},
+static arc arcs_49_10[1] = {
+ {131, 5},
};
-static state states_48[11] = {
- {7, arcs_48_0},
- {2, arcs_48_1},
- {2, arcs_48_2},
- {2, arcs_48_3},
- {1, arcs_48_4},
- {1, arcs_48_5},
- {2, arcs_48_6},
- {1, arcs_48_7},
- {1, arcs_48_8},
- {1, arcs_48_9},
- {1, arcs_48_10},
-};
-static arc arcs_49_0[1] = {
+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 arc arcs_50_0[1] = {
{21, 1},
};
-static arc arcs_49_1[3] = {
- {132, 2},
+static arc arcs_50_1[3] = {
+ {134, 2},
{22, 3},
{0, 1},
};
-static arc arcs_49_2[1] = {
+static arc arcs_50_2[1] = {
{0, 2},
};
-static arc arcs_49_3[2] = {
+static arc arcs_50_3[2] = {
{21, 4},
{0, 3},
};
-static arc arcs_49_4[2] = {
+static arc arcs_50_4[2] = {
{22, 3},
{0, 4},
};
-static state states_49[5] = {
- {1, arcs_49_0},
- {3, arcs_49_1},
- {1, arcs_49_2},
- {2, arcs_49_3},
- {2, arcs_49_4},
+static state states_50[5] = {
+ {1, arcs_50_0},
+ {3, arcs_50_1},
+ {1, arcs_50_2},
+ {2, arcs_50_3},
+ {2, arcs_50_4},
};
-static arc arcs_50_0[1] = {
- {133, 1},
+static arc arcs_51_0[1] = {
+ {135, 1},
};
-static arc arcs_50_1[2] = {
+static arc arcs_51_1[2] = {
{17, 2},
{14, 3},
};
-static arc arcs_50_2[1] = {
+static arc arcs_51_2[1] = {
{14, 3},
};
-static arc arcs_50_3[1] = {
+static arc arcs_51_3[1] = {
{21, 4},
};
-static arc arcs_50_4[1] = {
+static arc arcs_51_4[1] = {
{0, 4},
};
-static state states_50[5] = {
- {1, arcs_50_0},
- {2, arcs_50_1},
- {1, arcs_50_2},
- {1, arcs_50_3},
- {1, arcs_50_4},
+static state states_51[5] = {
+ {1, arcs_51_0},
+ {2, arcs_51_1},
+ {1, arcs_51_2},
+ {1, arcs_51_3},
+ {1, arcs_51_4},
};
-static arc arcs_51_0[3] = {
+static arc arcs_52_0[3] = {
{16, 1},
- {123, 2},
- {67, 3},
+ {125, 2},
+ {69, 3},
};
-static arc arcs_51_1[2] = {
- {134, 4},
+static arc arcs_52_1[2] = {
+ {136, 4},
{18, 5},
};
-static arc arcs_51_2[1] = {
- {135, 6},
+static arc arcs_52_2[1] = {
+ {137, 6},
};
-static arc arcs_51_3[1] = {
+static arc arcs_52_3[1] = {
{12, 5},
};
-static arc arcs_51_4[1] = {
+static arc arcs_52_4[1] = {
{18, 5},
};
-static arc arcs_51_5[1] = {
+static arc arcs_52_5[1] = {
{0, 5},
};
-static arc arcs_51_6[1] = {
- {125, 5},
+static arc arcs_52_6[1] = {
+ {127, 5},
};
-static state states_51[7] = {
- {3, arcs_51_0},
- {2, arcs_51_1},
- {1, arcs_51_2},
- {1, arcs_51_3},
- {1, arcs_51_4},
- {1, arcs_51_5},
- {1, arcs_51_6},
+static state states_52[7] = {
+ {3, arcs_52_0},
+ {2, arcs_52_1},
+ {1, arcs_52_2},
+ {1, arcs_52_3},
+ {1, arcs_52_4},
+ {1, arcs_52_5},
+ {1, arcs_52_6},
};
-static arc arcs_52_0[1] = {
- {136, 1},
+static arc arcs_53_0[1] = {
+ {138, 1},
};
-static arc arcs_52_1[2] = {
+static arc arcs_53_1[2] = {
{22, 2},
{0, 1},
};
-static arc arcs_52_2[2] = {
- {136, 1},
+static arc arcs_53_2[2] = {
+ {138, 1},
{0, 2},
};
-static state states_52[3] = {
- {1, arcs_52_0},
- {2, arcs_52_1},
- {2, arcs_52_2},
+static state states_53[3] = {
+ {1, arcs_53_0},
+ {2, arcs_53_1},
+ {2, arcs_53_2},
};
-static arc arcs_53_0[3] = {
- {67, 1},
+static arc arcs_54_0[3] = {
+ {69, 1},
{21, 2},
{14, 3},
};
-static arc arcs_53_1[1] = {
- {67, 4},
+static arc arcs_54_1[1] = {
+ {69, 4},
};
-static arc arcs_53_2[2] = {
+static arc arcs_54_2[2] = {
{14, 3},
{0, 2},
};
-static arc arcs_53_3[3] = {
+static arc arcs_54_3[3] = {
{21, 5},
- {137, 6},
+ {139, 6},
{0, 3},
};
-static arc arcs_53_4[1] = {
- {67, 6},
+static arc arcs_54_4[1] = {
+ {69, 6},
};
-static arc arcs_53_5[2] = {
- {137, 6},
+static arc arcs_54_5[2] = {
+ {139, 6},
{0, 5},
};
-static arc arcs_53_6[1] = {
+static arc arcs_54_6[1] = {
{0, 6},
};
-static state states_53[7] = {
- {3, arcs_53_0},
- {1, arcs_53_1},
- {2, arcs_53_2},
- {3, arcs_53_3},
- {1, arcs_53_4},
- {2, arcs_53_5},
- {1, arcs_53_6},
-};
-static arc arcs_54_0[1] = {
- {14, 1},
-};
-static arc arcs_54_1[2] = {
- {21, 2},
- {0, 1},
-};
-static arc arcs_54_2[1] = {
- {0, 2},
-};
-static state states_54[3] = {
- {1, arcs_54_0},
- {2, arcs_54_1},
- {1, arcs_54_2},
+static state states_54[7] = {
+ {3, arcs_54_0},
+ {1, arcs_54_1},
+ {2, arcs_54_2},
+ {3, arcs_54_3},
+ {1, arcs_54_4},
+ {2, arcs_54_5},
+ {1, arcs_54_6},
};
static arc arcs_55_0[1] = {
- {70, 1},
+ {14, 1},
};
static arc arcs_55_1[2] = {
- {22, 2},
+ {21, 2},
{0, 1},
};
-static arc arcs_55_2[2] = {
- {70, 1},
+static arc arcs_55_2[1] = {
{0, 2},
};
static state states_55[3] = {
{1, arcs_55_0},
{2, arcs_55_1},
- {2, arcs_55_2},
+ {1, arcs_55_2},
};
static arc arcs_56_0[1] = {
- {21, 1},
+ {72, 1},
};
static arc arcs_56_1[2] = {
{22, 2},
{0, 1},
};
static arc arcs_56_2[2] = {
- {21, 1},
+ {72, 1},
{0, 2},
};
static state states_56[3] = {
@@ -1238,186 +1237,202 @@ static state states_56[3] = {
static arc arcs_57_0[1] = {
{21, 1},
};
-static arc arcs_57_1[1] = {
+static arc arcs_57_1[2] = {
+ {22, 2},
+ {0, 1},
+};
+static arc arcs_57_2[2] = {
+ {21, 1},
+ {0, 2},
+};
+static state states_57[3] = {
+ {1, arcs_57_0},
+ {2, arcs_57_1},
+ {2, arcs_57_2},
+};
+static arc arcs_58_0[1] = {
+ {21, 1},
+};
+static arc arcs_58_1[1] = {
{14, 2},
};
-static arc arcs_57_2[1] = {
+static arc arcs_58_2[1] = {
{21, 3},
};
-static arc arcs_57_3[2] = {
+static arc arcs_58_3[2] = {
{22, 4},
{0, 3},
};
-static arc arcs_57_4[2] = {
+static arc arcs_58_4[2] = {
{21, 1},
{0, 4},
};
-static state states_57[5] = {
- {1, arcs_57_0},
- {1, arcs_57_1},
- {1, arcs_57_2},
- {2, arcs_57_3},
- {2, arcs_57_4},
+static state states_58[5] = {
+ {1, arcs_58_0},
+ {1, arcs_58_1},
+ {1, arcs_58_2},
+ {2, arcs_58_3},
+ {2, arcs_58_4},
};
-static arc arcs_58_0[1] = {
- {138, 1},
+static arc arcs_59_0[1] = {
+ {140, 1},
};
-static arc arcs_58_1[1] = {
+static arc arcs_59_1[1] = {
{12, 2},
};
-static arc arcs_58_2[2] = {
+static arc arcs_59_2[2] = {
{16, 3},
{14, 4},
};
-static arc arcs_58_3[1] = {
+static arc arcs_59_3[1] = {
{9, 5},
};
-static arc arcs_58_4[1] = {
+static arc arcs_59_4[1] = {
{15, 6},
};
-static arc arcs_58_5[1] = {
+static arc arcs_59_5[1] = {
{18, 7},
};
-static arc arcs_58_6[1] = {
+static arc arcs_59_6[1] = {
{0, 6},
};
-static arc arcs_58_7[1] = {
+static arc arcs_59_7[1] = {
{14, 4},
};
-static state states_58[8] = {
- {1, arcs_58_0},
- {1, arcs_58_1},
- {2, arcs_58_2},
- {1, arcs_58_3},
- {1, arcs_58_4},
- {1, arcs_58_5},
- {1, arcs_58_6},
- {1, arcs_58_7},
-};
-static arc arcs_59_0[3] = {
- {139, 1},
+static state states_59[8] = {
+ {1, arcs_59_0},
+ {1, arcs_59_1},
+ {2, arcs_59_2},
+ {1, arcs_59_3},
+ {1, arcs_59_4},
+ {1, arcs_59_5},
+ {1, arcs_59_6},
+ {1, arcs_59_7},
+};
+static arc arcs_60_0[3] = {
+ {141, 1},
{23, 2},
{24, 3},
};
-static arc arcs_59_1[2] = {
+static arc arcs_60_1[2] = {
{22, 4},
{0, 1},
};
-static arc arcs_59_2[1] = {
+static arc arcs_60_2[1] = {
{21, 5},
};
-static arc arcs_59_3[1] = {
+static arc arcs_60_3[1] = {
{21, 6},
};
-static arc arcs_59_4[4] = {
- {139, 1},
+static arc arcs_60_4[4] = {
+ {141, 1},
{23, 2},
{24, 3},
{0, 4},
};
-static arc arcs_59_5[2] = {
+static arc arcs_60_5[2] = {
{22, 7},
{0, 5},
};
-static arc arcs_59_6[1] = {
+static arc arcs_60_6[1] = {
{0, 6},
};
-static arc arcs_59_7[1] = {
+static arc arcs_60_7[1] = {
{24, 3},
};
-static state states_59[8] = {
- {3, arcs_59_0},
- {2, arcs_59_1},
- {1, arcs_59_2},
- {1, arcs_59_3},
- {4, arcs_59_4},
- {2, arcs_59_5},
- {1, arcs_59_6},
- {1, arcs_59_7},
+static state states_60[8] = {
+ {3, arcs_60_0},
+ {2, arcs_60_1},
+ {1, arcs_60_2},
+ {1, arcs_60_3},
+ {4, arcs_60_4},
+ {2, arcs_60_5},
+ {1, arcs_60_6},
+ {1, arcs_60_7},
};
-static arc arcs_60_0[1] = {
+static arc arcs_61_0[1] = {
{21, 1},
};
-static arc arcs_60_1[2] = {
+static arc arcs_61_1[2] = {
{20, 2},
{0, 1},
};
-static arc arcs_60_2[1] = {
+static arc arcs_61_2[1] = {
{21, 3},
};
-static arc arcs_60_3[1] = {
+static arc arcs_61_3[1] = {
{0, 3},
};
-static state states_60[4] = {
- {1, arcs_60_0},
- {2, arcs_60_1},
- {1, arcs_60_2},
- {1, arcs_60_3},
+static state states_61[4] = {
+ {1, arcs_61_0},
+ {2, arcs_61_1},
+ {1, arcs_61_2},
+ {1, arcs_61_3},
};
-static arc arcs_61_0[2] = {
- {132, 1},
- {141, 1},
+static arc arcs_62_0[2] = {
+ {134, 1},
+ {143, 1},
};
-static arc arcs_61_1[1] = {
+static arc arcs_62_1[1] = {
{0, 1},
};
-static state states_61[2] = {
- {2, arcs_61_0},
- {1, arcs_61_1},
+static state states_62[2] = {
+ {2, arcs_62_0},
+ {1, arcs_62_1},
};
-static arc arcs_62_0[1] = {
- {82, 1},
+static arc arcs_63_0[1] = {
+ {84, 1},
};
-static arc arcs_62_1[1] = {
+static arc arcs_63_1[1] = {
{52, 2},
};
-static arc arcs_62_2[1] = {
- {71, 3},
+static arc arcs_63_2[1] = {
+ {73, 3},
};
-static arc arcs_62_3[1] = {
+static arc arcs_63_3[1] = {
{9, 4},
};
-static arc arcs_62_4[2] = {
- {140, 5},
+static arc arcs_63_4[2] = {
+ {142, 5},
{0, 4},
};
-static arc arcs_62_5[1] = {
+static arc arcs_63_5[1] = {
{0, 5},
};
-static state states_62[6] = {
- {1, arcs_62_0},
- {1, arcs_62_1},
- {1, arcs_62_2},
- {1, arcs_62_3},
- {2, arcs_62_4},
- {1, arcs_62_5},
+static state states_63[6] = {
+ {1, arcs_63_0},
+ {1, arcs_63_1},
+ {1, arcs_63_2},
+ {1, arcs_63_3},
+ {2, arcs_63_4},
+ {1, arcs_63_5},
};
-static arc arcs_63_0[1] = {
- {78, 1},
+static arc arcs_64_0[1] = {
+ {80, 1},
};
-static arc arcs_63_1[1] = {
+static arc arcs_64_1[1] = {
{21, 2},
};
-static arc arcs_63_2[2] = {
- {140, 3},
+static arc arcs_64_2[2] = {
+ {142, 3},
{0, 2},
};
-static arc arcs_63_3[1] = {
+static arc arcs_64_3[1] = {
{0, 3},
};
-static state states_63[4] = {
- {1, arcs_63_0},
- {1, arcs_63_1},
- {2, arcs_63_2},
- {1, arcs_63_3},
+static state states_64[4] = {
+ {1, arcs_64_0},
+ {1, arcs_64_1},
+ {2, arcs_64_2},
+ {1, arcs_64_3},
};
-static dfa dfas[64] = {
+static dfa dfas[65] = {
{256, "single_input", 0, 3, states_0,
- "\004\030\001\000\000\000\052\174\061\101\016\100\000\000\214\110\056\004"},
+ "\004\030\001\000\000\000\052\370\305\004\071\000\001\000\060\042\271\020"},
{257, "file_input", 0, 2, states_1,
- "\204\030\001\000\000\000\052\174\061\101\016\100\000\000\214\110\056\004"},
+ "\204\030\001\000\000\000\052\370\305\004\071\000\001\000\060\042\271\020"},
{258, "eval_input", 0, 3, states_2,
- "\000\020\001\000\000\000\000\000\000\000\000\100\000\000\214\110\056\000"},
+ "\000\020\001\000\000\000\000\000\000\000\000\000\001\000\060\042\271\000"},
{259, "funcdef", 0, 6, states_3,
"\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
{260, "parameters", 0, 4, states_4,
@@ -1429,13 +1444,13 @@ static dfa dfas[64] = {
{263, "fplist", 0, 3, states_7,
"\000\020\001\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\052\174\061\101\016\100\000\000\214\110\056\004"},
+ "\000\030\001\000\000\000\052\370\305\004\071\000\001\000\060\042\271\020"},
{265, "simple_stmt", 0, 4, states_9,
- "\000\020\001\000\000\000\052\174\061\001\000\100\000\000\214\110\056\000"},
+ "\000\020\001\000\000\000\052\370\305\004\000\000\001\000\060\042\271\000"},
{266, "small_stmt", 0, 2, states_10,
- "\000\020\001\000\000\000\052\174\061\001\000\100\000\000\214\110\056\000"},
+ "\000\020\001\000\000\000\052\370\305\004\000\000\001\000\060\042\271\000"},
{267, "expr_stmt", 0, 6, states_11,
- "\000\020\001\000\000\000\000\000\000\000\000\100\000\000\214\110\056\000"},
+ "\000\020\001\000\000\000\000\000\000\000\000\000\001\000\060\042\271\000"},
{268, "augassign", 0, 2, states_12,
"\000\000\000\000\300\377\001\000\000\000\000\000\000\000\000\000\000\000"},
{269, "print_stmt", 0, 9, states_13,
@@ -1445,125 +1460,127 @@ static dfa dfas[64] = {
{271, "pass_stmt", 0, 2, states_15,
"\000\000\000\000\000\000\040\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\074\000\000\000\000\000\000\000\000\000\000"},
+ "\000\000\000\000\000\000\000\370\000\000\000\000\000\000\000\000\000\000"},
{273, "break_stmt", 0, 2, states_17,
- "\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000"},
- {274, "continue_stmt", 0, 2, states_18,
"\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000"},
- {275, "return_stmt", 0, 3, states_19,
+ {274, "continue_stmt", 0, 2, states_18,
"\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000"},
- {276, "raise_stmt", 0, 7, states_20,
+ {275, "return_stmt", 0, 3, states_19,
"\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000"},
- {277, "import_stmt", 0, 9, states_21,
- "\000\000\000\000\000\000\000\100\001\000\000\000\000\000\000\000\000\000"},
- {278, "import_as_name", 0, 4, states_22,
+ {276, "yield_stmt", 0, 3, states_20,
+ "\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000"},
+ {277, "raise_stmt", 0, 7, states_21,
+ "\000\000\000\000\000\000\000\200\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\005\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"},
- {279, "dotted_as_name", 0, 4, states_23,
+ {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"},
- {280, "dotted_name", 0, 2, states_24,
+ {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"},
- {281, "global_stmt", 0, 3, states_25,
- "\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000"},
- {282, "exec_stmt", 0, 7, states_26,
- "\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000"},
- {283, "assert_stmt", 0, 5, states_27,
- "\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000"},
- {284, "compound_stmt", 0, 2, states_28,
- "\000\010\000\000\000\000\000\000\000\100\016\000\000\000\000\000\000\004"},
- {285, "if_stmt", 0, 8, states_29,
- "\000\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000"},
- {286, "while_stmt", 0, 8, states_30,
- "\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000"},
- {287, "for_stmt", 0, 10, states_31,
- "\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000"},
- {288, "try_stmt", 0, 10, states_32,
+ {282, "global_stmt", 0, 3, states_26,
+ "\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000"},
+ {283, "exec_stmt", 0, 7, states_27,
+ "\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000"},
+ {284, "assert_stmt", 0, 5, states_28,
+ "\000\000\000\000\000\000\000\000\000\004\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\071\000\000\000\000\000\000\020"},
+ {286, "if_stmt", 0, 8, states_30,
+ "\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000"},
+ {287, "while_stmt", 0, 8, states_31,
"\000\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000"},
- {289, "except_clause", 0, 5, states_33,
- "\000\000\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000"},
- {290, "suite", 0, 5, states_34,
- "\004\020\001\000\000\000\052\174\061\001\000\100\000\000\214\110\056\000"},
- {291, "test", 0, 4, states_35,
- "\000\020\001\000\000\000\000\000\000\000\000\100\000\000\214\110\056\000"},
- {292, "and_test", 0, 2, states_36,
- "\000\020\001\000\000\000\000\000\000\000\000\100\000\000\214\110\016\000"},
- {293, "not_test", 0, 3, states_37,
- "\000\020\001\000\000\000\000\000\000\000\000\100\000\000\214\110\016\000"},
- {294, "comparison", 0, 2, states_38,
- "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\214\110\016\000"},
- {295, "comp_op", 0, 4, states_39,
- "\000\000\000\000\000\000\000\000\200\000\000\100\376\001\000\000\000\000"},
- {296, "expr", 0, 2, states_40,
- "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\214\110\016\000"},
- {297, "xor_expr", 0, 2, states_41,
- "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\214\110\016\000"},
- {298, "and_expr", 0, 2, states_42,
- "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\214\110\016\000"},
- {299, "shift_expr", 0, 2, states_43,
- "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\214\110\016\000"},
- {300, "arith_expr", 0, 2, states_44,
- "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\214\110\016\000"},
- {301, "term", 0, 2, states_45,
- "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\214\110\016\000"},
- {302, "factor", 0, 3, states_46,
- "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\214\110\016\000"},
- {303, "power", 0, 4, states_47,
- "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\000\110\016\000"},
- {304, "atom", 0, 11, states_48,
- "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\000\110\016\000"},
- {305, "listmaker", 0, 5, states_49,
- "\000\020\001\000\000\000\000\000\000\000\000\100\000\000\214\110\056\000"},
- {306, "lambdef", 0, 5, states_50,
- "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\040\000"},
- {307, "trailer", 0, 7, states_51,
- "\000\000\001\000\000\000\000\000\010\000\000\000\000\000\000\010\000\000"},
- {308, "subscriptlist", 0, 3, states_52,
- "\000\120\001\000\000\000\000\000\010\000\000\100\000\000\214\110\056\000"},
- {309, "subscript", 0, 7, states_53,
- "\000\120\001\000\000\000\000\000\010\000\000\100\000\000\214\110\056\000"},
- {310, "sliceop", 0, 3, states_54,
+ {288, "for_stmt", 0, 10, states_32,
+ "\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000"},
+ {289, "try_stmt", 0, 10, states_33,
+ "\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000"},
+ {290, "except_clause", 0, 5, states_34,
+ "\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000"},
+ {291, "suite", 0, 5, states_35,
+ "\004\020\001\000\000\000\052\370\305\004\000\000\001\000\060\042\271\000"},
+ {292, "test", 0, 4, states_36,
+ "\000\020\001\000\000\000\000\000\000\000\000\000\001\000\060\042\271\000"},
+ {293, "and_test", 0, 2, states_37,
+ "\000\020\001\000\000\000\000\000\000\000\000\000\001\000\060\042\071\000"},
+ {294, "not_test", 0, 3, states_38,
+ "\000\020\001\000\000\000\000\000\000\000\000\000\001\000\060\042\071\000"},
+ {295, "comparison", 0, 2, states_39,
+ "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\060\042\071\000"},
+ {296, "comp_op", 0, 4, states_40,
+ "\000\000\000\000\000\000\000\000\000\002\000\000\371\007\000\000\000\000"},
+ {297, "expr", 0, 2, states_41,
+ "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\060\042\071\000"},
+ {298, "xor_expr", 0, 2, states_42,
+ "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\060\042\071\000"},
+ {299, "and_expr", 0, 2, states_43,
+ "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\060\042\071\000"},
+ {300, "shift_expr", 0, 2, states_44,
+ "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\060\042\071\000"},
+ {301, "arith_expr", 0, 2, states_45,
+ "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\060\042\071\000"},
+ {302, "term", 0, 2, states_46,
+ "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\060\042\071\000"},
+ {303, "factor", 0, 3, states_47,
+ "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\060\042\071\000"},
+ {304, "power", 0, 4, states_48,
+ "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\000\040\071\000"},
+ {305, "atom", 0, 11, states_49,
+ "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\000\040\071\000"},
+ {306, "listmaker", 0, 5, states_50,
+ "\000\020\001\000\000\000\000\000\000\000\000\000\001\000\060\042\271\000"},
+ {307, "lambdef", 0, 5, states_51,
+ "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\200\000"},
+ {308, "trailer", 0, 7, states_52,
+ "\000\000\001\000\000\000\000\000\040\000\000\000\000\000\000\040\000\000"},
+ {309, "subscriptlist", 0, 3, states_53,
+ "\000\120\001\000\000\000\000\000\040\000\000\000\001\000\060\042\271\000"},
+ {310, "subscript", 0, 7, states_54,
+ "\000\120\001\000\000\000\000\000\040\000\000\000\001\000\060\042\271\000"},
+ {311, "sliceop", 0, 3, states_55,
"\000\100\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
- {311, "exprlist", 0, 3, states_55,
- "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\214\110\016\000"},
- {312, "testlist", 0, 3, states_56,
- "\000\020\001\000\000\000\000\000\000\000\000\100\000\000\214\110\056\000"},
- {313, "dictmaker", 0, 5, states_57,
- "\000\020\001\000\000\000\000\000\000\000\000\100\000\000\214\110\056\000"},
- {314, "classdef", 0, 8, states_58,
- "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\004"},
- {315, "arglist", 0, 8, states_59,
- "\000\020\201\001\000\000\000\000\000\000\000\100\000\000\214\110\056\000"},
- {316, "argument", 0, 4, states_60,
- "\000\020\001\000\000\000\000\000\000\000\000\100\000\000\214\110\056\000"},
- {317, "list_iter", 0, 2, states_61,
- "\000\000\000\000\000\000\000\000\000\100\004\000\000\000\000\000\000\000"},
- {318, "list_for", 0, 6, states_62,
- "\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000"},
- {319, "list_if", 0, 4, states_63,
- "\000\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000"},
-};
-static label labels[142] = {
+ {312, "exprlist", 0, 3, states_56,
+ "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\060\042\071\000"},
+ {313, "testlist", 0, 3, states_57,
+ "\000\020\001\000\000\000\000\000\000\000\000\000\001\000\060\042\271\000"},
+ {314, "dictmaker", 0, 5, states_58,
+ "\000\020\001\000\000\000\000\000\000\000\000\000\001\000\060\042\271\000"},
+ {315, "classdef", 0, 8, states_59,
+ "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\020"},
+ {316, "arglist", 0, 8, states_60,
+ "\000\020\201\001\000\000\000\000\000\000\000\000\001\000\060\042\271\000"},
+ {317, "argument", 0, 4, states_61,
+ "\000\020\001\000\000\000\000\000\000\000\000\000\001\000\060\042\271\000"},
+ {318, "list_iter", 0, 2, states_62,
+ "\000\000\000\000\000\000\000\000\000\000\021\000\000\000\000\000\000\000"},
+ {319, "list_for", 0, 6, states_63,
+ "\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000"},
+ {320, "list_if", 0, 4, states_64,
+ "\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000"},
+};
+static label labels[144] = {
{0, "EMPTY"},
{256, 0},
{4, 0},
{265, 0},
- {284, 0},
+ {285, 0},
{257, 0},
{264, 0},
{0, 0},
{258, 0},
- {312, 0},
+ {313, 0},
{259, 0},
{1, "def"},
{1, 0},
{260, 0},
{11, 0},
- {290, 0},
+ {291, 0},
{7, 0},
{261, 0},
{8, 0},
{262, 0},
{22, 0},
- {291, 0},
+ {292, 0},
{12, 0},
{16, 0},
{36, 0},
@@ -1575,10 +1592,10 @@ static label labels[142] = {
{270, 0},
{271, 0},
{272, 0},
- {277, 0},
- {281, 0},
+ {278, 0},
{282, 0},
{283, 0},
+ {284, 0},
{268, 0},
{37, 0},
{38, 0},
@@ -1594,51 +1611,53 @@ static label labels[142] = {
{1, "print"},
{35, 0},
{1, "del"},
- {311, 0},
+ {312, 0},
{1, "pass"},
{273, 0},
{274, 0},
{275, 0},
+ {277, 0},
{276, 0},
{1, "break"},
{1, "continue"},
{1, "return"},
+ {1, "yield"},
{1, "raise"},
{1, "import"},
- {279, 0},
- {1, "from"},
{280, 0},
- {278, 0},
+ {1, "from"},
+ {281, 0},
+ {279, 0},
{23, 0},
{1, "global"},
{1, "exec"},
- {296, 0},
+ {297, 0},
{1, "in"},
{1, "assert"},
- {285, 0},
{286, 0},
{287, 0},
{288, 0},
- {314, 0},
+ {289, 0},
+ {315, 0},
{1, "if"},
{1, "elif"},
{1, "else"},
{1, "while"},
{1, "for"},
{1, "try"},
- {289, 0},
+ {290, 0},
{1, "finally"},
{1, "except"},
{5, 0},
{6, 0},
- {292, 0},
- {1, "or"},
- {306, 0},
{293, 0},
+ {1, "or"},
+ {307, 0},
+ {294, 0},
{1, "and"},
{1, "not"},
- {294, 0},
{295, 0},
+ {296, 0},
{20, 0},
{21, 0},
{28, 0},
@@ -1647,47 +1666,47 @@ static label labels[142] = {
{29, 0},
{29, 0},
{1, "is"},
- {297, 0},
- {18, 0},
{298, 0},
- {33, 0},
+ {18, 0},
{299, 0},
- {19, 0},
+ {33, 0},
{300, 0},
- {34, 0},
+ {19, 0},
{301, 0},
+ {34, 0},
+ {302, 0},
{14, 0},
{15, 0},
- {302, 0},
+ {303, 0},
{17, 0},
{24, 0},
{32, 0},
- {303, 0},
{304, 0},
- {307, 0},
- {9, 0},
{305, 0},
+ {308, 0},
+ {9, 0},
+ {306, 0},
{10, 0},
{26, 0},
- {313, 0},
+ {314, 0},
{27, 0},
{25, 0},
{2, 0},
{3, 0},
- {318, 0},
+ {319, 0},
{1, "lambda"},
- {315, 0},
- {308, 0},
+ {316, 0},
{309, 0},
{310, 0},
+ {311, 0},
{1, "class"},
- {316, 0},
{317, 0},
- {319, 0},
+ {318, 0},
+ {320, 0},
};
grammar _PyParser_Grammar = {
- 64,
+ 65,
dfas,
- {142, labels},
+ {144, labels},
256
};
diff --git a/Python/marshal.c b/Python/marshal.c
index 7cd84f6..008659d 100644
--- a/Python/marshal.c
+++ b/Python/marshal.c
@@ -17,6 +17,7 @@
#define TYPE_NULL '0'
#define TYPE_NONE 'N'
+#define TYPE_STOPITER 'S'
#define TYPE_ELLIPSIS '.'
#define TYPE_INT 'i'
#define TYPE_INT64 'I'
@@ -120,6 +121,9 @@ w_object(PyObject *v, WFILE *p)
else if (v == Py_None) {
w_byte(TYPE_NONE, p);
}
+ else if (v == PyExc_StopIteration) {
+ w_byte(TYPE_STOPITER, p);
+ }
else if (v == Py_Ellipsis) {
w_byte(TYPE_ELLIPSIS, p);
}
@@ -376,6 +380,10 @@ r_object(RFILE *p)
Py_INCREF(Py_None);
return Py_None;
+ case TYPE_STOPITER:
+ Py_INCREF(PyExc_StopIteration);
+ return PyExc_StopIteration;
+
case TYPE_ELLIPSIS:
Py_INCREF(Py_Ellipsis);
return Py_Ellipsis;
diff --git a/Python/symtable.c b/Python/symtable.c
index aed8908..e115167 100644
--- a/Python/symtable.c
+++ b/Python/symtable.c
@@ -69,6 +69,7 @@ PySymtableEntry_New(struct symtable *st, char *name, int type, int lineno)
else
ste->ste_nested = 0;
ste->ste_child_free = 0;
+ ste->ste_generator = 0;
if (PyDict_SetItem(st->st_symbols, ste->ste_id, (PyObject *)ste) < 0)
goto fail;