Lines Matching refs:tree
633 static int validate_expr_tree(node *tree);
634 static int validate_file_input(node *tree);
635 static int validate_encoding_decl(node *tree);
656 node *tree; in parser_tuple2st() local
671 tree = build_node_tree(tuple); in parser_tuple2st()
672 if (tree != 0) { in parser_tuple2st()
673 int start_sym = TYPE(tree); in parser_tuple2st()
676 if (validate_expr_tree(tree)) in parser_tuple2st()
677 st = parser_newstobject(tree, PyST_EXPR); in parser_tuple2st()
679 PyNode_Free(tree); in parser_tuple2st()
683 if (validate_file_input(tree)) in parser_tuple2st()
684 st = parser_newstobject(tree, PyST_SUITE); in parser_tuple2st()
686 PyNode_Free(tree); in parser_tuple2st()
690 if (validate_encoding_decl(tree)) in parser_tuple2st()
691 st = parser_newstobject(tree, PyST_SUITE); in parser_tuple2st()
693 PyNode_Free(tree); in parser_tuple2st()
697 PyNode_Free(tree); in parser_tuple2st()
940 #define VALIDATER(n) static int validate_##n(node *tree)
1030 validate_repeating_list(node *tree, int ntype, int (*vfunc)(node *), in validate_repeating_list() argument
1033 int nch = NCH(tree); in validate_repeating_list()
1034 int res = (nch && validate_ntype(tree, ntype) in validate_repeating_list()
1035 && vfunc(CHILD(tree, 0))); in validate_repeating_list()
1038 (void) validate_numnodes(tree, 1, name); in validate_repeating_list()
1041 res = validate_comma(CHILD(tree, --nch)); in validate_repeating_list()
1045 res = (validate_comma(CHILD(tree, pos)) in validate_repeating_list()
1046 && vfunc(CHILD(tree, pos + 1))); in validate_repeating_list()
1059 validate_class(node *tree) in validate_class() argument
1061 int nch = NCH(tree); in validate_class()
1062 int res = (validate_ntype(tree, classdef) && in validate_class()
1066 res = (validate_name(CHILD(tree, 0), "class") in validate_class()
1067 && validate_ntype(CHILD(tree, 1), NAME) in validate_class()
1068 && validate_colon(CHILD(tree, nch - 2)) in validate_class()
1069 && validate_suite(CHILD(tree, nch - 1))); in validate_class()
1072 (void) validate_numnodes(tree, 4, "class"); in validate_class()
1077 res = ((validate_lparen(CHILD(tree, 2)) && in validate_class()
1078 validate_testlist(CHILD(tree, 3)) && in validate_class()
1079 validate_rparen(CHILD(tree, 4)))); in validate_class()
1082 res = (validate_lparen(CHILD(tree,2)) && in validate_class()
1083 validate_rparen(CHILD(tree,3))); in validate_class()
1094 validate_if(node *tree) in validate_if() argument
1096 int nch = NCH(tree); in validate_if()
1097 int res = (validate_ntype(tree, if_stmt) in validate_if()
1099 && validate_name(CHILD(tree, 0), "if") in validate_if()
1100 && validate_test(CHILD(tree, 1)) in validate_if()
1101 && validate_colon(CHILD(tree, 2)) in validate_if()
1102 && validate_suite(CHILD(tree, 3))); in validate_if()
1106 res = (validate_name(CHILD(tree, nch - 3), "else") in validate_if()
1107 && validate_colon(CHILD(tree, nch - 2)) in validate_if()
1108 && validate_suite(CHILD(tree, nch - 1))); in validate_if()
1112 (void) validate_numnodes(tree, 4, "if"); in validate_if()
1115 res = validate_numnodes(tree, 0, "if"); in validate_if()
1120 res = (validate_name(CHILD(tree, j), "elif") in validate_if()
1121 && validate_colon(CHILD(tree, j + 2)) in validate_if()
1122 && validate_test(CHILD(tree, j + 1)) in validate_if()
1123 && validate_suite(CHILD(tree, j + 3))); in validate_if()
1136 validate_parameters(node *tree) in validate_parameters() argument
1138 int nch = NCH(tree); in validate_parameters()
1139 int res = validate_ntype(tree, parameters) && ((nch == 2) || (nch == 3)); in validate_parameters()
1142 res = (validate_lparen(CHILD(tree, 0)) in validate_parameters()
1143 && validate_rparen(CHILD(tree, nch - 1))); in validate_parameters()
1145 res = validate_varargslist(CHILD(tree, 1)); in validate_parameters()
1148 (void) validate_numnodes(tree, 2, "parameters"); in validate_parameters()
1161 validate_suite(node *tree) in validate_suite() argument
1163 int nch = NCH(tree); in validate_suite()
1164 int res = (validate_ntype(tree, suite) && ((nch == 1) || (nch >= 4))); in validate_suite()
1167 res = validate_simple_stmt(CHILD(tree, 0)); in validate_suite()
1170 res = (validate_newline(CHILD(tree, 0)) in validate_suite()
1171 && validate_indent(CHILD(tree, 1)) in validate_suite()
1172 && validate_stmt(CHILD(tree, 2)) in validate_suite()
1173 && validate_dedent(CHILD(tree, nch - 1))); in validate_suite()
1179 res = validate_stmt(CHILD(tree, i)); in validate_suite()
1182 res = validate_numnodes(tree, 4, "suite"); in validate_suite()
1189 validate_testlist(node *tree) in validate_testlist() argument
1191 return (validate_repeating_list(tree, testlist, in validate_testlist()
1197 validate_testlist1(node *tree) in validate_testlist1() argument
1199 return (validate_repeating_list(tree, testlist1, in validate_testlist1()
1205 validate_testlist_safe(node *tree) in validate_testlist_safe() argument
1207 return (validate_repeating_list(tree, testlist_safe, in validate_testlist_safe()
1215 validate_varargslist_trailer(node *tree, int start) in validate_varargslist_trailer() argument
1217 int nch = NCH(tree); in validate_varargslist_trailer()
1225 sym = TYPE(CHILD(tree, start)); in validate_varargslist_trailer()
1231 res = validate_name(CHILD(tree, start+1), NULL); in validate_varargslist_trailer()
1233 res = (validate_name(CHILD(tree, start+1), NULL) in validate_varargslist_trailer()
1234 && validate_comma(CHILD(tree, start+2)) in validate_varargslist_trailer()
1235 && validate_doublestar(CHILD(tree, start+3)) in validate_varargslist_trailer()
1236 && validate_name(CHILD(tree, start+4), NULL)); in validate_varargslist_trailer()
1243 res = validate_name(CHILD(tree, start+1), NULL); in validate_varargslist_trailer()
1261 validate_varargslist(node *tree) in validate_varargslist() argument
1263 int nch = NCH(tree); in validate_varargslist()
1264 int res = validate_ntype(tree, varargslist) && (nch != 0); in validate_varargslist()
1273 sym = TYPE(CHILD(tree, 0)); in validate_varargslist()
1278 res = validate_varargslist_trailer(tree, 0); in validate_varargslist()
1282 sym = TYPE(CHILD(tree, nch-1)); in validate_varargslist()
1291 res = validate_fpdef(CHILD(tree, i)); in validate_varargslist()
1293 if (res && TYPE(CHILD(tree, i)) == EQUAL && (i+2 <= nch)) { in validate_varargslist()
1294 res = (validate_equal(CHILD(tree, i)) in validate_varargslist()
1295 && validate_test(CHILD(tree, i+1))); in validate_varargslist()
1300 res = validate_comma(CHILD(tree, i)); in validate_varargslist()
1303 && (TYPE(CHILD(tree, i)) == DOUBLESTAR in validate_varargslist()
1304 || TYPE(CHILD(tree, i)) == STAR)) in validate_varargslist()
1312 res = validate_varargslist_trailer(tree, i); in validate_varargslist()
1320 res = validate_comma(CHILD(tree, nch-1)); in validate_varargslist()
1328 res = validate_fpdef(CHILD(tree, 0)); in validate_varargslist()
1330 if (res && (i+2 <= nch) && TYPE(CHILD(tree, i)) == EQUAL) { in validate_varargslist()
1331 res = (validate_equal(CHILD(tree, i)) in validate_varargslist()
1332 && validate_test(CHILD(tree, i+1))); in validate_varargslist()
1340 res = (validate_comma(CHILD(tree, i)) in validate_varargslist()
1341 && validate_fpdef(CHILD(tree, i+1))); in validate_varargslist()
1343 if (res && (nch - i) >= 2 && TYPE(CHILD(tree, i)) == EQUAL) { in validate_varargslist()
1344 res = (validate_equal(CHILD(tree, i)) in validate_varargslist()
1345 && validate_test(CHILD(tree, i+1))); in validate_varargslist()
1362 validate_list_iter(node *tree) in validate_list_iter() argument
1364 int res = (validate_ntype(tree, list_iter) in validate_list_iter()
1365 && validate_numnodes(tree, 1, "list_iter")); in validate_list_iter()
1366 if (res && TYPE(CHILD(tree, 0)) == list_for) in validate_list_iter()
1367 res = validate_list_for(CHILD(tree, 0)); in validate_list_iter()
1369 res = validate_list_if(CHILD(tree, 0)); in validate_list_iter()
1377 validate_comp_iter(node *tree) in validate_comp_iter() argument
1379 int res = (validate_ntype(tree, comp_iter) in validate_comp_iter()
1380 && validate_numnodes(tree, 1, "comp_iter")); in validate_comp_iter()
1381 if (res && TYPE(CHILD(tree, 0)) == comp_for) in validate_comp_iter()
1382 res = validate_comp_for(CHILD(tree, 0)); in validate_comp_iter()
1384 res = validate_comp_if(CHILD(tree, 0)); in validate_comp_iter()
1392 validate_list_for(node *tree) in validate_list_for() argument
1394 int nch = NCH(tree); in validate_list_for()
1398 res = validate_list_iter(CHILD(tree, 4)); in validate_list_for()
1400 res = validate_numnodes(tree, 4, "list_for"); in validate_list_for()
1403 res = (validate_name(CHILD(tree, 0), "for") in validate_list_for()
1404 && validate_exprlist(CHILD(tree, 1)) in validate_list_for()
1405 && validate_name(CHILD(tree, 2), "in") in validate_list_for()
1406 && validate_testlist_safe(CHILD(tree, 3))); in validate_list_for()
1414 validate_comp_for(node *tree) in validate_comp_for() argument
1416 int nch = NCH(tree); in validate_comp_for()
1420 res = validate_comp_iter(CHILD(tree, 4)); in validate_comp_for()
1422 res = validate_numnodes(tree, 4, "comp_for"); in validate_comp_for()
1425 res = (validate_name(CHILD(tree, 0), "for") in validate_comp_for()
1426 && validate_exprlist(CHILD(tree, 1)) in validate_comp_for()
1427 && validate_name(CHILD(tree, 2), "in") in validate_comp_for()
1428 && validate_or_test(CHILD(tree, 3))); in validate_comp_for()
1436 validate_list_if(node *tree) in validate_list_if() argument
1438 int nch = NCH(tree); in validate_list_if()
1442 res = validate_list_iter(CHILD(tree, 2)); in validate_list_if()
1444 res = validate_numnodes(tree, 2, "list_if"); in validate_list_if()
1447 res = (validate_name(CHILD(tree, 0), "if") in validate_list_if()
1448 && validate_old_test(CHILD(tree, 1))); in validate_list_if()
1456 validate_comp_if(node *tree) in validate_comp_if() argument
1458 int nch = NCH(tree); in validate_comp_if()
1462 res = validate_comp_iter(CHILD(tree, 2)); in validate_comp_if()
1464 res = validate_numnodes(tree, 2, "comp_if"); in validate_comp_if()
1467 res = (validate_name(CHILD(tree, 0), "if") in validate_comp_if()
1468 && validate_old_test(CHILD(tree, 1))); in validate_comp_if()
1480 validate_fpdef(node *tree) in validate_fpdef() argument
1482 int nch = NCH(tree); in validate_fpdef()
1483 int res = validate_ntype(tree, fpdef); in validate_fpdef()
1487 res = validate_ntype(CHILD(tree, 0), NAME); in validate_fpdef()
1489 res = (validate_lparen(CHILD(tree, 0)) in validate_fpdef()
1490 && validate_fplist(CHILD(tree, 1)) in validate_fpdef()
1491 && validate_rparen(CHILD(tree, 2))); in validate_fpdef()
1493 res = validate_numnodes(tree, 1, "fpdef"); in validate_fpdef()
1500 validate_fplist(node *tree) in validate_fplist() argument
1502 return (validate_repeating_list(tree, fplist, in validate_fplist()
1511 validate_stmt(node *tree) in validate_stmt() argument
1513 int res = (validate_ntype(tree, stmt) in validate_stmt()
1514 && validate_numnodes(tree, 1, "stmt")); in validate_stmt()
1517 tree = CHILD(tree, 0); in validate_stmt()
1519 if (TYPE(tree) == simple_stmt) in validate_stmt()
1520 res = validate_simple_stmt(tree); in validate_stmt()
1522 res = validate_compound_stmt(tree); in validate_stmt()
1532 validate_simple_stmt(node *tree) in validate_simple_stmt() argument
1534 int nch = NCH(tree); in validate_simple_stmt()
1535 int res = (validate_ntype(tree, simple_stmt) in validate_simple_stmt()
1537 && validate_small_stmt(CHILD(tree, 0)) in validate_simple_stmt()
1538 && validate_newline(CHILD(tree, nch - 1))); in validate_simple_stmt()
1541 res = validate_numnodes(tree, 2, "simple_stmt"); in validate_simple_stmt()
1544 res = validate_semi(CHILD(tree, --nch)); in validate_simple_stmt()
1549 res = (validate_semi(CHILD(tree, i)) in validate_simple_stmt()
1550 && validate_small_stmt(CHILD(tree, i + 1))); in validate_simple_stmt()
1557 validate_small_stmt(node *tree) in validate_small_stmt() argument
1559 int nch = NCH(tree); in validate_small_stmt()
1560 int res = validate_numnodes(tree, 1, "small_stmt"); in validate_small_stmt()
1563 int ntype = TYPE(CHILD(tree, 0)); in validate_small_stmt()
1574 res = validate_node(CHILD(tree, 0)); in validate_small_stmt()
1584 TYPE(CHILD(tree, 0))); in validate_small_stmt()
1594 validate_compound_stmt(node *tree) in validate_compound_stmt() argument
1596 int res = (validate_ntype(tree, compound_stmt) in validate_compound_stmt()
1597 && validate_numnodes(tree, 1, "compound_stmt")); in validate_compound_stmt()
1603 tree = CHILD(tree, 0); in validate_compound_stmt()
1604 ntype = TYPE(tree); in validate_compound_stmt()
1613 res = validate_node(tree); in validate_compound_stmt()
1617 "Illegal compound statement type: %d.", TYPE(tree)); in validate_compound_stmt()
1623 validate_yield_or_testlist(node *tree) in validate_yield_or_testlist() argument
1625 if (TYPE(tree) == yield_expr) in validate_yield_or_testlist()
1626 return validate_yield_expr(tree); in validate_yield_or_testlist()
1628 return validate_testlist(tree); in validate_yield_or_testlist()
1632 validate_expr_stmt(node *tree) in validate_expr_stmt() argument
1635 int nch = NCH(tree); in validate_expr_stmt()
1636 int res = (validate_ntype(tree, expr_stmt) in validate_expr_stmt()
1638 && validate_testlist(CHILD(tree, 0))); in validate_expr_stmt()
1641 && TYPE(CHILD(tree, 1)) == augassign) { in validate_expr_stmt()
1642 res = validate_numnodes(CHILD(tree, 1), 1, "augassign") in validate_expr_stmt()
1643 && validate_yield_or_testlist(CHILD(tree, 2)); in validate_expr_stmt()
1646 char *s = STR(CHILD(CHILD(tree, 1), 0)); in validate_expr_stmt()
1666 res = validate_equal(CHILD(tree, j)) in validate_expr_stmt()
1667 && validate_yield_or_testlist(CHILD(tree, j + 1)); in validate_expr_stmt()
1679 validate_print_stmt(node *tree) in validate_print_stmt() argument
1681 int nch = NCH(tree); in validate_print_stmt()
1682 int res = (validate_ntype(tree, print_stmt) in validate_print_stmt()
1684 && validate_name(CHILD(tree, 0), "print")); in validate_print_stmt()
1687 int sym = TYPE(CHILD(tree, 1)); in validate_print_stmt()
1692 res = validate_test(CHILD(tree, i++)); in validate_print_stmt()
1695 res = validate_numnodes(tree, 3, "print_stmt"); in validate_print_stmt()
1697 res = (validate_ntype(CHILD(tree, i), RIGHTSHIFT) in validate_print_stmt()
1698 && validate_test(CHILD(tree, i+1))); in validate_print_stmt()
1706 res = (validate_comma(CHILD(tree, i)) in validate_print_stmt()
1707 && validate_test(CHILD(tree, i+1))); in validate_print_stmt()
1712 res = validate_numnodes(tree, i, "print_stmt"); in validate_print_stmt()
1714 res = validate_comma(CHILD(tree, i)); in validate_print_stmt()
1722 validate_del_stmt(node *tree) in validate_del_stmt() argument
1724 return (validate_numnodes(tree, 2, "del_stmt") in validate_del_stmt()
1725 && validate_name(CHILD(tree, 0), "del") in validate_del_stmt()
1726 && validate_exprlist(CHILD(tree, 1))); in validate_del_stmt()
1731 validate_return_stmt(node *tree) in validate_return_stmt() argument
1733 int nch = NCH(tree); in validate_return_stmt()
1734 int res = (validate_ntype(tree, return_stmt) in validate_return_stmt()
1736 && validate_name(CHILD(tree, 0), "return")); in validate_return_stmt()
1739 res = validate_testlist(CHILD(tree, 1)); in validate_return_stmt()
1746 validate_raise_stmt(node *tree) in validate_raise_stmt() argument
1748 int nch = NCH(tree); in validate_raise_stmt()
1749 int res = (validate_ntype(tree, raise_stmt) in validate_raise_stmt()
1753 res = validate_name(CHILD(tree, 0), "raise"); in validate_raise_stmt()
1755 res = validate_test(CHILD(tree, 1)); in validate_raise_stmt()
1757 res = (validate_comma(CHILD(tree, 2)) in validate_raise_stmt()
1758 && validate_test(CHILD(tree, 3))); in validate_raise_stmt()
1760 res = (validate_comma(CHILD(tree, 4)) in validate_raise_stmt()
1761 && validate_test(CHILD(tree, 5))); in validate_raise_stmt()
1765 (void) validate_numnodes(tree, 2, "raise"); in validate_raise_stmt()
1767 res = (validate_comma(CHILD(tree, 2)) in validate_raise_stmt()
1768 && validate_test(CHILD(tree, 3))); in validate_raise_stmt()
1777 validate_yield_expr(node *tree) in validate_yield_expr() argument
1779 int nch = NCH(tree); in validate_yield_expr()
1780 int res = (validate_ntype(tree, yield_expr) in validate_yield_expr()
1782 && validate_name(CHILD(tree, 0), "yield")); in validate_yield_expr()
1785 res = validate_testlist(CHILD(tree, 1)); in validate_yield_expr()
1794 validate_yield_stmt(node *tree) in validate_yield_stmt() argument
1796 return (validate_ntype(tree, yield_stmt) in validate_yield_stmt()
1797 && validate_numnodes(tree, 1, "yield_stmt") in validate_yield_stmt()
1798 && validate_yield_expr(CHILD(tree, 0))); in validate_yield_stmt()
1803 validate_import_as_name(node *tree) in validate_import_as_name() argument
1805 int nch = NCH(tree); in validate_import_as_name()
1806 int ok = validate_ntype(tree, import_as_name); in validate_import_as_name()
1810 ok = validate_name(CHILD(tree, 0), NULL); in validate_import_as_name()
1812 ok = (validate_name(CHILD(tree, 0), NULL) in validate_import_as_name()
1813 && validate_name(CHILD(tree, 1), "as") in validate_import_as_name()
1814 && validate_name(CHILD(tree, 2), NULL)); in validate_import_as_name()
1816 ok = validate_numnodes(tree, 3, "import_as_name"); in validate_import_as_name()
1825 validate_dotted_name(node *tree) in validate_dotted_name() argument
1827 int nch = NCH(tree); in validate_dotted_name()
1828 int res = (validate_ntype(tree, dotted_name) in validate_dotted_name()
1830 && validate_name(CHILD(tree, 0), NULL)); in validate_dotted_name()
1834 res = (validate_dot(CHILD(tree, i)) in validate_dotted_name()
1835 && validate_name(CHILD(tree, i+1), NULL)); in validate_dotted_name()
1844 validate_dotted_as_name(node *tree) in validate_dotted_as_name() argument
1846 int nch = NCH(tree); in validate_dotted_as_name()
1847 int res = validate_ntype(tree, dotted_as_name); in validate_dotted_as_name()
1851 res = validate_dotted_name(CHILD(tree, 0)); in validate_dotted_as_name()
1853 res = (validate_dotted_name(CHILD(tree, 0)) in validate_dotted_as_name()
1854 && validate_name(CHILD(tree, 1), "as") in validate_dotted_as_name()
1855 && validate_name(CHILD(tree, 2), NULL)); in validate_dotted_as_name()
1867 validate_dotted_as_names(node *tree) in validate_dotted_as_names() argument
1869 int nch = NCH(tree); in validate_dotted_as_names()
1870 int res = is_odd(nch) && validate_dotted_as_name(CHILD(tree, 0)); in validate_dotted_as_names()
1874 res = (validate_comma(CHILD(tree, i)) in validate_dotted_as_names()
1875 && validate_dotted_as_name(CHILD(tree, i + 1))); in validate_dotted_as_names()
1882 validate_import_as_names(node *tree) in validate_import_as_names() argument
1884 int nch = NCH(tree); in validate_import_as_names()
1885 int res = validate_import_as_name(CHILD(tree, 0)); in validate_import_as_names()
1889 res = (validate_comma(CHILD(tree, i)) in validate_import_as_names()
1890 && validate_import_as_name(CHILD(tree, i + 1))); in validate_import_as_names()
1897 validate_import_name(node *tree) in validate_import_name() argument
1899 return (validate_ntype(tree, import_name) in validate_import_name()
1900 && validate_numnodes(tree, 2, "import_name") in validate_import_name()
1901 && validate_name(CHILD(tree, 0), "import") in validate_import_name()
1902 && validate_dotted_as_names(CHILD(tree, 1))); in validate_import_name()
1909 count_from_dots(node *tree) in count_from_dots() argument
1912 for (i = 1; i < NCH(tree); i++) in count_from_dots()
1913 if (TYPE(CHILD(tree, i)) != DOT) in count_from_dots()
1922 validate_import_from(node *tree) in validate_import_from() argument
1924 int nch = NCH(tree); in validate_import_from()
1925 int ndots = count_from_dots(tree); in validate_import_from()
1926 int havename = (TYPE(CHILD(tree, ndots + 1)) == dotted_name); in validate_import_from()
1928 int res = validate_ntype(tree, import_from) in validate_import_from()
1931 && validate_name(CHILD(tree, 0), "from") in validate_import_from()
1932 && (!havename || validate_dotted_name(CHILD(tree, ndots + 1))) in validate_import_from()
1933 && validate_name(CHILD(tree, offset + 1), "import"); in validate_import_from()
1935 if (res && TYPE(CHILD(tree, offset + 2)) == LPAR) in validate_import_from()
1937 && validate_lparen(CHILD(tree, offset + 2)) in validate_import_from()
1938 && validate_import_as_names(CHILD(tree, offset + 3)) in validate_import_from()
1939 && validate_rparen(CHILD(tree, offset + 4))); in validate_import_from()
1940 else if (res && TYPE(CHILD(tree, offset + 2)) != STAR) in validate_import_from()
1941 res = validate_import_as_names(CHILD(tree, offset + 2)); in validate_import_from()
1948 validate_import_stmt(node *tree) in validate_import_stmt() argument
1950 int nch = NCH(tree); in validate_import_stmt()
1951 int res = validate_numnodes(tree, 1, "import_stmt"); in validate_import_stmt()
1954 int ntype = TYPE(CHILD(tree, 0)); in validate_import_stmt()
1957 res = validate_node(CHILD(tree, 0)); in validate_import_stmt()
1967 TYPE(CHILD(tree, 0))); in validate_import_stmt()
1976 validate_global_stmt(node *tree) in validate_global_stmt() argument
1979 int nch = NCH(tree); in validate_global_stmt()
1980 int res = (validate_ntype(tree, global_stmt) in validate_global_stmt()
1987 res = (validate_name(CHILD(tree, 0), "global") in validate_global_stmt()
1988 && validate_ntype(CHILD(tree, 1), NAME)); in validate_global_stmt()
1990 res = (validate_comma(CHILD(tree, j)) in validate_global_stmt()
1991 && validate_ntype(CHILD(tree, j + 1), NAME)); in validate_global_stmt()
2002 validate_exec_stmt(node *tree) in validate_exec_stmt() argument
2004 int nch = NCH(tree); in validate_exec_stmt()
2005 int res = (validate_ntype(tree, exec_stmt) in validate_exec_stmt()
2007 && validate_name(CHILD(tree, 0), "exec") in validate_exec_stmt()
2008 && validate_expr(CHILD(tree, 1))); in validate_exec_stmt()
2013 res = (validate_name(CHILD(tree, 2), "in") in validate_exec_stmt()
2014 && validate_test(CHILD(tree, 3))); in validate_exec_stmt()
2016 res = (validate_comma(CHILD(tree, 4)) in validate_exec_stmt()
2017 && validate_test(CHILD(tree, 5))); in validate_exec_stmt()
2028 validate_assert_stmt(node *tree) in validate_assert_stmt() argument
2030 int nch = NCH(tree); in validate_assert_stmt()
2031 int res = (validate_ntype(tree, assert_stmt) in validate_assert_stmt()
2033 && (validate_name(CHILD(tree, 0), "assert")) in validate_assert_stmt()
2034 && validate_test(CHILD(tree, 1))); in validate_assert_stmt()
2039 res = (validate_comma(CHILD(tree, 2)) in validate_assert_stmt()
2040 && validate_test(CHILD(tree, 3))); in validate_assert_stmt()
2047 validate_while(node *tree) in validate_while() argument
2049 int nch = NCH(tree); in validate_while()
2050 int res = (validate_ntype(tree, while_stmt) in validate_while()
2052 && validate_name(CHILD(tree, 0), "while") in validate_while()
2053 && validate_test(CHILD(tree, 1)) in validate_while()
2054 && validate_colon(CHILD(tree, 2)) in validate_while()
2055 && validate_suite(CHILD(tree, 3))); in validate_while()
2058 res = (validate_name(CHILD(tree, 4), "else") in validate_while()
2059 && validate_colon(CHILD(tree, 5)) in validate_while()
2060 && validate_suite(CHILD(tree, 6))); in validate_while()
2067 validate_for(node *tree) in validate_for() argument
2069 int nch = NCH(tree); in validate_for()
2070 int res = (validate_ntype(tree, for_stmt) in validate_for()
2072 && validate_name(CHILD(tree, 0), "for") in validate_for()
2073 && validate_exprlist(CHILD(tree, 1)) in validate_for()
2074 && validate_name(CHILD(tree, 2), "in") in validate_for()
2075 && validate_testlist(CHILD(tree, 3)) in validate_for()
2076 && validate_colon(CHILD(tree, 4)) in validate_for()
2077 && validate_suite(CHILD(tree, 5))); in validate_for()
2080 res = (validate_name(CHILD(tree, 6), "else") in validate_for()
2081 && validate_colon(CHILD(tree, 7)) in validate_for()
2082 && validate_suite(CHILD(tree, 8))); in validate_for()
2095 validate_try(node *tree) in validate_try() argument
2097 int nch = NCH(tree); in validate_try()
2099 int res = (validate_ntype(tree, try_stmt) in validate_try()
2103 res = (validate_name(CHILD(tree, 0), "try") in validate_try()
2104 && validate_colon(CHILD(tree, 1)) in validate_try()
2105 && validate_suite(CHILD(tree, 2)) in validate_try()
2106 && validate_colon(CHILD(tree, nch - 2)) in validate_try()
2107 && validate_suite(CHILD(tree, nch - 1))); in validate_try()
2110 if (TYPE(CHILD(tree, nch - 3)) != except_clause) in validate_try()
2111 name = STR(CHILD(tree, nch - 3)); in validate_try()
2117 if (res && (TYPE(CHILD(tree, pos)) == NAME) && in validate_try()
2118 (strcmp(STR(CHILD(tree, pos)), "finally") == 0)) { in validate_try()
2119 res = (validate_numnodes(tree, 6, "try/finally") in validate_try()
2120 && validate_colon(CHILD(tree, 4)) in validate_try()
2121 && validate_suite(CHILD(tree, 5))); in validate_try()
2125 while (res && pos < nch && (TYPE(CHILD(tree, pos)) == except_clause)) { in validate_try()
2126 res = (validate_except_clause(CHILD(tree, pos)) in validate_try()
2127 && validate_colon(CHILD(tree, pos + 1)) in validate_try()
2128 && validate_suite(CHILD(tree, pos + 2))); in validate_try()
2132 if (res && pos < nch && (TYPE(CHILD(tree, pos)) == NAME) && in validate_try()
2133 (strcmp(STR(CHILD(tree, pos)), "else") == 0)) { in validate_try()
2134 res = (validate_colon(CHILD(tree, pos + 1)) in validate_try()
2135 && validate_suite(CHILD(tree, pos + 2))); in validate_try()
2140 res = (validate_name(CHILD(tree, pos), "finally") in validate_try()
2141 && validate_numnodes(tree, pos + 3, "try/except/finally") in validate_try()
2142 && validate_colon(CHILD(tree, pos + 1)) in validate_try()
2143 && validate_suite(CHILD(tree, pos + 2))); in validate_try()
2150 validate_except_clause(node *tree) in validate_except_clause() argument
2152 int nch = NCH(tree); in validate_except_clause()
2153 int res = (validate_ntype(tree, except_clause) in validate_except_clause()
2155 && validate_name(CHILD(tree, 0), "except")); in validate_except_clause()
2158 res = validate_test(CHILD(tree, 1)); in validate_except_clause()
2160 if (TYPE(CHILD(tree, 2)) == NAME) in validate_except_clause()
2161 res = validate_name(CHILD(tree, 2), "as"); in validate_except_clause()
2163 res = validate_comma(CHILD(tree, 2)); in validate_except_clause()
2164 res = res && validate_test(CHILD(tree, 3)); in validate_except_clause()
2171 validate_test(node *tree) in validate_test() argument
2173 int nch = NCH(tree); in validate_test()
2174 int res = validate_ntype(tree, test) && is_odd(nch); in validate_test()
2176 if (res && (TYPE(CHILD(tree, 0)) == lambdef)) in validate_test()
2178 && validate_lambdef(CHILD(tree, 0))); in validate_test()
2180 res = validate_or_test(CHILD(tree, 0)); in validate_test()
2182 validate_name(CHILD(tree, 1), "if") && in validate_test()
2183 validate_or_test(CHILD(tree, 2)) && in validate_test()
2184 validate_name(CHILD(tree, 3), "else") && in validate_test()
2185 validate_test(CHILD(tree, 4))))); in validate_test()
2191 validate_old_test(node *tree) in validate_old_test() argument
2193 int nch = NCH(tree); in validate_old_test()
2194 int res = validate_ntype(tree, old_test) && (nch == 1); in validate_old_test()
2196 if (res && (TYPE(CHILD(tree, 0)) == old_lambdef)) in validate_old_test()
2197 res = (validate_old_lambdef(CHILD(tree, 0))); in validate_old_test()
2199 res = (validate_or_test(CHILD(tree, 0))); in validate_old_test()
2205 validate_or_test(node *tree) in validate_or_test() argument
2207 int nch = NCH(tree); in validate_or_test()
2208 int res = validate_ntype(tree, or_test) && is_odd(nch); in validate_or_test()
2212 res = validate_and_test(CHILD(tree, 0)); in validate_or_test()
2214 res = (validate_name(CHILD(tree, pos), "or") in validate_or_test()
2215 && validate_and_test(CHILD(tree, pos + 1))); in validate_or_test()
2222 validate_and_test(node *tree) in validate_and_test() argument
2225 int nch = NCH(tree); in validate_and_test()
2226 int res = (validate_ntype(tree, and_test) in validate_and_test()
2228 && validate_not_test(CHILD(tree, 0))); in validate_and_test()
2231 res = (validate_name(CHILD(tree, pos), "and") in validate_and_test()
2232 && validate_not_test(CHILD(tree, 0))); in validate_and_test()
2239 validate_not_test(node *tree) in validate_not_test() argument
2241 int nch = NCH(tree); in validate_not_test()
2242 int res = validate_ntype(tree, not_test) && ((nch == 1) || (nch == 2)); in validate_not_test()
2246 res = (validate_name(CHILD(tree, 0), "not") in validate_not_test()
2247 && validate_not_test(CHILD(tree, 1))); in validate_not_test()
2249 res = validate_comparison(CHILD(tree, 0)); in validate_not_test()
2256 validate_comparison(node *tree) in validate_comparison() argument
2259 int nch = NCH(tree); in validate_comparison()
2260 int res = (validate_ntype(tree, comparison) in validate_comparison()
2262 && validate_expr(CHILD(tree, 0))); in validate_comparison()
2265 res = (validate_comp_op(CHILD(tree, pos)) in validate_comparison()
2266 && validate_expr(CHILD(tree, pos + 1))); in validate_comparison()
2273 validate_comp_op(node *tree) in validate_comp_op() argument
2276 int nch = NCH(tree); in validate_comp_op()
2278 if (!validate_ntype(tree, comp_op)) in validate_comp_op()
2285 tree = CHILD(tree, 0); in validate_comp_op()
2286 switch (TYPE(tree)) { in validate_comp_op()
2297 res = ((strcmp(STR(tree), "in") == 0) in validate_comp_op()
2298 || (strcmp(STR(tree), "is") == 0)); in validate_comp_op()
2301 "illegal operator '%s'", STR(tree)); in validate_comp_op()
2309 else if ((res = validate_numnodes(tree, 2, "comp_op")) != 0) { in validate_comp_op()
2310 res = (validate_ntype(CHILD(tree, 0), NAME) in validate_comp_op()
2311 && validate_ntype(CHILD(tree, 1), NAME) in validate_comp_op()
2312 && (((strcmp(STR(CHILD(tree, 0)), "is") == 0) in validate_comp_op()
2313 && (strcmp(STR(CHILD(tree, 1)), "not") == 0)) in validate_comp_op()
2314 || ((strcmp(STR(CHILD(tree, 0)), "not") == 0) in validate_comp_op()
2315 && (strcmp(STR(CHILD(tree, 1)), "in") == 0)))); in validate_comp_op()
2324 validate_expr(node *tree) in validate_expr() argument
2327 int nch = NCH(tree); in validate_expr()
2328 int res = (validate_ntype(tree, expr) in validate_expr()
2330 && validate_xor_expr(CHILD(tree, 0))); in validate_expr()
2333 res = (validate_xor_expr(CHILD(tree, j)) in validate_expr()
2334 && validate_vbar(CHILD(tree, j - 1))); in validate_expr()
2341 validate_xor_expr(node *tree) in validate_xor_expr() argument
2344 int nch = NCH(tree); in validate_xor_expr()
2345 int res = (validate_ntype(tree, xor_expr) in validate_xor_expr()
2347 && validate_and_expr(CHILD(tree, 0))); in validate_xor_expr()
2350 res = (validate_circumflex(CHILD(tree, j - 1)) in validate_xor_expr()
2351 && validate_and_expr(CHILD(tree, j))); in validate_xor_expr()
2358 validate_and_expr(node *tree) in validate_and_expr() argument
2361 int nch = NCH(tree); in validate_and_expr()
2362 int res = (validate_ntype(tree, and_expr) in validate_and_expr()
2364 && validate_shift_expr(CHILD(tree, 0))); in validate_and_expr()
2367 res = (validate_ampersand(CHILD(tree, pos)) in validate_and_expr()
2368 && validate_shift_expr(CHILD(tree, pos + 1))); in validate_and_expr()
2375 validate_chain_two_ops(node *tree, int (*termvalid)(node *), int op1, int op2) in validate_chain_two_ops() argument
2378 int nch = NCH(tree); in validate_chain_two_ops()
2380 && (*termvalid)(CHILD(tree, 0))); in validate_chain_two_ops()
2383 if (TYPE(CHILD(tree, pos)) != op1) in validate_chain_two_ops()
2384 res = validate_ntype(CHILD(tree, pos), op2); in validate_chain_two_ops()
2386 res = (*termvalid)(CHILD(tree, pos + 1)); in validate_chain_two_ops()
2393 validate_shift_expr(node *tree) in validate_shift_expr() argument
2395 return (validate_ntype(tree, shift_expr) in validate_shift_expr()
2396 && validate_chain_two_ops(tree, validate_arith_expr, in validate_shift_expr()
2402 validate_arith_expr(node *tree) in validate_arith_expr() argument
2404 return (validate_ntype(tree, arith_expr) in validate_arith_expr()
2405 && validate_chain_two_ops(tree, validate_term, PLUS, MINUS)); in validate_arith_expr()
2410 validate_term(node *tree) in validate_term() argument
2413 int nch = NCH(tree); in validate_term()
2414 int res = (validate_ntype(tree, term) in validate_term()
2416 && validate_factor(CHILD(tree, 0))); in validate_term()
2419 res = (((TYPE(CHILD(tree, pos)) == STAR) in validate_term()
2420 || (TYPE(CHILD(tree, pos)) == SLASH) in validate_term()
2421 || (TYPE(CHILD(tree, pos)) == DOUBLESLASH) in validate_term()
2422 || (TYPE(CHILD(tree, pos)) == PERCENT)) in validate_term()
2423 && validate_factor(CHILD(tree, pos + 1))); in validate_term()
2434 validate_factor(node *tree) in validate_factor() argument
2436 int nch = NCH(tree); in validate_factor()
2437 int res = (validate_ntype(tree, factor) in validate_factor()
2439 && ((TYPE(CHILD(tree, 0)) == PLUS) in validate_factor()
2440 || (TYPE(CHILD(tree, 0)) == MINUS) in validate_factor()
2441 || (TYPE(CHILD(tree, 0)) == TILDE)) in validate_factor()
2442 && validate_factor(CHILD(tree, 1))) in validate_factor()
2444 && validate_power(CHILD(tree, 0))))); in validate_factor()
2454 validate_power(node *tree) in validate_power() argument
2457 int nch = NCH(tree); in validate_power()
2458 int res = (validate_ntype(tree, power) && (nch >= 1) in validate_power()
2459 && validate_atom(CHILD(tree, 0))); in validate_power()
2461 while (res && (pos < nch) && (TYPE(CHILD(tree, pos)) == trailer)) in validate_power()
2462 res = validate_trailer(CHILD(tree, pos++)); in validate_power()
2469 res = (validate_doublestar(CHILD(tree, pos)) in validate_power()
2470 && validate_factor(CHILD(tree, pos + 1))); in validate_power()
2477 validate_atom(node *tree) in validate_atom() argument
2480 int nch = NCH(tree); in validate_atom()
2481 int res = validate_ntype(tree, atom); in validate_atom()
2484 res = validate_numnodes(tree, nch+1, "atom"); in validate_atom()
2486 switch (TYPE(CHILD(tree, 0))) { in validate_atom()
2489 && (validate_rparen(CHILD(tree, nch - 1)))); in validate_atom()
2492 if (TYPE(CHILD(tree, 1))==yield_expr) in validate_atom()
2493 res = validate_yield_expr(CHILD(tree, 1)); in validate_atom()
2495 res = validate_testlist_comp(CHILD(tree, 1)); in validate_atom()
2500 res = validate_ntype(CHILD(tree, 1), RSQB); in validate_atom()
2502 res = (validate_listmaker(CHILD(tree, 1)) in validate_atom()
2503 && validate_ntype(CHILD(tree, 2), RSQB)); in validate_atom()
2511 && validate_ntype(CHILD(tree, nch - 1), RBRACE)); in validate_atom()
2514 res = validate_dictorsetmaker(CHILD(tree, 1)); in validate_atom()
2518 && validate_testlist1(CHILD(tree, 1)) in validate_atom()
2519 && validate_ntype(CHILD(tree, 2), BACKQUOTE)); in validate_atom()
2527 res = validate_ntype(CHILD(tree, pos), STRING); in validate_atom()
2542 validate_listmaker(node *tree) in validate_listmaker() argument
2544 int nch = NCH(tree); in validate_listmaker()
2550 ok = validate_test(CHILD(tree, 0)); in validate_listmaker()
2555 if (nch == 2 && TYPE(CHILD(tree, 1)) == list_for) in validate_listmaker()
2556 ok = validate_list_for(CHILD(tree, 1)); in validate_listmaker()
2561 ok = (validate_comma(CHILD(tree, i)) in validate_listmaker()
2562 && validate_test(CHILD(tree, i+1))); in validate_listmaker()
2566 ok = validate_comma(CHILD(tree, i)); in validate_listmaker()
2579 validate_testlist_comp(node *tree) in validate_testlist_comp() argument
2581 int nch = NCH(tree); in validate_testlist_comp()
2587 ok = validate_test(CHILD(tree, 0)); in validate_testlist_comp()
2593 if (nch == 2 && TYPE(CHILD(tree, 1)) == comp_for) in validate_testlist_comp()
2594 ok = validate_comp_for(CHILD(tree, 1)); in validate_testlist_comp()
2599 ok = (validate_comma(CHILD(tree, i)) in validate_testlist_comp()
2600 && validate_test(CHILD(tree, i+1))); in validate_testlist_comp()
2604 ok = validate_comma(CHILD(tree, i)); in validate_testlist_comp()
2617 validate_decorator(node *tree) in validate_decorator() argument
2620 int nch = NCH(tree); in validate_decorator()
2621 ok = (validate_ntype(tree, decorator) && in validate_decorator()
2623 validate_at(CHILD(tree, 0)) && in validate_decorator()
2624 validate_dotted_name(CHILD(tree, 1)) && in validate_decorator()
2625 validate_newline(RCHILD(tree, -1))); in validate_decorator()
2628 ok = (validate_lparen(CHILD(tree, 2)) && in validate_decorator()
2629 validate_rparen(RCHILD(tree, -2))); in validate_decorator()
2632 ok = validate_arglist(CHILD(tree, 3)); in validate_decorator()
2642 validate_decorators(node *tree) in validate_decorators() argument
2645 nch = NCH(tree); in validate_decorators()
2646 ok = validate_ntype(tree, decorators) && nch >= 1; in validate_decorators()
2649 ok = validate_decorator(CHILD(tree, i)); in validate_decorators()
2658 validate_with_item(node *tree) in validate_with_item() argument
2660 int nch = NCH(tree); in validate_with_item()
2661 int ok = (validate_ntype(tree, with_item) in validate_with_item()
2663 && validate_test(CHILD(tree, 0))); in validate_with_item()
2665 ok = (validate_name(CHILD(tree, 1), "as") in validate_with_item()
2666 && validate_expr(CHILD(tree, 2))); in validate_with_item()
2675 validate_with_stmt(node *tree) in validate_with_stmt() argument
2678 int nch = NCH(tree); in validate_with_stmt()
2679 int ok = (validate_ntype(tree, with_stmt) in validate_with_stmt()
2681 && validate_name(CHILD(tree, 0), "with") in validate_with_stmt()
2682 && validate_colon(RCHILD(tree, -2)) in validate_with_stmt()
2683 && validate_suite(RCHILD(tree, -1))); in validate_with_stmt()
2685 ok = validate_with_item(CHILD(tree, i)); in validate_with_stmt()
2695 validate_funcdef(node *tree) in validate_funcdef() argument
2697 int nch = NCH(tree); in validate_funcdef()
2698 int ok = (validate_ntype(tree, funcdef) in validate_funcdef()
2700 && validate_name(RCHILD(tree, -5), "def") in validate_funcdef()
2701 && validate_ntype(RCHILD(tree, -4), NAME) in validate_funcdef()
2702 && validate_colon(RCHILD(tree, -2)) in validate_funcdef()
2703 && validate_parameters(RCHILD(tree, -3)) in validate_funcdef()
2704 && validate_suite(RCHILD(tree, -1))); in validate_funcdef()
2713 validate_decorated(node *tree) in validate_decorated() argument
2715 int nch = NCH(tree); in validate_decorated()
2716 int ok = (validate_ntype(tree, decorated) in validate_decorated()
2718 && validate_decorators(RCHILD(tree, -2))); in validate_decorated()
2719 if (TYPE(RCHILD(tree, -1)) == funcdef) in validate_decorated()
2720 ok = ok && validate_funcdef(RCHILD(tree, -1)); in validate_decorated()
2722 ok = ok && validate_class(RCHILD(tree, -1)); in validate_decorated()
2727 validate_lambdef(node *tree) in validate_lambdef() argument
2729 int nch = NCH(tree); in validate_lambdef()
2730 int res = (validate_ntype(tree, lambdef) in validate_lambdef()
2732 && validate_name(CHILD(tree, 0), "lambda") in validate_lambdef()
2733 && validate_colon(CHILD(tree, nch - 2)) in validate_lambdef()
2734 && validate_test(CHILD(tree, nch - 1))); in validate_lambdef()
2737 res = validate_varargslist(CHILD(tree, 1)); in validate_lambdef()
2739 (void) validate_numnodes(tree, 3, "lambdef"); in validate_lambdef()
2746 validate_old_lambdef(node *tree) in validate_old_lambdef() argument
2748 int nch = NCH(tree); in validate_old_lambdef()
2749 int res = (validate_ntype(tree, old_lambdef) in validate_old_lambdef()
2751 && validate_name(CHILD(tree, 0), "lambda") in validate_old_lambdef()
2752 && validate_colon(CHILD(tree, nch - 2)) in validate_old_lambdef()
2753 && validate_test(CHILD(tree, nch - 1))); in validate_old_lambdef()
2756 res = validate_varargslist(CHILD(tree, 1)); in validate_old_lambdef()
2758 (void) validate_numnodes(tree, 3, "old_lambdef"); in validate_old_lambdef()
2769 validate_arglist(node *tree) in validate_arglist() argument
2771 int nch = NCH(tree); in validate_arglist()
2777 return validate_numnodes(tree, nch + 1, "arglist"); in validate_arglist()
2781 if (TYPE(CHILD(tree, i)) == argument) { in validate_arglist()
2782 node *ch = CHILD(tree, i); in validate_arglist()
2793 ok = (validate_argument(CHILD(tree, i)) in validate_arglist()
2794 && validate_comma(CHILD(tree, i+1))); in validate_arglist()
2805 int sym = TYPE(CHILD(tree, i)); in validate_arglist()
2808 ok = validate_argument(CHILD(tree, i)); in validate_arglist()
2816 ok = validate_star(CHILD(tree, i)); in validate_arglist()
2818 ok = validate_test(CHILD(tree, i+1)); in validate_arglist()
2820 ok = (validate_test(CHILD(tree, i+1)) in validate_arglist()
2821 && validate_comma(CHILD(tree, i+2)) in validate_arglist()
2822 && validate_doublestar(CHILD(tree, i+3)) in validate_arglist()
2823 && validate_test(CHILD(tree, i+4))); in validate_arglist()
2831 ok = (validate_doublestar(CHILD(tree, i)) in validate_arglist()
2832 && validate_test(CHILD(tree, i+1))); in validate_arglist()
2853 validate_argument(node *tree) in validate_argument() argument
2855 int nch = NCH(tree); in validate_argument()
2856 int res = (validate_ntype(tree, argument) in validate_argument()
2858 && validate_test(CHILD(tree, 0))); in validate_argument()
2861 res = validate_comp_for(CHILD(tree, 1)); in validate_argument()
2863 res = (validate_equal(CHILD(tree, 1)) in validate_argument()
2864 && validate_test(CHILD(tree, 2))); in validate_argument()
2876 validate_trailer(node *tree) in validate_trailer() argument
2878 int nch = NCH(tree); in validate_trailer()
2879 int res = validate_ntype(tree, trailer) && ((nch == 2) || (nch == 3)); in validate_trailer()
2882 switch (TYPE(CHILD(tree, 0))) { in validate_trailer()
2884 res = validate_rparen(CHILD(tree, nch - 1)); in validate_trailer()
2886 res = validate_arglist(CHILD(tree, 1)); in validate_trailer()
2889 res = (validate_numnodes(tree, 3, "trailer") in validate_trailer()
2890 && validate_subscriptlist(CHILD(tree, 1)) in validate_trailer()
2891 && validate_ntype(CHILD(tree, 2), RSQB)); in validate_trailer()
2894 res = (validate_numnodes(tree, 2, "trailer") in validate_trailer()
2895 && validate_ntype(CHILD(tree, 1), NAME)); in validate_trailer()
2903 (void) validate_numnodes(tree, 2, "trailer"); in validate_trailer()
2914 validate_subscriptlist(node *tree) in validate_subscriptlist() argument
2916 return (validate_repeating_list(tree, subscriptlist, in validate_subscriptlist()
2926 validate_subscript(node *tree) in validate_subscript() argument
2929 int nch = NCH(tree); in validate_subscript()
2930 int res = validate_ntype(tree, subscript) && (nch >= 1) && (nch <= 4); in validate_subscript()
2937 if (TYPE(CHILD(tree, 0)) == DOT) in validate_subscript()
2939 return (validate_numnodes(tree, 3, "subscript") in validate_subscript()
2940 && validate_dot(CHILD(tree, 0)) in validate_subscript()
2941 && validate_dot(CHILD(tree, 1)) in validate_subscript()
2942 && validate_dot(CHILD(tree, 2))); in validate_subscript()
2944 if (TYPE(CHILD(tree, 0)) == test) in validate_subscript()
2945 res = validate_test(CHILD(tree, 0)); in validate_subscript()
2947 res = validate_colon(CHILD(tree, 0)); in validate_subscript()
2954 if ((TYPE(CHILD(tree, 0)) != COLON) || (nch == 4)) { in validate_subscript()
2955 res = validate_test(CHILD(tree, 0)); in validate_subscript()
2959 res = validate_colon(CHILD(tree, offset)); in validate_subscript()
2963 if (TYPE(CHILD(tree, offset)) == test) { in validate_subscript()
2964 res = validate_test(CHILD(tree, offset)); in validate_subscript()
2969 res = validate_sliceop(CHILD(tree, offset)); in validate_subscript()
2977 validate_sliceop(node *tree) in validate_sliceop() argument
2979 int nch = NCH(tree); in validate_sliceop()
2980 int res = ((nch == 1) || validate_numnodes(tree, 2, "sliceop")) in validate_sliceop()
2981 && validate_ntype(tree, sliceop); in validate_sliceop()
2983 res = validate_numnodes(tree, 1, "sliceop"); in validate_sliceop()
2986 res = validate_colon(CHILD(tree, 0)); in validate_sliceop()
2988 res = validate_test(CHILD(tree, 1)); in validate_sliceop()
2995 validate_exprlist(node *tree) in validate_exprlist() argument
2997 return (validate_repeating_list(tree, exprlist, in validate_exprlist()
3009 validate_dictorsetmaker(node *tree) in validate_dictorsetmaker() argument
3011 int nch = NCH(tree); in validate_dictorsetmaker()
3012 int ok = validate_ntype(tree, dictorsetmaker); in validate_dictorsetmaker()
3018 if (ok && (nch == 1 || TYPE(CHILD(tree, 1)) == COMMA)) { in validate_dictorsetmaker()
3022 ok = validate_test(CHILD(tree, i++)); in validate_dictorsetmaker()
3024 ok = (validate_comma(CHILD(tree, i)) in validate_dictorsetmaker()
3025 && validate_test(CHILD(tree, i+1))); in validate_dictorsetmaker()
3030 else if (ok && TYPE(CHILD(tree, 1)) == comp_for) { in validate_dictorsetmaker()
3034 ok = (validate_test(CHILD(tree, 0)) in validate_dictorsetmaker()
3035 && validate_comp_for(CHILD(tree, 1))); in validate_dictorsetmaker()
3037 else if (ok && NCH(tree) > 3 && TYPE(CHILD(tree, 3)) == comp_for) { in validate_dictorsetmaker()
3041 ok = (validate_test(CHILD(tree, 0)) in validate_dictorsetmaker()
3042 && validate_colon(CHILD(tree, 1)) in validate_dictorsetmaker()
3043 && validate_test(CHILD(tree, 2)) in validate_dictorsetmaker()
3044 && validate_comp_for(CHILD(tree, 3))); in validate_dictorsetmaker()
3051 ok = (validate_test(CHILD(tree, i)) in validate_dictorsetmaker()
3052 && validate_colon(CHILD(tree, i+1)) in validate_dictorsetmaker()
3053 && validate_test(CHILD(tree, i+2))); in validate_dictorsetmaker()
3062 ok = (validate_comma(CHILD(tree, i)) in validate_dictorsetmaker()
3063 && validate_test(CHILD(tree, i+1)) in validate_dictorsetmaker()
3064 && validate_colon(CHILD(tree, i+2)) in validate_dictorsetmaker()
3065 && validate_test(CHILD(tree, i+3))); in validate_dictorsetmaker()
3072 ok = validate_comma(CHILD(tree, i)); in validate_dictorsetmaker()
3084 validate_eval_input(node *tree) in validate_eval_input() argument
3087 int nch = NCH(tree); in validate_eval_input()
3088 int res = (validate_ntype(tree, eval_input) in validate_eval_input()
3090 && validate_testlist(CHILD(tree, 0)) in validate_eval_input()
3091 && validate_ntype(CHILD(tree, nch - 1), ENDMARKER)); in validate_eval_input()
3094 res = validate_ntype(CHILD(tree, pos), NEWLINE); in validate_eval_input()
3101 validate_node(node *tree) in validate_node() argument
3107 while (res && (tree != 0)) { in validate_node()
3108 nch = NCH(tree); in validate_node()
3110 switch (TYPE(tree)) { in validate_node()
3115 res = validate_funcdef(tree); in validate_node()
3118 res = validate_with_stmt(tree); in validate_node()
3121 res = validate_class(tree); in validate_node()
3124 res = validate_decorated(tree); in validate_node()
3131 res = validate_stmt(tree); in validate_node()
3138 res = validate_small_stmt(tree); in validate_node()
3141 res = (validate_numnodes(tree, 1, "flow_stmt") in validate_node()
3142 && ((TYPE(CHILD(tree, 0)) == break_stmt) in validate_node()
3143 || (TYPE(CHILD(tree, 0)) == continue_stmt) in validate_node()
3144 || (TYPE(CHILD(tree, 0)) == yield_stmt) in validate_node()
3145 || (TYPE(CHILD(tree, 0)) == return_stmt) in validate_node()
3146 || (TYPE(CHILD(tree, 0)) == raise_stmt))); in validate_node()
3148 next = CHILD(tree, 0); in validate_node()
3153 res = validate_yield_stmt(tree); in validate_node()
3159 res = validate_simple_stmt(tree); in validate_node()
3162 res = validate_compound_stmt(tree); in validate_node()
3168 res = validate_expr_stmt(tree); in validate_node()
3171 res = validate_print_stmt(tree); in validate_node()
3174 res = validate_del_stmt(tree); in validate_node()
3177 res = (validate_numnodes(tree, 1, "pass") in validate_node()
3178 && validate_name(CHILD(tree, 0), "pass")); in validate_node()
3181 res = (validate_numnodes(tree, 1, "break") in validate_node()
3182 && validate_name(CHILD(tree, 0), "break")); in validate_node()
3185 res = (validate_numnodes(tree, 1, "continue") in validate_node()
3186 && validate_name(CHILD(tree, 0), "continue")); in validate_node()
3189 res = validate_return_stmt(tree); in validate_node()
3192 res = validate_raise_stmt(tree); in validate_node()
3195 res = validate_import_stmt(tree); in validate_node()
3198 res = validate_import_name(tree); in validate_node()
3201 res = validate_import_from(tree); in validate_node()
3204 res = validate_global_stmt(tree); in validate_node()
3207 res = validate_exec_stmt(tree); in validate_node()
3210 res = validate_assert_stmt(tree); in validate_node()
3213 res = validate_if(tree); in validate_node()
3216 res = validate_while(tree); in validate_node()
3219 res = validate_for(tree); in validate_node()
3222 res = validate_try(tree); in validate_node()
3225 res = validate_suite(tree); in validate_node()
3231 res = validate_testlist(tree); in validate_node()
3234 res = validate_yield_expr(tree); in validate_node()
3237 res = validate_testlist1(tree); in validate_node()
3240 res = validate_test(tree); in validate_node()
3243 res = validate_and_test(tree); in validate_node()
3246 res = validate_not_test(tree); in validate_node()
3249 res = validate_comparison(tree); in validate_node()
3252 res = validate_exprlist(tree); in validate_node()
3255 res = validate_comp_op(tree); in validate_node()
3258 res = validate_expr(tree); in validate_node()
3261 res = validate_xor_expr(tree); in validate_node()
3264 res = validate_and_expr(tree); in validate_node()
3267 res = validate_shift_expr(tree); in validate_node()
3270 res = validate_arith_expr(tree); in validate_node()
3273 res = validate_term(tree); in validate_node()
3276 res = validate_factor(tree); in validate_node()
3279 res = validate_power(tree); in validate_node()
3282 res = validate_atom(tree); in validate_node()
3291 tree = next; in validate_node()
3298 validate_expr_tree(node *tree) in validate_expr_tree() argument
3300 int res = validate_eval_input(tree); in validate_expr_tree()
3313 validate_file_input(node *tree) in validate_file_input() argument
3316 int nch = NCH(tree) - 1; in validate_file_input()
3318 && validate_ntype(CHILD(tree, nch), ENDMARKER)); in validate_file_input()
3321 if (TYPE(CHILD(tree, j)) == stmt) in validate_file_input()
3322 res = validate_stmt(CHILD(tree, j)); in validate_file_input()
3324 res = validate_newline(CHILD(tree, j)); in validate_file_input()
3337 validate_encoding_decl(node *tree) in validate_encoding_decl() argument
3339 int nch = NCH(tree); in validate_encoding_decl()
3341 && validate_file_input(CHILD(tree, 0))); in validate_encoding_decl()