comparison Python/Python-ast.c @ 41717:9ad84070b22d

Merged revisions 55328-55341 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/p3yk ........ r55329 | brett.cannon | 2007-05-14 16:36:56 -0700 (Mon, 14 May 2007) | 3 lines Implement the removal of tuple parameter unpacking (PEP 3113). Thanks, Tony Lownds for the patch. ........ r55331 | neal.norwitz | 2007-05-14 16:40:30 -0700 (Mon, 14 May 2007) | 1 line Update to use Python 3.0 ........ r55332 | brett.cannon | 2007-05-14 16:47:18 -0700 (Mon, 14 May 2007) | 2 lines Mention PEP 3113. And thanks to Tony Lownds for the PEP 3113 patch. ........ r55333 | neal.norwitz | 2007-05-14 16:57:06 -0700 (Mon, 14 May 2007) | 1 line Fix exception printing (no more exceptions module) ........ r55334 | neal.norwitz | 2007-05-14 17:11:10 -0700 (Mon, 14 May 2007) | 1 line Remove popen* functions from os ........ r55335 | neal.norwitz | 2007-05-14 18:03:38 -0700 (Mon, 14 May 2007) | 1 line Get rid of most of popen. There are still some uses I need to cleanup. ........ r55336 | neal.norwitz | 2007-05-14 21:11:34 -0700 (Mon, 14 May 2007) | 1 line Remove a few more remnants of the compiler package ........ r55337 | neal.norwitz | 2007-05-14 22:28:27 -0700 (Mon, 14 May 2007) | 1 line Get test_[cx]pickle working on 64-bit platforms (avoid overflow int/long) ........
author Guido van Rossum <guido@python.org>
date Tue, 15 May 2007 18:46:22 +0000
parents e16c8e5c5ca4
children d3cd2920beb6
comparison
equal deleted inserted replaced
41716:00c02c4488ce 41717:9ad84070b22d
1 /* File automatically generated by Parser/asdl_c.py. */ 1 /* File automatically generated by Parser/asdl_c.py. */
2 2
3 3
4 /* 4 /*
5 __version__ 54835. 5 __version__ 55270.
6 6
7 This module must be committed separately after each AST grammar change; 7 This module must be committed separately after each AST grammar change;
8 The __version__ number is set to the revision number of the commit 8 The __version__ number is set to the revision number of the commit
9 containing the grammar change. 9 containing the grammar change.
10 */ 10 */
365 "defaults", 365 "defaults",
366 "kw_defaults", 366 "kw_defaults",
367 }; 367 };
368 static PyTypeObject *arg_type; 368 static PyTypeObject *arg_type;
369 static PyObject* ast2obj_arg(void*); 369 static PyObject* ast2obj_arg(void*);
370 static PyTypeObject *SimpleArg_type; 370 static char *arg_fields[]={
371 static char *SimpleArg_fields[]={
372 "arg", 371 "arg",
373 "annotation", 372 "annotation",
374 };
375 static PyTypeObject *NestedArgs_type;
376 static char *NestedArgs_fields[]={
377 "args",
378 }; 373 };
379 static PyTypeObject *keyword_type; 374 static PyTypeObject *keyword_type;
380 static PyObject* ast2obj_keyword(void*); 375 static PyObject* ast2obj_keyword(void*);
381 static char *keyword_fields[]={ 376 static char *keyword_fields[]={
382 "arg", 377 "arg",
750 excepthandler_type = make_type("excepthandler", AST_type, 745 excepthandler_type = make_type("excepthandler", AST_type,
751 excepthandler_fields, 5); 746 excepthandler_fields, 5);
752 if (!excepthandler_type) return 0; 747 if (!excepthandler_type) return 0;
753 arguments_type = make_type("arguments", AST_type, arguments_fields, 8); 748 arguments_type = make_type("arguments", AST_type, arguments_fields, 8);
754 if (!arguments_type) return 0; 749 if (!arguments_type) return 0;
755 arg_type = make_type("arg", AST_type, NULL, 0); 750 arg_type = make_type("arg", AST_type, arg_fields, 2);
756 if (!arg_type) return 0; 751 if (!arg_type) return 0;
757 if (!add_attributes(arg_type, NULL, 0)) return 0;
758 SimpleArg_type = make_type("SimpleArg", arg_type, SimpleArg_fields, 2);
759 if (!SimpleArg_type) return 0;
760 NestedArgs_type = make_type("NestedArgs", arg_type, NestedArgs_fields,
761 1);
762 if (!NestedArgs_type) return 0;
763 keyword_type = make_type("keyword", AST_type, keyword_fields, 2); 752 keyword_type = make_type("keyword", AST_type, keyword_fields, 2);
764 if (!keyword_type) return 0; 753 if (!keyword_type) return 0;
765 alias_type = make_type("alias", AST_type, alias_fields, 2); 754 alias_type = make_type("alias", AST_type, alias_fields, 2);
766 if (!alias_type) return 0; 755 if (!alias_type) return 0;
767 initialized = 1; 756 initialized = 1;
1863 p->kw_defaults = kw_defaults; 1852 p->kw_defaults = kw_defaults;
1864 return p; 1853 return p;
1865 } 1854 }
1866 1855
1867 arg_ty 1856 arg_ty
1868 SimpleArg(identifier arg, expr_ty annotation, PyArena *arena) 1857 arg(identifier arg, expr_ty annotation, PyArena *arena)
1869 { 1858 {
1870 arg_ty p; 1859 arg_ty p;
1871 if (!arg) { 1860 if (!arg) {
1872 PyErr_SetString(PyExc_ValueError, 1861 PyErr_SetString(PyExc_ValueError,
1873 "field arg is required for SimpleArg"); 1862 "field arg is required for arg");
1874 return NULL; 1863 return NULL;
1875 } 1864 }
1876 p = (arg_ty)PyArena_Malloc(arena, sizeof(*p)); 1865 p = (arg_ty)PyArena_Malloc(arena, sizeof(*p));
1877 if (!p) 1866 if (!p)
1878 return NULL; 1867 return NULL;
1879 p->kind = SimpleArg_kind; 1868 p->arg = arg;
1880 p->v.SimpleArg.arg = arg; 1869 p->annotation = annotation;
1881 p->v.SimpleArg.annotation = annotation;
1882 return p;
1883 }
1884
1885 arg_ty
1886 NestedArgs(asdl_seq * args, PyArena *arena)
1887 {
1888 arg_ty p;
1889 p = (arg_ty)PyArena_Malloc(arena, sizeof(*p));
1890 if (!p)
1891 return NULL;
1892 p->kind = NestedArgs_kind;
1893 p->v.NestedArgs.args = args;
1894 return p; 1870 return p;
1895 } 1871 }
1896 1872
1897 keyword_ty 1873 keyword_ty
1898 keyword(identifier arg, expr_ty value, PyArena *arena) 1874 keyword(identifier arg, expr_ty value, PyArena *arena)
3046 if (!o) { 3022 if (!o) {
3047 Py_INCREF(Py_None); 3023 Py_INCREF(Py_None);
3048 return Py_None; 3024 return Py_None;
3049 } 3025 }
3050 3026
3051 switch (o->kind) { 3027 result = PyType_GenericNew(arg_type, NULL, NULL);
3052 case SimpleArg_kind: 3028 if (!result) return NULL;
3053 result = PyType_GenericNew(SimpleArg_type, NULL, NULL); 3029 value = ast2obj_identifier(o->arg);
3054 if (!result) goto failed; 3030 if (!value) goto failed;
3055 value = ast2obj_identifier(o->v.SimpleArg.arg); 3031 if (PyObject_SetAttrString(result, "arg", value) == -1)
3056 if (!value) goto failed; 3032 goto failed;
3057 if (PyObject_SetAttrString(result, "arg", value) == -1) 3033 Py_DECREF(value);
3058 goto failed; 3034 value = ast2obj_expr(o->annotation);
3059 Py_DECREF(value); 3035 if (!value) goto failed;
3060 value = ast2obj_expr(o->v.SimpleArg.annotation); 3036 if (PyObject_SetAttrString(result, "annotation", value) == -1)
3061 if (!value) goto failed; 3037 goto failed;
3062 if (PyObject_SetAttrString(result, "annotation", value) == -1) 3038 Py_DECREF(value);
3063 goto failed;
3064 Py_DECREF(value);
3065 break;
3066 case NestedArgs_kind:
3067 result = PyType_GenericNew(NestedArgs_type, NULL, NULL);
3068 if (!result) goto failed;
3069 value = ast2obj_list(o->v.NestedArgs.args, ast2obj_arg);
3070 if (!value) goto failed;
3071 if (PyObject_SetAttrString(result, "args", value) == -1)
3072 goto failed;
3073 Py_DECREF(value);
3074 break;
3075 }
3076 return result; 3039 return result;
3077 failed: 3040 failed:
3078 Py_XDECREF(value); 3041 Py_XDECREF(value);
3079 Py_XDECREF(result); 3042 Py_XDECREF(result);
3080 return NULL; 3043 return NULL;
3148 if (!m) return; 3111 if (!m) return;
3149 d = PyModule_GetDict(m); 3112 d = PyModule_GetDict(m);
3150 if (PyDict_SetItemString(d, "AST", (PyObject*)AST_type) < 0) return; 3113 if (PyDict_SetItemString(d, "AST", (PyObject*)AST_type) < 0) return;
3151 if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0) 3114 if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0)
3152 return; 3115 return;
3153 if (PyModule_AddStringConstant(m, "__version__", "54835") < 0) 3116 if (PyModule_AddStringConstant(m, "__version__", "55270") < 0)
3154 return; 3117 return;
3155 if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return; 3118 if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return;
3156 if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0) 3119 if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0)
3157 return; 3120 return;
3158 if (PyDict_SetItemString(d, "Interactive", (PyObject*)Interactive_type) 3121 if (PyDict_SetItemString(d, "Interactive", (PyObject*)Interactive_type)
3293 if (PyDict_SetItemString(d, "excepthandler", 3256 if (PyDict_SetItemString(d, "excepthandler",
3294 (PyObject*)excepthandler_type) < 0) return; 3257 (PyObject*)excepthandler_type) < 0) return;
3295 if (PyDict_SetItemString(d, "arguments", (PyObject*)arguments_type) < 3258 if (PyDict_SetItemString(d, "arguments", (PyObject*)arguments_type) <
3296 0) return; 3259 0) return;
3297 if (PyDict_SetItemString(d, "arg", (PyObject*)arg_type) < 0) return; 3260 if (PyDict_SetItemString(d, "arg", (PyObject*)arg_type) < 0) return;
3298 if (PyDict_SetItemString(d, "SimpleArg", (PyObject*)SimpleArg_type) <
3299 0) return;
3300 if (PyDict_SetItemString(d, "NestedArgs", (PyObject*)NestedArgs_type) <
3301 0) return;
3302 if (PyDict_SetItemString(d, "keyword", (PyObject*)keyword_type) < 0) 3261 if (PyDict_SetItemString(d, "keyword", (PyObject*)keyword_type) < 0)
3303 return; 3262 return;
3304 if (PyDict_SetItemString(d, "alias", (PyObject*)alias_type) < 0) return; 3263 if (PyDict_SetItemString(d, "alias", (PyObject*)alias_type) < 0) return;
3305 } 3264 }
3306 3265