Mercurial > cpython-lru_cache-weakref
comparison Python/Python-ast.c @ 40894:0ea24f4f2467
Bytes literal.
| author | Thomas Wouters <thomas@python.org> |
|---|---|
| date | Fri, 23 Feb 2007 19:56:57 +0000 |
| parents | 32c4897b5d46 |
| children | b05790d066b4 |
comparison
equal
deleted
inserted
replaced
| 40893:32c4897b5d46 | 40894:0ea24f4f2467 |
|---|---|
| 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__ 53731. | 5 __version__ 53866. |
| 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 */ |
| 212 static char *Num_fields[]={ | 212 static char *Num_fields[]={ |
| 213 "n", | 213 "n", |
| 214 }; | 214 }; |
| 215 static PyTypeObject *Str_type; | 215 static PyTypeObject *Str_type; |
| 216 static char *Str_fields[]={ | 216 static char *Str_fields[]={ |
| 217 "s", | |
| 218 }; | |
| 219 static PyTypeObject *Bytes_type; | |
| 220 static char *Bytes_fields[]={ | |
| 217 "s", | 221 "s", |
| 218 }; | 222 }; |
| 219 static PyTypeObject *Ellipsis_type; | 223 static PyTypeObject *Ellipsis_type; |
| 220 static PyTypeObject *Attribute_type; | 224 static PyTypeObject *Attribute_type; |
| 221 static char *Attribute_fields[]={ | 225 static char *Attribute_fields[]={ |
| 545 if (!Call_type) return 0; | 549 if (!Call_type) return 0; |
| 546 Num_type = make_type("Num", expr_type, Num_fields, 1); | 550 Num_type = make_type("Num", expr_type, Num_fields, 1); |
| 547 if (!Num_type) return 0; | 551 if (!Num_type) return 0; |
| 548 Str_type = make_type("Str", expr_type, Str_fields, 1); | 552 Str_type = make_type("Str", expr_type, Str_fields, 1); |
| 549 if (!Str_type) return 0; | 553 if (!Str_type) return 0; |
| 554 Bytes_type = make_type("Bytes", expr_type, Bytes_fields, 1); | |
| 555 if (!Bytes_type) return 0; | |
| 550 Ellipsis_type = make_type("Ellipsis", expr_type, NULL, 0); | 556 Ellipsis_type = make_type("Ellipsis", expr_type, NULL, 0); |
| 551 if (!Ellipsis_type) return 0; | 557 if (!Ellipsis_type) return 0; |
| 552 Attribute_type = make_type("Attribute", expr_type, Attribute_fields, 3); | 558 Attribute_type = make_type("Attribute", expr_type, Attribute_fields, 3); |
| 553 if (!Attribute_type) return 0; | 559 if (!Attribute_type) return 0; |
| 554 Subscript_type = make_type("Subscript", expr_type, Subscript_fields, 3); | 560 Subscript_type = make_type("Subscript", expr_type, Subscript_fields, 3); |
| 1585 p->col_offset = col_offset; | 1591 p->col_offset = col_offset; |
| 1586 return p; | 1592 return p; |
| 1587 } | 1593 } |
| 1588 | 1594 |
| 1589 expr_ty | 1595 expr_ty |
| 1596 Bytes(string s, int lineno, int col_offset, PyArena *arena) | |
| 1597 { | |
| 1598 expr_ty p; | |
| 1599 if (!s) { | |
| 1600 PyErr_SetString(PyExc_ValueError, | |
| 1601 "field s is required for Bytes"); | |
| 1602 return NULL; | |
| 1603 } | |
| 1604 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | |
| 1605 if (!p) { | |
| 1606 PyErr_NoMemory(); | |
| 1607 return NULL; | |
| 1608 } | |
| 1609 p->kind = Bytes_kind; | |
| 1610 p->v.Bytes.s = s; | |
| 1611 p->lineno = lineno; | |
| 1612 p->col_offset = col_offset; | |
| 1613 return p; | |
| 1614 } | |
| 1615 | |
| 1616 expr_ty | |
| 1590 Ellipsis(int lineno, int col_offset, PyArena *arena) | 1617 Ellipsis(int lineno, int col_offset, PyArena *arena) |
| 1591 { | 1618 { |
| 1592 expr_ty p; | 1619 expr_ty p; |
| 1593 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1620 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1594 if (!p) { | 1621 if (!p) { |
| 2543 break; | 2570 break; |
| 2544 case Str_kind: | 2571 case Str_kind: |
| 2545 result = PyType_GenericNew(Str_type, NULL, NULL); | 2572 result = PyType_GenericNew(Str_type, NULL, NULL); |
| 2546 if (!result) goto failed; | 2573 if (!result) goto failed; |
| 2547 value = ast2obj_string(o->v.Str.s); | 2574 value = ast2obj_string(o->v.Str.s); |
| 2575 if (!value) goto failed; | |
| 2576 if (PyObject_SetAttrString(result, "s", value) == -1) | |
| 2577 goto failed; | |
| 2578 Py_DECREF(value); | |
| 2579 break; | |
| 2580 case Bytes_kind: | |
| 2581 result = PyType_GenericNew(Bytes_type, NULL, NULL); | |
| 2582 if (!result) goto failed; | |
| 2583 value = ast2obj_string(o->v.Bytes.s); | |
| 2548 if (!value) goto failed; | 2584 if (!value) goto failed; |
| 2549 if (PyObject_SetAttrString(result, "s", value) == -1) | 2585 if (PyObject_SetAttrString(result, "s", value) == -1) |
| 2550 goto failed; | 2586 goto failed; |
| 2551 Py_DECREF(value); | 2587 Py_DECREF(value); |
| 2552 break; | 2588 break; |
| 3087 if (!m) return; | 3123 if (!m) return; |
| 3088 d = PyModule_GetDict(m); | 3124 d = PyModule_GetDict(m); |
| 3089 if (PyDict_SetItemString(d, "AST", (PyObject*)AST_type) < 0) return; | 3125 if (PyDict_SetItemString(d, "AST", (PyObject*)AST_type) < 0) return; |
| 3090 if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0) | 3126 if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0) |
| 3091 return; | 3127 return; |
| 3092 if (PyModule_AddStringConstant(m, "__version__", "53731") < 0) | 3128 if (PyModule_AddStringConstant(m, "__version__", "53866") < 0) |
| 3093 return; | 3129 return; |
| 3094 if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return; | 3130 if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return; |
| 3095 if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0) | 3131 if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0) |
| 3096 return; | 3132 return; |
| 3097 if (PyDict_SetItemString(d, "Interactive", (PyObject*)Interactive_type) | 3133 if (PyDict_SetItemString(d, "Interactive", (PyObject*)Interactive_type) |
| 3153 if (PyDict_SetItemString(d, "Compare", (PyObject*)Compare_type) < 0) | 3189 if (PyDict_SetItemString(d, "Compare", (PyObject*)Compare_type) < 0) |
| 3154 return; | 3190 return; |
| 3155 if (PyDict_SetItemString(d, "Call", (PyObject*)Call_type) < 0) return; | 3191 if (PyDict_SetItemString(d, "Call", (PyObject*)Call_type) < 0) return; |
| 3156 if (PyDict_SetItemString(d, "Num", (PyObject*)Num_type) < 0) return; | 3192 if (PyDict_SetItemString(d, "Num", (PyObject*)Num_type) < 0) return; |
| 3157 if (PyDict_SetItemString(d, "Str", (PyObject*)Str_type) < 0) return; | 3193 if (PyDict_SetItemString(d, "Str", (PyObject*)Str_type) < 0) return; |
| 3194 if (PyDict_SetItemString(d, "Bytes", (PyObject*)Bytes_type) < 0) return; | |
| 3158 if (PyDict_SetItemString(d, "Ellipsis", (PyObject*)Ellipsis_type) < 0) | 3195 if (PyDict_SetItemString(d, "Ellipsis", (PyObject*)Ellipsis_type) < 0) |
| 3159 return; | 3196 return; |
| 3160 if (PyDict_SetItemString(d, "Attribute", (PyObject*)Attribute_type) < | 3197 if (PyDict_SetItemString(d, "Attribute", (PyObject*)Attribute_type) < |
| 3161 0) return; | 3198 0) return; |
| 3162 if (PyDict_SetItemString(d, "Subscript", (PyObject*)Subscript_type) < | 3199 if (PyDict_SetItemString(d, "Subscript", (PyObject*)Subscript_type) < |
