1 # We declare all of these here to type the first argument. 2 3 cimport cython 4 from Cython.Compiler.Scanning cimport PyrexScanner 5 6 ctypedef object (*p_sub_expr_func)(PyrexScanner obj) 7 8 # entry points 9 10 cpdef p_module(PyrexScanner s, pxd, full_module_name, ctx=*) 11 cpdef p_code(PyrexScanner s, level= *, ctx=*) 12 13 # internal parser states 14 15 cdef p_ident(PyrexScanner s, message =*) 16 cdef p_ident_list(PyrexScanner s) 17 18 cdef tuple p_binop_operator(PyrexScanner s) 19 cdef p_binop_expr(PyrexScanner s, ops, p_sub_expr_func p_sub_expr) 20 cdef p_lambdef(PyrexScanner s, bint allow_conditional=*) 21 cdef p_lambdef_nocond(PyrexScanner s) 22 cdef p_test(PyrexScanner s) 23 cdef p_test_nocond(PyrexScanner s) 24 cdef p_or_test(PyrexScanner s) 25 cdef p_rassoc_binop_expr(PyrexScanner s, ops, p_sub_expr_func p_subexpr) 26 cdef p_and_test(PyrexScanner s) 27 cdef p_not_test(PyrexScanner s) 28 cdef p_comparison(PyrexScanner s) 29 cdef p_test_or_starred_expr(PyrexScanner s) 30 cdef p_starred_expr(PyrexScanner s) 31 cdef p_cascaded_cmp(PyrexScanner s) 32 cdef p_cmp_op(PyrexScanner s) 33 cdef p_bit_expr(PyrexScanner s) 34 cdef p_xor_expr(PyrexScanner s) 35 cdef p_and_expr(PyrexScanner s) 36 cdef p_shift_expr(PyrexScanner s) 37 cdef p_arith_expr(PyrexScanner s) 38 cdef p_term(PyrexScanner s) 39 cdef p_factor(PyrexScanner s) 40 cdef _p_factor(PyrexScanner s) 41 cdef p_typecast(PyrexScanner s) 42 cdef p_sizeof(PyrexScanner s) 43 cdef p_yield_expression(PyrexScanner s) 44 cdef p_yield_statement(PyrexScanner s) 45 cdef p_power(PyrexScanner s) 46 cdef p_new_expr(PyrexScanner s) 47 cdef p_trailer(PyrexScanner s, node1) 48 cdef p_call_parse_args(PyrexScanner s, bint allow_genexp = *) 49 cdef p_call_build_packed_args(pos, positional_args, keyword_args, star_arg, starstar_arg) 50 cdef p_call(PyrexScanner s, function) 51 cdef p_index(PyrexScanner s, base) 52 cdef tuple p_subscript_list(PyrexScanner s) 53 cdef p_subscript(PyrexScanner s) 54 cdef p_slice_element(PyrexScanner s, follow_set) 55 cdef expect_ellipsis(PyrexScanner s) 56 cdef make_slice_nodes(pos, subscripts) 57 cpdef make_slice_node(pos, start, stop = *, step = *) 58 cdef p_atom(PyrexScanner s) 59 @cython.locals(value=unicode) 60 cdef p_int_literal(PyrexScanner s) 61 cdef p_name(PyrexScanner s, name) 62 cdef wrap_compile_time_constant(pos, value) 63 cdef p_cat_string_literal(PyrexScanner s) 64 cdef p_opt_string_literal(PyrexScanner s, required_type=*) 65 cdef bint check_for_non_ascii_characters(unicode string) 66 @cython.locals(systr=unicode, is_python3_source=bint, is_raw=bint) 67 cdef p_string_literal(PyrexScanner s, kind_override=*) 68 cdef p_list_maker(PyrexScanner s) 69 cdef p_comp_iter(PyrexScanner s, body) 70 cdef p_comp_for(PyrexScanner s, body) 71 cdef p_comp_if(PyrexScanner s, body) 72 cdef p_dict_or_set_maker(PyrexScanner s) 73 cdef p_backquote_expr(PyrexScanner s) 74 cdef p_simple_expr_list(PyrexScanner s, expr=*) 75 cdef p_test_or_starred_expr_list(PyrexScanner s, expr=*) 76 cdef p_testlist(PyrexScanner s) 77 cdef p_testlist_star_expr(PyrexScanner s) 78 cdef p_testlist_comp(PyrexScanner s) 79 cdef p_genexp(PyrexScanner s, expr) 80 81 #------------------------------------------------------- 82 # 83 # Statements 84 # 85 #------------------------------------------------------- 86 87 cdef p_global_statement(PyrexScanner s) 88 cdef p_nonlocal_statement(PyrexScanner s) 89 cdef p_expression_or_assignment(PyrexScanner s) 90 cdef p_print_statement(PyrexScanner s) 91 cdef p_exec_statement(PyrexScanner s) 92 cdef p_del_statement(PyrexScanner s) 93 cdef p_pass_statement(PyrexScanner s, bint with_newline = *) 94 cdef p_break_statement(PyrexScanner s) 95 cdef p_continue_statement(PyrexScanner s) 96 cdef p_return_statement(PyrexScanner s) 97 cdef p_raise_statement(PyrexScanner s) 98 cdef p_import_statement(PyrexScanner s) 99 cdef p_from_import_statement(PyrexScanner s, bint first_statement = *) 100 cdef p_imported_name(PyrexScanner s, bint is_cimport) 101 cdef p_dotted_name(PyrexScanner s, bint as_allowed) 102 cdef p_as_name(PyrexScanner s) 103 cdef p_assert_statement(PyrexScanner s) 104 cdef p_if_statement(PyrexScanner s) 105 cdef p_if_clause(PyrexScanner s) 106 cdef p_else_clause(PyrexScanner s) 107 cdef p_while_statement(PyrexScanner s) 108 cdef p_for_statement(PyrexScanner s) 109 cdef dict p_for_bounds(PyrexScanner s, bint allow_testlist = *) 110 cdef p_for_from_relation(PyrexScanner s) 111 cdef p_for_from_step(PyrexScanner s) 112 cdef p_target(PyrexScanner s, terminator) 113 cdef p_for_target(PyrexScanner s) 114 cdef p_for_iterator(PyrexScanner s, bint allow_testlist = *) 115 cdef p_try_statement(PyrexScanner s) 116 cdef p_except_clause(PyrexScanner s) 117 cdef p_include_statement(PyrexScanner s, ctx) 118 cdef p_with_statement(PyrexScanner s) 119 cdef p_with_items(PyrexScanner s) 120 cdef p_with_template(PyrexScanner s) 121 cdef p_simple_statement(PyrexScanner s, bint first_statement = *) 122 cdef p_simple_statement_list(PyrexScanner s, ctx, bint first_statement = *) 123 cdef p_compile_time_expr(PyrexScanner s) 124 cdef p_DEF_statement(PyrexScanner s) 125 cdef p_IF_statement(PyrexScanner s, ctx) 126 cdef p_statement(PyrexScanner s, ctx, bint first_statement = *) 127 cdef p_statement_list(PyrexScanner s, ctx, bint first_statement = *) 128 cdef p_suite(PyrexScanner s, ctx = *) 129 cdef tuple p_suite_with_docstring(PyrexScanner s, ctx, with_doc_only = *) 130 cdef tuple _extract_docstring(node) 131 cdef p_positional_and_keyword_args(PyrexScanner s, end_sy_set, templates = *) 132 133 cpdef p_c_base_type(PyrexScanner s, bint self_flag = *, bint nonempty = *, templates = *) 134 cdef p_calling_convention(PyrexScanner s) 135 cdef p_c_complex_base_type(PyrexScanner s, templates = *) 136 cdef p_c_simple_base_type(PyrexScanner s, bint self_flag, bint nonempty, templates = *) 137 cdef p_buffer_or_template(PyrexScanner s, base_type_node, templates) 138 cdef p_bracketed_base_type(PyrexScanner s, base_type_node, nonempty, empty) 139 cdef is_memoryviewslice_access(PyrexScanner s) 140 cdef p_memoryviewslice_access(PyrexScanner s, base_type_node) 141 cdef bint looking_at_name(PyrexScanner s) except -2 142 cdef object looking_at_expr(PyrexScanner s)# except -2 143 cdef bint looking_at_base_type(PyrexScanner s) except -2 144 cdef bint looking_at_dotted_name(PyrexScanner s) except -2 145 cdef bint looking_at_call(PyrexScanner s) except -2 146 cdef p_sign_and_longness(PyrexScanner s) 147 cdef p_opt_cname(PyrexScanner s) 148 cpdef p_c_declarator(PyrexScanner s, ctx = *, bint empty = *, bint is_type = *, bint cmethod_flag = *, 149 bint assignable = *, bint nonempty = *, 150 bint calling_convention_allowed = *) 151 cdef p_c_array_declarator(PyrexScanner s, base) 152 cdef p_c_func_declarator(PyrexScanner s, pos, ctx, base, bint cmethod_flag) 153 cdef p_c_simple_declarator(PyrexScanner s, ctx, bint empty, bint is_type, bint cmethod_flag, 154 bint assignable, bint nonempty) 155 cdef p_nogil(PyrexScanner s) 156 cdef p_with_gil(PyrexScanner s) 157 cdef p_exception_value_clause(PyrexScanner s) 158 cpdef p_c_arg_list(PyrexScanner s, ctx = *, bint in_pyfunc = *, bint cmethod_flag = *, 159 bint nonempty_declarators = *, bint kw_only = *, bint annotated = *) 160 cdef p_optional_ellipsis(PyrexScanner s) 161 cdef p_c_arg_decl(PyrexScanner s, ctx, in_pyfunc, bint cmethod_flag = *, bint nonempty = *, bint kw_only = *, bint annotated = *) 162 cdef p_api(PyrexScanner s) 163 cdef p_cdef_statement(PyrexScanner s, ctx) 164 cdef p_cdef_block(PyrexScanner s, ctx) 165 cdef p_cdef_extern_block(PyrexScanner s, pos, ctx) 166 cdef p_c_enum_definition(PyrexScanner s, pos, ctx) 167 cdef p_c_enum_line(PyrexScanner s, ctx, list items) 168 cdef p_c_enum_item(PyrexScanner s, ctx, list items) 169 cdef p_c_struct_or_union_definition(PyrexScanner s, pos, ctx) 170 cdef p_fused_definition(PyrexScanner s, pos, ctx) 171 cdef p_struct_enum(PyrexScanner s, pos, ctx) 172 cdef p_visibility(PyrexScanner s, prev_visibility) 173 cdef p_c_modifiers(PyrexScanner s) 174 cdef p_c_func_or_var_declaration(PyrexScanner s, pos, ctx) 175 cdef p_ctypedef_statement(PyrexScanner s, ctx) 176 cdef p_decorators(PyrexScanner s) 177 cdef p_def_statement(PyrexScanner s, list decorators = *) 178 cdef p_varargslist(PyrexScanner s, terminator=*, bint annotated = *) 179 cdef p_py_arg_decl(PyrexScanner s, bint annotated = *) 180 cdef p_class_statement(PyrexScanner s, decorators) 181 cdef p_c_class_definition(PyrexScanner s, pos, ctx) 182 cdef p_c_class_options(PyrexScanner s) 183 cdef p_property_decl(PyrexScanner s) 184 cdef p_doc_string(PyrexScanner s) 185 cdef p_ignorable_statement(PyrexScanner s) 186 cdef p_compiler_directive_comments(PyrexScanner s) 187 cdef p_cpp_class_definition(PyrexScanner s, pos, ctx) 188