diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-05-09 15:52:27 +0000 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-05-09 15:52:27 +0000 |
commit | 567b94adaaceb622c33f9be1998735dfb95f1707 (patch) | |
tree | 435e6e81b103b098c38ca2d5cfc20c27d4e17b54 /Modules/parsermodule.c | |
parent | 043c1cd9525013647c193ccf8686635f09eb4cbf (diff) | |
download | cpython-567b94adaaceb622c33f9be1998735dfb95f1707.tar.gz |
Recorded merge of revisions 81029 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines
Untabify C files. Will watch buildbots.
........
Diffstat (limited to 'Modules/parsermodule.c')
-rw-r--r-- | Modules/parsermodule.c | 204 |
1 files changed, 102 insertions, 102 deletions
diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c index 2fa8529006..3e0f53082d 100644 --- a/Modules/parsermodule.c +++ b/Modules/parsermodule.c @@ -578,8 +578,8 @@ parser_do_parse(PyObject *args, PyObject *kw, char *argspec, int type) ? eval_input : file_input, &err, &flags); - if (n) { - res = parser_newstobject(n, type); + if (n) { + res = parser_newstobject(n, type); if (res) ((PyST_Object *)res)->st_flags.cf_flags = flags & PyCF_MASK; } @@ -784,7 +784,7 @@ build_node_children(PyObject *tuple, node *root, int *line_num) PyErr_Format(parser_error, "third item in terminal node must be an" " integer, found %s", - Py_TYPE(temp)->tp_name); + Py_TYPE(temp)->tp_name); Py_DECREF(o); Py_DECREF(temp); Py_DECREF(elem); @@ -1051,7 +1051,7 @@ validate_class(node *tree) { int nch = NCH(tree); int res = (validate_ntype(tree, classdef) && - ((nch == 4) || (nch == 6) || (nch == 7))); + ((nch == 4) || (nch == 6) || (nch == 7))); if (res) { res = (validate_name(CHILD(tree, 0), "class") @@ -1064,15 +1064,15 @@ validate_class(node *tree) } if (res) { - if (nch == 7) { - res = ((validate_lparen(CHILD(tree, 2)) && - validate_arglist(CHILD(tree, 3)) && - validate_rparen(CHILD(tree, 4)))); - } - else if (nch == 6) { - res = (validate_lparen(CHILD(tree,2)) && - validate_rparen(CHILD(tree,3))); - } + if (nch == 7) { + res = ((validate_lparen(CHILD(tree, 2)) && + validate_arglist(CHILD(tree, 3)) && + validate_rparen(CHILD(tree, 4)))); + } + else if (nch == 6) { + res = (validate_lparen(CHILD(tree,2)) && + validate_rparen(CHILD(tree,3))); + } } return (res); } @@ -1244,10 +1244,10 @@ validate_varargslist_trailer(node *tree, int start) else { /* skip over vfpdef (',' vfpdef ['=' test])* */ i = start + 1; - if (TYPE(CHILD(tree, i)) == vfpdef || - TYPE(CHILD(tree, i)) == tfpdef) { /* skip over vfpdef or tfpdef */ - i += 1; - } + if (TYPE(CHILD(tree, i)) == vfpdef || + TYPE(CHILD(tree, i)) == tfpdef) { /* skip over vfpdef or tfpdef */ + i += 1; + } while (res && i+1 < nch) { /* validate (',' vfpdef ['=' test])* */ res = validate_comma(CHILD(tree, i)); if (TYPE(CHILD(tree, i+1)) == DOUBLESTAR) @@ -1718,14 +1718,14 @@ validate_dotted_as_name(node *tree) static int validate_dotted_as_names(node *tree) { - int nch = NCH(tree); - int res = is_odd(nch) && validate_dotted_as_name(CHILD(tree, 0)); - int i; + int nch = NCH(tree); + int res = is_odd(nch) && validate_dotted_as_name(CHILD(tree, 0)); + int i; - for (i = 1; res && (i < nch); i += 2) - res = (validate_comma(CHILD(tree, i)) - && validate_dotted_as_name(CHILD(tree, i + 1))); - return (res); + for (i = 1; res && (i < nch); i += 2) + res = (validate_comma(CHILD(tree, i)) + && validate_dotted_as_name(CHILD(tree, i + 1))); + return (res); } @@ -1738,8 +1738,8 @@ validate_import_as_names(node *tree) int i; for (i = 1; res && (i + 1 < nch); i += 2) - res = (validate_comma(CHILD(tree, i)) - && validate_import_as_name(CHILD(tree, i + 1))); + res = (validate_comma(CHILD(tree, i)) + && validate_import_as_name(CHILD(tree, i + 1))); return (res); } @@ -1748,10 +1748,10 @@ validate_import_as_names(node *tree) static int validate_import_name(node *tree) { - return (validate_ntype(tree, import_name) - && validate_numnodes(tree, 2, "import_name") - && validate_name(CHILD(tree, 0), "import") - && validate_dotted_as_names(CHILD(tree, 1))); + return (validate_ntype(tree, import_name) + && validate_numnodes(tree, 2, "import_name") + && validate_name(CHILD(tree, 0), "import") + && validate_dotted_as_names(CHILD(tree, 1))); } /* Helper function to count the number of leading dots in @@ -1762,8 +1762,8 @@ count_from_dots(node *tree) { int i; for (i = 1; i < NCH(tree); i++) - if (TYPE(CHILD(tree, i)) != DOT) - break; + if (TYPE(CHILD(tree, i)) != DOT) + break; return i-1; } @@ -1773,24 +1773,24 @@ count_from_dots(node *tree) static int validate_import_from(node *tree) { - int nch = NCH(tree); - int ndots = count_from_dots(tree); - int havename = (TYPE(CHILD(tree, ndots + 1)) == dotted_name); - int offset = ndots + havename; - int res = validate_ntype(tree, import_from) - && (nch >= 4 + ndots) - && validate_name(CHILD(tree, 0), "from") - && (!havename || validate_dotted_name(CHILD(tree, ndots + 1))) - && validate_name(CHILD(tree, offset + 1), "import"); - - if (res && TYPE(CHILD(tree, offset + 2)) == LPAR) - res = ((nch == offset + 5) - && validate_lparen(CHILD(tree, offset + 2)) - && validate_import_as_names(CHILD(tree, offset + 3)) - && validate_rparen(CHILD(tree, offset + 4))); - else if (res && TYPE(CHILD(tree, offset + 2)) != STAR) - res = validate_import_as_names(CHILD(tree, offset + 2)); - return (res); + int nch = NCH(tree); + int ndots = count_from_dots(tree); + int havename = (TYPE(CHILD(tree, ndots + 1)) == dotted_name); + int offset = ndots + havename; + int res = validate_ntype(tree, import_from) + && (nch >= 4 + ndots) + && validate_name(CHILD(tree, 0), "from") + && (!havename || validate_dotted_name(CHILD(tree, ndots + 1))) + && validate_name(CHILD(tree, offset + 1), "import"); + + if (res && TYPE(CHILD(tree, offset + 2)) == LPAR) + res = ((nch == offset + 5) + && validate_lparen(CHILD(tree, offset + 2)) + && validate_import_as_names(CHILD(tree, offset + 3)) + && validate_rparen(CHILD(tree, offset + 4))); + else if (res && TYPE(CHILD(tree, offset + 2)) != STAR) + res = validate_import_as_names(CHILD(tree, offset + 2)); + return (res); } @@ -1802,9 +1802,9 @@ validate_import_stmt(node *tree) int res = validate_numnodes(tree, 1, "import_stmt"); if (res) { - int ntype = TYPE(CHILD(tree, 0)); + int ntype = TYPE(CHILD(tree, 0)); - if (ntype == import_name || ntype == import_from) + if (ntype == import_name || ntype == import_from) res = validate_node(CHILD(tree, 0)); else { res = 0; @@ -2323,11 +2323,11 @@ validate_atom(node *tree) && (validate_rparen(CHILD(tree, nch - 1)))); if (res && (nch == 3)) { - if (TYPE(CHILD(tree, 1))==yield_expr) - res = validate_yield_expr(CHILD(tree, 1)); - else - res = validate_testlist_comp(CHILD(tree, 1)); - } + if (TYPE(CHILD(tree, 1))==yield_expr) + res = validate_yield_expr(CHILD(tree, 1)); + else + res = validate_testlist_comp(CHILD(tree, 1)); + } break; case LSQB: if (nch == 2) @@ -2355,11 +2355,11 @@ validate_atom(node *tree) for (pos = 1; res && (pos < nch); ++pos) res = validate_ntype(CHILD(tree, pos), STRING); break; - case DOT: - res = (nch == 3 && - validate_ntype(CHILD(tree, 1), DOT) && - validate_ntype(CHILD(tree, 2), DOT)); - break; + case DOT: + res = (nch == 3 && + validate_ntype(CHILD(tree, 1), DOT) && + validate_ntype(CHILD(tree, 2), DOT)); + break; default: res = 0; break; @@ -2416,17 +2416,17 @@ validate_decorator(node *tree) int ok; int nch = NCH(tree); ok = (validate_ntype(tree, decorator) && - (nch == 3 || nch == 5 || nch == 6) && - validate_at(CHILD(tree, 0)) && - validate_dotted_name(CHILD(tree, 1)) && - validate_newline(RCHILD(tree, -1))); + (nch == 3 || nch == 5 || nch == 6) && + validate_at(CHILD(tree, 0)) && + validate_dotted_name(CHILD(tree, 1)) && + validate_newline(RCHILD(tree, -1))); if (ok && nch != 3) { - ok = (validate_lparen(CHILD(tree, 2)) && - validate_rparen(RCHILD(tree, -2))); + ok = (validate_lparen(CHILD(tree, 2)) && + validate_rparen(RCHILD(tree, -2))); - if (ok && nch == 6) - ok = validate_arglist(CHILD(tree, 3)); + if (ok && nch == 6) + ok = validate_arglist(CHILD(tree, 3)); } return ok; @@ -2443,7 +2443,7 @@ validate_decorators(node *tree) ok = validate_ntype(tree, decorators) && nch >= 1; for (i = 0; ok && i < nch; ++i) - ok = validate_decorator(CHILD(tree, i)); + ok = validate_decorator(CHILD(tree, i)); return ok; } @@ -2458,7 +2458,7 @@ validate_with_item(node *tree) int ok = (validate_ntype(tree, with_item) && (nch == 1 || nch == 3) && validate_test(CHILD(tree, 0))); - if (ok && nch == 3) + if (ok && nch == 3) ok = (validate_name(CHILD(tree, 1), "as") && validate_expr(CHILD(tree, 2))); return ok; @@ -2493,12 +2493,12 @@ validate_funcdef(node *tree) { int nch = NCH(tree); int ok = (validate_ntype(tree, funcdef) - && (nch == 5) - && validate_name(RCHILD(tree, -5), "def") - && validate_ntype(RCHILD(tree, -4), NAME) - && validate_colon(RCHILD(tree, -2)) - && validate_parameters(RCHILD(tree, -3)) - && validate_suite(RCHILD(tree, -1))); + && (nch == 5) + && validate_name(RCHILD(tree, -5), "def") + && validate_ntype(RCHILD(tree, -4), NAME) + && validate_colon(RCHILD(tree, -2)) + && validate_parameters(RCHILD(tree, -3)) + && validate_suite(RCHILD(tree, -1))); return ok; } @@ -2511,11 +2511,11 @@ validate_decorated(node *tree) { int nch = NCH(tree); int ok = (validate_ntype(tree, decorated) - && (nch == 2) - && validate_decorators(RCHILD(tree, -2)) - && (validate_funcdef(RCHILD(tree, -1)) - || validate_class(RCHILD(tree, -1))) - ); + && (nch == 2) + && validate_decorators(RCHILD(tree, -2)) + && (validate_funcdef(RCHILD(tree, -1)) + || validate_class(RCHILD(tree, -1))) + ); return ok; } @@ -2882,9 +2882,9 @@ validate_node(node *tree) case classdef: res = validate_class(tree); break; - case decorated: - res = validate_decorated(tree); - break; + case decorated: + res = validate_decorated(tree); + break; /* * "Trivial" parse tree nodes. * (Why did I call these trivial?) @@ -2953,12 +2953,12 @@ validate_node(node *tree) case import_stmt: res = validate_import_stmt(tree); break; - case import_name: - res = validate_import_name(tree); - break; - case import_from: - res = validate_import_from(tree); - break; + case import_name: + res = validate_import_name(tree); + break; + case import_from: + res = validate_import_from(tree); + break; case global_stmt: res = validate_global_stmt(tree); break; @@ -3170,15 +3170,15 @@ static PyMethodDef parser_functions[] = { static struct PyModuleDef parsermodule = { - PyModuleDef_HEAD_INIT, - "parser", - NULL, - -1, - parser_functions, - NULL, - NULL, - NULL, - NULL + PyModuleDef_HEAD_INIT, + "parser", + NULL, + -1, + parser_functions, + NULL, + NULL, + NULL, + NULL }; PyMODINIT_FUNC PyInit_parser(void); /* supply a prototype */ @@ -3192,7 +3192,7 @@ PyInit_parser(void) return NULL; module = PyModule_Create(&parsermodule); if (module == NULL) - return NULL; + return NULL; if (parser_error == 0) parser_error = PyErr_NewException("parser.ParserError", NULL, NULL); |