From 708eeb510ac12f5acf9b4ac8bffc7948493cd496 Mon Sep 17 00:00:00 2001 From: ldXiao Date: Sun, 11 Apr 2021 13:32:23 -0400 Subject: [PATCH] pa2grade --- pa2-tests/README.md | 24 + pa2-tests/chocopy-ref.jar | Bin 0 -> 144775 bytes pa2-tests/core/ast_coverage.py | 38 + pa2-tests/core/ast_coverage.py.ast | 627 ++++ pa2-tests/core/ast_coverage.py.ast.typed | 952 ++++++ pa2-tests/core/bad_assign_expr.py | 11 + pa2-tests/core/bad_assign_expr.py.ast | 177 ++ pa2-tests/core/bad_assign_expr.py.ast.typed | 301 ++ pa2-tests/core/bad_class_attr.py | 13 + pa2-tests/core/bad_class_attr.py.ast | 155 + pa2-tests/core/bad_class_attr.py.ast.typed | 165 + pa2-tests/core/bad_class_attr_type.py | 4 + pa2-tests/core/bad_class_attr_type.py.ast | 60 + .../core/bad_class_attr_type.py.ast.typed | 73 + pa2-tests/core/bad_class_init_override.py | 8 + pa2-tests/core/bad_class_init_override.py.ast | 106 + .../core/bad_class_init_override.py.ast.typed | 111 + pa2-tests/core/bad_class_init_return.py | 5 + pa2-tests/core/bad_class_init_return.py.ast | 75 + .../core/bad_class_init_return.py.ast.typed | 88 + pa2-tests/core/bad_class_member_expr.py | 6 + pa2-tests/core/bad_class_member_expr.py.ast | 110 + .../core/bad_class_member_expr.py.ast.typed | 161 + pa2-tests/core/bad_class_method.py | 14 + pa2-tests/core/bad_class_method.py.ast | 158 + pa2-tests/core/bad_class_method.py.ast.typed | 168 + pa2-tests/core/bad_class_method_invoke.py | 30 + pa2-tests/core/bad_class_method_invoke.py.ast | 474 +++ .../core/bad_class_method_invoke.py.ast.typed | 668 ++++ pa2-tests/core/bad_class_method_override.py | 33 + .../core/bad_class_method_override.py.ast | 439 +++ .../bad_class_method_override.py.ast.typed | 454 +++ .../core/bad_class_method_override_attr.py | 8 + .../bad_class_method_override_attr.py.ast | 111 + ...ad_class_method_override_attr.py.ast.typed | 116 + pa2-tests/core/bad_class_super.py | 15 + pa2-tests/core/bad_class_super.py.ast | 154 + pa2-tests/core/bad_class_super.py.ast.typed | 169 + pa2-tests/core/bad_concat.py | 3 + pa2-tests/core/bad_concat.py.ast | 77 + pa2-tests/core/bad_concat.py.ast.typed | 149 + pa2-tests/core/bad_duplicate_class.py | 18 + pa2-tests/core/bad_duplicate_class.py.ast | 190 ++ .../core/bad_duplicate_class.py.ast.typed | 205 ++ pa2-tests/core/bad_duplicate_class_member.py | 12 + .../core/bad_duplicate_class_member.py.ast | 156 + .../bad_duplicate_class_member.py.ast.typed | 166 + pa2-tests/core/bad_duplicate_global.py | 18 + pa2-tests/core/bad_duplicate_global.py.ast | 129 + .../core/bad_duplicate_global.py.ast.typed | 144 + pa2-tests/core/bad_duplicate_global_2.py | 6 + pa2-tests/core/bad_duplicate_global_2.py.ast | 47 + .../core/bad_duplicate_global_2.py.ast.typed | 52 + pa2-tests/core/bad_duplicate_local.py | 21 + pa2-tests/core/bad_duplicate_local.py.ast | 257 ++ .../core/bad_duplicate_local.py.ast.typed | 277 ++ pa2-tests/core/bad_expr_binary.py | 13 + pa2-tests/core/bad_expr_binary.py.ast | 239 ++ pa2-tests/core/bad_expr_binary.py.ast.typed | 455 +++ pa2-tests/core/bad_expr_if.py | 2 + pa2-tests/core/bad_expr_if.py.ast | 70 + pa2-tests/core/bad_expr_if.py.ast.typed | 107 + pa2-tests/core/bad_expr_unary.py | 4 + pa2-tests/core/bad_expr_unary.py.ast | 62 + pa2-tests/core/bad_expr_unary.py.ast.typed | 114 + pa2-tests/core/bad_func_def_call.py | 13 + pa2-tests/core/bad_func_def_call.py.ast | 187 ++ pa2-tests/core/bad_func_def_call.py.ast.typed | 336 ++ pa2-tests/core/bad_func_def_return.py | 10 + pa2-tests/core/bad_func_def_return.py.ast | 125 + .../core/bad_func_def_return.py.ast.typed | 174 + pa2-tests/core/bad_list_assign.py | 6 + pa2-tests/core/bad_list_assign.py.ast | 116 + pa2-tests/core/bad_list_assign.py.ast.typed | 192 ++ pa2-tests/core/bad_list_index.py | 7 + pa2-tests/core/bad_list_index.py.ast | 147 + pa2-tests/core/bad_list_index.py.ast.typed | 275 ++ pa2-tests/core/bad_local_assign.py | 23 + pa2-tests/core/bad_local_assign.py.ast | 253 ++ pa2-tests/core/bad_local_assign.py.ast.typed | 330 ++ pa2-tests/core/bad_none_assign.py | 14 + pa2-tests/core/bad_none_assign.py.ast | 187 ++ pa2-tests/core/bad_none_assign.py.ast.typed | 265 ++ pa2-tests/core/bad_nonlocal_global.py | 25 + pa2-tests/core/bad_nonlocal_global.py.ast | 229 ++ .../core/bad_nonlocal_global.py.ast.typed | 259 ++ pa2-tests/core/bad_return_missing.py | 6 + pa2-tests/core/bad_return_missing.py.ast | 58 + .../core/bad_return_missing.py.ast.typed | 63 + pa2-tests/core/bad_return_top.py | 3 + pa2-tests/core/bad_return_top.py.ast | 41 + pa2-tests/core/bad_return_top.py.ast.typed | 50 + pa2-tests/core/bad_shadow_local.py | 14 + pa2-tests/core/bad_shadow_local.py.ast | 179 ++ pa2-tests/core/bad_shadow_local.py.ast.typed | 199 ++ pa2-tests/core/bad_shadow_local_2.py | 8 + pa2-tests/core/bad_shadow_local_2.py.ast | 98 + .../core/bad_shadow_local_2.py.ast.typed | 103 + pa2-tests/core/bad_strings.py | 10 + pa2-tests/core/bad_strings.py.ast | 183 ++ pa2-tests/core/bad_strings.py.ast.typed | 301 ++ pa2-tests/core/bad_type_annotation.py | 7 + pa2-tests/core/bad_type_annotation.py.ast | 86 + .../core/bad_type_annotation.py.ast.typed | 106 + pa2-tests/core/bad_type_id.py | 1 + pa2-tests/core/bad_type_id.py.ast | 29 + pa2-tests/core/bad_type_id.py.ast.typed | 51 + pa2-tests/core/bad_var_assign.py | 8 + pa2-tests/core/bad_var_assign.py.ast | 127 + pa2-tests/core/bad_var_assign.py.ast.typed | 213 ++ pa2-tests/core/class_def_assign.py | 18 + pa2-tests/core/class_def_assign.py.ast | 263 ++ pa2-tests/core/class_def_assign.py.ast.typed | 323 ++ pa2-tests/core/class_def_attr.py | 22 + pa2-tests/core/class_def_attr.py.ast | 346 ++ pa2-tests/core/class_def_attr.py.ast.typed | 446 +++ pa2-tests/core/class_def_init.py | 17 + pa2-tests/core/class_def_init.py.ast | 243 ++ pa2-tests/core/class_def_init.py.ast.typed | 287 ++ pa2-tests/core/class_def_methods.py | 28 + pa2-tests/core/class_def_methods.py.ast | 451 +++ pa2-tests/core/class_def_methods.py.ast.typed | 595 ++++ pa2-tests/core/decl_global_forward.py | 9 + pa2-tests/core/decl_global_forward.py.ast | 108 + .../core/decl_global_forward.py.ast.typed | 155 + pa2-tests/core/decl_nonlocal_forward.py | 10 + pa2-tests/core/decl_nonlocal_forward.py.ast | 137 + .../core/decl_nonlocal_forward.py.ast.typed | 196 ++ pa2-tests/core/expr_binary.py | 2 + pa2-tests/core/expr_binary.py.ast | 109 + pa2-tests/core/expr_binary.py.ast.typed | 185 ++ pa2-tests/core/expr_concat.py | 3 + pa2-tests/core/expr_concat.py.ast | 93 + pa2-tests/core/expr_concat.py.ast.typed | 175 + pa2-tests/core/expr_id.py | 3 + pa2-tests/core/expr_id.py.ast | 51 + pa2-tests/core/expr_id.py.ast.typed | 67 + pa2-tests/core/expr_if.py | 1 + pa2-tests/core/expr_if.py.ast | 43 + pa2-tests/core/expr_if.py.ast.typed | 67 + pa2-tests/core/expr_int.py | 1 + pa2-tests/core/expr_int.py.ast | 29 + pa2-tests/core/expr_int.py.ast.typed | 41 + pa2-tests/core/expr_list_index.py | 12 + pa2-tests/core/expr_list_index.py.ast | 247 ++ pa2-tests/core/expr_list_index.py.ast.typed | 398 +++ pa2-tests/core/expr_lists.py | 12 + pa2-tests/core/expr_lists.py.ast | 233 ++ pa2-tests/core/expr_lists.py.ast.typed | 374 +++ pa2-tests/core/expr_unary.py | 2 + pa2-tests/core/expr_unary.py.ast | 37 + pa2-tests/core/expr_unary.py.ast.typed | 53 + pa2-tests/core/expr_var_assign.py | 4 + pa2-tests/core/expr_var_assign.py.ast | 71 + pa2-tests/core/expr_var_assign.py.ast.typed | 91 + pa2-tests/core/func_def_call.py | 7 + pa2-tests/core/func_def_call.py.ast | 111 + pa2-tests/core/func_def_call.py.ast.typed | 153 + pa2-tests/core/stmt_for_lists.py | 4 + pa2-tests/core/stmt_for_lists.py.ast | 77 + pa2-tests/core/stmt_for_lists.py.ast.typed | 116 + pa2-tests/core/stmt_for_strings.py | 4 + pa2-tests/core/stmt_for_strings.py.ast | 64 + pa2-tests/core/stmt_for_strings.py.ast.typed | 88 + pa2-tests/core/stmt_if.py | 7 + pa2-tests/core/stmt_if.py.ast | 51 + pa2-tests/core/stmt_if.py.ast.typed | 71 + pa2-tests/core/stmt_list_assign.py | 7 + pa2-tests/core/stmt_list_assign.py.ast | 155 + pa2-tests/core/stmt_list_assign.py.ast.typed | 256 ++ pa2-tests/core/stmt_var_assign.py | 9 + pa2-tests/core/stmt_var_assign.py.ast | 150 + pa2-tests/core/stmt_var_assign.py.ast.typed | 198 ++ pa2-tests/core/stmt_while.py | 3 + pa2-tests/core/stmt_while.py.ast | 75 + pa2-tests/core/stmt_while.py.ast.typed | 107 + pa2-tests/core/strings.py | 8 + pa2-tests/core/strings.py.ast | 139 + pa2-tests/core/strings.py.ast.typed | 195 ++ pa2-tests/extra/exp.py | 25 + pa2-tests/extra/exp.py.ast | 375 +++ pa2-tests/extra/exp.py.ast.typed | 562 ++++ pa2-tests/extra/mergesort.py | 62 + pa2-tests/extra/mergesort.py.ast | 1262 ++++++++ pa2-tests/extra/mergesort.py.ast.typed | 2353 ++++++++++++++ pa2-tests/extra/nested.py | 18 + pa2-tests/extra/nested.py.ast | 325 ++ pa2-tests/extra/nested.py.ast.typed | 439 +++ pa2-tests/extra/prime.py | 30 + pa2-tests/extra/prime.py.ast | 445 +++ pa2-tests/extra/prime.py.ast.typed | 658 ++++ pa2-tests/extra/sieve.py | 107 + pa2-tests/extra/sieve.py.ast | 1841 +++++++++++ pa2-tests/extra/sieve.py.ast.typed | 2816 +++++++++++++++++ pa2-tests/extra/stdlib.py | 77 + pa2-tests/extra/stdlib.py.ast | 1168 +++++++ pa2-tests/extra/stdlib.py.ast.typed | 1813 +++++++++++ pa2-tests/extra/tree.py | 83 + pa2-tests/extra/tree.py.ast | 1513 +++++++++ pa2-tests/extra/tree.py.ast.typed | 2301 ++++++++++++++ pa2-tests/run-tests.sh | 25 + .../student_contributed/bad_semantic.py.ast | 1005 +++++- .../bad_semantic.py.ast.typed | 34 +- .../pa2/student_contributed/bad_types.py.ast | 1278 +++++++- .../bad_types.py.ast.typed | 20 +- .../data/pa2/student_contributed/good.py.ast | 1971 ++++++------ .../pa2/student_contributed/good.py.ast.typed | 20 +- 207 files changed, 44075 insertions(+), 1055 deletions(-) create mode 100644 pa2-tests/README.md create mode 100644 pa2-tests/chocopy-ref.jar create mode 100644 pa2-tests/core/ast_coverage.py create mode 100644 pa2-tests/core/ast_coverage.py.ast create mode 100644 pa2-tests/core/ast_coverage.py.ast.typed create mode 100644 pa2-tests/core/bad_assign_expr.py create mode 100644 pa2-tests/core/bad_assign_expr.py.ast create mode 100644 pa2-tests/core/bad_assign_expr.py.ast.typed create mode 100644 pa2-tests/core/bad_class_attr.py create mode 100644 pa2-tests/core/bad_class_attr.py.ast create mode 100644 pa2-tests/core/bad_class_attr.py.ast.typed create mode 100644 pa2-tests/core/bad_class_attr_type.py create mode 100644 pa2-tests/core/bad_class_attr_type.py.ast create mode 100644 pa2-tests/core/bad_class_attr_type.py.ast.typed create mode 100644 pa2-tests/core/bad_class_init_override.py create mode 100644 pa2-tests/core/bad_class_init_override.py.ast create mode 100644 pa2-tests/core/bad_class_init_override.py.ast.typed create mode 100644 pa2-tests/core/bad_class_init_return.py create mode 100644 pa2-tests/core/bad_class_init_return.py.ast create mode 100644 pa2-tests/core/bad_class_init_return.py.ast.typed create mode 100644 pa2-tests/core/bad_class_member_expr.py create mode 100644 pa2-tests/core/bad_class_member_expr.py.ast create mode 100644 pa2-tests/core/bad_class_member_expr.py.ast.typed create mode 100644 pa2-tests/core/bad_class_method.py create mode 100644 pa2-tests/core/bad_class_method.py.ast create mode 100644 pa2-tests/core/bad_class_method.py.ast.typed create mode 100644 pa2-tests/core/bad_class_method_invoke.py create mode 100644 pa2-tests/core/bad_class_method_invoke.py.ast create mode 100644 pa2-tests/core/bad_class_method_invoke.py.ast.typed create mode 100644 pa2-tests/core/bad_class_method_override.py create mode 100644 pa2-tests/core/bad_class_method_override.py.ast create mode 100644 pa2-tests/core/bad_class_method_override.py.ast.typed create mode 100644 pa2-tests/core/bad_class_method_override_attr.py create mode 100644 pa2-tests/core/bad_class_method_override_attr.py.ast create mode 100644 pa2-tests/core/bad_class_method_override_attr.py.ast.typed create mode 100644 pa2-tests/core/bad_class_super.py create mode 100644 pa2-tests/core/bad_class_super.py.ast create mode 100644 pa2-tests/core/bad_class_super.py.ast.typed create mode 100644 pa2-tests/core/bad_concat.py create mode 100644 pa2-tests/core/bad_concat.py.ast create mode 100644 pa2-tests/core/bad_concat.py.ast.typed create mode 100644 pa2-tests/core/bad_duplicate_class.py create mode 100644 pa2-tests/core/bad_duplicate_class.py.ast create mode 100644 pa2-tests/core/bad_duplicate_class.py.ast.typed create mode 100644 pa2-tests/core/bad_duplicate_class_member.py create mode 100644 pa2-tests/core/bad_duplicate_class_member.py.ast create mode 100644 pa2-tests/core/bad_duplicate_class_member.py.ast.typed create mode 100644 pa2-tests/core/bad_duplicate_global.py create mode 100644 pa2-tests/core/bad_duplicate_global.py.ast create mode 100644 pa2-tests/core/bad_duplicate_global.py.ast.typed create mode 100644 pa2-tests/core/bad_duplicate_global_2.py create mode 100644 pa2-tests/core/bad_duplicate_global_2.py.ast create mode 100644 pa2-tests/core/bad_duplicate_global_2.py.ast.typed create mode 100644 pa2-tests/core/bad_duplicate_local.py create mode 100644 pa2-tests/core/bad_duplicate_local.py.ast create mode 100644 pa2-tests/core/bad_duplicate_local.py.ast.typed create mode 100644 pa2-tests/core/bad_expr_binary.py create mode 100644 pa2-tests/core/bad_expr_binary.py.ast create mode 100644 pa2-tests/core/bad_expr_binary.py.ast.typed create mode 100644 pa2-tests/core/bad_expr_if.py create mode 100644 pa2-tests/core/bad_expr_if.py.ast create mode 100644 pa2-tests/core/bad_expr_if.py.ast.typed create mode 100644 pa2-tests/core/bad_expr_unary.py create mode 100644 pa2-tests/core/bad_expr_unary.py.ast create mode 100644 pa2-tests/core/bad_expr_unary.py.ast.typed create mode 100644 pa2-tests/core/bad_func_def_call.py create mode 100644 pa2-tests/core/bad_func_def_call.py.ast create mode 100644 pa2-tests/core/bad_func_def_call.py.ast.typed create mode 100644 pa2-tests/core/bad_func_def_return.py create mode 100644 pa2-tests/core/bad_func_def_return.py.ast create mode 100644 pa2-tests/core/bad_func_def_return.py.ast.typed create mode 100644 pa2-tests/core/bad_list_assign.py create mode 100644 pa2-tests/core/bad_list_assign.py.ast create mode 100644 pa2-tests/core/bad_list_assign.py.ast.typed create mode 100644 pa2-tests/core/bad_list_index.py create mode 100644 pa2-tests/core/bad_list_index.py.ast create mode 100644 pa2-tests/core/bad_list_index.py.ast.typed create mode 100644 pa2-tests/core/bad_local_assign.py create mode 100644 pa2-tests/core/bad_local_assign.py.ast create mode 100644 pa2-tests/core/bad_local_assign.py.ast.typed create mode 100644 pa2-tests/core/bad_none_assign.py create mode 100644 pa2-tests/core/bad_none_assign.py.ast create mode 100644 pa2-tests/core/bad_none_assign.py.ast.typed create mode 100644 pa2-tests/core/bad_nonlocal_global.py create mode 100644 pa2-tests/core/bad_nonlocal_global.py.ast create mode 100644 pa2-tests/core/bad_nonlocal_global.py.ast.typed create mode 100644 pa2-tests/core/bad_return_missing.py create mode 100644 pa2-tests/core/bad_return_missing.py.ast create mode 100644 pa2-tests/core/bad_return_missing.py.ast.typed create mode 100644 pa2-tests/core/bad_return_top.py create mode 100644 pa2-tests/core/bad_return_top.py.ast create mode 100644 pa2-tests/core/bad_return_top.py.ast.typed create mode 100644 pa2-tests/core/bad_shadow_local.py create mode 100644 pa2-tests/core/bad_shadow_local.py.ast create mode 100644 pa2-tests/core/bad_shadow_local.py.ast.typed create mode 100644 pa2-tests/core/bad_shadow_local_2.py create mode 100644 pa2-tests/core/bad_shadow_local_2.py.ast create mode 100644 pa2-tests/core/bad_shadow_local_2.py.ast.typed create mode 100644 pa2-tests/core/bad_strings.py create mode 100644 pa2-tests/core/bad_strings.py.ast create mode 100644 pa2-tests/core/bad_strings.py.ast.typed create mode 100644 pa2-tests/core/bad_type_annotation.py create mode 100644 pa2-tests/core/bad_type_annotation.py.ast create mode 100644 pa2-tests/core/bad_type_annotation.py.ast.typed create mode 100644 pa2-tests/core/bad_type_id.py create mode 100644 pa2-tests/core/bad_type_id.py.ast create mode 100644 pa2-tests/core/bad_type_id.py.ast.typed create mode 100644 pa2-tests/core/bad_var_assign.py create mode 100644 pa2-tests/core/bad_var_assign.py.ast create mode 100644 pa2-tests/core/bad_var_assign.py.ast.typed create mode 100644 pa2-tests/core/class_def_assign.py create mode 100644 pa2-tests/core/class_def_assign.py.ast create mode 100644 pa2-tests/core/class_def_assign.py.ast.typed create mode 100644 pa2-tests/core/class_def_attr.py create mode 100644 pa2-tests/core/class_def_attr.py.ast create mode 100644 pa2-tests/core/class_def_attr.py.ast.typed create mode 100644 pa2-tests/core/class_def_init.py create mode 100644 pa2-tests/core/class_def_init.py.ast create mode 100644 pa2-tests/core/class_def_init.py.ast.typed create mode 100644 pa2-tests/core/class_def_methods.py create mode 100644 pa2-tests/core/class_def_methods.py.ast create mode 100644 pa2-tests/core/class_def_methods.py.ast.typed create mode 100644 pa2-tests/core/decl_global_forward.py create mode 100644 pa2-tests/core/decl_global_forward.py.ast create mode 100644 pa2-tests/core/decl_global_forward.py.ast.typed create mode 100644 pa2-tests/core/decl_nonlocal_forward.py create mode 100644 pa2-tests/core/decl_nonlocal_forward.py.ast create mode 100644 pa2-tests/core/decl_nonlocal_forward.py.ast.typed create mode 100644 pa2-tests/core/expr_binary.py create mode 100644 pa2-tests/core/expr_binary.py.ast create mode 100644 pa2-tests/core/expr_binary.py.ast.typed create mode 100644 pa2-tests/core/expr_concat.py create mode 100644 pa2-tests/core/expr_concat.py.ast create mode 100644 pa2-tests/core/expr_concat.py.ast.typed create mode 100644 pa2-tests/core/expr_id.py create mode 100644 pa2-tests/core/expr_id.py.ast create mode 100644 pa2-tests/core/expr_id.py.ast.typed create mode 100644 pa2-tests/core/expr_if.py create mode 100644 pa2-tests/core/expr_if.py.ast create mode 100644 pa2-tests/core/expr_if.py.ast.typed create mode 100644 pa2-tests/core/expr_int.py create mode 100644 pa2-tests/core/expr_int.py.ast create mode 100644 pa2-tests/core/expr_int.py.ast.typed create mode 100644 pa2-tests/core/expr_list_index.py create mode 100644 pa2-tests/core/expr_list_index.py.ast create mode 100644 pa2-tests/core/expr_list_index.py.ast.typed create mode 100644 pa2-tests/core/expr_lists.py create mode 100644 pa2-tests/core/expr_lists.py.ast create mode 100644 pa2-tests/core/expr_lists.py.ast.typed create mode 100644 pa2-tests/core/expr_unary.py create mode 100644 pa2-tests/core/expr_unary.py.ast create mode 100644 pa2-tests/core/expr_unary.py.ast.typed create mode 100644 pa2-tests/core/expr_var_assign.py create mode 100644 pa2-tests/core/expr_var_assign.py.ast create mode 100644 pa2-tests/core/expr_var_assign.py.ast.typed create mode 100644 pa2-tests/core/func_def_call.py create mode 100644 pa2-tests/core/func_def_call.py.ast create mode 100644 pa2-tests/core/func_def_call.py.ast.typed create mode 100644 pa2-tests/core/stmt_for_lists.py create mode 100644 pa2-tests/core/stmt_for_lists.py.ast create mode 100644 pa2-tests/core/stmt_for_lists.py.ast.typed create mode 100644 pa2-tests/core/stmt_for_strings.py create mode 100644 pa2-tests/core/stmt_for_strings.py.ast create mode 100644 pa2-tests/core/stmt_for_strings.py.ast.typed create mode 100644 pa2-tests/core/stmt_if.py create mode 100644 pa2-tests/core/stmt_if.py.ast create mode 100644 pa2-tests/core/stmt_if.py.ast.typed create mode 100644 pa2-tests/core/stmt_list_assign.py create mode 100644 pa2-tests/core/stmt_list_assign.py.ast create mode 100644 pa2-tests/core/stmt_list_assign.py.ast.typed create mode 100644 pa2-tests/core/stmt_var_assign.py create mode 100644 pa2-tests/core/stmt_var_assign.py.ast create mode 100644 pa2-tests/core/stmt_var_assign.py.ast.typed create mode 100644 pa2-tests/core/stmt_while.py create mode 100644 pa2-tests/core/stmt_while.py.ast create mode 100644 pa2-tests/core/stmt_while.py.ast.typed create mode 100644 pa2-tests/core/strings.py create mode 100644 pa2-tests/core/strings.py.ast create mode 100644 pa2-tests/core/strings.py.ast.typed create mode 100644 pa2-tests/extra/exp.py create mode 100644 pa2-tests/extra/exp.py.ast create mode 100644 pa2-tests/extra/exp.py.ast.typed create mode 100644 pa2-tests/extra/mergesort.py create mode 100644 pa2-tests/extra/mergesort.py.ast create mode 100644 pa2-tests/extra/mergesort.py.ast.typed create mode 100644 pa2-tests/extra/nested.py create mode 100644 pa2-tests/extra/nested.py.ast create mode 100644 pa2-tests/extra/nested.py.ast.typed create mode 100644 pa2-tests/extra/prime.py create mode 100644 pa2-tests/extra/prime.py.ast create mode 100644 pa2-tests/extra/prime.py.ast.typed create mode 100644 pa2-tests/extra/sieve.py create mode 100644 pa2-tests/extra/sieve.py.ast create mode 100644 pa2-tests/extra/sieve.py.ast.typed create mode 100644 pa2-tests/extra/stdlib.py create mode 100644 pa2-tests/extra/stdlib.py.ast create mode 100644 pa2-tests/extra/stdlib.py.ast.typed create mode 100644 pa2-tests/extra/tree.py create mode 100644 pa2-tests/extra/tree.py.ast create mode 100644 pa2-tests/extra/tree.py.ast.typed create mode 100755 pa2-tests/run-tests.sh diff --git a/pa2-tests/README.md b/pa2-tests/README.md new file mode 100644 index 0000000..51f2eec --- /dev/null +++ b/pa2-tests/README.md @@ -0,0 +1,24 @@ +# Tests for PA2: ChocoPy Semantic Analysis + +Clone a student repository: +``` +TEAM="team" +git clone --branch=pa2final \ + https://github.com/nyu-compiler-construction/pa2-chocopy-semantic-analysis-${TEAM} +``` + +Build it: +``` +cd pa2-chocopy-semantic-analysis-${TEAM} +mvn clean package +``` + +Clone the tests _into_ the student repository: +``` +git clone https://github.com/nyu-compiler-construction/pa2-tests +``` + +Run the tests: +``` +./pa2-tests/run-tests.sh +``` diff --git a/pa2-tests/chocopy-ref.jar b/pa2-tests/chocopy-ref.jar new file mode 100644 index 0000000000000000000000000000000000000000..a497f250c0918754ad6e49ccd25efddcf20f9036 GIT binary patch literal 144775 zcmaI718`cX1sQM%I1msJ7!Z|I7x`$ozxi6NylM}Ksbo6rwGIZ3_lQWGLN||w) z1$>Mr+3YyU-!$r;1@!?ARhgMunYf>-Lyu}r4KBqK%9FfHr%MM!;eWJ+uM8dP4ITt! zog4%N=esS&7WT&W4jv4yrgkn)3~K*zrZ=`RbaKj0cQZg=!W_OK4&aNB;qhNofE4x* zuAmeXK{YT`9wjsAV_(ZA`;ob2>Y9S=1>CMLEHD5D!j*xF);(`;RQ7ByuK3)PcR971 zre02SVohXD7?qGXT!HB_pFkUE6#JnMOM0=LO;4siAIYRE3 zdtAXMD0+hKD0{zxQ&IGU+%fjpf>%(s1>Mp1=z?2OwuRiW_V|LIQTPR4W3nl$BJ~fW%!g`!`6kY+3misa4Pv48 zroI#o=Ek8y57v@>9-{9=*^~7ozto~Z_=_S@JO<{-IfQ?45zD_1z`pM1%AJyaUI+K= z+smC&^f(Ip-8G|y^Z0}AGst06ex3)%?+eIb(`^iow$$&_AajKz>ijHoNbrj3(PN0v z;P;Ezz-l=T#GZ_~h!G^yF?#FI`TL8_tZr>l`$Sxfra%YMNFkr5=I=$oal-j9Tc||E z2v$jxRm#~9))@c-?Zd?$gs8K&vLkaYoJ*~ z3TFll%~am*Z*(&YdCT9Bw1sPoC*vNt3AkD-Mo=5h^wjGzzxVc7(#nQ!epDS1w-w*H z%I%j4^YmUidhearuw)wMJLH7@yVd+5_?UquFiQ8s69M@Z1CLjH^d1u2FxE-c(xq6{ z6ys-TrMbqmO6a(WSFiMd6|ASVbIoiWeB!^$YRwLF+hW3sL>5q^zVn*Iu}rm-`Nz7d z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pbrL!2oJRT^@+^qM}Htex>mNg%&SLMu8eaoIxdL)suSagcrM)?xU7s)g=jOtHnJ_gIDfl%3;(iC(>H5TGneR{j zFWYoEvANscZP`gcU*7S=2ioVl6RtbvKMs_-^W@ zl!BI)R`wu!6D!Nx+deG*+vYjYRF}5&dKa}7xtsj2rfz=OjXw~mQXOC*xqf%LO!RJ~ zu$6^1;M>{$Cq~!pvepxkmV5;IEH3%Yxr`6sMBLDaU*_reP%yV+=LlyRo&r@64t$A$ z@70m?^bf3+uBm~ZJ-v?3<$X&Xoj=_N(SuK;-GI`z07?toRsQXuSGuD8Zd@$w%mJ0U zWkja+IXRfe00WDZ00X1{4Fvcls<)%`fpN%^;kqYsd!chT2}W%IW)$$fF6J|{+t`;k zb98}u?JZ)qY@o$g0_q-(a?>2an%{={#~l5=ob+b5XLE)xUIl8;2WaZ+=IGq!R-V1> z?e|+`_>?&mfbyvV-^<9dR|kP3IM_drfh<74a~y_$)W;Z@TUk3ZSX)`pTiaS$8`#>L z82oVui|E5Q;nx5U7;|pSf2#rXKdir^5*ZtStm!ZHe=9mLvU}c5y}aiEvi%p6#E>u%q1s4?JK5 zdgS%7SRwNY@w-{O%@zRM9zzG6`w-^TjKH2t$?`)28HE_c2nGM(H;{JTQ0&y}EnQ3H7J2>f>d M7)%dzU?2hee}*l!7XSbN literal 0 HcmV?d00001 diff --git a/pa2-tests/core/ast_coverage.py b/pa2-tests/core/ast_coverage.py new file mode 100644 index 0000000..a27e796 --- /dev/null +++ b/pa2-tests/core/ast_coverage.py @@ -0,0 +1,38 @@ +count:int = 0 + +def foo(s: str) -> int: + return len(s) + +class bar(object): + p: bool = True + + def baz(self:"bar", xx: [int]) -> str: + global count + x:int = 0 + y:int = 1 + + def qux(y: int) -> object: + nonlocal x + if x > y: + x = -1 + + for x in xx: + self.p = x == 2 + + qux(0) # Yay! ChocoPy + + count = count + 1 + + while x <= 0: + if self.p: + xx[0] = xx[1] + self.p = not self.p + x = x + 1 + elif foo("Long"[0]) == 1: + self.p = self is None + + return "Nope" + +print(bar().baz([1,2])) + + diff --git a/pa2-tests/core/ast_coverage.py.ast b/pa2-tests/core/ast_coverage.py.ast new file mode 100644 index 0000000..18d47cd --- /dev/null +++ b/pa2-tests/core/ast_coverage.py.ast @@ -0,0 +1,627 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 36, 24 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 5 ], + "name" : "count" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 7, 1, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 13, 1, 13 ], + "value" : 0 + } + }, { + "kind" : "FuncDef", + "location" : [ 3, 1, 4, 18 ], + "name" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 3, 9, 3, 14 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 9, 3, 9 ], + "name" : "s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 12, 3, 14 ], + "className" : "str" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 3, 20, 3, 22 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 4, 5, 4, 17 ], + "value" : { + "kind" : "CallExpr", + "location" : [ 4, 12, 4, 17 ], + "function" : { + "kind" : "Identifier", + "location" : [ 4, 12, 4, 14 ], + "name" : "len" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 4, 16, 4, 16 ], + "name" : "s" + } ] + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 6, 1, 36, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 6, 7, 6, 9 ], + "name" : "bar" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 6, 11, 6, 16 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 7, 5, 7, 18 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 7, 5, 7, 11 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "name" : "p" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 7, 8, 7, 11 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 7, 15, 7, 18 ], + "value" : true + } + }, { + "kind" : "FuncDef", + "location" : [ 9, 5, 34, 22 ], + "name" : { + "kind" : "Identifier", + "location" : [ 9, 9, 9, 11 ], + "name" : "baz" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 9, 13, 9, 22 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 13, 9, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 18, 9, 22 ], + "className" : "bar" + } + }, { + "kind" : "TypedVar", + "location" : [ 9, 25, 9, 33 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 25, 9, 26 ], + "name" : "xx" + }, + "type" : { + "kind" : "ListType", + "location" : [ 9, 29, 9, 33 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 9, 30, 9, 32 ], + "className" : "int" + } + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 9, 39, 9, 41 ], + "className" : "str" + }, + "declarations" : [ { + "kind" : "GlobalDecl", + "location" : [ 10, 9, 10, 20 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 10, 16, 10, 20 ], + "name" : "count" + } + }, { + "kind" : "VarDef", + "location" : [ 11, 9, 11, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 11, 9, 11, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 9, 11, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 11, 11, 13 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 11, 17, 11, 17 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 12, 9, 12, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 9, 12, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 9, 12, 9 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 11, 12, 13 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 12, 17, 12, 17 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 14, 9, 19, 8 ], + "name" : { + "kind" : "Identifier", + "location" : [ 14, 13, 14, 15 ], + "name" : "qux" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 14, 17, 14, 22 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 14, 17, 14, 17 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 14, 20, 14, 22 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 14, 28, 14, 33 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "NonLocalDecl", + "location" : [ 15, 13, 15, 22 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 15, 22, 15, 22 ], + "name" : "x" + } + } ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 16, 13, 19, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 16, 16, 16, 20 ], + "left" : { + "kind" : "Identifier", + "location" : [ 16, 16, 16, 16 ], + "name" : "x" + }, + "operator" : ">", + "right" : { + "kind" : "Identifier", + "location" : [ 16, 20, 16, 20 ], + "name" : "y" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 17, 17, 17, 22 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 17, 17, 17, 17 ], + "name" : "x" + } ], + "value" : { + "kind" : "UnaryExpr", + "location" : [ 17, 21, 17, 22 ], + "operator" : "-", + "operand" : { + "kind" : "IntegerLiteral", + "location" : [ 17, 22, 17, 22 ], + "value" : 1 + } + } + } ], + "elseBody" : [ ] + } ] + } ], + "statements" : [ { + "kind" : "ForStmt", + "location" : [ 19, 9, 22, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 19, 13, 19, 13 ], + "name" : "x" + }, + "iterable" : { + "kind" : "Identifier", + "location" : [ 19, 18, 19, 19 ], + "name" : "xx" + }, + "body" : [ { + "kind" : "AssignStmt", + "location" : [ 20, 13, 20, 27 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 20, 13, 20, 18 ], + "object" : { + "kind" : "Identifier", + "location" : [ 20, 13, 20, 16 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 20, 18, 20, 18 ], + "name" : "p" + } + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 20, 22, 20, 27 ], + "left" : { + "kind" : "Identifier", + "location" : [ 20, 22, 20, 22 ], + "name" : "x" + }, + "operator" : "==", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 20, 27, 20, 27 ], + "value" : 2 + } + } + } ] + }, { + "kind" : "ExprStmt", + "location" : [ 22, 9, 22, 14 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 22, 9, 22, 14 ], + "function" : { + "kind" : "Identifier", + "location" : [ 22, 9, 22, 11 ], + "name" : "qux" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 22, 13, 22, 13 ], + "value" : 0 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 24, 9, 24, 25 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 24, 9, 24, 13 ], + "name" : "count" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 24, 17, 24, 25 ], + "left" : { + "kind" : "Identifier", + "location" : [ 24, 17, 24, 21 ], + "name" : "count" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 24, 25, 24, 25 ], + "value" : 1 + } + } + }, { + "kind" : "WhileStmt", + "location" : [ 26, 9, 34, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 26, 15, 26, 20 ], + "left" : { + "kind" : "Identifier", + "location" : [ 26, 15, 26, 15 ], + "name" : "x" + }, + "operator" : "<=", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 26, 20, 26, 20 ], + "value" : 0 + } + }, + "body" : [ { + "kind" : "IfStmt", + "location" : [ 27, 13, 34, 8 ], + "condition" : { + "kind" : "MemberExpr", + "location" : [ 27, 16, 27, 21 ], + "object" : { + "kind" : "Identifier", + "location" : [ 27, 16, 27, 19 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 27, 21, 27, 21 ], + "name" : "p" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 28, 17, 28, 29 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 28, 17, 28, 21 ], + "list" : { + "kind" : "Identifier", + "location" : [ 28, 17, 28, 18 ], + "name" : "xx" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 28, 20, 28, 20 ], + "value" : 0 + } + } ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 28, 25, 28, 29 ], + "list" : { + "kind" : "Identifier", + "location" : [ 28, 25, 28, 26 ], + "name" : "xx" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 28, 28, 28, 28 ], + "value" : 1 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 29, 17, 29, 35 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 29, 17, 29, 22 ], + "object" : { + "kind" : "Identifier", + "location" : [ 29, 17, 29, 20 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 29, 22, 29, 22 ], + "name" : "p" + } + } ], + "value" : { + "kind" : "UnaryExpr", + "location" : [ 29, 26, 29, 35 ], + "operator" : "not", + "operand" : { + "kind" : "MemberExpr", + "location" : [ 29, 30, 29, 35 ], + "object" : { + "kind" : "Identifier", + "location" : [ 29, 30, 29, 33 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 29, 35, 29, 35 ], + "name" : "p" + } + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 30, 17, 30, 25 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 30, 17, 30, 17 ], + "name" : "x" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 30, 21, 30, 25 ], + "left" : { + "kind" : "Identifier", + "location" : [ 30, 21, 30, 21 ], + "name" : "x" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 30, 25, 30, 25 ], + "value" : 1 + } + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 31, 13, 34, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 31, 18, 31, 36 ], + "left" : { + "kind" : "CallExpr", + "location" : [ 31, 18, 31, 31 ], + "function" : { + "kind" : "Identifier", + "location" : [ 31, 18, 31, 20 ], + "name" : "foo" + }, + "args" : [ { + "kind" : "IndexExpr", + "location" : [ 31, 22, 31, 30 ], + "list" : { + "kind" : "StringLiteral", + "location" : [ 31, 22, 31, 27 ], + "value" : "Long" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 31, 29, 31, 29 ], + "value" : 0 + } + } ] + }, + "operator" : "==", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 31, 36, 31, 36 ], + "value" : 1 + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 32, 17, 32, 37 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 32, 17, 32, 22 ], + "object" : { + "kind" : "Identifier", + "location" : [ 32, 17, 32, 20 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 32, 22, 32, 22 ], + "name" : "p" + } + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 32, 26, 32, 37 ], + "left" : { + "kind" : "Identifier", + "location" : [ 32, 26, 32, 29 ], + "name" : "self" + }, + "operator" : "is", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 32, 34, 32, 37 ] + } + } + } ], + "elseBody" : [ ] + } ] + } ] + }, { + "kind" : "ReturnStmt", + "location" : [ 34, 9, 34, 21 ], + "value" : { + "kind" : "StringLiteral", + "location" : [ 34, 16, 34, 21 ], + "value" : "Nope" + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 36, 1, 36, 23 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 36, 1, 36, 23 ], + "function" : { + "kind" : "Identifier", + "location" : [ 36, 1, 36, 5 ], + "name" : "print" + }, + "args" : [ { + "kind" : "MethodCallExpr", + "location" : [ 36, 7, 36, 22 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 36, 7, 36, 15 ], + "object" : { + "kind" : "CallExpr", + "location" : [ 36, 7, 36, 11 ], + "function" : { + "kind" : "Identifier", + "location" : [ 36, 7, 36, 9 ], + "name" : "bar" + }, + "args" : [ ] + }, + "member" : { + "kind" : "Identifier", + "location" : [ 36, 13, 36, 15 ], + "name" : "baz" + } + }, + "args" : [ { + "kind" : "ListExpr", + "location" : [ 36, 17, 36, 21 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 36, 18, 36, 18 ], + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 36, 20, 36, 20 ], + "value" : 2 + } ] + } ] + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/ast_coverage.py.ast.typed b/pa2-tests/core/ast_coverage.py.ast.typed new file mode 100644 index 0000000..709f895 --- /dev/null +++ b/pa2-tests/core/ast_coverage.py.ast.typed @@ -0,0 +1,952 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 36, 24 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 5 ], + "name" : "count" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 7, 1, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 13, 1, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, { + "kind" : "FuncDef", + "location" : [ 3, 1, 4, 18 ], + "name" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 3, 9, 3, 14 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 9, 3, 9 ], + "name" : "s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 12, 3, 14 ], + "className" : "str" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 3, 20, 3, 22 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 4, 5, 4, 17 ], + "value" : { + "kind" : "CallExpr", + "location" : [ 4, 12, 4, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 4, 12, 4, 14 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "len" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 4, 16, 4, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "s" + } ] + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 6, 1, 36, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 6, 7, 6, 9 ], + "name" : "bar" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 6, 11, 6, 16 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 7, 5, 7, 18 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 7, 5, 7, 11 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "name" : "p" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 7, 8, 7, 11 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 7, 15, 7, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + }, { + "kind" : "FuncDef", + "location" : [ 9, 5, 34, 22 ], + "name" : { + "kind" : "Identifier", + "location" : [ 9, 9, 9, 11 ], + "name" : "baz" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 9, 13, 9, 22 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 13, 9, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 18, 9, 22 ], + "className" : "bar" + } + }, { + "kind" : "TypedVar", + "location" : [ 9, 25, 9, 33 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 25, 9, 26 ], + "name" : "xx" + }, + "type" : { + "kind" : "ListType", + "location" : [ 9, 29, 9, 33 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 9, 30, 9, 32 ], + "className" : "int" + } + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 9, 39, 9, 41 ], + "className" : "str" + }, + "declarations" : [ { + "kind" : "GlobalDecl", + "location" : [ 10, 9, 10, 20 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 10, 16, 10, 20 ], + "name" : "count" + } + }, { + "kind" : "VarDef", + "location" : [ 11, 9, 11, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 11, 9, 11, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 9, 11, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 11, 11, 13 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 11, 17, 11, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 12, 9, 12, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 9, 12, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 9, 12, 9 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 11, 12, 13 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 12, 17, 12, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 14, 9, 19, 8 ], + "name" : { + "kind" : "Identifier", + "location" : [ 14, 13, 14, 15 ], + "name" : "qux" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 14, 17, 14, 22 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 14, 17, 14, 17 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 14, 20, 14, 22 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 14, 28, 14, 33 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "NonLocalDecl", + "location" : [ 15, 13, 15, 22 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 15, 22, 15, 22 ], + "name" : "x" + } + } ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 16, 13, 19, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 16, 16, 16, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 16, 16, 16, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "operator" : ">", + "right" : { + "kind" : "Identifier", + "location" : [ 16, 20, 16, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "y" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 17, 17, 17, 22 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 17, 17, 17, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ], + "value" : { + "kind" : "UnaryExpr", + "location" : [ 17, 21, 17, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "operator" : "-", + "operand" : { + "kind" : "IntegerLiteral", + "location" : [ 17, 22, 17, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ], + "elseBody" : [ ] + } ] + } ], + "statements" : [ { + "kind" : "ForStmt", + "location" : [ 19, 9, 22, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 19, 13, 19, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "iterable" : { + "kind" : "Identifier", + "location" : [ 19, 18, 19, 19 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "xx" + }, + "body" : [ { + "kind" : "AssignStmt", + "location" : [ 20, 13, 20, 27 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 20, 13, 20, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 20, 13, 20, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bar" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 20, 18, 20, 18 ], + "name" : "p" + } + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 20, 22, 20, 27 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 20, 22, 20, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "operator" : "==", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 20, 27, 20, 27 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } + } + } ] + }, { + "kind" : "ExprStmt", + "location" : [ 22, 9, 22, 14 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 22, 9, 22, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 22, 9, 22, 11 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "name" : "qux" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 22, 13, 22, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 24, 9, 24, 25 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 24, 9, 24, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "count" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 24, 17, 24, 25 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 24, 17, 24, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "count" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 24, 25, 24, 25 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + }, { + "kind" : "WhileStmt", + "location" : [ 26, 9, 34, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 26, 15, 26, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 26, 15, 26, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "operator" : "<=", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 26, 20, 26, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, + "body" : [ { + "kind" : "IfStmt", + "location" : [ 27, 13, 34, 8 ], + "condition" : { + "kind" : "MemberExpr", + "location" : [ 27, 16, 27, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 27, 16, 27, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bar" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 27, 21, 27, 21 ], + "name" : "p" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 28, 17, 28, 29 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 28, 17, 28, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 28, 17, 28, 18 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "xx" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 28, 20, 28, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 28, 25, 28, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 28, 25, 28, 26 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "xx" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 28, 28, 28, 28 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 29, 17, 29, 35 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 29, 17, 29, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 29, 17, 29, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bar" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 29, 22, 29, 22 ], + "name" : "p" + } + } ], + "value" : { + "kind" : "UnaryExpr", + "location" : [ 29, 26, 29, 35 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "operator" : "not", + "operand" : { + "kind" : "MemberExpr", + "location" : [ 29, 30, 29, 35 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 29, 30, 29, 33 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bar" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 29, 35, 29, 35 ], + "name" : "p" + } + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 30, 17, 30, 25 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 30, 17, 30, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 30, 21, 30, 25 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 30, 21, 30, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 30, 25, 30, 25 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 31, 13, 34, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 31, 18, 31, 36 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "CallExpr", + "location" : [ 31, 18, 31, 31 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 31, 18, 31, 20 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "str" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "foo" + }, + "args" : [ { + "kind" : "IndexExpr", + "location" : [ 31, 22, 31, 30 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "list" : { + "kind" : "StringLiteral", + "location" : [ 31, 22, 31, 27 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Long" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 31, 29, 31, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ] + }, + "operator" : "==", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 31, 36, 31, 36 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 32, 17, 32, 37 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 32, 17, 32, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 32, 17, 32, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bar" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 32, 22, 32, 22 ], + "name" : "p" + } + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 32, 26, 32, 37 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 32, 26, 32, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bar" + }, + "name" : "self" + }, + "operator" : "is", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 32, 34, 32, 37 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } + } ], + "elseBody" : [ ] + } ] + } ] + }, { + "kind" : "ReturnStmt", + "location" : [ 34, 9, 34, 21 ], + "value" : { + "kind" : "StringLiteral", + "location" : [ 34, 16, 34, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Nope" + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 36, 1, 36, 23 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 36, 1, 36, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 36, 1, 36, 5 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, + "name" : "print" + }, + "args" : [ { + "kind" : "MethodCallExpr", + "location" : [ 36, 7, 36, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 36, 7, 36, 15 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "bar" + }, { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "str" + } + }, + "object" : { + "kind" : "CallExpr", + "location" : [ 36, 7, 36, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bar" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 36, 7, 36, 9 ], + "name" : "bar" + }, + "args" : [ ] + }, + "member" : { + "kind" : "Identifier", + "location" : [ 36, 13, 36, 15 ], + "name" : "baz" + } + }, + "args" : [ { + "kind" : "ListExpr", + "location" : [ 36, 17, 36, 21 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 36, 18, 36, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 36, 20, 36, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } ] + } ] + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_assign_expr.py b/pa2-tests/core/bad_assign_expr.py new file mode 100644 index 0000000..9e68917 --- /dev/null +++ b/pa2-tests/core/bad_assign_expr.py @@ -0,0 +1,11 @@ +x:int = 0 +y:int = 0 +z:bool = False + +x = z = 1 # Only one error here (assignment to `x = 1` should succeed) +x = y = None +x = y = [] +x = a = None +x = a = [] +x = y = True + diff --git a/pa2-tests/core/bad_assign_expr.py.ast b/pa2-tests/core/bad_assign_expr.py.ast new file mode 100644 index 0000000..6651bd2 --- /dev/null +++ b/pa2-tests/core/bad_assign_expr.py.ast @@ -0,0 +1,177 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 10, 13 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 9, 2, 9 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 6 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 6 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 3, 10, 3, 14 ], + "value" : false + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 5, 1, 5, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 5 ], + "name" : "z" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 9, 5, 9 ], + "value" : 1 + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 12 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "name" : "y" + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 6, 9, 6, 12 ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "name" : "y" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 7, 9, 7, 10 ], + "elements" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 8, 1, 8, 12 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 8, 5, 8, 5 ], + "name" : "a" + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 8, 9, 8, 12 ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 9, 1, 9, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 1 ], + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "name" : "a" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 9, 9, 9, 10 ], + "elements" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 10, 1, 10, 12 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 10, 1, 10, 1 ], + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 10, 5, 10, 5 ], + "name" : "y" + } ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 10, 9, 10, 12 ], + "value" : true + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_assign_expr.py.ast.typed b/pa2-tests/core/bad_assign_expr.py.ast.typed new file mode 100644 index 0000000..2f99fae --- /dev/null +++ b/pa2-tests/core/bad_assign_expr.py.ast.typed @@ -0,0 +1,301 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 10, 13 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 9, 2, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 6 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 6 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 3, 10, 3, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 5, 1, 5, 9 ], + "errorMsg" : "Expected type `bool`; got type `int`", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "name" : "z" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 9, 5, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 12 ], + "errorMsg" : "Expected type `int`; got type ``", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "y" + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 6, 9, 6, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 10 ], + "errorMsg" : "Expected type `int`; got type ``", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "y" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 7, 9, 7, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "elements" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 8, 1, 8, 12 ], + "errorMsg" : "Expected type `int`; got type ``", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 8, 5, 8, 5 ], + "errorMsg" : "Not a variable: a", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "name" : "a" + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 8, 9, 8, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 9, 1, 9, 10 ], + "errorMsg" : "Expected type `int`; got type ``", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "errorMsg" : "Not a variable: a", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "name" : "a" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 9, 9, 9, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "elements" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 10, 1, 10, 12 ], + "errorMsg" : "Expected type `int`; got type `bool`", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 10, 1, 10, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 10, 5, 10, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "y" + } ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 10, 9, 10, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 5, 1, 5, 9 ], + "message" : "Expected type `bool`; got type `int`" + }, { + "kind" : "CompilerError", + "location" : [ 6, 1, 6, 12 ], + "message" : "Expected type `int`; got type ``" + }, { + "kind" : "CompilerError", + "location" : [ 7, 1, 7, 10 ], + "message" : "Expected type `int`; got type ``" + }, { + "kind" : "CompilerError", + "location" : [ 8, 1, 8, 12 ], + "message" : "Expected type `int`; got type ``" + }, { + "kind" : "CompilerError", + "location" : [ 8, 5, 8, 5 ], + "message" : "Not a variable: a" + }, { + "kind" : "CompilerError", + "location" : [ 9, 1, 9, 10 ], + "message" : "Expected type `int`; got type ``" + }, { + "kind" : "CompilerError", + "location" : [ 9, 5, 9, 5 ], + "message" : "Not a variable: a" + }, { + "kind" : "CompilerError", + "location" : [ 10, 1, 10, 12 ], + "message" : "Expected type `int`; got type `bool`" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_class_attr.py b/pa2-tests/core/bad_class_attr.py new file mode 100644 index 0000000..b30eb7c --- /dev/null +++ b/pa2-tests/core/bad_class_attr.py @@ -0,0 +1,13 @@ +class A(object): + x:int = 1 + + def foo(self:"A") -> int: + return 0 + +class B(A): + x:int = 2 # Bad + foo:str = "" # Bad + +A() + + diff --git a/pa2-tests/core/bad_class_attr.py.ast b/pa2-tests/core/bad_class_attr.py.ast new file mode 100644 index 0000000..ec25404 --- /dev/null +++ b/pa2-tests/core/bad_class_attr.py.ast @@ -0,0 +1,155 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 11, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 7, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 11 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 13, 4, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 13, 4, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 18, 4, 20 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 26, 4, 28 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 9, 5, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 16, 5, 16 ], + "value" : 0 + } + } ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 7, 1, 9, 23 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 7, 7, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 8, 5, 8, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 8, 5, 8, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 5, 8, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 7, 8, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 8, 13, 8, 13 ], + "value" : 2 + } + }, { + "kind" : "VarDef", + "location" : [ 9, 5, 9, 16 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 9, 5, 9, 11 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 7 ], + "name" : "foo" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 9, 9, 11 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 9, 15, 9, 16 ], + "value" : "" + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 11, 1, 11, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 11, 1, 11, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_class_attr.py.ast.typed b/pa2-tests/core/bad_class_attr.py.ast.typed new file mode 100644 index 0000000..5ea1e74 --- /dev/null +++ b/pa2-tests/core/bad_class_attr.py.ast.typed @@ -0,0 +1,165 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 11, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 7, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 11 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 13, 4, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 13, 4, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 18, 4, 20 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 26, 4, 28 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 9, 5, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 16, 5, 16 ], + "value" : 0 + } + } ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 7, 1, 9, 23 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 7, 7, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 8, 5, 8, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 8, 5, 8, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 5, 8, 5 ], + "errorMsg" : "Cannot re-define attribute: x", + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 7, 8, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 8, 13, 8, 13 ], + "value" : 2 + } + }, { + "kind" : "VarDef", + "location" : [ 9, 5, 9, 16 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 9, 5, 9, 11 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 7 ], + "errorMsg" : "Cannot re-define attribute: foo", + "name" : "foo" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 9, 9, 11 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 9, 15, 9, 16 ], + "value" : "" + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 11, 1, 11, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 11, 1, 11, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 8, 5, 8, 5 ], + "message" : "Cannot re-define attribute: x" + }, { + "kind" : "CompilerError", + "location" : [ 9, 5, 9, 7 ], + "message" : "Cannot re-define attribute: foo" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_class_attr_type.py b/pa2-tests/core/bad_class_attr_type.py new file mode 100644 index 0000000..5a7bee7 --- /dev/null +++ b/pa2-tests/core/bad_class_attr_type.py @@ -0,0 +1,4 @@ +class A(object): + x:int = True + +A() diff --git a/pa2-tests/core/bad_class_attr_type.py.ast b/pa2-tests/core/bad_class_attr_type.py.ast new file mode 100644 index 0000000..6b9d252 --- /dev/null +++ b/pa2-tests/core/bad_class_attr_type.py.ast @@ -0,0 +1,60 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 4, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 16 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 2, 13, 2, 16 ], + "value" : true + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 4, 1, 4, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 4, 1, 4, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_class_attr_type.py.ast.typed b/pa2-tests/core/bad_class_attr_type.py.ast.typed new file mode 100644 index 0000000..f0a9461 --- /dev/null +++ b/pa2-tests/core/bad_class_attr_type.py.ast.typed @@ -0,0 +1,73 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 4, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 16 ], + "errorMsg" : "Expected type `int`; got type `bool`", + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 2, 13, 2, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 4, 1, 4, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 4, 1, 4, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 2, 5, 2, 16 ], + "message" : "Expected type `int`; got type `bool`" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_class_init_override.py b/pa2-tests/core/bad_class_init_override.py new file mode 100644 index 0000000..ceb612c --- /dev/null +++ b/pa2-tests/core/bad_class_init_override.py @@ -0,0 +1,8 @@ +class A(object): + x:int = 1 + + def __init__(self:"A", x:int): # Bad override + pass + +A(1) + diff --git a/pa2-tests/core/bad_class_init_override.py.ast b/pa2-tests/core/bad_class_init_override.py.ast new file mode 100644 index 0000000..bdd151d --- /dev/null +++ b/pa2-tests/core/bad_class_init_override.py.ast @@ -0,0 +1,106 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 7, 5 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 7, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 18, 4, 25 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 18, 4, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 23, 4, 25 ], + "className" : "A" + } + }, { + "kind" : "TypedVar", + "location" : [ 4, 28, 4, 32 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 28, 4, 28 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 30, 4, 32 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 34, 4, 34 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 7, 1, 7, 4 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 7, 1, 7, 4 ], + "function" : { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "name" : "A" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 7, 3, 7, 3 ], + "value" : 1 + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_class_init_override.py.ast.typed b/pa2-tests/core/bad_class_init_override.py.ast.typed new file mode 100644 index 0000000..9daa89c --- /dev/null +++ b/pa2-tests/core/bad_class_init_override.py.ast.typed @@ -0,0 +1,111 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 7, 5 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 7, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 16 ], + "errorMsg" : "Method overridden with different type signature: __init__", + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 18, 4, 25 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 18, 4, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 23, 4, 25 ], + "className" : "A" + } + }, { + "kind" : "TypedVar", + "location" : [ 4, 28, 4, 32 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 28, 4, 28 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 30, 4, 32 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 34, 4, 34 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 7, 1, 7, 4 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 7, 1, 7, 4 ], + "function" : { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "name" : "A" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 7, 3, 7, 3 ], + "value" : 1 + } ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 4, 9, 4, 16 ], + "message" : "Method overridden with different type signature: __init__" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_class_init_return.py b/pa2-tests/core/bad_class_init_return.py new file mode 100644 index 0000000..cc6eb34 --- /dev/null +++ b/pa2-tests/core/bad_class_init_return.py @@ -0,0 +1,5 @@ +class A(object): + def __init__(self:"A"): + return 1 # Bad + +A() diff --git a/pa2-tests/core/bad_class_init_return.py.ast b/pa2-tests/core/bad_class_init_return.py.ast new file mode 100644 index 0000000..24e972f --- /dev/null +++ b/pa2-tests/core/bad_class_init_return.py.ast @@ -0,0 +1,75 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 5, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 5, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 2, 5, 3, 23 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 9, 2, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 2, 18, 2, 25 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 18, 2, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 23, 2, 25 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 2, 27, 2, 27 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 3, 9, 3, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 16, 3, 16 ], + "value" : 1 + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 5, 1, 5, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 5, 1, 5, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_class_init_return.py.ast.typed b/pa2-tests/core/bad_class_init_return.py.ast.typed new file mode 100644 index 0000000..cf0cde2 --- /dev/null +++ b/pa2-tests/core/bad_class_init_return.py.ast.typed @@ -0,0 +1,88 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 5, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 5, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 2, 5, 3, 23 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 9, 2, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 2, 18, 2, 25 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 18, 2, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 23, 2, 25 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 2, 27, 2, 27 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 3, 9, 3, 16 ], + "errorMsg" : "Expected type ``; got type `int`", + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 16, 3, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 5, 1, 5, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 5, 1, 5, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 3, 9, 3, 16 ], + "message" : "Expected type ``; got type `int`" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_class_member_expr.py b/pa2-tests/core/bad_class_member_expr.py new file mode 100644 index 0000000..bbfa1c1 --- /dev/null +++ b/pa2-tests/core/bad_class_member_expr.py @@ -0,0 +1,6 @@ +x:int = 0 +o:object = None + +x.foo +o.bar +o.baz = 1 diff --git a/pa2-tests/core/bad_class_member_expr.py.ast b/pa2-tests/core/bad_class_member_expr.py.ast new file mode 100644 index 0000000..4949375 --- /dev/null +++ b/pa2-tests/core/bad_class_member_expr.py.ast @@ -0,0 +1,110 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 6, 10 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "o" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 8 ], + "className" : "object" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 2, 12, 2, 15 ] + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 4, 1, 4, 5 ], + "expr" : { + "kind" : "MemberExpr", + "location" : [ 4, 1, 4, 5 ], + "object" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "x" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 4, 3, 4, 5 ], + "name" : "foo" + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 5, 1, 5, 5 ], + "expr" : { + "kind" : "MemberExpr", + "location" : [ 5, 1, 5, 5 ], + "object" : { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "name" : "o" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 5, 3, 5, 5 ], + "name" : "bar" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 9 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 6, 1, 6, 5 ], + "object" : { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "o" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 6, 3, 6, 5 ], + "name" : "baz" + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 9, 6, 9 ], + "value" : 1 + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_class_member_expr.py.ast.typed b/pa2-tests/core/bad_class_member_expr.py.ast.typed new file mode 100644 index 0000000..4e570c0 --- /dev/null +++ b/pa2-tests/core/bad_class_member_expr.py.ast.typed @@ -0,0 +1,161 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 6, 10 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "o" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 8 ], + "className" : "object" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 2, 12, 2, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 4, 1, 4, 5 ], + "expr" : { + "kind" : "MemberExpr", + "location" : [ 4, 1, 4, 5 ], + "errorMsg" : "There is no attribute named `foo` in class `int`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 4, 3, 4, 5 ], + "name" : "foo" + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 5, 1, 5, 5 ], + "expr" : { + "kind" : "MemberExpr", + "location" : [ 5, 1, 5, 5 ], + "errorMsg" : "There is no attribute named `bar` in class `object`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "name" : "o" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 5, 3, 5, 5 ], + "name" : "bar" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 9 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 6, 1, 6, 5 ], + "errorMsg" : "There is no attribute named `baz` in class `object`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "name" : "o" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 6, 3, 6, 5 ], + "name" : "baz" + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 9, 6, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 4, 1, 4, 5 ], + "message" : "There is no attribute named `foo` in class `int`" + }, { + "kind" : "CompilerError", + "location" : [ 5, 1, 5, 5 ], + "message" : "There is no attribute named `bar` in class `object`" + }, { + "kind" : "CompilerError", + "location" : [ 6, 1, 6, 5 ], + "message" : "There is no attribute named `baz` in class `object`" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_class_method.py b/pa2-tests/core/bad_class_method.py new file mode 100644 index 0000000..d5a10d8 --- /dev/null +++ b/pa2-tests/core/bad_class_method.py @@ -0,0 +1,14 @@ +class A(object): + x:int = 1 + + def foo(self:"A") -> int: # OK + return 0 + + def bar() -> int: # Needs self param + return 0 + + def baz(self:int) -> int: # Incorrect self type + return 0 + +A() + diff --git a/pa2-tests/core/bad_class_method.py.ast b/pa2-tests/core/bad_class_method.py.ast new file mode 100644 index 0000000..7c359ef --- /dev/null +++ b/pa2-tests/core/bad_class_method.py.ast @@ -0,0 +1,158 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 13, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 13, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 11 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 13, 4, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 13, 4, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 18, 4, 20 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 26, 4, 28 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 9, 5, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 16, 5, 16 ], + "value" : 0 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 7, 5, 8, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 11 ], + "name" : "bar" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 7, 18, 7, 20 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 8, 9, 8, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 8, 16, 8, 16 ], + "value" : 0 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 10, 5, 11, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 10, 9, 10, 11 ], + "name" : "baz" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 10, 13, 10, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 10, 13, 10, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 10, 18, 10, 20 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 10, 26, 10, 28 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 11, 9, 11, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 11, 16, 11, 16 ], + "value" : 0 + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 13, 1, 13, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 13, 1, 13, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 13, 1, 13, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_class_method.py.ast.typed b/pa2-tests/core/bad_class_method.py.ast.typed new file mode 100644 index 0000000..9e08da8 --- /dev/null +++ b/pa2-tests/core/bad_class_method.py.ast.typed @@ -0,0 +1,168 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 13, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 13, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 11 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 13, 4, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 13, 4, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 18, 4, 20 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 26, 4, 28 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 9, 5, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 16, 5, 16 ], + "value" : 0 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 7, 5, 8, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 11 ], + "errorMsg" : "First parameter of the following method must be of the enclosing class: bar", + "name" : "bar" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 7, 18, 7, 20 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 8, 9, 8, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 8, 16, 8, 16 ], + "value" : 0 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 10, 5, 11, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 10, 9, 10, 11 ], + "errorMsg" : "First parameter of the following method must be of the enclosing class: baz", + "name" : "baz" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 10, 13, 10, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 10, 13, 10, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 10, 18, 10, 20 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 10, 26, 10, 28 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 11, 9, 11, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 11, 16, 11, 16 ], + "value" : 0 + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 13, 1, 13, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 13, 1, 13, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 13, 1, 13, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 7, 9, 7, 11 ], + "message" : "First parameter of the following method must be of the enclosing class: bar" + }, { + "kind" : "CompilerError", + "location" : [ 10, 9, 10, 11 ], + "message" : "First parameter of the following method must be of the enclosing class: baz" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_class_method_invoke.py b/pa2-tests/core/bad_class_method_invoke.py new file mode 100644 index 0000000..d5bb97c --- /dev/null +++ b/pa2-tests/core/bad_class_method_invoke.py @@ -0,0 +1,30 @@ +class A(object): + x:int = 1 + + def get_A(self: "A") -> int: + return self.x + +class B(A): + def __init__(self: "B"): + pass + +class C(B): + z:bool = True + + def set_A(self: "C", val: int) -> object: + self.x = val + +a:A = None +b:B = None +c:C = None + +a = A() +b = B() +c = C() + +a.get_A(1) +b.get_Z() +c.set_A() +c.set_A(False) +c.set_A(None) + diff --git a/pa2-tests/core/bad_class_method_invoke.py.ast b/pa2-tests/core/bad_class_method_invoke.py.ast new file mode 100644 index 0000000..e01db23 --- /dev/null +++ b/pa2-tests/core/bad_class_method_invoke.py.ast @@ -0,0 +1,474 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 29, 14 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 7, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 22 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 13 ], + "name" : "get_A" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 15, 4, 23 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 15, 4, 18 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 21, 4, 23 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 29, 4, 31 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 9, 5, 21 ], + "value" : { + "kind" : "MemberExpr", + "location" : [ 5, 16, 5, 21 ], + "object" : { + "kind" : "Identifier", + "location" : [ 5, 16, 5, 19 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 5, 21, 5, 21 ], + "name" : "x" + } + } + } ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 7, 1, 11, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 7, 7, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 8, 5, 9, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 8, 18, 8, 26 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 18, 8, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 24, 8, 26 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 8, 28, 8, 28 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 11, 1, 17, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 11, 7, 11, 7 ], + "name" : "C" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 11, 9, 11, 9 ], + "name" : "B" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 12, 5, 12, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 5, 12, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 5, 12, 5 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 7, 12, 10 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 12, 14, 12, 17 ], + "value" : true + } + }, { + "kind" : "FuncDef", + "location" : [ 14, 5, 15, 21 ], + "name" : { + "kind" : "Identifier", + "location" : [ 14, 9, 14, 13 ], + "name" : "set_A" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 14, 15, 14, 23 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 14, 15, 14, 18 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 14, 21, 14, 23 ], + "className" : "C" + } + }, { + "kind" : "TypedVar", + "location" : [ 14, 26, 14, 33 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 14, 26, 14, 28 ], + "name" : "val" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 14, 31, 14, 33 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 14, 39, 14, 44 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 15, 9, 15, 20 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 15, 9, 15, 14 ], + "object" : { + "kind" : "Identifier", + "location" : [ 15, 9, 15, 12 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 15, 14, 15, 14 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 15, 18, 15, 20 ], + "name" : "val" + } + } ] + } ] + }, { + "kind" : "VarDef", + "location" : [ 17, 1, 17, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 17, 1, 17, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 17, 1, 17, 1 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 17, 3, 17, 3 ], + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 17, 7, 17, 10 ] + } + }, { + "kind" : "VarDef", + "location" : [ 18, 1, 18, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 18, 1, 18, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 18, 1, 18, 1 ], + "name" : "b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 18, 3, 18, 3 ], + "className" : "B" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 18, 7, 18, 10 ] + } + }, { + "kind" : "VarDef", + "location" : [ 19, 1, 19, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 19, 1, 19, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 19, 1, 19, 1 ], + "name" : "c" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 19, 3, 19, 3 ], + "className" : "C" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 19, 7, 19, 10 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 21, 1, 21, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 21, 1, 21, 1 ], + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 21, 5, 21, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 21, 5, 21, 5 ], + "name" : "A" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 22, 1, 22, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 22, 1, 22, 1 ], + "name" : "b" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 22, 5, 22, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 22, 5, 22, 5 ], + "name" : "B" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 23, 1, 23, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 23, 1, 23, 1 ], + "name" : "c" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 23, 5, 23, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 23, 5, 23, 5 ], + "name" : "C" + }, + "args" : [ ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 25, 1, 25, 10 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 25, 1, 25, 10 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 25, 1, 25, 7 ], + "object" : { + "kind" : "Identifier", + "location" : [ 25, 1, 25, 1 ], + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 25, 3, 25, 7 ], + "name" : "get_A" + } + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 25, 9, 25, 9 ], + "value" : 1 + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 26, 1, 26, 9 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 26, 1, 26, 9 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 26, 1, 26, 7 ], + "object" : { + "kind" : "Identifier", + "location" : [ 26, 1, 26, 1 ], + "name" : "b" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 26, 3, 26, 7 ], + "name" : "get_Z" + } + }, + "args" : [ ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 27, 1, 27, 9 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 27, 1, 27, 9 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 27, 1, 27, 7 ], + "object" : { + "kind" : "Identifier", + "location" : [ 27, 1, 27, 1 ], + "name" : "c" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 27, 3, 27, 7 ], + "name" : "set_A" + } + }, + "args" : [ ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 28, 1, 28, 14 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 28, 1, 28, 14 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 28, 1, 28, 7 ], + "object" : { + "kind" : "Identifier", + "location" : [ 28, 1, 28, 1 ], + "name" : "c" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 28, 3, 28, 7 ], + "name" : "set_A" + } + }, + "args" : [ { + "kind" : "BooleanLiteral", + "location" : [ 28, 9, 28, 13 ], + "value" : false + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 29, 1, 29, 13 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 29, 1, 29, 13 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 29, 1, 29, 7 ], + "object" : { + "kind" : "Identifier", + "location" : [ 29, 1, 29, 1 ], + "name" : "c" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 29, 3, 29, 7 ], + "name" : "set_A" + } + }, + "args" : [ { + "kind" : "NoneLiteral", + "location" : [ 29, 9, 29, 12 ] + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_class_method_invoke.py.ast.typed b/pa2-tests/core/bad_class_method_invoke.py.ast.typed new file mode 100644 index 0000000..77867db --- /dev/null +++ b/pa2-tests/core/bad_class_method_invoke.py.ast.typed @@ -0,0 +1,668 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 29, 14 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 7, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 22 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 13 ], + "name" : "get_A" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 15, 4, 23 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 15, 4, 18 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 21, 4, 23 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 29, 4, 31 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 9, 5, 21 ], + "value" : { + "kind" : "MemberExpr", + "location" : [ 5, 16, 5, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 5, 16, 5, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 5, 21, 5, 21 ], + "name" : "x" + } + } + } ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 7, 1, 11, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 7, 7, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 8, 5, 9, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 8, 18, 8, 26 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 18, 8, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 24, 8, 26 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 8, 28, 8, 28 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 11, 1, 17, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 11, 7, 11, 7 ], + "name" : "C" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 11, 9, 11, 9 ], + "name" : "B" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 12, 5, 12, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 5, 12, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 5, 12, 5 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 7, 12, 10 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 12, 14, 12, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + }, { + "kind" : "FuncDef", + "location" : [ 14, 5, 15, 21 ], + "name" : { + "kind" : "Identifier", + "location" : [ 14, 9, 14, 13 ], + "name" : "set_A" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 14, 15, 14, 23 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 14, 15, 14, 18 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 14, 21, 14, 23 ], + "className" : "C" + } + }, { + "kind" : "TypedVar", + "location" : [ 14, 26, 14, 33 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 14, 26, 14, 28 ], + "name" : "val" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 14, 31, 14, 33 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 14, 39, 14, 44 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 15, 9, 15, 20 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 15, 9, 15, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 15, 9, 15, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 15, 14, 15, 14 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 15, 18, 15, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "val" + } + } ] + } ] + }, { + "kind" : "VarDef", + "location" : [ 17, 1, 17, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 17, 1, 17, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 17, 1, 17, 1 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 17, 3, 17, 3 ], + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 17, 7, 17, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 18, 1, 18, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 18, 1, 18, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 18, 1, 18, 1 ], + "name" : "b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 18, 3, 18, 3 ], + "className" : "B" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 18, 7, 18, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 19, 1, 19, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 19, 1, 19, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 19, 1, 19, 1 ], + "name" : "c" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 19, 3, 19, 3 ], + "className" : "C" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 19, 7, 19, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 21, 1, 21, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 21, 1, 21, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 21, 5, 21, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 21, 5, 21, 5 ], + "name" : "A" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 22, 1, 22, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 22, 1, 22, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "name" : "b" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 22, 5, 22, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 22, 5, 22, 5 ], + "name" : "B" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 23, 1, 23, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 23, 1, 23, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "name" : "c" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 23, 5, 23, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 23, 5, 23, 5 ], + "name" : "C" + }, + "args" : [ ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 25, 1, 25, 10 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 25, 1, 25, 10 ], + "errorMsg" : "Expected 0 arguments; got 1", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 25, 1, 25, 7 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "A" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 25, 1, 25, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 25, 3, 25, 7 ], + "name" : "get_A" + } + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 25, 9, 25, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 26, 1, 26, 9 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 26, 1, 26, 9 ], + "errorMsg" : "There is no method named `get_Z` in class `B`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 26, 1, 26, 7 ], + "object" : { + "kind" : "Identifier", + "location" : [ 26, 1, 26, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "name" : "b" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 26, 3, 26, 7 ], + "name" : "get_Z" + } + }, + "args" : [ ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 27, 1, 27, 9 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 27, 1, 27, 9 ], + "errorMsg" : "Expected 1 arguments; got 0", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 27, 1, 27, 7 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "C" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 27, 1, 27, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "name" : "c" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 27, 3, 27, 7 ], + "name" : "set_A" + } + }, + "args" : [ ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 28, 1, 28, 14 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 28, 1, 28, 14 ], + "errorMsg" : "Expected type `int`; got type `bool` in parameter 1", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 28, 1, 28, 7 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "C" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 28, 1, 28, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "name" : "c" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 28, 3, 28, 7 ], + "name" : "set_A" + } + }, + "args" : [ { + "kind" : "BooleanLiteral", + "location" : [ 28, 9, 28, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 29, 1, 29, 13 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 29, 1, 29, 13 ], + "errorMsg" : "Expected type `int`; got type `` in parameter 1", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 29, 1, 29, 7 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "C" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 29, 1, 29, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "name" : "c" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 29, 3, 29, 7 ], + "name" : "set_A" + } + }, + "args" : [ { + "kind" : "NoneLiteral", + "location" : [ 29, 9, 29, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 25, 1, 25, 10 ], + "message" : "Expected 0 arguments; got 1" + }, { + "kind" : "CompilerError", + "location" : [ 26, 1, 26, 9 ], + "message" : "There is no method named `get_Z` in class `B`" + }, { + "kind" : "CompilerError", + "location" : [ 27, 1, 27, 9 ], + "message" : "Expected 1 arguments; got 0" + }, { + "kind" : "CompilerError", + "location" : [ 28, 1, 28, 14 ], + "message" : "Expected type `int`; got type `bool` in parameter 1" + }, { + "kind" : "CompilerError", + "location" : [ 29, 1, 29, 13 ], + "message" : "Expected type `int`; got type `` in parameter 1" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_class_method_override.py b/pa2-tests/core/bad_class_method_override.py new file mode 100644 index 0000000..3f76544 --- /dev/null +++ b/pa2-tests/core/bad_class_method_override.py @@ -0,0 +1,33 @@ +class A(object): + def foo(self:"A", x:int) -> int: + return x + + def bar(self:"A", x:int) -> int: + return x + + def baz(self:"A", x:int) -> int: + return x + + def qux(self:"A", x:int) -> int: + return x + +class B(A): + + # OK override + def foo(self:"B", x:int) -> int: + return 0 + + # Bad override + def bar(self:"B") -> int: + return 0 + + # Bad override + def baz(self:"B", x:int) -> bool: + return True + + # Bad override + def qux(self:"B", x:bool) -> int: + return 0 + +B() + diff --git a/pa2-tests/core/bad_class_method_override.py.ast b/pa2-tests/core/bad_class_method_override.py.ast new file mode 100644 index 0000000..e82a758 --- /dev/null +++ b/pa2-tests/core/bad_class_method_override.py.ast @@ -0,0 +1,439 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 32, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 14, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 2, 5, 3, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 9, 2, 11 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 2, 13, 2, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 13, 2, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 18, 2, 20 ], + "className" : "A" + } + }, { + "kind" : "TypedVar", + "location" : [ 2, 23, 2, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 23, 2, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 25, 2, 27 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 2, 33, 2, 35 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 3, 9, 3, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 3, 16, 3, 16 ], + "name" : "x" + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 5, 5, 6, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 11 ], + "name" : "bar" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 13, 5, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 13, 5, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 18, 5, 20 ], + "className" : "A" + } + }, { + "kind" : "TypedVar", + "location" : [ 5, 23, 5, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 23, 5, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 25, 5, 27 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 33, 5, 35 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 6, 9, 6, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 6, 16, 6, 16 ], + "name" : "x" + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 8, 5, 9, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 11 ], + "name" : "baz" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 8, 13, 8, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 13, 8, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 18, 8, 20 ], + "className" : "A" + } + }, { + "kind" : "TypedVar", + "location" : [ 8, 23, 8, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 23, 8, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 25, 8, 27 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 8, 33, 8, 35 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 9, 9, 9, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 9, 16, 9, 16 ], + "name" : "x" + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 11, 5, 12, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 11, 9, 11, 11 ], + "name" : "qux" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 11, 13, 11, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 13, 11, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 18, 11, 20 ], + "className" : "A" + } + }, { + "kind" : "TypedVar", + "location" : [ 11, 23, 11, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 23, 11, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 25, 11, 27 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 11, 33, 11, 35 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 12, 9, 12, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 12, 16, 12, 16 ], + "name" : "x" + } + } ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 14, 1, 32, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 14, 7, 14, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 14, 9, 14, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 17, 5, 18, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 17, 9, 17, 11 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 17, 13, 17, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 17, 13, 17, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 17, 18, 17, 20 ], + "className" : "B" + } + }, { + "kind" : "TypedVar", + "location" : [ 17, 23, 17, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 17, 23, 17, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 17, 25, 17, 27 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 17, 33, 17, 35 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 18, 9, 18, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 18, 16, 18, 16 ], + "value" : 0 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 21, 5, 22, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 21, 9, 21, 11 ], + "name" : "bar" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 21, 13, 21, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 21, 13, 21, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 21, 18, 21, 20 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 21, 26, 21, 28 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 22, 9, 22, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 22, 16, 22, 16 ], + "value" : 0 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 25, 5, 26, 20 ], + "name" : { + "kind" : "Identifier", + "location" : [ 25, 9, 25, 11 ], + "name" : "baz" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 25, 13, 25, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 25, 13, 25, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 25, 18, 25, 20 ], + "className" : "B" + } + }, { + "kind" : "TypedVar", + "location" : [ 25, 23, 25, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 25, 23, 25, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 25, 25, 25, 27 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 25, 33, 25, 36 ], + "className" : "bool" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 26, 9, 26, 19 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 26, 16, 26, 19 ], + "value" : true + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 29, 5, 30, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 29, 9, 29, 11 ], + "name" : "qux" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 29, 13, 29, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 29, 13, 29, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 29, 18, 29, 20 ], + "className" : "B" + } + }, { + "kind" : "TypedVar", + "location" : [ 29, 23, 29, 28 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 29, 23, 29, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 29, 25, 29, 28 ], + "className" : "bool" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 29, 34, 29, 36 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 30, 9, 30, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 30, 16, 30, 16 ], + "value" : 0 + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 32, 1, 32, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 32, 1, 32, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 32, 1, 32, 1 ], + "name" : "B" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_class_method_override.py.ast.typed b/pa2-tests/core/bad_class_method_override.py.ast.typed new file mode 100644 index 0000000..68716c5 --- /dev/null +++ b/pa2-tests/core/bad_class_method_override.py.ast.typed @@ -0,0 +1,454 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 32, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 14, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 2, 5, 3, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 9, 2, 11 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 2, 13, 2, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 13, 2, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 18, 2, 20 ], + "className" : "A" + } + }, { + "kind" : "TypedVar", + "location" : [ 2, 23, 2, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 23, 2, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 25, 2, 27 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 2, 33, 2, 35 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 3, 9, 3, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 3, 16, 3, 16 ], + "name" : "x" + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 5, 5, 6, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 11 ], + "name" : "bar" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 13, 5, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 13, 5, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 18, 5, 20 ], + "className" : "A" + } + }, { + "kind" : "TypedVar", + "location" : [ 5, 23, 5, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 23, 5, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 25, 5, 27 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 33, 5, 35 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 6, 9, 6, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 6, 16, 6, 16 ], + "name" : "x" + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 8, 5, 9, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 11 ], + "name" : "baz" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 8, 13, 8, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 13, 8, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 18, 8, 20 ], + "className" : "A" + } + }, { + "kind" : "TypedVar", + "location" : [ 8, 23, 8, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 23, 8, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 25, 8, 27 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 8, 33, 8, 35 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 9, 9, 9, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 9, 16, 9, 16 ], + "name" : "x" + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 11, 5, 12, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 11, 9, 11, 11 ], + "name" : "qux" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 11, 13, 11, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 13, 11, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 18, 11, 20 ], + "className" : "A" + } + }, { + "kind" : "TypedVar", + "location" : [ 11, 23, 11, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 23, 11, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 25, 11, 27 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 11, 33, 11, 35 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 12, 9, 12, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 12, 16, 12, 16 ], + "name" : "x" + } + } ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 14, 1, 32, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 14, 7, 14, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 14, 9, 14, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 17, 5, 18, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 17, 9, 17, 11 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 17, 13, 17, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 17, 13, 17, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 17, 18, 17, 20 ], + "className" : "B" + } + }, { + "kind" : "TypedVar", + "location" : [ 17, 23, 17, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 17, 23, 17, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 17, 25, 17, 27 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 17, 33, 17, 35 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 18, 9, 18, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 18, 16, 18, 16 ], + "value" : 0 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 21, 5, 22, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 21, 9, 21, 11 ], + "errorMsg" : "Method overridden with different type signature: bar", + "name" : "bar" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 21, 13, 21, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 21, 13, 21, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 21, 18, 21, 20 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 21, 26, 21, 28 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 22, 9, 22, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 22, 16, 22, 16 ], + "value" : 0 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 25, 5, 26, 20 ], + "name" : { + "kind" : "Identifier", + "location" : [ 25, 9, 25, 11 ], + "errorMsg" : "Method overridden with different type signature: baz", + "name" : "baz" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 25, 13, 25, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 25, 13, 25, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 25, 18, 25, 20 ], + "className" : "B" + } + }, { + "kind" : "TypedVar", + "location" : [ 25, 23, 25, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 25, 23, 25, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 25, 25, 25, 27 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 25, 33, 25, 36 ], + "className" : "bool" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 26, 9, 26, 19 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 26, 16, 26, 19 ], + "value" : true + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 29, 5, 30, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 29, 9, 29, 11 ], + "errorMsg" : "Method overridden with different type signature: qux", + "name" : "qux" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 29, 13, 29, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 29, 13, 29, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 29, 18, 29, 20 ], + "className" : "B" + } + }, { + "kind" : "TypedVar", + "location" : [ 29, 23, 29, 28 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 29, 23, 29, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 29, 25, 29, 28 ], + "className" : "bool" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 29, 34, 29, 36 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 30, 9, 30, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 30, 16, 30, 16 ], + "value" : 0 + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 32, 1, 32, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 32, 1, 32, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 32, 1, 32, 1 ], + "name" : "B" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 21, 9, 21, 11 ], + "message" : "Method overridden with different type signature: bar" + }, { + "kind" : "CompilerError", + "location" : [ 25, 9, 25, 11 ], + "message" : "Method overridden with different type signature: baz" + }, { + "kind" : "CompilerError", + "location" : [ 29, 9, 29, 11 ], + "message" : "Method overridden with different type signature: qux" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_class_method_override_attr.py b/pa2-tests/core/bad_class_method_override_attr.py new file mode 100644 index 0000000..52c01bd --- /dev/null +++ b/pa2-tests/core/bad_class_method_override_attr.py @@ -0,0 +1,8 @@ +class A(object): + f:int = 3 + +class B(A): + def f(self:B) -> int: + return 3 + +A() diff --git a/pa2-tests/core/bad_class_method_override_attr.py.ast b/pa2-tests/core/bad_class_method_override_attr.py.ast new file mode 100644 index 0000000..1574d53 --- /dev/null +++ b/pa2-tests/core/bad_class_method_override_attr.py.ast @@ -0,0 +1,111 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 8, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 11 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 2, 2, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 2, 2, 6 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 2, 2, 2 ], + "name" : "f" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 4, 2, 6 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 10, 2, 10 ], + "value" : 3 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 4, 1, 8, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 7, 4, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 5, 2, 6, 11 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 6, 5, 6 ], + "name" : "f" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 8, 5, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 8, 5, 11 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 13, 5, 13 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 19, 5, 21 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 6, 3, 6, 10 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 10, 6, 10 ], + "value" : 3 + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 8, 1, 8, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 8, 1, 8, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_class_method_override_attr.py.ast.typed b/pa2-tests/core/bad_class_method_override_attr.py.ast.typed new file mode 100644 index 0000000..fcfb779 --- /dev/null +++ b/pa2-tests/core/bad_class_method_override_attr.py.ast.typed @@ -0,0 +1,116 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 8, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 11 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 2, 2, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 2, 2, 6 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 2, 2, 2 ], + "name" : "f" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 4, 2, 6 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 10, 2, 10 ], + "value" : 3 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 4, 1, 8, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 7, 4, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 5, 2, 6, 11 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 6, 5, 6 ], + "errorMsg" : "Cannot re-define attribute: f", + "name" : "f" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 8, 5, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 8, 5, 11 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 13, 5, 13 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 19, 5, 21 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 6, 3, 6, 10 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 10, 6, 10 ], + "value" : 3 + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 8, 1, 8, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 8, 1, 8, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 5, 6, 5, 6 ], + "message" : "Cannot re-define attribute: f" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_class_super.py b/pa2-tests/core/bad_class_super.py new file mode 100644 index 0000000..9701776 --- /dev/null +++ b/pa2-tests/core/bad_class_super.py @@ -0,0 +1,15 @@ +# Super is not defined +class A(B): + x:int = 1 + +z:int = 2 + +# Super is not a class +class B(z): + x:int = 1 + +# Cannot extend special classes +class C(int): + x:int = 1 + +A() diff --git a/pa2-tests/core/bad_class_super.py.ast b/pa2-tests/core/bad_class_super.py.ast new file mode 100644 index 0000000..4aed62a --- /dev/null +++ b/pa2-tests/core/bad_class_super.py.ast @@ -0,0 +1,154 @@ +{ + "kind" : "Program", + "location" : [ 2, 1, 15, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 2, 1, 3, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 7, 2, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 2, 9, 2, 9 ], + "name" : "B" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 3, 5, 3, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 5, 3, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 7, 3, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 13, 3, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 5, 1, 5, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 5, 1, 5, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 3, 5, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 9, 5, 9 ], + "value" : 2 + } + }, { + "kind" : "ClassDef", + "location" : [ 8, 1, 9, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 7, 8, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 9 ], + "name" : "z" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 9, 5, 9, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 9, 5, 9, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 7, 9, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 9, 13, 9, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 12, 1, 13, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 12, 7, 12, 7 ], + "name" : "C" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 12, 9, 12, 11 ], + "name" : "int" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 13, 5, 13, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 13, 5, 13, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 13, 5, 13, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 13, 7, 13, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 13, 13, 13, 13 ], + "value" : 1 + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 15, 1, 15, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 15, 1, 15, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 15, 1, 15, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_class_super.py.ast.typed b/pa2-tests/core/bad_class_super.py.ast.typed new file mode 100644 index 0000000..128383f --- /dev/null +++ b/pa2-tests/core/bad_class_super.py.ast.typed @@ -0,0 +1,169 @@ +{ + "kind" : "Program", + "location" : [ 2, 1, 15, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 2, 1, 3, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 7, 2, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 2, 9, 2, 9 ], + "errorMsg" : "Super-class not defined: B", + "name" : "B" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 3, 5, 3, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 5, 3, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 7, 3, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 13, 3, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 5, 1, 5, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 5, 1, 5, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 3, 5, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 9, 5, 9 ], + "value" : 2 + } + }, { + "kind" : "ClassDef", + "location" : [ 8, 1, 9, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 7, 8, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 9 ], + "errorMsg" : "Super-class must be a class: z", + "name" : "z" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 9, 5, 9, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 9, 5, 9, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 7, 9, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 9, 13, 9, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 12, 1, 13, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 12, 7, 12, 7 ], + "name" : "C" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 12, 9, 12, 11 ], + "errorMsg" : "Cannot extend special class: int", + "name" : "int" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 13, 5, 13, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 13, 5, 13, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 13, 5, 13, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 13, 7, 13, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 13, 13, 13, 13 ], + "value" : 1 + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 15, 1, 15, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 15, 1, 15, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 15, 1, 15, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 2, 9, 2, 9 ], + "message" : "Super-class not defined: B" + }, { + "kind" : "CompilerError", + "location" : [ 8, 9, 8, 9 ], + "message" : "Super-class must be a class: z" + }, { + "kind" : "CompilerError", + "location" : [ 12, 9, 12, 11 ], + "message" : "Cannot extend special class: int" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_concat.py b/pa2-tests/core/bad_concat.py new file mode 100644 index 0000000..56e7802 --- /dev/null +++ b/pa2-tests/core/bad_concat.py @@ -0,0 +1,3 @@ +"Hello" + ["World"] +1 + [2] +[] + [1] diff --git a/pa2-tests/core/bad_concat.py.ast b/pa2-tests/core/bad_concat.py.ast new file mode 100644 index 0000000..0fdfbd6 --- /dev/null +++ b/pa2-tests/core/bad_concat.py.ast @@ -0,0 +1,77 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 3, 9 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 19 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 19 ], + "left" : { + "kind" : "StringLiteral", + "location" : [ 1, 1, 1, 7 ], + "value" : "Hello" + }, + "operator" : "+", + "right" : { + "kind" : "ListExpr", + "location" : [ 1, 11, 1, 19 ], + "elements" : [ { + "kind" : "StringLiteral", + "location" : [ 1, 12, 1, 18 ], + "value" : "World" + } ] + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 2, 1, 2, 7 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 2, 1, 2, 7 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 1, 2, 1 ], + "value" : 1 + }, + "operator" : "+", + "right" : { + "kind" : "ListExpr", + "location" : [ 2, 5, 2, 7 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 2, 6, 2, 6 ], + "value" : 2 + } ] + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 3, 1, 3, 8 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 3, 1, 3, 8 ], + "left" : { + "kind" : "ListExpr", + "location" : [ 3, 1, 3, 2 ], + "elements" : [ ] + }, + "operator" : "+", + "right" : { + "kind" : "ListExpr", + "location" : [ 3, 6, 3, 8 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 3, 7, 3, 7 ], + "value" : 1 + } ] + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_concat.py.ast.typed b/pa2-tests/core/bad_concat.py.ast.typed new file mode 100644 index 0000000..60f5b0c --- /dev/null +++ b/pa2-tests/core/bad_concat.py.ast.typed @@ -0,0 +1,149 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 3, 9 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 19 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 19 ], + "errorMsg" : "Cannot apply operator `+` on types `str` and `[str]`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "left" : { + "kind" : "StringLiteral", + "location" : [ 1, 1, 1, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Hello" + }, + "operator" : "+", + "right" : { + "kind" : "ListExpr", + "location" : [ 1, 11, 1, 19 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "str" + } + }, + "elements" : [ { + "kind" : "StringLiteral", + "location" : [ 1, 12, 1, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "World" + } ] + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 2, 1, 2, 7 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 2, 1, 2, 7 ], + "errorMsg" : "Cannot apply operator `+` on types `int` and `[int]`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 1, 2, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, + "operator" : "+", + "right" : { + "kind" : "ListExpr", + "location" : [ 2, 5, 2, 7 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 2, 6, 2, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } ] + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 3, 1, 3, 8 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 3, 1, 3, 8 ], + "errorMsg" : "Cannot apply operator `+` on types `` and `[int]`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "left" : { + "kind" : "ListExpr", + "location" : [ 3, 1, 3, 2 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "elements" : [ ] + }, + "operator" : "+", + "right" : { + "kind" : "ListExpr", + "location" : [ 3, 6, 3, 8 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 3, 7, 3, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } ] + } + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 1, 1, 1, 19 ], + "message" : "Cannot apply operator `+` on types `str` and `[str]`" + }, { + "kind" : "CompilerError", + "location" : [ 2, 1, 2, 7 ], + "message" : "Cannot apply operator `+` on types `int` and `[int]`" + }, { + "kind" : "CompilerError", + "location" : [ 3, 1, 3, 8 ], + "message" : "Cannot apply operator `+` on types `` and `[int]`" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_duplicate_class.py b/pa2-tests/core/bad_duplicate_class.py new file mode 100644 index 0000000..8f8dd05 --- /dev/null +++ b/pa2-tests/core/bad_duplicate_class.py @@ -0,0 +1,18 @@ +class A(object): + x:int = 1 + +z:bool = True + +# Duplicate +class A(object): + x:int = 1 + +# Duplicate +class str(object): + x:int = 1 + +# Duplicate +class z(object): + x:int = 1 + +A() diff --git a/pa2-tests/core/bad_duplicate_class.py.ast b/pa2-tests/core/bad_duplicate_class.py.ast new file mode 100644 index 0000000..547360b --- /dev/null +++ b/pa2-tests/core/bad_duplicate_class.py.ast @@ -0,0 +1,190 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 18, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 4, 1, 4, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 1, 4, 6 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 3, 4, 6 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 4, 10, 4, 13 ], + "value" : true + } + }, { + "kind" : "ClassDef", + "location" : [ 7, 1, 8, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 7, 7, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 8, 5, 8, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 8, 5, 8, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 5, 8, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 7, 8, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 8, 13, 8, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 11, 1, 12, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 11, 7, 11, 9 ], + "name" : "str" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 11, 11, 11, 16 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 12, 5, 12, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 5, 12, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 5, 12, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 7, 12, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 12, 13, 12, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 15, 1, 16, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 15, 7, 15, 7 ], + "name" : "z" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 15, 9, 15, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 16, 5, 16, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 16, 5, 16, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 16, 5, 16, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 16, 7, 16, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 16, 13, 16, 13 ], + "value" : 1 + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 18, 1, 18, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 18, 1, 18, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 18, 1, 18, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_duplicate_class.py.ast.typed b/pa2-tests/core/bad_duplicate_class.py.ast.typed new file mode 100644 index 0000000..3791ada --- /dev/null +++ b/pa2-tests/core/bad_duplicate_class.py.ast.typed @@ -0,0 +1,205 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 18, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 4, 1, 4, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 1, 4, 6 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 3, 4, 6 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 4, 10, 4, 13 ], + "value" : true + } + }, { + "kind" : "ClassDef", + "location" : [ 7, 1, 8, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 7, 7, 7 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: A", + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 8, 5, 8, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 8, 5, 8, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 5, 8, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 7, 8, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 8, 13, 8, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 11, 1, 12, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 11, 7, 11, 9 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: str", + "name" : "str" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 11, 11, 11, 16 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 12, 5, 12, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 5, 12, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 5, 12, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 7, 12, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 12, 13, 12, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 15, 1, 16, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 15, 7, 15, 7 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: z", + "name" : "z" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 15, 9, 15, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 16, 5, 16, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 16, 5, 16, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 16, 5, 16, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 16, 7, 16, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 16, 13, 16, 13 ], + "value" : 1 + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 18, 1, 18, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 18, 1, 18, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 18, 1, 18, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 7, 7, 7, 7 ], + "message" : "Duplicate declaration of identifier in same scope: A" + }, { + "kind" : "CompilerError", + "location" : [ 11, 7, 11, 9 ], + "message" : "Duplicate declaration of identifier in same scope: str" + }, { + "kind" : "CompilerError", + "location" : [ 15, 7, 15, 7 ], + "message" : "Duplicate declaration of identifier in same scope: z" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_duplicate_class_member.py b/pa2-tests/core/bad_duplicate_class_member.py new file mode 100644 index 0000000..7a5026f --- /dev/null +++ b/pa2-tests/core/bad_duplicate_class_member.py @@ -0,0 +1,12 @@ +class A(object): + x:int = 1 # OK + + def foo(self: "A") -> int: # OK + return 0 + + x:int = 1 # Duplicate + + def foo(self: "A") -> int: # Duplicate + return 0 + +A() diff --git a/pa2-tests/core/bad_duplicate_class_member.py.ast b/pa2-tests/core/bad_duplicate_class_member.py.ast new file mode 100644 index 0000000..58b0ddb --- /dev/null +++ b/pa2-tests/core/bad_duplicate_class_member.py.ast @@ -0,0 +1,156 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 12, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 12, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 11 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 13, 4, 21 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 13, 4, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 19, 4, 21 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 27, 4, 29 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 9, 5, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 16, 5, 16 ], + "value" : 0 + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 7, 5, 7, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 7, 5, 7, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 7, 7, 7, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 13, 7, 13 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 9, 5, 10, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 9, 9, 9, 11 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 9, 13, 9, 21 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 13, 9, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 19, 9, 21 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 9, 27, 9, 29 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 10, 9, 10, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 10, 16, 10, 16 ], + "value" : 0 + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 12, 1, 12, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 12, 1, 12, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_duplicate_class_member.py.ast.typed b/pa2-tests/core/bad_duplicate_class_member.py.ast.typed new file mode 100644 index 0000000..cb97ac4 --- /dev/null +++ b/pa2-tests/core/bad_duplicate_class_member.py.ast.typed @@ -0,0 +1,166 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 12, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 12, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 11 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 13, 4, 21 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 13, 4, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 19, 4, 21 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 27, 4, 29 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 9, 5, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 16, 5, 16 ], + "value" : 0 + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 7, 5, 7, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 7, 5, 7, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: x", + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 7, 7, 7, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 13, 7, 13 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 9, 5, 10, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 9, 9, 9, 11 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: foo", + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 9, 13, 9, 21 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 13, 9, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 19, 9, 21 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 9, 27, 9, 29 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 10, 9, 10, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 10, 16, 10, 16 ], + "value" : 0 + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 12, 1, 12, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 12, 1, 12, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 7, 5, 7, 5 ], + "message" : "Duplicate declaration of identifier in same scope: x" + }, { + "kind" : "CompilerError", + "location" : [ 9, 9, 9, 11 ], + "message" : "Duplicate declaration of identifier in same scope: foo" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_duplicate_global.py b/pa2-tests/core/bad_duplicate_global.py new file mode 100644 index 0000000..4b293ea --- /dev/null +++ b/pa2-tests/core/bad_duplicate_global.py @@ -0,0 +1,18 @@ +x:int = 1 + +def foo() -> object: + pass + +# `foo` cannot be redefined in the same scope +def foo() -> object: + pass + +# `print` cannot be redefined in the same scope +def print(val:object) -> object: + pass + +# `x` cannot be redefined in the same scope +x:int = 2 + + +foo() diff --git a/pa2-tests/core/bad_duplicate_global.py.ast b/pa2-tests/core/bad_duplicate_global.py.ast new file mode 100644 index 0000000..76e6707 --- /dev/null +++ b/pa2-tests/core/bad_duplicate_global.py.ast @@ -0,0 +1,129 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 18, 6 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 3, 1, 4, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 7 ], + "name" : "foo" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 3, 14, 3, 19 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ ] + }, { + "kind" : "FuncDef", + "location" : [ 7, 1, 8, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 7 ], + "name" : "foo" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 7, 14, 7, 19 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ ] + }, { + "kind" : "FuncDef", + "location" : [ 11, 1, 12, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 11, 5, 11, 9 ], + "name" : "print" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 11, 11, 11, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 11, 11, 13 ], + "name" : "val" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 15, 11, 20 ], + "className" : "object" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 11, 26, 11, 31 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ ] + }, { + "kind" : "VarDef", + "location" : [ 15, 1, 15, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 15, 1, 15, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 15, 1, 15, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 15, 3, 15, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 15, 9, 15, 9 ], + "value" : 2 + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 18, 1, 18, 5 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 18, 1, 18, 5 ], + "function" : { + "kind" : "Identifier", + "location" : [ 18, 1, 18, 3 ], + "name" : "foo" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_duplicate_global.py.ast.typed b/pa2-tests/core/bad_duplicate_global.py.ast.typed new file mode 100644 index 0000000..7d72792 --- /dev/null +++ b/pa2-tests/core/bad_duplicate_global.py.ast.typed @@ -0,0 +1,144 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 18, 6 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 3, 1, 4, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 7 ], + "name" : "foo" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 3, 14, 3, 19 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ ] + }, { + "kind" : "FuncDef", + "location" : [ 7, 1, 8, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 7 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: foo", + "name" : "foo" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 7, 14, 7, 19 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ ] + }, { + "kind" : "FuncDef", + "location" : [ 11, 1, 12, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 11, 5, 11, 9 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: print", + "name" : "print" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 11, 11, 11, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 11, 11, 13 ], + "name" : "val" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 15, 11, 20 ], + "className" : "object" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 11, 26, 11, 31 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ ] + }, { + "kind" : "VarDef", + "location" : [ 15, 1, 15, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 15, 1, 15, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 15, 1, 15, 1 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: x", + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 15, 3, 15, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 15, 9, 15, 9 ], + "value" : 2 + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 18, 1, 18, 5 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 18, 1, 18, 5 ], + "function" : { + "kind" : "Identifier", + "location" : [ 18, 1, 18, 3 ], + "name" : "foo" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 7, 5, 7, 7 ], + "message" : "Duplicate declaration of identifier in same scope: foo" + }, { + "kind" : "CompilerError", + "location" : [ 11, 5, 11, 9 ], + "message" : "Duplicate declaration of identifier in same scope: print" + }, { + "kind" : "CompilerError", + "location" : [ 15, 1, 15, 1 ], + "message" : "Duplicate declaration of identifier in same scope: x" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_duplicate_global_2.py b/pa2-tests/core/bad_duplicate_global_2.py new file mode 100644 index 0000000..62ee129 --- /dev/null +++ b/pa2-tests/core/bad_duplicate_global_2.py @@ -0,0 +1,6 @@ +class x(object): + pass + +x:int = 5 + +pass diff --git a/pa2-tests/core/bad_duplicate_global_2.py.ast b/pa2-tests/core/bad_duplicate_global_2.py.ast new file mode 100644 index 0000000..c3a5985 --- /dev/null +++ b/pa2-tests/core/bad_duplicate_global_2.py.ast @@ -0,0 +1,47 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 6, 5 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "x" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ ] + }, { + "kind" : "VarDef", + "location" : [ 4, 1, 4, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 1, 4, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 3, 4, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 9, 4, 9 ], + "value" : 5 + } + } ], + "statements" : [ ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_duplicate_global_2.py.ast.typed b/pa2-tests/core/bad_duplicate_global_2.py.ast.typed new file mode 100644 index 0000000..506a6ca --- /dev/null +++ b/pa2-tests/core/bad_duplicate_global_2.py.ast.typed @@ -0,0 +1,52 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 6, 5 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "x" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ ] + }, { + "kind" : "VarDef", + "location" : [ 4, 1, 4, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 1, 4, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: x", + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 3, 4, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 9, 4, 9 ], + "value" : 5 + } + } ], + "statements" : [ ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 4, 1, 4, 1 ], + "message" : "Duplicate declaration of identifier in same scope: x" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_duplicate_local.py b/pa2-tests/core/bad_duplicate_local.py new file mode 100644 index 0000000..bb25faf --- /dev/null +++ b/pa2-tests/core/bad_duplicate_local.py @@ -0,0 +1,21 @@ +x:int = 1 +y:int = 2 +z:int = 3 + +def foo(x:int) -> object: + y:int = 4 # OK + x:int = 5 # Duplicate declaration + global z # OK + global y # Duplicate declaration + + def x() -> int: # Duplicate declaration + return 0 + + pass + +def bar(x:int, x:int) -> int: # Duplicate params + return x + + +foo(1) + diff --git a/pa2-tests/core/bad_duplicate_local.py.ast b/pa2-tests/core/bad_duplicate_local.py.ast new file mode 100644 index 0000000..53f6fad --- /dev/null +++ b/pa2-tests/core/bad_duplicate_local.py.ast @@ -0,0 +1,257 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 20, 7 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 1 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 9, 2, 9 ], + "value" : 2 + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 9, 3, 9 ], + "value" : 3 + } + }, { + "kind" : "FuncDef", + "location" : [ 5, 1, 14, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 9, 5, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 11, 5, 13 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 19, 5, 24 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 6, 5, 6, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 5, 6, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 7, 6, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 13, 6, 13 ], + "value" : 4 + } + }, { + "kind" : "VarDef", + "location" : [ 7, 5, 7, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 7, 5, 7, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 7, 7, 7, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 13, 7, 13 ], + "value" : 5 + } + }, { + "kind" : "GlobalDecl", + "location" : [ 8, 5, 8, 12 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 8, 12, 8, 12 ], + "name" : "z" + } + }, { + "kind" : "GlobalDecl", + "location" : [ 9, 5, 9, 12 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 9, 12, 9, 12 ], + "name" : "y" + } + }, { + "kind" : "FuncDef", + "location" : [ 11, 5, 12, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 11, 9, 11, 9 ], + "name" : "x" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 11, 16, 11, 18 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 12, 9, 12, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 12, 16, 12, 16 ], + "value" : 0 + } + } ] + } ], + "statements" : [ ] + }, { + "kind" : "FuncDef", + "location" : [ 16, 1, 17, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 16, 5, 16, 7 ], + "name" : "bar" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 16, 9, 16, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 16, 9, 16, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 16, 11, 16, 13 ], + "className" : "int" + } + }, { + "kind" : "TypedVar", + "location" : [ 16, 16, 16, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 16, 16, 16, 16 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 16, 18, 16, 20 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 16, 26, 16, 28 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 17, 5, 17, 12 ], + "value" : { + "kind" : "Identifier", + "location" : [ 17, 12, 17, 12 ], + "name" : "x" + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 20, 1, 20, 6 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 20, 1, 20, 6 ], + "function" : { + "kind" : "Identifier", + "location" : [ 20, 1, 20, 3 ], + "name" : "foo" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 20, 5, 20, 5 ], + "value" : 1 + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_duplicate_local.py.ast.typed b/pa2-tests/core/bad_duplicate_local.py.ast.typed new file mode 100644 index 0000000..1559865 --- /dev/null +++ b/pa2-tests/core/bad_duplicate_local.py.ast.typed @@ -0,0 +1,277 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 20, 7 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 1 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 9, 2, 9 ], + "value" : 2 + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 9, 3, 9 ], + "value" : 3 + } + }, { + "kind" : "FuncDef", + "location" : [ 5, 1, 14, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 9, 5, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 11, 5, 13 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 19, 5, 24 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 6, 5, 6, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 5, 6, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 7, 6, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 13, 6, 13 ], + "value" : 4 + } + }, { + "kind" : "VarDef", + "location" : [ 7, 5, 7, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 7, 5, 7, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: x", + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 7, 7, 7, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 13, 7, 13 ], + "value" : 5 + } + }, { + "kind" : "GlobalDecl", + "location" : [ 8, 5, 8, 12 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 8, 12, 8, 12 ], + "name" : "z" + } + }, { + "kind" : "GlobalDecl", + "location" : [ 9, 5, 9, 12 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 9, 12, 9, 12 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: y", + "name" : "y" + } + }, { + "kind" : "FuncDef", + "location" : [ 11, 5, 12, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 11, 9, 11, 9 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: x", + "name" : "x" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 11, 16, 11, 18 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 12, 9, 12, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 12, 16, 12, 16 ], + "value" : 0 + } + } ] + } ], + "statements" : [ ] + }, { + "kind" : "FuncDef", + "location" : [ 16, 1, 17, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 16, 5, 16, 7 ], + "name" : "bar" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 16, 9, 16, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 16, 9, 16, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 16, 11, 16, 13 ], + "className" : "int" + } + }, { + "kind" : "TypedVar", + "location" : [ 16, 16, 16, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 16, 16, 16, 16 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: x", + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 16, 18, 16, 20 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 16, 26, 16, 28 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 17, 5, 17, 12 ], + "value" : { + "kind" : "Identifier", + "location" : [ 17, 12, 17, 12 ], + "name" : "x" + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 20, 1, 20, 6 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 20, 1, 20, 6 ], + "function" : { + "kind" : "Identifier", + "location" : [ 20, 1, 20, 3 ], + "name" : "foo" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 20, 5, 20, 5 ], + "value" : 1 + } ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 7, 5, 7, 5 ], + "message" : "Duplicate declaration of identifier in same scope: x" + }, { + "kind" : "CompilerError", + "location" : [ 9, 12, 9, 12 ], + "message" : "Duplicate declaration of identifier in same scope: y" + }, { + "kind" : "CompilerError", + "location" : [ 11, 9, 11, 9 ], + "message" : "Duplicate declaration of identifier in same scope: x" + }, { + "kind" : "CompilerError", + "location" : [ 16, 16, 16, 16 ], + "message" : "Duplicate declaration of identifier in same scope: x" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_expr_binary.py b/pa2-tests/core/bad_expr_binary.py new file mode 100644 index 0000000..1668849 --- /dev/null +++ b/pa2-tests/core/bad_expr_binary.py @@ -0,0 +1,13 @@ +1 and 2 +1 or 2 +True - False +True < False +1 + True +False + 0 +1 == True +False != 0 +1 is 1 +True is False +None + None +None == None +None is None diff --git a/pa2-tests/core/bad_expr_binary.py.ast b/pa2-tests/core/bad_expr_binary.py.ast new file mode 100644 index 0000000..c55893a --- /dev/null +++ b/pa2-tests/core/bad_expr_binary.py.ast @@ -0,0 +1,239 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 13, 13 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 7 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 7 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 1, 1, 1 ], + "value" : 1 + }, + "operator" : "and", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 7, 1, 7 ], + "value" : 2 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 2, 1, 2, 6 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 2, 1, 2, 6 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 1, 2, 1 ], + "value" : 1 + }, + "operator" : "or", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 6, 2, 6 ], + "value" : 2 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 3, 1, 3, 12 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 3, 1, 3, 12 ], + "left" : { + "kind" : "BooleanLiteral", + "location" : [ 3, 1, 3, 4 ], + "value" : true + }, + "operator" : "-", + "right" : { + "kind" : "BooleanLiteral", + "location" : [ 3, 8, 3, 12 ], + "value" : false + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 4, 1, 4, 12 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 4, 1, 4, 12 ], + "left" : { + "kind" : "BooleanLiteral", + "location" : [ 4, 1, 4, 4 ], + "value" : true + }, + "operator" : "<", + "right" : { + "kind" : "BooleanLiteral", + "location" : [ 4, 8, 4, 12 ], + "value" : false + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 5, 1, 5, 8 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 5, 1, 5, 8 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 1, 5, 1 ], + "value" : 1 + }, + "operator" : "+", + "right" : { + "kind" : "BooleanLiteral", + "location" : [ 5, 5, 5, 8 ], + "value" : true + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 6, 1, 6, 9 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 6, 1, 6, 9 ], + "left" : { + "kind" : "BooleanLiteral", + "location" : [ 6, 1, 6, 5 ], + "value" : false + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 9, 6, 9 ], + "value" : 0 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 7, 1, 7, 9 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 7, 1, 7, 9 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 1, 7, 1 ], + "value" : 1 + }, + "operator" : "==", + "right" : { + "kind" : "BooleanLiteral", + "location" : [ 7, 6, 7, 9 ], + "value" : true + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 8, 1, 8, 10 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 8, 1, 8, 10 ], + "left" : { + "kind" : "BooleanLiteral", + "location" : [ 8, 1, 8, 5 ], + "value" : false + }, + "operator" : "!=", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 8, 10, 8, 10 ], + "value" : 0 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 9, 1, 9, 6 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 9, 1, 9, 6 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 9, 1, 9, 1 ], + "value" : 1 + }, + "operator" : "is", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 9, 6, 9, 6 ], + "value" : 1 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 10, 1, 10, 13 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 10, 1, 10, 13 ], + "left" : { + "kind" : "BooleanLiteral", + "location" : [ 10, 1, 10, 4 ], + "value" : true + }, + "operator" : "is", + "right" : { + "kind" : "BooleanLiteral", + "location" : [ 10, 9, 10, 13 ], + "value" : false + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 11, 1, 11, 11 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 11, 1, 11, 11 ], + "left" : { + "kind" : "NoneLiteral", + "location" : [ 11, 1, 11, 4 ] + }, + "operator" : "+", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 11, 8, 11, 11 ] + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 12, 1, 12, 12 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 12, 1, 12, 12 ], + "left" : { + "kind" : "NoneLiteral", + "location" : [ 12, 1, 12, 4 ] + }, + "operator" : "==", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 12, 9, 12, 12 ] + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 13, 1, 13, 12 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 13, 1, 13, 12 ], + "left" : { + "kind" : "NoneLiteral", + "location" : [ 13, 1, 13, 4 ] + }, + "operator" : "is", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 13, 9, 13, 12 ] + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_expr_binary.py.ast.typed b/pa2-tests/core/bad_expr_binary.py.ast.typed new file mode 100644 index 0000000..851cc92 --- /dev/null +++ b/pa2-tests/core/bad_expr_binary.py.ast.typed @@ -0,0 +1,455 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 13, 13 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 7 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 7 ], + "errorMsg" : "Cannot apply operator `and` on types `int` and `int`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 1, 1, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, + "operator" : "and", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 7, 1, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 2, 1, 2, 6 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 2, 1, 2, 6 ], + "errorMsg" : "Cannot apply operator `or` on types `int` and `int`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 1, 2, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, + "operator" : "or", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 6, 2, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 3, 1, 3, 12 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 3, 1, 3, 12 ], + "errorMsg" : "Cannot apply operator `-` on types `bool` and `bool`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "BooleanLiteral", + "location" : [ 3, 1, 3, 4 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + }, + "operator" : "-", + "right" : { + "kind" : "BooleanLiteral", + "location" : [ 3, 8, 3, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 4, 1, 4, 12 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 4, 1, 4, 12 ], + "errorMsg" : "Cannot apply operator `<` on types `bool` and `bool`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "BooleanLiteral", + "location" : [ 4, 1, 4, 4 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + }, + "operator" : "<", + "right" : { + "kind" : "BooleanLiteral", + "location" : [ 4, 8, 4, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 5, 1, 5, 8 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 5, 1, 5, 8 ], + "errorMsg" : "Cannot apply operator `+` on types `int` and `bool`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 1, 5, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, + "operator" : "+", + "right" : { + "kind" : "BooleanLiteral", + "location" : [ 5, 5, 5, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 6, 1, 6, 9 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 6, 1, 6, 9 ], + "errorMsg" : "Cannot apply operator `+` on types `bool` and `int`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "BooleanLiteral", + "location" : [ 6, 1, 6, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 9, 6, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 7, 1, 7, 9 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 7, 1, 7, 9 ], + "errorMsg" : "Cannot apply operator `==` on types `int` and `bool`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 1, 7, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, + "operator" : "==", + "right" : { + "kind" : "BooleanLiteral", + "location" : [ 7, 6, 7, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 8, 1, 8, 10 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 8, 1, 8, 10 ], + "errorMsg" : "Cannot apply operator `!=` on types `bool` and `int`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "BooleanLiteral", + "location" : [ 8, 1, 8, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + }, + "operator" : "!=", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 8, 10, 8, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 9, 1, 9, 6 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 9, 1, 9, 6 ], + "errorMsg" : "Cannot apply operator `is` on types `int` and `int`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 9, 1, 9, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, + "operator" : "is", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 9, 6, 9, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 10, 1, 10, 13 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 10, 1, 10, 13 ], + "errorMsg" : "Cannot apply operator `is` on types `bool` and `bool`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "BooleanLiteral", + "location" : [ 10, 1, 10, 4 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + }, + "operator" : "is", + "right" : { + "kind" : "BooleanLiteral", + "location" : [ 10, 9, 10, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 11, 1, 11, 11 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 11, 1, 11, 11 ], + "errorMsg" : "Cannot apply operator `+` on types `` and ``", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "left" : { + "kind" : "NoneLiteral", + "location" : [ 11, 1, 11, 4 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, + "operator" : "+", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 11, 8, 11, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 12, 1, 12, 12 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 12, 1, 12, 12 ], + "errorMsg" : "Cannot apply operator `==` on types `` and ``", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "NoneLiteral", + "location" : [ 12, 1, 12, 4 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, + "operator" : "==", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 12, 9, 12, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 13, 1, 13, 12 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 13, 1, 13, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "NoneLiteral", + "location" : [ 13, 1, 13, 4 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, + "operator" : "is", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 13, 9, 13, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 1, 1, 1, 7 ], + "message" : "Cannot apply operator `and` on types `int` and `int`" + }, { + "kind" : "CompilerError", + "location" : [ 2, 1, 2, 6 ], + "message" : "Cannot apply operator `or` on types `int` and `int`" + }, { + "kind" : "CompilerError", + "location" : [ 3, 1, 3, 12 ], + "message" : "Cannot apply operator `-` on types `bool` and `bool`" + }, { + "kind" : "CompilerError", + "location" : [ 4, 1, 4, 12 ], + "message" : "Cannot apply operator `<` on types `bool` and `bool`" + }, { + "kind" : "CompilerError", + "location" : [ 5, 1, 5, 8 ], + "message" : "Cannot apply operator `+` on types `int` and `bool`" + }, { + "kind" : "CompilerError", + "location" : [ 6, 1, 6, 9 ], + "message" : "Cannot apply operator `+` on types `bool` and `int`" + }, { + "kind" : "CompilerError", + "location" : [ 7, 1, 7, 9 ], + "message" : "Cannot apply operator `==` on types `int` and `bool`" + }, { + "kind" : "CompilerError", + "location" : [ 8, 1, 8, 10 ], + "message" : "Cannot apply operator `!=` on types `bool` and `int`" + }, { + "kind" : "CompilerError", + "location" : [ 9, 1, 9, 6 ], + "message" : "Cannot apply operator `is` on types `int` and `int`" + }, { + "kind" : "CompilerError", + "location" : [ 10, 1, 10, 13 ], + "message" : "Cannot apply operator `is` on types `bool` and `bool`" + }, { + "kind" : "CompilerError", + "location" : [ 11, 1, 11, 11 ], + "message" : "Cannot apply operator `+` on types `` and ``" + }, { + "kind" : "CompilerError", + "location" : [ 12, 1, 12, 12 ], + "message" : "Cannot apply operator `==` on types `` and ``" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_expr_if.py b/pa2-tests/core/bad_expr_if.py new file mode 100644 index 0000000..4ae5fbe --- /dev/null +++ b/pa2-tests/core/bad_expr_if.py @@ -0,0 +1,2 @@ +x: int = 0 +x = "Hello" if 2 > 3 else 3 diff --git a/pa2-tests/core/bad_expr_if.py.ast b/pa2-tests/core/bad_expr_if.py.ast new file mode 100644 index 0000000..24d9ed3 --- /dev/null +++ b/pa2-tests/core/bad_expr_if.py.ast @@ -0,0 +1,70 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 2, 28 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 6 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 4, 1, 6 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 10, 1, 10 ], + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 2, 1, 2, 27 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "x" + } ], + "value" : { + "kind" : "IfExpr", + "location" : [ 2, 5, 2, 27 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 2, 16, 2, 20 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 16, 2, 16 ], + "value" : 2 + }, + "operator" : ">", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 20, 2, 20 ], + "value" : 3 + } + }, + "thenExpr" : { + "kind" : "StringLiteral", + "location" : [ 2, 5, 2, 11 ], + "value" : "Hello" + }, + "elseExpr" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 27, 2, 27 ], + "value" : 3 + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_expr_if.py.ast.typed b/pa2-tests/core/bad_expr_if.py.ast.typed new file mode 100644 index 0000000..0da86f1 --- /dev/null +++ b/pa2-tests/core/bad_expr_if.py.ast.typed @@ -0,0 +1,107 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 2, 28 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 6 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 4, 1, 6 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 10, 1, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 2, 1, 2, 27 ], + "errorMsg" : "Expected type `int`; got type `object`", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ], + "value" : { + "kind" : "IfExpr", + "location" : [ 2, 5, 2, 27 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 2, 16, 2, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 16, 2, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + }, + "operator" : ">", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 20, 2, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } + }, + "thenExpr" : { + "kind" : "StringLiteral", + "location" : [ 2, 5, 2, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Hello" + }, + "elseExpr" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 27, 2, 27 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 2, 1, 2, 27 ], + "message" : "Expected type `int`; got type `object`" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_expr_unary.py b/pa2-tests/core/bad_expr_unary.py new file mode 100644 index 0000000..0b113ac --- /dev/null +++ b/pa2-tests/core/bad_expr_unary.py @@ -0,0 +1,4 @@ +not "Bad" +-True +-None +not [] diff --git a/pa2-tests/core/bad_expr_unary.py.ast b/pa2-tests/core/bad_expr_unary.py.ast new file mode 100644 index 0000000..7632c06 --- /dev/null +++ b/pa2-tests/core/bad_expr_unary.py.ast @@ -0,0 +1,62 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 4, 7 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 9 ], + "expr" : { + "kind" : "UnaryExpr", + "location" : [ 1, 1, 1, 9 ], + "operator" : "not", + "operand" : { + "kind" : "StringLiteral", + "location" : [ 1, 5, 1, 9 ], + "value" : "Bad" + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 2, 1, 2, 5 ], + "expr" : { + "kind" : "UnaryExpr", + "location" : [ 2, 1, 2, 5 ], + "operator" : "-", + "operand" : { + "kind" : "BooleanLiteral", + "location" : [ 2, 2, 2, 5 ], + "value" : true + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 3, 1, 3, 5 ], + "expr" : { + "kind" : "UnaryExpr", + "location" : [ 3, 1, 3, 5 ], + "operator" : "-", + "operand" : { + "kind" : "NoneLiteral", + "location" : [ 3, 2, 3, 5 ] + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 4, 1, 4, 6 ], + "expr" : { + "kind" : "UnaryExpr", + "location" : [ 4, 1, 4, 6 ], + "operator" : "not", + "operand" : { + "kind" : "ListExpr", + "location" : [ 4, 5, 4, 6 ], + "elements" : [ ] + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_expr_unary.py.ast.typed b/pa2-tests/core/bad_expr_unary.py.ast.typed new file mode 100644 index 0000000..f366c93 --- /dev/null +++ b/pa2-tests/core/bad_expr_unary.py.ast.typed @@ -0,0 +1,114 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 4, 7 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 9 ], + "expr" : { + "kind" : "UnaryExpr", + "location" : [ 1, 1, 1, 9 ], + "errorMsg" : "Cannot apply operator `not` on type `str`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "operator" : "not", + "operand" : { + "kind" : "StringLiteral", + "location" : [ 1, 5, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Bad" + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 2, 1, 2, 5 ], + "expr" : { + "kind" : "UnaryExpr", + "location" : [ 2, 1, 2, 5 ], + "errorMsg" : "Cannot apply operator `-` on type `bool`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "operator" : "-", + "operand" : { + "kind" : "BooleanLiteral", + "location" : [ 2, 2, 2, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 3, 1, 3, 5 ], + "expr" : { + "kind" : "UnaryExpr", + "location" : [ 3, 1, 3, 5 ], + "errorMsg" : "Cannot apply operator `-` on type ``", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "operator" : "-", + "operand" : { + "kind" : "NoneLiteral", + "location" : [ 3, 2, 3, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 4, 1, 4, 6 ], + "expr" : { + "kind" : "UnaryExpr", + "location" : [ 4, 1, 4, 6 ], + "errorMsg" : "Cannot apply operator `not` on type ``", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "operator" : "not", + "operand" : { + "kind" : "ListExpr", + "location" : [ 4, 5, 4, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "elements" : [ ] + } + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 1, 1, 1, 9 ], + "message" : "Cannot apply operator `not` on type `str`" + }, { + "kind" : "CompilerError", + "location" : [ 2, 1, 2, 5 ], + "message" : "Cannot apply operator `-` on type `bool`" + }, { + "kind" : "CompilerError", + "location" : [ 3, 1, 3, 5 ], + "message" : "Cannot apply operator `-` on type ``" + }, { + "kind" : "CompilerError", + "location" : [ 4, 1, 4, 6 ], + "message" : "Cannot apply operator `not` on type ``" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_func_def_call.py b/pa2-tests/core/bad_func_def_call.py new file mode 100644 index 0000000..a929805 --- /dev/null +++ b/pa2-tests/core/bad_func_def_call.py @@ -0,0 +1,13 @@ +def foo(x:str, y:bool) -> int: + return bar() + +def bar() -> int: + return 1 + +# All of the below are bad calls +foo("Hello") +foo("Hello", False, 3) +foo("Hello", 3) +foo(1, "Hello") +baz() + diff --git a/pa2-tests/core/bad_func_def_call.py.ast b/pa2-tests/core/bad_func_def_call.py.ast new file mode 100644 index 0000000..64c0e9d --- /dev/null +++ b/pa2-tests/core/bad_func_def_call.py.ast @@ -0,0 +1,187 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 12, 6 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 2, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 1, 9, 1, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 11, 1, 13 ], + "className" : "str" + } + }, { + "kind" : "TypedVar", + "location" : [ 1, 16, 1, 21 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 16, 1, 16 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 18, 1, 21 ], + "className" : "bool" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 27, 1, 29 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 2, 5, 2, 16 ], + "value" : { + "kind" : "CallExpr", + "location" : [ 2, 12, 2, 16 ], + "function" : { + "kind" : "Identifier", + "location" : [ 2, 12, 2, 14 ], + "name" : "bar" + }, + "args" : [ ] + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 4, 1, 5, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 7 ], + "name" : "bar" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 14, 4, 16 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 5, 5, 12 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 12, 5, 12 ], + "value" : 1 + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 8, 1, 8, 12 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 8, 1, 8, 12 ], + "function" : { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 3 ], + "name" : "foo" + }, + "args" : [ { + "kind" : "StringLiteral", + "location" : [ 8, 5, 8, 11 ], + "value" : "Hello" + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 9, 1, 9, 22 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 9, 1, 9, 22 ], + "function" : { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 3 ], + "name" : "foo" + }, + "args" : [ { + "kind" : "StringLiteral", + "location" : [ 9, 5, 9, 11 ], + "value" : "Hello" + }, { + "kind" : "BooleanLiteral", + "location" : [ 9, 14, 9, 18 ], + "value" : false + }, { + "kind" : "IntegerLiteral", + "location" : [ 9, 21, 9, 21 ], + "value" : 3 + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 10, 1, 10, 15 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 10, 1, 10, 15 ], + "function" : { + "kind" : "Identifier", + "location" : [ 10, 1, 10, 3 ], + "name" : "foo" + }, + "args" : [ { + "kind" : "StringLiteral", + "location" : [ 10, 5, 10, 11 ], + "value" : "Hello" + }, { + "kind" : "IntegerLiteral", + "location" : [ 10, 14, 10, 14 ], + "value" : 3 + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 11, 1, 11, 15 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 11, 1, 11, 15 ], + "function" : { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 3 ], + "name" : "foo" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 11, 5, 11, 5 ], + "value" : 1 + }, { + "kind" : "StringLiteral", + "location" : [ 11, 8, 11, 14 ], + "value" : "Hello" + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 12, 1, 12, 5 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 12, 1, 12, 5 ], + "function" : { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 3 ], + "name" : "baz" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_func_def_call.py.ast.typed b/pa2-tests/core/bad_func_def_call.py.ast.typed new file mode 100644 index 0000000..e9dc647 --- /dev/null +++ b/pa2-tests/core/bad_func_def_call.py.ast.typed @@ -0,0 +1,336 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 12, 6 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 2, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 1, 9, 1, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 11, 1, 13 ], + "className" : "str" + } + }, { + "kind" : "TypedVar", + "location" : [ 1, 16, 1, 21 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 16, 1, 16 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 18, 1, 21 ], + "className" : "bool" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 27, 1, 29 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 2, 5, 2, 16 ], + "value" : { + "kind" : "CallExpr", + "location" : [ 2, 12, 2, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 2, 12, 2, 14 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "bar" + }, + "args" : [ ] + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 4, 1, 5, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 7 ], + "name" : "bar" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 14, 4, 16 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 5, 5, 12 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 12, 5, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 8, 1, 8, 12 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 8, 1, 8, 12 ], + "errorMsg" : "Expected 2 arguments; got 1", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 3 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "str" + }, { + "kind" : "ClassValueType", + "className" : "bool" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "foo" + }, + "args" : [ { + "kind" : "StringLiteral", + "location" : [ 8, 5, 8, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Hello" + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 9, 1, 9, 22 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 9, 1, 9, 22 ], + "errorMsg" : "Expected 2 arguments; got 3", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 3 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "str" + }, { + "kind" : "ClassValueType", + "className" : "bool" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "foo" + }, + "args" : [ { + "kind" : "StringLiteral", + "location" : [ 9, 5, 9, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Hello" + }, { + "kind" : "BooleanLiteral", + "location" : [ 9, 14, 9, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + }, { + "kind" : "IntegerLiteral", + "location" : [ 9, 21, 9, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 10, 1, 10, 15 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 10, 1, 10, 15 ], + "errorMsg" : "Expected type `bool`; got type `int` in parameter 1", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 10, 1, 10, 3 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "str" + }, { + "kind" : "ClassValueType", + "className" : "bool" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "foo" + }, + "args" : [ { + "kind" : "StringLiteral", + "location" : [ 10, 5, 10, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Hello" + }, { + "kind" : "IntegerLiteral", + "location" : [ 10, 14, 10, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 11, 1, 11, 15 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 11, 1, 11, 15 ], + "errorMsg" : "Expected type `str`; got type `int` in parameter 0", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 3 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "str" + }, { + "kind" : "ClassValueType", + "className" : "bool" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "foo" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 11, 5, 11, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, { + "kind" : "StringLiteral", + "location" : [ 11, 8, 11, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Hello" + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 12, 1, 12, 5 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 12, 1, 12, 5 ], + "errorMsg" : "Not a function or class: baz", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 3 ], + "name" : "baz" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 8, 1, 8, 12 ], + "message" : "Expected 2 arguments; got 1" + }, { + "kind" : "CompilerError", + "location" : [ 9, 1, 9, 22 ], + "message" : "Expected 2 arguments; got 3" + }, { + "kind" : "CompilerError", + "location" : [ 10, 1, 10, 15 ], + "message" : "Expected type `bool`; got type `int` in parameter 1" + }, { + "kind" : "CompilerError", + "location" : [ 11, 1, 11, 15 ], + "message" : "Expected type `str`; got type `int` in parameter 0" + }, { + "kind" : "CompilerError", + "location" : [ 12, 1, 12, 5 ], + "message" : "Not a function or class: baz" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_func_def_return.py b/pa2-tests/core/bad_func_def_return.py new file mode 100644 index 0000000..efccffb --- /dev/null +++ b/pa2-tests/core/bad_func_def_return.py @@ -0,0 +1,10 @@ +def foo(x:str, y:bool) -> int: + return None + +def bar() -> bool: + return 1 + +def baz() -> str: + return + +foo("Hello", False) diff --git a/pa2-tests/core/bad_func_def_return.py.ast b/pa2-tests/core/bad_func_def_return.py.ast new file mode 100644 index 0000000..e7aaa31 --- /dev/null +++ b/pa2-tests/core/bad_func_def_return.py.ast @@ -0,0 +1,125 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 10, 20 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 2, 16 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 1, 9, 1, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 11, 1, 13 ], + "className" : "str" + } + }, { + "kind" : "TypedVar", + "location" : [ 1, 16, 1, 21 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 16, 1, 16 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 18, 1, 21 ], + "className" : "bool" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 27, 1, 29 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 2, 5, 2, 15 ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 2, 12, 2, 15 ] + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 4, 1, 5, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 7 ], + "name" : "bar" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 14, 4, 17 ], + "className" : "bool" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 5, 5, 12 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 12, 5, 12 ], + "value" : 1 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 7, 1, 8, 11 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 7 ], + "name" : "baz" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 7, 14, 7, 16 ], + "className" : "str" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 8, 5, 8, 10 ], + "value" : null + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 10, 1, 10, 19 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 10, 1, 10, 19 ], + "function" : { + "kind" : "Identifier", + "location" : [ 10, 1, 10, 3 ], + "name" : "foo" + }, + "args" : [ { + "kind" : "StringLiteral", + "location" : [ 10, 5, 10, 11 ], + "value" : "Hello" + }, { + "kind" : "BooleanLiteral", + "location" : [ 10, 14, 10, 18 ], + "value" : false + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_func_def_return.py.ast.typed b/pa2-tests/core/bad_func_def_return.py.ast.typed new file mode 100644 index 0000000..8dafad8 --- /dev/null +++ b/pa2-tests/core/bad_func_def_return.py.ast.typed @@ -0,0 +1,174 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 10, 20 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 2, 16 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 1, 9, 1, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 11, 1, 13 ], + "className" : "str" + } + }, { + "kind" : "TypedVar", + "location" : [ 1, 16, 1, 21 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 16, 1, 16 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 18, 1, 21 ], + "className" : "bool" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 27, 1, 29 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 2, 5, 2, 15 ], + "errorMsg" : "Expected type `int`; got type ``", + "value" : { + "kind" : "NoneLiteral", + "location" : [ 2, 12, 2, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 4, 1, 5, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 7 ], + "name" : "bar" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 14, 4, 17 ], + "className" : "bool" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 5, 5, 12 ], + "errorMsg" : "Expected type `bool`; got type `int`", + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 12, 5, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 7, 1, 8, 11 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 7 ], + "name" : "baz" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 7, 14, 7, 16 ], + "className" : "str" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 8, 5, 8, 10 ], + "errorMsg" : "Expected type `str`; got `None`", + "value" : null + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 10, 1, 10, 19 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 10, 1, 10, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 10, 1, 10, 3 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "str" + }, { + "kind" : "ClassValueType", + "className" : "bool" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "foo" + }, + "args" : [ { + "kind" : "StringLiteral", + "location" : [ 10, 5, 10, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Hello" + }, { + "kind" : "BooleanLiteral", + "location" : [ 10, 14, 10, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 2, 5, 2, 15 ], + "message" : "Expected type `int`; got type ``" + }, { + "kind" : "CompilerError", + "location" : [ 5, 5, 5, 12 ], + "message" : "Expected type `bool`; got type `int`" + }, { + "kind" : "CompilerError", + "location" : [ 8, 5, 8, 10 ], + "message" : "Expected type `str`; got `None`" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_list_assign.py b/pa2-tests/core/bad_list_assign.py new file mode 100644 index 0000000..f85c242 --- /dev/null +++ b/pa2-tests/core/bad_list_assign.py @@ -0,0 +1,6 @@ +x:[int] = None +y:[object] = None + +x = [1, 2, 3] +y = x +y = [1] diff --git a/pa2-tests/core/bad_list_assign.py.ast b/pa2-tests/core/bad_list_assign.py.ast new file mode 100644 index 0000000..5fa5dd5 --- /dev/null +++ b/pa2-tests/core/bad_list_assign.py.ast @@ -0,0 +1,116 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 6, 8 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ListType", + "location" : [ 1, 3, 1, 7 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 1, 4, 1, 6 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 1, 11, 1, 14 ] + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ListType", + "location" : [ 2, 3, 2, 10 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 2, 4, 2, 9 ], + "className" : "object" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 2, 14, 2, 17 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 4, 1, 4, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 4, 5, 4, 13 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 4, 6, 4, 6 ], + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 4, 9, 4, 9 ], + "value" : 2 + }, { + "kind" : "IntegerLiteral", + "location" : [ 4, 12, 4, 12 ], + "value" : 3 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 5, 1, 5, 5 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "name" : "y" + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 5 ], + "name" : "x" + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "y" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 6, 5, 6, 7 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 6, 6, 6, 6 ], + "value" : 1 + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_list_assign.py.ast.typed b/pa2-tests/core/bad_list_assign.py.ast.typed new file mode 100644 index 0000000..b07e2b3 --- /dev/null +++ b/pa2-tests/core/bad_list_assign.py.ast.typed @@ -0,0 +1,192 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 6, 8 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ListType", + "location" : [ 1, 3, 1, 7 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 1, 4, 1, 6 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 1, 11, 1, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ListType", + "location" : [ 2, 3, 2, 10 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 2, 4, 2, 9 ], + "className" : "object" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 2, 14, 2, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 4, 1, 4, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 4, 5, 4, 13 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 4, 6, 4, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 4, 9, 4, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + }, { + "kind" : "IntegerLiteral", + "location" : [ 4, 12, 4, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 5, 1, 5, 5 ], + "errorMsg" : "Expected type `[object]`; got type `[int]`", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "name" : "y" + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 5 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 7 ], + "errorMsg" : "Expected type `[object]`; got type `[int]`", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "name" : "y" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 6, 5, 6, 7 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 6, 6, 6, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 5, 1, 5, 5 ], + "message" : "Expected type `[object]`; got type `[int]`" + }, { + "kind" : "CompilerError", + "location" : [ 6, 1, 6, 7 ], + "message" : "Expected type `[object]`; got type `[int]`" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_list_index.py b/pa2-tests/core/bad_list_index.py new file mode 100644 index 0000000..7b0c708 --- /dev/null +++ b/pa2-tests/core/bad_list_index.py @@ -0,0 +1,7 @@ +x:[int] = None + +x = [1, 2, 3] +x[True] # Bad +False[0] # Bad +[][0] # Bad +x[True] = x[False] = 1 diff --git a/pa2-tests/core/bad_list_index.py.ast b/pa2-tests/core/bad_list_index.py.ast new file mode 100644 index 0000000..b805e51 --- /dev/null +++ b/pa2-tests/core/bad_list_index.py.ast @@ -0,0 +1,147 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 7, 23 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ListType", + "location" : [ 1, 3, 1, 7 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 1, 4, 1, 6 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 1, 11, 1, 14 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 3, 1, 3, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 3, 5, 3, 13 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 3, 6, 3, 6 ], + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 3, 9, 3, 9 ], + "value" : 2 + }, { + "kind" : "IntegerLiteral", + "location" : [ 3, 12, 3, 12 ], + "value" : 3 + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 4, 1, 4, 7 ], + "expr" : { + "kind" : "IndexExpr", + "location" : [ 4, 1, 4, 7 ], + "list" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "x" + }, + "index" : { + "kind" : "BooleanLiteral", + "location" : [ 4, 3, 4, 6 ], + "value" : true + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 5, 1, 5, 8 ], + "expr" : { + "kind" : "IndexExpr", + "location" : [ 5, 1, 5, 8 ], + "list" : { + "kind" : "BooleanLiteral", + "location" : [ 5, 1, 5, 5 ], + "value" : false + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 7, 5, 7 ], + "value" : 0 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 6, 1, 6, 5 ], + "expr" : { + "kind" : "IndexExpr", + "location" : [ 6, 1, 6, 5 ], + "list" : { + "kind" : "ListExpr", + "location" : [ 6, 1, 6, 2 ], + "elements" : [ ] + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 4, 6, 4 ], + "value" : 0 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 22 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 7, 1, 7, 7 ], + "list" : { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "name" : "x" + }, + "index" : { + "kind" : "BooleanLiteral", + "location" : [ 7, 3, 7, 6 ], + "value" : true + } + }, { + "kind" : "IndexExpr", + "location" : [ 7, 11, 7, 18 ], + "list" : { + "kind" : "Identifier", + "location" : [ 7, 11, 7, 11 ], + "name" : "x" + }, + "index" : { + "kind" : "BooleanLiteral", + "location" : [ 7, 13, 7, 17 ], + "value" : false + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 22, 7, 22 ], + "value" : 1 + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_list_index.py.ast.typed b/pa2-tests/core/bad_list_index.py.ast.typed new file mode 100644 index 0000000..fa390f3 --- /dev/null +++ b/pa2-tests/core/bad_list_index.py.ast.typed @@ -0,0 +1,275 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 7, 23 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ListType", + "location" : [ 1, 3, 1, 7 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 1, 4, 1, 6 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 1, 11, 1, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 3, 1, 3, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 3, 5, 3, 13 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 3, 6, 3, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 3, 9, 3, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + }, { + "kind" : "IntegerLiteral", + "location" : [ 3, 12, 3, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 4, 1, 4, 7 ], + "expr" : { + "kind" : "IndexExpr", + "location" : [ 4, 1, 4, 7 ], + "errorMsg" : "Index is of non-integer type `bool`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + }, + "index" : { + "kind" : "BooleanLiteral", + "location" : [ 4, 3, 4, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 5, 1, 5, 8 ], + "expr" : { + "kind" : "IndexExpr", + "location" : [ 5, 1, 5, 8 ], + "errorMsg" : "Cannot index into type `bool`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "list" : { + "kind" : "BooleanLiteral", + "location" : [ 5, 1, 5, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 7, 5, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 6, 1, 6, 5 ], + "expr" : { + "kind" : "IndexExpr", + "location" : [ 6, 1, 6, 5 ], + "errorMsg" : "Cannot index into type ``", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "list" : { + "kind" : "ListExpr", + "location" : [ 6, 1, 6, 2 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "elements" : [ ] + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 4, 6, 4 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 22 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 7, 1, 7, 7 ], + "errorMsg" : "Index is of non-integer type `bool`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + }, + "index" : { + "kind" : "BooleanLiteral", + "location" : [ 7, 3, 7, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + }, { + "kind" : "IndexExpr", + "location" : [ 7, 11, 7, 18 ], + "errorMsg" : "Index is of non-integer type `bool`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 7, 11, 7, 11 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + }, + "index" : { + "kind" : "BooleanLiteral", + "location" : [ 7, 13, 7, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 22, 7, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 4, 1, 4, 7 ], + "message" : "Index is of non-integer type `bool`" + }, { + "kind" : "CompilerError", + "location" : [ 5, 1, 5, 8 ], + "message" : "Cannot index into type `bool`" + }, { + "kind" : "CompilerError", + "location" : [ 6, 1, 6, 5 ], + "message" : "Cannot index into type ``" + }, { + "kind" : "CompilerError", + "location" : [ 7, 1, 7, 7 ], + "message" : "Index is of non-integer type `bool`" + }, { + "kind" : "CompilerError", + "location" : [ 7, 11, 7, 18 ], + "message" : "Index is of non-integer type `bool`" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_local_assign.py b/pa2-tests/core/bad_local_assign.py new file mode 100644 index 0000000..77f3420 --- /dev/null +++ b/pa2-tests/core/bad_local_assign.py @@ -0,0 +1,23 @@ +x:int = 1 +y:int = 2 +z:int = 3 + +def foo(x:int) -> object: + y:int = 4 # OK + global z # OK + + def qux() -> int: + y = 1 # Bad, nonlocal not declared + return 0 + + z = 1 # OK + + pass + +def bar(x:int) -> int: + z = 1 # Bad, global not declared + return x + + +foo(1) + diff --git a/pa2-tests/core/bad_local_assign.py.ast b/pa2-tests/core/bad_local_assign.py.ast new file mode 100644 index 0000000..ffac6b5 --- /dev/null +++ b/pa2-tests/core/bad_local_assign.py.ast @@ -0,0 +1,253 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 22, 7 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 1 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 9, 2, 9 ], + "value" : 2 + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 9, 3, 9 ], + "value" : 3 + } + }, { + "kind" : "FuncDef", + "location" : [ 5, 1, 15, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 9, 5, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 11, 5, 13 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 19, 5, 24 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 6, 5, 6, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 5, 6, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 7, 6, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 13, 6, 13 ], + "value" : 4 + } + }, { + "kind" : "GlobalDecl", + "location" : [ 7, 5, 7, 12 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 7, 12, 7, 12 ], + "name" : "z" + } + }, { + "kind" : "FuncDef", + "location" : [ 9, 5, 11, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 9, 9, 9, 11 ], + "name" : "qux" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 9, 18, 9, 20 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 10, 9, 10, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 10, 9, 10, 9 ], + "name" : "y" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 10, 13, 10, 13 ], + "value" : 1 + } + }, { + "kind" : "ReturnStmt", + "location" : [ 11, 9, 11, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 11, 16, 11, 16 ], + "value" : 0 + } + } ] + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 13, 5, 13, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 13, 5, 13, 5 ], + "name" : "z" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 13, 9, 13, 9 ], + "value" : 1 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 17, 1, 19, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 17, 5, 17, 7 ], + "name" : "bar" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 17, 9, 17, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 17, 9, 17, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 17, 11, 17, 13 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 17, 19, 17, 21 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 18, 5, 18, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 18, 5, 18, 5 ], + "name" : "z" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 18, 9, 18, 9 ], + "value" : 1 + } + }, { + "kind" : "ReturnStmt", + "location" : [ 19, 5, 19, 12 ], + "value" : { + "kind" : "Identifier", + "location" : [ 19, 12, 19, 12 ], + "name" : "x" + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 22, 1, 22, 6 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 22, 1, 22, 6 ], + "function" : { + "kind" : "Identifier", + "location" : [ 22, 1, 22, 3 ], + "name" : "foo" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 22, 5, 22, 5 ], + "value" : 1 + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_local_assign.py.ast.typed b/pa2-tests/core/bad_local_assign.py.ast.typed new file mode 100644 index 0000000..ec39de4 --- /dev/null +++ b/pa2-tests/core/bad_local_assign.py.ast.typed @@ -0,0 +1,330 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 22, 7 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 9, 2, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 9, 3, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } + }, { + "kind" : "FuncDef", + "location" : [ 5, 1, 15, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 9, 5, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 11, 5, 13 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 19, 5, 24 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 6, 5, 6, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 5, 6, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 7, 6, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 13, 6, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 4 + } + }, { + "kind" : "GlobalDecl", + "location" : [ 7, 5, 7, 12 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 7, 12, 7, 12 ], + "name" : "z" + } + }, { + "kind" : "FuncDef", + "location" : [ 9, 5, 11, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 9, 9, 9, 11 ], + "name" : "qux" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 9, 18, 9, 20 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 10, 9, 10, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 10, 9, 10, 9 ], + "errorMsg" : "Cannot assign to variable that is not explicitly declared in this scope: y", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "y" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 10, 13, 10, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "ReturnStmt", + "location" : [ 11, 9, 11, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 11, 16, 11, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ] + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 13, 5, 13, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 13, 5, 13, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "z" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 13, 9, 13, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 17, 1, 19, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 17, 5, 17, 7 ], + "name" : "bar" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 17, 9, 17, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 17, 9, 17, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 17, 11, 17, 13 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 17, 19, 17, 21 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 18, 5, 18, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 18, 5, 18, 5 ], + "errorMsg" : "Cannot assign to variable that is not explicitly declared in this scope: z", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "z" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 18, 9, 18, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "ReturnStmt", + "location" : [ 19, 5, 19, 12 ], + "value" : { + "kind" : "Identifier", + "location" : [ 19, 12, 19, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 22, 1, 22, 6 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 22, 1, 22, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 22, 1, 22, 3 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "name" : "foo" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 22, 5, 22, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 10, 9, 10, 9 ], + "message" : "Cannot assign to variable that is not explicitly declared in this scope: y" + }, { + "kind" : "CompilerError", + "location" : [ 18, 5, 18, 5 ], + "message" : "Cannot assign to variable that is not explicitly declared in this scope: z" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_none_assign.py b/pa2-tests/core/bad_none_assign.py new file mode 100644 index 0000000..fc0ec3f --- /dev/null +++ b/pa2-tests/core/bad_none_assign.py @@ -0,0 +1,14 @@ +class A(object): + x:int = 1 + +y:[bool] = None +z:str = "" +a:A = None + +a = A() + +# Cannot assign None to integer/bool/str types +z = None +a.x = None +y[0] = None + diff --git a/pa2-tests/core/bad_none_assign.py.ast b/pa2-tests/core/bad_none_assign.py.ast new file mode 100644 index 0000000..a0a1246 --- /dev/null +++ b/pa2-tests/core/bad_none_assign.py.ast @@ -0,0 +1,187 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 13, 12 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 4, 1, 4, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 1, 4, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ListType", + "location" : [ 4, 3, 4, 8 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 4, 4, 4, 7 ], + "className" : "bool" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 4, 12, 4, 15 ] + } + }, { + "kind" : "VarDef", + "location" : [ 5, 1, 5, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 5, 1, 5, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 3, 5, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 5, 9, 5, 10 ], + "value" : "" + } + }, { + "kind" : "VarDef", + "location" : [ 6, 1, 6, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 1, 6, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 3, 6, 3 ], + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 6, 7, 6, 10 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 8, 1, 8, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 8, 5, 8, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 8, 5, 8, 5 ], + "name" : "A" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 11, 1, 11, 8 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "name" : "z" + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 11, 5, 11, 8 ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 12, 1, 12, 10 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 12, 1, 12, 3 ], + "object" : { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 12, 3, 12, 3 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 12, 7, 12, 10 ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 13, 1, 13, 11 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 13, 1, 13, 4 ], + "list" : { + "kind" : "Identifier", + "location" : [ 13, 1, 13, 1 ], + "name" : "y" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 13, 3, 13, 3 ], + "value" : 0 + } + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 13, 8, 13, 11 ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_none_assign.py.ast.typed b/pa2-tests/core/bad_none_assign.py.ast.typed new file mode 100644 index 0000000..2edc3c2 --- /dev/null +++ b/pa2-tests/core/bad_none_assign.py.ast.typed @@ -0,0 +1,265 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 13, 12 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 4, 1, 4, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 1, 4, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ListType", + "location" : [ 4, 3, 4, 8 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 4, 4, 4, 7 ], + "className" : "bool" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 4, 12, 4, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 5, 1, 5, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 5, 1, 5, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 3, 5, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 5, 9, 5, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "" + } + }, { + "kind" : "VarDef", + "location" : [ 6, 1, 6, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 1, 6, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 3, 6, 3 ], + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 6, 7, 6, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 8, 1, 8, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 8, 5, 8, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 8, 5, 8, 5 ], + "name" : "A" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 11, 1, 11, 8 ], + "errorMsg" : "Expected type `str`; got type ``", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "z" + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 11, 5, 11, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 12, 1, 12, 10 ], + "errorMsg" : "Expected type `int`; got type ``", + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 12, 1, 12, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 12, 3, 12, 3 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 12, 7, 12, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 13, 1, 13, 11 ], + "errorMsg" : "Expected type `bool`; got type ``", + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 13, 1, 13, 4 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 13, 1, 13, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "bool" + } + }, + "name" : "y" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 13, 3, 13, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 13, 8, 13, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 11, 1, 11, 8 ], + "message" : "Expected type `str`; got type ``" + }, { + "kind" : "CompilerError", + "location" : [ 12, 1, 12, 10 ], + "message" : "Expected type `int`; got type ``" + }, { + "kind" : "CompilerError", + "location" : [ 13, 1, 13, 11 ], + "message" : "Expected type `bool`; got type ``" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_nonlocal_global.py b/pa2-tests/core/bad_nonlocal_global.py new file mode 100644 index 0000000..98eea5c --- /dev/null +++ b/pa2-tests/core/bad_nonlocal_global.py @@ -0,0 +1,25 @@ +x:int = 1 +y:int = 2 +z:int = 3 + +def foo() -> object: + global x # OK + nonlocal y # No such nonlocal var + global w # No such global var + global int # No such global var + + z:bool = True # OK + + def bar() -> object: + global x # OK + nonlocal z # OK + nonlocal y # No such nonlocal var + global foo # No such global var + nonlocal bar # No such nonlocal var + + pass + + bar() + +foo() + diff --git a/pa2-tests/core/bad_nonlocal_global.py.ast b/pa2-tests/core/bad_nonlocal_global.py.ast new file mode 100644 index 0000000..dce287d --- /dev/null +++ b/pa2-tests/core/bad_nonlocal_global.py.ast @@ -0,0 +1,229 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 24, 6 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 1 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 9, 2, 9 ], + "value" : 2 + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 9, 3, 9 ], + "value" : 3 + } + }, { + "kind" : "FuncDef", + "location" : [ 5, 1, 22, 10 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 7 ], + "name" : "foo" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 14, 5, 19 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "GlobalDecl", + "location" : [ 6, 5, 6, 12 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 6, 12, 6, 12 ], + "name" : "x" + } + }, { + "kind" : "NonLocalDecl", + "location" : [ 7, 5, 7, 14 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 7, 14, 7, 14 ], + "name" : "y" + } + }, { + "kind" : "GlobalDecl", + "location" : [ 8, 5, 8, 12 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 8, 12, 8, 12 ], + "name" : "w" + } + }, { + "kind" : "GlobalDecl", + "location" : [ 9, 5, 9, 14 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 9, 12, 9, 14 ], + "name" : "int" + } + }, { + "kind" : "VarDef", + "location" : [ 11, 5, 11, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 11, 5, 11, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 5, 11, 5 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 7, 11, 10 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 11, 14, 11, 17 ], + "value" : true + } + }, { + "kind" : "FuncDef", + "location" : [ 13, 5, 20, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 13, 9, 13, 11 ], + "name" : "bar" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 13, 18, 13, 23 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "GlobalDecl", + "location" : [ 14, 9, 14, 16 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 14, 16, 14, 16 ], + "name" : "x" + } + }, { + "kind" : "NonLocalDecl", + "location" : [ 15, 9, 15, 18 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 15, 18, 15, 18 ], + "name" : "z" + } + }, { + "kind" : "NonLocalDecl", + "location" : [ 16, 9, 16, 18 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 16, 18, 16, 18 ], + "name" : "y" + } + }, { + "kind" : "GlobalDecl", + "location" : [ 17, 9, 17, 18 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 17, 16, 17, 18 ], + "name" : "foo" + } + }, { + "kind" : "NonLocalDecl", + "location" : [ 18, 9, 18, 20 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 18, 18, 18, 20 ], + "name" : "bar" + } + } ], + "statements" : [ ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 22, 5, 22, 9 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 22, 5, 22, 9 ], + "function" : { + "kind" : "Identifier", + "location" : [ 22, 5, 22, 7 ], + "name" : "bar" + }, + "args" : [ ] + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 24, 1, 24, 5 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 24, 1, 24, 5 ], + "function" : { + "kind" : "Identifier", + "location" : [ 24, 1, 24, 3 ], + "name" : "foo" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_nonlocal_global.py.ast.typed b/pa2-tests/core/bad_nonlocal_global.py.ast.typed new file mode 100644 index 0000000..3b80c08 --- /dev/null +++ b/pa2-tests/core/bad_nonlocal_global.py.ast.typed @@ -0,0 +1,259 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 24, 6 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 1 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 9, 2, 9 ], + "value" : 2 + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 9, 3, 9 ], + "value" : 3 + } + }, { + "kind" : "FuncDef", + "location" : [ 5, 1, 22, 10 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 7 ], + "name" : "foo" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 14, 5, 19 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "GlobalDecl", + "location" : [ 6, 5, 6, 12 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 6, 12, 6, 12 ], + "name" : "x" + } + }, { + "kind" : "NonLocalDecl", + "location" : [ 7, 5, 7, 14 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 7, 14, 7, 14 ], + "errorMsg" : "Not a nonlocal variable: y", + "name" : "y" + } + }, { + "kind" : "GlobalDecl", + "location" : [ 8, 5, 8, 12 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 8, 12, 8, 12 ], + "errorMsg" : "Not a global variable: w", + "name" : "w" + } + }, { + "kind" : "GlobalDecl", + "location" : [ 9, 5, 9, 14 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 9, 12, 9, 14 ], + "errorMsg" : "Not a global variable: int", + "name" : "int" + } + }, { + "kind" : "VarDef", + "location" : [ 11, 5, 11, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 11, 5, 11, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 5, 11, 5 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 7, 11, 10 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 11, 14, 11, 17 ], + "value" : true + } + }, { + "kind" : "FuncDef", + "location" : [ 13, 5, 20, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 13, 9, 13, 11 ], + "name" : "bar" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 13, 18, 13, 23 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "GlobalDecl", + "location" : [ 14, 9, 14, 16 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 14, 16, 14, 16 ], + "name" : "x" + } + }, { + "kind" : "NonLocalDecl", + "location" : [ 15, 9, 15, 18 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 15, 18, 15, 18 ], + "name" : "z" + } + }, { + "kind" : "NonLocalDecl", + "location" : [ 16, 9, 16, 18 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 16, 18, 16, 18 ], + "errorMsg" : "Not a nonlocal variable: y", + "name" : "y" + } + }, { + "kind" : "GlobalDecl", + "location" : [ 17, 9, 17, 18 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 17, 16, 17, 18 ], + "errorMsg" : "Not a global variable: foo", + "name" : "foo" + } + }, { + "kind" : "NonLocalDecl", + "location" : [ 18, 9, 18, 20 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 18, 18, 18, 20 ], + "errorMsg" : "Not a nonlocal variable: bar", + "name" : "bar" + } + } ], + "statements" : [ ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 22, 5, 22, 9 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 22, 5, 22, 9 ], + "function" : { + "kind" : "Identifier", + "location" : [ 22, 5, 22, 7 ], + "name" : "bar" + }, + "args" : [ ] + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 24, 1, 24, 5 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 24, 1, 24, 5 ], + "function" : { + "kind" : "Identifier", + "location" : [ 24, 1, 24, 3 ], + "name" : "foo" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 7, 14, 7, 14 ], + "message" : "Not a nonlocal variable: y" + }, { + "kind" : "CompilerError", + "location" : [ 8, 12, 8, 12 ], + "message" : "Not a global variable: w" + }, { + "kind" : "CompilerError", + "location" : [ 9, 12, 9, 14 ], + "message" : "Not a global variable: int" + }, { + "kind" : "CompilerError", + "location" : [ 16, 18, 16, 18 ], + "message" : "Not a nonlocal variable: y" + }, { + "kind" : "CompilerError", + "location" : [ 17, 16, 17, 18 ], + "message" : "Not a global variable: foo" + }, { + "kind" : "CompilerError", + "location" : [ 18, 18, 18, 20 ], + "message" : "Not a nonlocal variable: bar" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_return_missing.py b/pa2-tests/core/bad_return_missing.py new file mode 100644 index 0000000..9200f93 --- /dev/null +++ b/pa2-tests/core/bad_return_missing.py @@ -0,0 +1,6 @@ +def foo() -> int: + if True: + return 1 + # Bad: all paths MUST return int + +foo() diff --git a/pa2-tests/core/bad_return_missing.py.ast b/pa2-tests/core/bad_return_missing.py.ast new file mode 100644 index 0000000..8efc035 --- /dev/null +++ b/pa2-tests/core/bad_return_missing.py.ast @@ -0,0 +1,58 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 6, 6 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 6, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 7 ], + "name" : "foo" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 14, 1, 16 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 2, 5, 6, 0 ], + "condition" : { + "kind" : "BooleanLiteral", + "location" : [ 2, 8, 2, 11 ], + "value" : true + }, + "thenBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 3, 9, 3, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 16, 3, 16 ], + "value" : 1 + } + } ], + "elseBody" : [ ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 6, 1, 6, 5 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 6, 1, 6, 5 ], + "function" : { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 3 ], + "name" : "foo" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_return_missing.py.ast.typed b/pa2-tests/core/bad_return_missing.py.ast.typed new file mode 100644 index 0000000..627d4f3 --- /dev/null +++ b/pa2-tests/core/bad_return_missing.py.ast.typed @@ -0,0 +1,63 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 6, 6 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 6, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 7 ], + "errorMsg" : "All paths in this function/method must have a return statement: foo", + "name" : "foo" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 14, 1, 16 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 2, 5, 6, 0 ], + "condition" : { + "kind" : "BooleanLiteral", + "location" : [ 2, 8, 2, 11 ], + "value" : true + }, + "thenBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 3, 9, 3, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 16, 3, 16 ], + "value" : 1 + } + } ], + "elseBody" : [ ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 6, 1, 6, 5 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 6, 1, 6, 5 ], + "function" : { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 3 ], + "name" : "foo" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 1, 5, 1, 7 ], + "message" : "All paths in this function/method must have a return statement: foo" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_return_top.py b/pa2-tests/core/bad_return_top.py new file mode 100644 index 0000000..ca0d0e0 --- /dev/null +++ b/pa2-tests/core/bad_return_top.py @@ -0,0 +1,3 @@ +x:int = 0 + +return x diff --git a/pa2-tests/core/bad_return_top.py.ast b/pa2-tests/core/bad_return_top.py.ast new file mode 100644 index 0000000..992907a --- /dev/null +++ b/pa2-tests/core/bad_return_top.py.ast @@ -0,0 +1,41 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 3, 9 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 3, 1, 3, 8 ], + "value" : { + "kind" : "Identifier", + "location" : [ 3, 8, 3, 8 ], + "name" : "x" + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_return_top.py.ast.typed b/pa2-tests/core/bad_return_top.py.ast.typed new file mode 100644 index 0000000..56df1de --- /dev/null +++ b/pa2-tests/core/bad_return_top.py.ast.typed @@ -0,0 +1,50 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 3, 9 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 3, 1, 3, 8 ], + "errorMsg" : "Return statement cannot appear at the top level", + "value" : { + "kind" : "Identifier", + "location" : [ 3, 8, 3, 8 ], + "name" : "x" + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 3, 1, 3, 8 ], + "message" : "Return statement cannot appear at the top level" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_shadow_local.py b/pa2-tests/core/bad_shadow_local.py new file mode 100644 index 0000000..9fc916b --- /dev/null +++ b/pa2-tests/core/bad_shadow_local.py @@ -0,0 +1,14 @@ +class A(object): + x:int = 1 + +def foo(x:int, bool:str) -> object: # Second param uses an invalid name + y:int = 4 # OK + A:int = 5 # Invalid name + object:str = "" # Invalid name + + def str() -> bool: # Invalid name + return False + + pass + +pass diff --git a/pa2-tests/core/bad_shadow_local.py.ast b/pa2-tests/core/bad_shadow_local.py.ast new file mode 100644 index 0000000..cff93dc --- /dev/null +++ b/pa2-tests/core/bad_shadow_local.py.ast @@ -0,0 +1,179 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 14, 5 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 4, 1, 12, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 9, 4, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 11, 4, 13 ], + "className" : "int" + } + }, { + "kind" : "TypedVar", + "location" : [ 4, 16, 4, 23 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 16, 4, 19 ], + "name" : "bool" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 21, 4, 23 ], + "className" : "str" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 29, 4, 34 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 5, 5, 5, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 5, 5, 5, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 5 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 7, 5, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 13, 5, 13 ], + "value" : 4 + } + }, { + "kind" : "VarDef", + "location" : [ 6, 5, 6, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 5, 6, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "name" : "A" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 7, 6, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 13, 6, 13 ], + "value" : 5 + } + }, { + "kind" : "VarDef", + "location" : [ 7, 5, 7, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 7, 5, 7, 14 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 10 ], + "name" : "object" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 7, 12, 7, 14 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 7, 18, 7, 19 ], + "value" : "" + } + }, { + "kind" : "FuncDef", + "location" : [ 9, 5, 10, 21 ], + "name" : { + "kind" : "Identifier", + "location" : [ 9, 9, 9, 11 ], + "name" : "str" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 9, 18, 9, 21 ], + "className" : "bool" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 10, 9, 10, 20 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 10, 16, 10, 20 ], + "value" : false + } + } ] + } ], + "statements" : [ ] + } ], + "statements" : [ ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_shadow_local.py.ast.typed b/pa2-tests/core/bad_shadow_local.py.ast.typed new file mode 100644 index 0000000..3cc9b9b --- /dev/null +++ b/pa2-tests/core/bad_shadow_local.py.ast.typed @@ -0,0 +1,199 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 14, 5 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 4, 1, 12, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 9, 4, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 11, 4, 13 ], + "className" : "int" + } + }, { + "kind" : "TypedVar", + "location" : [ 4, 16, 4, 23 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 16, 4, 19 ], + "errorMsg" : "Cannot shadow class name: bool", + "name" : "bool" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 21, 4, 23 ], + "className" : "str" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 29, 4, 34 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 5, 5, 5, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 5, 5, 5, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 5 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 7, 5, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 13, 5, 13 ], + "value" : 4 + } + }, { + "kind" : "VarDef", + "location" : [ 6, 5, 6, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 5, 6, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "errorMsg" : "Cannot shadow class name: A", + "name" : "A" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 7, 6, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 13, 6, 13 ], + "value" : 5 + } + }, { + "kind" : "VarDef", + "location" : [ 7, 5, 7, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 7, 5, 7, 14 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 10 ], + "errorMsg" : "Cannot shadow class name: object", + "name" : "object" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 7, 12, 7, 14 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 7, 18, 7, 19 ], + "value" : "" + } + }, { + "kind" : "FuncDef", + "location" : [ 9, 5, 10, 21 ], + "name" : { + "kind" : "Identifier", + "location" : [ 9, 9, 9, 11 ], + "errorMsg" : "Cannot shadow class name: str", + "name" : "str" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 9, 18, 9, 21 ], + "className" : "bool" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 10, 9, 10, 20 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 10, 16, 10, 20 ], + "value" : false + } + } ] + } ], + "statements" : [ ] + } ], + "statements" : [ ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 4, 16, 4, 19 ], + "message" : "Cannot shadow class name: bool" + }, { + "kind" : "CompilerError", + "location" : [ 6, 5, 6, 5 ], + "message" : "Cannot shadow class name: A" + }, { + "kind" : "CompilerError", + "location" : [ 7, 5, 7, 10 ], + "message" : "Cannot shadow class name: object" + }, { + "kind" : "CompilerError", + "location" : [ 9, 9, 9, 11 ], + "message" : "Cannot shadow class name: str" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_shadow_local_2.py b/pa2-tests/core/bad_shadow_local_2.py new file mode 100644 index 0000000..67a327e --- /dev/null +++ b/pa2-tests/core/bad_shadow_local_2.py @@ -0,0 +1,8 @@ +def foo(x:int) -> object: + A:int = 5 # Invalid name + pass + +class A(object): + x:int = 1 + +pass diff --git a/pa2-tests/core/bad_shadow_local_2.py.ast b/pa2-tests/core/bad_shadow_local_2.py.ast new file mode 100644 index 0000000..5eb5b2e --- /dev/null +++ b/pa2-tests/core/bad_shadow_local_2.py.ast @@ -0,0 +1,98 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 8, 5 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 3, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 1, 9, 1, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 11, 1, 13 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 19, 1, 24 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "A" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 5 + } + } ], + "statements" : [ ] + }, { + "kind" : "ClassDef", + "location" : [ 5, 1, 6, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 7, 5, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 6, 5, 6, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 5, 6, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 7, 6, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 13, 6, 13 ], + "value" : 1 + } + } ] + } ], + "statements" : [ ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_shadow_local_2.py.ast.typed b/pa2-tests/core/bad_shadow_local_2.py.ast.typed new file mode 100644 index 0000000..ff6ef1b --- /dev/null +++ b/pa2-tests/core/bad_shadow_local_2.py.ast.typed @@ -0,0 +1,103 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 8, 5 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 3, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 1, 9, 1, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 11, 1, 13 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 19, 1, 24 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "errorMsg" : "Cannot shadow class name: A", + "name" : "A" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 5 + } + } ], + "statements" : [ ] + }, { + "kind" : "ClassDef", + "location" : [ 5, 1, 6, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 7, 5, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 6, 5, 6, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 5, 6, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 7, 6, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 13, 6, 13 ], + "value" : 1 + } + } ] + } ], + "statements" : [ ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 2, 5, 2, 5 ], + "message" : "Cannot shadow class name: A" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_strings.py b/pa2-tests/core/bad_strings.py new file mode 100644 index 0000000..86e0e16 --- /dev/null +++ b/pa2-tests/core/bad_strings.py @@ -0,0 +1,10 @@ +x:str = "Hello" +y:str = "World" +z:str = "" + +1 + x +z = x + 1 +z = x[0] = y +x[1] = y +x[True] + diff --git a/pa2-tests/core/bad_strings.py.ast b/pa2-tests/core/bad_strings.py.ast new file mode 100644 index 0000000..04473bf --- /dev/null +++ b/pa2-tests/core/bad_strings.py.ast @@ -0,0 +1,183 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 9, 8 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 1, 9, 1, 15 ], + "value" : "Hello" + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 2, 9, 2, 15 ], + "value" : "World" + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 3, 9, 3, 10 ], + "value" : "" + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 5, 1, 5, 5 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 5, 1, 5, 5 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 1, 5, 1 ], + "value" : 1 + }, + "operator" : "+", + "right" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 5 ], + "name" : "x" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "z" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 6, 5, 6, 9 ], + "left" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "name" : "x" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 9, 6, 9 ], + "value" : 1 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 12 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "name" : "z" + }, { + "kind" : "IndexExpr", + "location" : [ 7, 5, 7, 8 ], + "list" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 7, 7, 7 ], + "value" : 0 + } + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 7, 12, 7, 12 ], + "name" : "y" + } + }, { + "kind" : "AssignStmt", + "location" : [ 8, 1, 8, 8 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 8, 1, 8, 4 ], + "list" : { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 8, 3, 8, 3 ], + "value" : 1 + } + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 8, 8, 8, 8 ], + "name" : "y" + } + }, { + "kind" : "ExprStmt", + "location" : [ 9, 1, 9, 7 ], + "expr" : { + "kind" : "IndexExpr", + "location" : [ 9, 1, 9, 7 ], + "list" : { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 1 ], + "name" : "x" + }, + "index" : { + "kind" : "BooleanLiteral", + "location" : [ 9, 3, 9, 6 ], + "value" : true + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_strings.py.ast.typed b/pa2-tests/core/bad_strings.py.ast.typed new file mode 100644 index 0000000..f6f2fbe --- /dev/null +++ b/pa2-tests/core/bad_strings.py.ast.typed @@ -0,0 +1,301 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 9, 8 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 1, 9, 1, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Hello" + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 2, 9, 2, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "World" + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 3, 9, 3, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "" + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 5, 1, 5, 5 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 5, 1, 5, 5 ], + "errorMsg" : "Cannot apply operator `+` on types `int` and `str`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 1, 5, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, + "operator" : "+", + "right" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "x" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 9 ], + "errorMsg" : "Expected type `str`; got type `int`", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "z" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 6, 5, 6, 9 ], + "errorMsg" : "Cannot apply operator `+` on types `str` and `int`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "x" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 9, 6, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 12 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "z" + }, { + "kind" : "IndexExpr", + "location" : [ 7, 5, 7, 8 ], + "errorMsg" : "`str` is not a list type", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 7, 7, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 7, 12, 7, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "y" + } + }, { + "kind" : "AssignStmt", + "location" : [ 8, 1, 8, 8 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 8, 1, 8, 4 ], + "errorMsg" : "`str` is not a list type", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 8, 3, 8, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 8, 8, 8, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "y" + } + }, { + "kind" : "ExprStmt", + "location" : [ 9, 1, 9, 7 ], + "expr" : { + "kind" : "IndexExpr", + "location" : [ 9, 1, 9, 7 ], + "errorMsg" : "Index is of non-integer type `bool`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "x" + }, + "index" : { + "kind" : "BooleanLiteral", + "location" : [ 9, 3, 9, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 5, 1, 5, 5 ], + "message" : "Cannot apply operator `+` on types `int` and `str`" + }, { + "kind" : "CompilerError", + "location" : [ 6, 5, 6, 9 ], + "message" : "Cannot apply operator `+` on types `str` and `int`" + }, { + "kind" : "CompilerError", + "location" : [ 6, 1, 6, 9 ], + "message" : "Expected type `str`; got type `int`" + }, { + "kind" : "CompilerError", + "location" : [ 7, 5, 7, 8 ], + "message" : "`str` is not a list type" + }, { + "kind" : "CompilerError", + "location" : [ 8, 1, 8, 4 ], + "message" : "`str` is not a list type" + }, { + "kind" : "CompilerError", + "location" : [ 9, 1, 9, 7 ], + "message" : "Index is of non-integer type `bool`" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_type_annotation.py b/pa2-tests/core/bad_type_annotation.py new file mode 100644 index 0000000..a25abb6 --- /dev/null +++ b/pa2-tests/core/bad_type_annotation.py @@ -0,0 +1,7 @@ +x:A = None + +def foo(x:B) -> C: + y:D = None + return + +pass diff --git a/pa2-tests/core/bad_type_annotation.py.ast b/pa2-tests/core/bad_type_annotation.py.ast new file mode 100644 index 0000000..e42cf91 --- /dev/null +++ b/pa2-tests/core/bad_type_annotation.py.ast @@ -0,0 +1,86 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 7, 5 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 3 ], + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 1, 7, 1, 10 ] + } + }, { + "kind" : "FuncDef", + "location" : [ 3, 1, 5, 11 ], + "name" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 3, 9, 3, 11 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 9, 3, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 11, 3, 11 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 3, 17, 3, 17 ], + "className" : "C" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 4, 5, 4, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 5, 4, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 5 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 7, 4, 7 ], + "className" : "D" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 4, 11, 4, 14 ] + } + } ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 5, 5, 10 ], + "value" : null + } ] + } ], + "statements" : [ ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_type_annotation.py.ast.typed b/pa2-tests/core/bad_type_annotation.py.ast.typed new file mode 100644 index 0000000..221ad45 --- /dev/null +++ b/pa2-tests/core/bad_type_annotation.py.ast.typed @@ -0,0 +1,106 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 7, 5 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 3 ], + "errorMsg" : "Invalid type annotation; there is no class named: A", + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 1, 7, 1, 10 ] + } + }, { + "kind" : "FuncDef", + "location" : [ 3, 1, 5, 11 ], + "name" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 3, 9, 3, 11 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 9, 3, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 11, 3, 11 ], + "errorMsg" : "Invalid type annotation; there is no class named: B", + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 3, 17, 3, 17 ], + "errorMsg" : "Invalid type annotation; there is no class named: C", + "className" : "C" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 4, 5, 4, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 5, 4, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 5 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 7, 4, 7 ], + "errorMsg" : "Invalid type annotation; there is no class named: D", + "className" : "D" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 4, 11, 4, 14 ] + } + } ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 5, 5, 10 ], + "value" : null + } ] + } ], + "statements" : [ ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 1, 3, 1, 3 ], + "message" : "Invalid type annotation; there is no class named: A" + }, { + "kind" : "CompilerError", + "location" : [ 3, 11, 3, 11 ], + "message" : "Invalid type annotation; there is no class named: B" + }, { + "kind" : "CompilerError", + "location" : [ 3, 17, 3, 17 ], + "message" : "Invalid type annotation; there is no class named: C" + }, { + "kind" : "CompilerError", + "location" : [ 4, 7, 4, 7 ], + "message" : "Invalid type annotation; there is no class named: D" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_type_id.py b/pa2-tests/core/bad_type_id.py new file mode 100644 index 0000000..0f931fb --- /dev/null +++ b/pa2-tests/core/bad_type_id.py @@ -0,0 +1 @@ +x - 1 diff --git a/pa2-tests/core/bad_type_id.py.ast b/pa2-tests/core/bad_type_id.py.ast new file mode 100644 index 0000000..ff5c46d --- /dev/null +++ b/pa2-tests/core/bad_type_id.py.ast @@ -0,0 +1,29 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 1, 6 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 5 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 5 ], + "left" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "operator" : "-", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 5, 1, 5 ], + "value" : 1 + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_type_id.py.ast.typed b/pa2-tests/core/bad_type_id.py.ast.typed new file mode 100644 index 0000000..5200116 --- /dev/null +++ b/pa2-tests/core/bad_type_id.py.ast.typed @@ -0,0 +1,51 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 1, 6 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 5 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 5 ], + "errorMsg" : "Cannot apply operator `-` on types `object` and `int`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "errorMsg" : "Not a variable: x", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "name" : "x" + }, + "operator" : "-", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 5, 1, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 1, 1, 1, 1 ], + "message" : "Not a variable: x" + }, { + "kind" : "CompilerError", + "location" : [ 1, 1, 1, 5 ], + "message" : "Cannot apply operator `-` on types `object` and `int`" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_var_assign.py b/pa2-tests/core/bad_var_assign.py new file mode 100644 index 0000000..a383775 --- /dev/null +++ b/pa2-tests/core/bad_var_assign.py @@ -0,0 +1,8 @@ +x:int = 1 +y:bool = True + +x = False +y = 2 +z = 3 +x = z = 4 +x = z = None diff --git a/pa2-tests/core/bad_var_assign.py.ast b/pa2-tests/core/bad_var_assign.py.ast new file mode 100644 index 0000000..6dabcbd --- /dev/null +++ b/pa2-tests/core/bad_var_assign.py.ast @@ -0,0 +1,127 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 8, 13 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 1 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 6 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 6 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 2, 10, 2, 13 ], + "value" : true + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 4, 1, 4, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "x" + } ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 4, 5, 4, 9 ], + "value" : false + } + }, { + "kind" : "AssignStmt", + "location" : [ 5, 1, 5, 5 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "name" : "y" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 5, 5, 5 ], + "value" : 2 + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 5 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "z" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 5, 6, 5 ], + "value" : 3 + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "name" : "z" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 9, 7, 9 ], + "value" : 4 + } + }, { + "kind" : "AssignStmt", + "location" : [ 8, 1, 8, 12 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 8, 5, 8, 5 ], + "name" : "z" + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 8, 9, 8, 12 ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/bad_var_assign.py.ast.typed b/pa2-tests/core/bad_var_assign.py.ast.typed new file mode 100644 index 0000000..d8217b8 --- /dev/null +++ b/pa2-tests/core/bad_var_assign.py.ast.typed @@ -0,0 +1,213 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 8, 13 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 6 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 6 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 2, 10, 2, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 4, 1, 4, 9 ], + "errorMsg" : "Expected type `int`; got type `bool`", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 4, 5, 4, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } + }, { + "kind" : "AssignStmt", + "location" : [ 5, 1, 5, 5 ], + "errorMsg" : "Expected type `bool`; got type `int`", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "name" : "y" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 5, 5, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 5 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "errorMsg" : "Not a variable: z", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "name" : "z" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 5, 6, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "errorMsg" : "Not a variable: z", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "name" : "z" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 9, 7, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 4 + } + }, { + "kind" : "AssignStmt", + "location" : [ 8, 1, 8, 12 ], + "errorMsg" : "Expected type `int`; got type ``", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 8, 5, 8, 5 ], + "errorMsg" : "Not a variable: z", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "name" : "z" + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 8, 9, 8, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 4, 1, 4, 9 ], + "message" : "Expected type `int`; got type `bool`" + }, { + "kind" : "CompilerError", + "location" : [ 5, 1, 5, 5 ], + "message" : "Expected type `bool`; got type `int`" + }, { + "kind" : "CompilerError", + "location" : [ 6, 1, 6, 1 ], + "message" : "Not a variable: z" + }, { + "kind" : "CompilerError", + "location" : [ 7, 5, 7, 5 ], + "message" : "Not a variable: z" + }, { + "kind" : "CompilerError", + "location" : [ 8, 1, 8, 12 ], + "message" : "Expected type `int`; got type ``" + }, { + "kind" : "CompilerError", + "location" : [ 8, 5, 8, 5 ], + "message" : "Not a variable: z" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/class_def_assign.py b/pa2-tests/core/class_def_assign.py new file mode 100644 index 0000000..44459ff --- /dev/null +++ b/pa2-tests/core/class_def_assign.py @@ -0,0 +1,18 @@ +class A(object): + x:int = 1 + +class B(A): + def __init__(self: "B"): + pass + +class C(B): + z:bool = True + +a:A = None +b:B = None +c:C = None + +a = A() +a = B() +b = a = c = C() +c = None diff --git a/pa2-tests/core/class_def_assign.py.ast b/pa2-tests/core/class_def_assign.py.ast new file mode 100644 index 0000000..92ae3a1 --- /dev/null +++ b/pa2-tests/core/class_def_assign.py.ast @@ -0,0 +1,263 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 18, 9 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 4, 1, 8, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 7, 4, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 5, 5, 6, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 18, 5, 26 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 18, 5, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 24, 5, 26 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 28, 5, 28 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 8, 1, 9, 18 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 7, 8, 7 ], + "name" : "C" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 9 ], + "name" : "B" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 9, 5, 9, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 9, 5, 9, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 7, 9, 10 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 9, 14, 9, 17 ], + "value" : true + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 11, 1, 11, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 11, 1, 11, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 3, 11, 3 ], + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 11, 7, 11, 10 ] + } + }, { + "kind" : "VarDef", + "location" : [ 12, 1, 12, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 1, 12, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "name" : "b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 3, 12, 3 ], + "className" : "B" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 12, 7, 12, 10 ] + } + }, { + "kind" : "VarDef", + "location" : [ 13, 1, 13, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 13, 1, 13, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 13, 1, 13, 1 ], + "name" : "c" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 13, 3, 13, 3 ], + "className" : "C" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 13, 7, 13, 10 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 15, 1, 15, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 15, 1, 15, 1 ], + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 15, 5, 15, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 15, 5, 15, 5 ], + "name" : "A" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 16, 1, 16, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 16, 1, 16, 1 ], + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 16, 5, 16, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 16, 5, 16, 5 ], + "name" : "B" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 17, 1, 17, 15 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 17, 1, 17, 1 ], + "name" : "b" + }, { + "kind" : "Identifier", + "location" : [ 17, 5, 17, 5 ], + "name" : "a" + }, { + "kind" : "Identifier", + "location" : [ 17, 9, 17, 9 ], + "name" : "c" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 17, 13, 17, 15 ], + "function" : { + "kind" : "Identifier", + "location" : [ 17, 13, 17, 13 ], + "name" : "C" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 18, 1, 18, 8 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 18, 1, 18, 1 ], + "name" : "c" + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 18, 5, 18, 8 ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/class_def_assign.py.ast.typed b/pa2-tests/core/class_def_assign.py.ast.typed new file mode 100644 index 0000000..e012a95 --- /dev/null +++ b/pa2-tests/core/class_def_assign.py.ast.typed @@ -0,0 +1,323 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 18, 9 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 4, 1, 8, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 7, 4, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 5, 5, 6, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 18, 5, 26 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 18, 5, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 24, 5, 26 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 28, 5, 28 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 8, 1, 9, 18 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 7, 8, 7 ], + "name" : "C" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 9 ], + "name" : "B" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 9, 5, 9, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 9, 5, 9, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 7, 9, 10 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 9, 14, 9, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 11, 1, 11, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 11, 1, 11, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 3, 11, 3 ], + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 11, 7, 11, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 12, 1, 12, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 1, 12, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "name" : "b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 3, 12, 3 ], + "className" : "B" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 12, 7, 12, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 13, 1, 13, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 13, 1, 13, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 13, 1, 13, 1 ], + "name" : "c" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 13, 3, 13, 3 ], + "className" : "C" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 13, 7, 13, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 15, 1, 15, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 15, 1, 15, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 15, 5, 15, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 15, 5, 15, 5 ], + "name" : "A" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 16, 1, 16, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 16, 1, 16, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 16, 5, 16, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 16, 5, 16, 5 ], + "name" : "B" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 17, 1, 17, 15 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 17, 1, 17, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "name" : "b" + }, { + "kind" : "Identifier", + "location" : [ 17, 5, 17, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + }, { + "kind" : "Identifier", + "location" : [ 17, 9, 17, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "name" : "c" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 17, 13, 17, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 17, 13, 17, 13 ], + "name" : "C" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 18, 1, 18, 8 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 18, 1, 18, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "name" : "c" + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 18, 5, 18, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/class_def_attr.py b/pa2-tests/core/class_def_attr.py new file mode 100644 index 0000000..9a5d948 --- /dev/null +++ b/pa2-tests/core/class_def_attr.py @@ -0,0 +1,22 @@ +class A(object): + x:int = 1 + +class B(A): + def __init__(self: "B"): + pass + +class C(B): + z:bool = True + +a:A = None +b:B = None +c:C = None + +a = A() +b = B() +c = C() + +a.x = 1 +b.x = a.x +c.z = a.x == b.x + diff --git a/pa2-tests/core/class_def_attr.py.ast b/pa2-tests/core/class_def_attr.py.ast new file mode 100644 index 0000000..b4dcc19 --- /dev/null +++ b/pa2-tests/core/class_def_attr.py.ast @@ -0,0 +1,346 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 21, 17 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 4, 1, 8, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 7, 4, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 5, 5, 6, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 18, 5, 26 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 18, 5, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 24, 5, 26 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 28, 5, 28 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 8, 1, 9, 18 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 7, 8, 7 ], + "name" : "C" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 9 ], + "name" : "B" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 9, 5, 9, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 9, 5, 9, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 7, 9, 10 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 9, 14, 9, 17 ], + "value" : true + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 11, 1, 11, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 11, 1, 11, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 3, 11, 3 ], + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 11, 7, 11, 10 ] + } + }, { + "kind" : "VarDef", + "location" : [ 12, 1, 12, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 1, 12, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "name" : "b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 3, 12, 3 ], + "className" : "B" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 12, 7, 12, 10 ] + } + }, { + "kind" : "VarDef", + "location" : [ 13, 1, 13, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 13, 1, 13, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 13, 1, 13, 1 ], + "name" : "c" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 13, 3, 13, 3 ], + "className" : "C" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 13, 7, 13, 10 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 15, 1, 15, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 15, 1, 15, 1 ], + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 15, 5, 15, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 15, 5, 15, 5 ], + "name" : "A" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 16, 1, 16, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 16, 1, 16, 1 ], + "name" : "b" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 16, 5, 16, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 16, 5, 16, 5 ], + "name" : "B" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 17, 1, 17, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 17, 1, 17, 1 ], + "name" : "c" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 17, 5, 17, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 17, 5, 17, 5 ], + "name" : "C" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 19, 1, 19, 7 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 19, 1, 19, 3 ], + "object" : { + "kind" : "Identifier", + "location" : [ 19, 1, 19, 1 ], + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 19, 3, 19, 3 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 19, 7, 19, 7 ], + "value" : 1 + } + }, { + "kind" : "AssignStmt", + "location" : [ 20, 1, 20, 9 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 20, 1, 20, 3 ], + "object" : { + "kind" : "Identifier", + "location" : [ 20, 1, 20, 1 ], + "name" : "b" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 20, 3, 20, 3 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "MemberExpr", + "location" : [ 20, 7, 20, 9 ], + "object" : { + "kind" : "Identifier", + "location" : [ 20, 7, 20, 7 ], + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 20, 9, 20, 9 ], + "name" : "x" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 21, 1, 21, 16 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 21, 1, 21, 3 ], + "object" : { + "kind" : "Identifier", + "location" : [ 21, 1, 21, 1 ], + "name" : "c" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 21, 3, 21, 3 ], + "name" : "z" + } + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 21, 7, 21, 16 ], + "left" : { + "kind" : "MemberExpr", + "location" : [ 21, 7, 21, 9 ], + "object" : { + "kind" : "Identifier", + "location" : [ 21, 7, 21, 7 ], + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 21, 9, 21, 9 ], + "name" : "x" + } + }, + "operator" : "==", + "right" : { + "kind" : "MemberExpr", + "location" : [ 21, 14, 21, 16 ], + "object" : { + "kind" : "Identifier", + "location" : [ 21, 14, 21, 14 ], + "name" : "b" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 21, 16, 21, 16 ], + "name" : "x" + } + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/class_def_attr.py.ast.typed b/pa2-tests/core/class_def_attr.py.ast.typed new file mode 100644 index 0000000..600032c --- /dev/null +++ b/pa2-tests/core/class_def_attr.py.ast.typed @@ -0,0 +1,446 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 21, 17 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 4, 1, 8, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 7, 4, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 5, 5, 6, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 18, 5, 26 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 18, 5, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 24, 5, 26 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 28, 5, 28 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 8, 1, 9, 18 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 7, 8, 7 ], + "name" : "C" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 9 ], + "name" : "B" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 9, 5, 9, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 9, 5, 9, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 7, 9, 10 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 9, 14, 9, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 11, 1, 11, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 11, 1, 11, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 3, 11, 3 ], + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 11, 7, 11, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 12, 1, 12, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 1, 12, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "name" : "b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 3, 12, 3 ], + "className" : "B" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 12, 7, 12, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 13, 1, 13, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 13, 1, 13, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 13, 1, 13, 1 ], + "name" : "c" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 13, 3, 13, 3 ], + "className" : "C" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 13, 7, 13, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 15, 1, 15, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 15, 1, 15, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 15, 5, 15, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 15, 5, 15, 5 ], + "name" : "A" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 16, 1, 16, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 16, 1, 16, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "name" : "b" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 16, 5, 16, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 16, 5, 16, 5 ], + "name" : "B" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 17, 1, 17, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 17, 1, 17, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "name" : "c" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 17, 5, 17, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 17, 5, 17, 5 ], + "name" : "C" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 19, 1, 19, 7 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 19, 1, 19, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 19, 1, 19, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 19, 3, 19, 3 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 19, 7, 19, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "AssignStmt", + "location" : [ 20, 1, 20, 9 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 20, 1, 20, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 20, 1, 20, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "name" : "b" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 20, 3, 20, 3 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "MemberExpr", + "location" : [ 20, 7, 20, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 20, 7, 20, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 20, 9, 20, 9 ], + "name" : "x" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 21, 1, 21, 16 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 21, 1, 21, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 21, 1, 21, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "name" : "c" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 21, 3, 21, 3 ], + "name" : "z" + } + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 21, 7, 21, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "MemberExpr", + "location" : [ 21, 7, 21, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 21, 7, 21, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 21, 9, 21, 9 ], + "name" : "x" + } + }, + "operator" : "==", + "right" : { + "kind" : "MemberExpr", + "location" : [ 21, 14, 21, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 21, 14, 21, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "name" : "b" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 21, 16, 21, 16 ], + "name" : "x" + } + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/class_def_init.py b/pa2-tests/core/class_def_init.py new file mode 100644 index 0000000..733f489 --- /dev/null +++ b/pa2-tests/core/class_def_init.py @@ -0,0 +1,17 @@ +class A(object): + x:int = 1 + +class B(A): + def __init__(self: "B"): + pass + +class C(B): + z:bool = True + +a:A = None +b:B = None +c:C = None + +a = A() +b = B() +c = C() diff --git a/pa2-tests/core/class_def_init.py.ast b/pa2-tests/core/class_def_init.py.ast new file mode 100644 index 0000000..2cf1bba --- /dev/null +++ b/pa2-tests/core/class_def_init.py.ast @@ -0,0 +1,243 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 17, 8 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 4, 1, 8, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 7, 4, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 5, 5, 6, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 18, 5, 26 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 18, 5, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 24, 5, 26 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 28, 5, 28 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 8, 1, 9, 18 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 7, 8, 7 ], + "name" : "C" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 9 ], + "name" : "B" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 9, 5, 9, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 9, 5, 9, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 7, 9, 10 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 9, 14, 9, 17 ], + "value" : true + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 11, 1, 11, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 11, 1, 11, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 3, 11, 3 ], + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 11, 7, 11, 10 ] + } + }, { + "kind" : "VarDef", + "location" : [ 12, 1, 12, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 1, 12, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "name" : "b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 3, 12, 3 ], + "className" : "B" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 12, 7, 12, 10 ] + } + }, { + "kind" : "VarDef", + "location" : [ 13, 1, 13, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 13, 1, 13, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 13, 1, 13, 1 ], + "name" : "c" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 13, 3, 13, 3 ], + "className" : "C" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 13, 7, 13, 10 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 15, 1, 15, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 15, 1, 15, 1 ], + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 15, 5, 15, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 15, 5, 15, 5 ], + "name" : "A" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 16, 1, 16, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 16, 1, 16, 1 ], + "name" : "b" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 16, 5, 16, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 16, 5, 16, 5 ], + "name" : "B" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 17, 1, 17, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 17, 1, 17, 1 ], + "name" : "c" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 17, 5, 17, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 17, 5, 17, 5 ], + "name" : "C" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/class_def_init.py.ast.typed b/pa2-tests/core/class_def_init.py.ast.typed new file mode 100644 index 0000000..c2f9d72 --- /dev/null +++ b/pa2-tests/core/class_def_init.py.ast.typed @@ -0,0 +1,287 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 17, 8 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 4, 1, 8, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 7, 4, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 5, 5, 6, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 18, 5, 26 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 18, 5, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 24, 5, 26 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 28, 5, 28 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 8, 1, 9, 18 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 7, 8, 7 ], + "name" : "C" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 9 ], + "name" : "B" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 9, 5, 9, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 9, 5, 9, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 7, 9, 10 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 9, 14, 9, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 11, 1, 11, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 11, 1, 11, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 3, 11, 3 ], + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 11, 7, 11, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 12, 1, 12, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 1, 12, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "name" : "b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 3, 12, 3 ], + "className" : "B" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 12, 7, 12, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 13, 1, 13, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 13, 1, 13, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 13, 1, 13, 1 ], + "name" : "c" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 13, 3, 13, 3 ], + "className" : "C" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 13, 7, 13, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 15, 1, 15, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 15, 1, 15, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 15, 5, 15, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 15, 5, 15, 5 ], + "name" : "A" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 16, 1, 16, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 16, 1, 16, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "name" : "b" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 16, 5, 16, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 16, 5, 16, 5 ], + "name" : "B" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 17, 1, 17, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 17, 1, 17, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "name" : "c" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 17, 5, 17, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 17, 5, 17, 5 ], + "name" : "C" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/class_def_methods.py b/pa2-tests/core/class_def_methods.py new file mode 100644 index 0000000..a8d70f1 --- /dev/null +++ b/pa2-tests/core/class_def_methods.py @@ -0,0 +1,28 @@ +class A(object): + x:int = 1 + + def get_A(self: "A") -> int: + return self.x + +class B(A): + def __init__(self: "B"): + pass + +class C(B): + z:bool = True + + def set_A(self: "C", val: int) -> object: + self.x = val + +a:A = None +b:B = None +c:C = None + +a = A() +b = B() +c = C() + +b.x = a.get_A() +a.x = b.get_A() +c.set_A(0) + diff --git a/pa2-tests/core/class_def_methods.py.ast b/pa2-tests/core/class_def_methods.py.ast new file mode 100644 index 0000000..2ddc48e --- /dev/null +++ b/pa2-tests/core/class_def_methods.py.ast @@ -0,0 +1,451 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 27, 11 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 7, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 22 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 13 ], + "name" : "get_A" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 15, 4, 23 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 15, 4, 18 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 21, 4, 23 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 29, 4, 31 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 9, 5, 21 ], + "value" : { + "kind" : "MemberExpr", + "location" : [ 5, 16, 5, 21 ], + "object" : { + "kind" : "Identifier", + "location" : [ 5, 16, 5, 19 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 5, 21, 5, 21 ], + "name" : "x" + } + } + } ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 7, 1, 11, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 7, 7, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 8, 5, 9, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 8, 18, 8, 26 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 18, 8, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 24, 8, 26 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 8, 28, 8, 28 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 11, 1, 17, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 11, 7, 11, 7 ], + "name" : "C" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 11, 9, 11, 9 ], + "name" : "B" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 12, 5, 12, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 5, 12, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 5, 12, 5 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 7, 12, 10 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 12, 14, 12, 17 ], + "value" : true + } + }, { + "kind" : "FuncDef", + "location" : [ 14, 5, 15, 21 ], + "name" : { + "kind" : "Identifier", + "location" : [ 14, 9, 14, 13 ], + "name" : "set_A" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 14, 15, 14, 23 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 14, 15, 14, 18 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 14, 21, 14, 23 ], + "className" : "C" + } + }, { + "kind" : "TypedVar", + "location" : [ 14, 26, 14, 33 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 14, 26, 14, 28 ], + "name" : "val" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 14, 31, 14, 33 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 14, 39, 14, 44 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 15, 9, 15, 20 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 15, 9, 15, 14 ], + "object" : { + "kind" : "Identifier", + "location" : [ 15, 9, 15, 12 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 15, 14, 15, 14 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 15, 18, 15, 20 ], + "name" : "val" + } + } ] + } ] + }, { + "kind" : "VarDef", + "location" : [ 17, 1, 17, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 17, 1, 17, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 17, 1, 17, 1 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 17, 3, 17, 3 ], + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 17, 7, 17, 10 ] + } + }, { + "kind" : "VarDef", + "location" : [ 18, 1, 18, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 18, 1, 18, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 18, 1, 18, 1 ], + "name" : "b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 18, 3, 18, 3 ], + "className" : "B" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 18, 7, 18, 10 ] + } + }, { + "kind" : "VarDef", + "location" : [ 19, 1, 19, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 19, 1, 19, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 19, 1, 19, 1 ], + "name" : "c" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 19, 3, 19, 3 ], + "className" : "C" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 19, 7, 19, 10 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 21, 1, 21, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 21, 1, 21, 1 ], + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 21, 5, 21, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 21, 5, 21, 5 ], + "name" : "A" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 22, 1, 22, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 22, 1, 22, 1 ], + "name" : "b" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 22, 5, 22, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 22, 5, 22, 5 ], + "name" : "B" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 23, 1, 23, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 23, 1, 23, 1 ], + "name" : "c" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 23, 5, 23, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 23, 5, 23, 5 ], + "name" : "C" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 25, 1, 25, 15 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 25, 1, 25, 3 ], + "object" : { + "kind" : "Identifier", + "location" : [ 25, 1, 25, 1 ], + "name" : "b" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 25, 3, 25, 3 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 25, 7, 25, 15 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 25, 7, 25, 13 ], + "object" : { + "kind" : "Identifier", + "location" : [ 25, 7, 25, 7 ], + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 25, 9, 25, 13 ], + "name" : "get_A" + } + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 26, 1, 26, 15 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 26, 1, 26, 3 ], + "object" : { + "kind" : "Identifier", + "location" : [ 26, 1, 26, 1 ], + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 26, 3, 26, 3 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 26, 7, 26, 15 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 26, 7, 26, 13 ], + "object" : { + "kind" : "Identifier", + "location" : [ 26, 7, 26, 7 ], + "name" : "b" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 26, 9, 26, 13 ], + "name" : "get_A" + } + }, + "args" : [ ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 27, 1, 27, 10 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 27, 1, 27, 10 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 27, 1, 27, 7 ], + "object" : { + "kind" : "Identifier", + "location" : [ 27, 1, 27, 1 ], + "name" : "c" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 27, 3, 27, 7 ], + "name" : "set_A" + } + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 27, 9, 27, 9 ], + "value" : 0 + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/class_def_methods.py.ast.typed b/pa2-tests/core/class_def_methods.py.ast.typed new file mode 100644 index 0000000..1f58660 --- /dev/null +++ b/pa2-tests/core/class_def_methods.py.ast.typed @@ -0,0 +1,595 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 27, 11 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 7, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 22 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 13 ], + "name" : "get_A" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 15, 4, 23 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 15, 4, 18 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 21, 4, 23 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 29, 4, 31 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 9, 5, 21 ], + "value" : { + "kind" : "MemberExpr", + "location" : [ 5, 16, 5, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 5, 16, 5, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 5, 21, 5, 21 ], + "name" : "x" + } + } + } ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 7, 1, 11, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 7, 7, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 8, 5, 9, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 8, 18, 8, 26 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 18, 8, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 24, 8, 26 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 8, 28, 8, 28 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 11, 1, 17, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 11, 7, 11, 7 ], + "name" : "C" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 11, 9, 11, 9 ], + "name" : "B" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 12, 5, 12, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 5, 12, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 5, 12, 5 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 7, 12, 10 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 12, 14, 12, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + }, { + "kind" : "FuncDef", + "location" : [ 14, 5, 15, 21 ], + "name" : { + "kind" : "Identifier", + "location" : [ 14, 9, 14, 13 ], + "name" : "set_A" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 14, 15, 14, 23 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 14, 15, 14, 18 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 14, 21, 14, 23 ], + "className" : "C" + } + }, { + "kind" : "TypedVar", + "location" : [ 14, 26, 14, 33 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 14, 26, 14, 28 ], + "name" : "val" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 14, 31, 14, 33 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 14, 39, 14, 44 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 15, 9, 15, 20 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 15, 9, 15, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 15, 9, 15, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 15, 14, 15, 14 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 15, 18, 15, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "val" + } + } ] + } ] + }, { + "kind" : "VarDef", + "location" : [ 17, 1, 17, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 17, 1, 17, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 17, 1, 17, 1 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 17, 3, 17, 3 ], + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 17, 7, 17, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 18, 1, 18, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 18, 1, 18, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 18, 1, 18, 1 ], + "name" : "b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 18, 3, 18, 3 ], + "className" : "B" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 18, 7, 18, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 19, 1, 19, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 19, 1, 19, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 19, 1, 19, 1 ], + "name" : "c" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 19, 3, 19, 3 ], + "className" : "C" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 19, 7, 19, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 21, 1, 21, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 21, 1, 21, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 21, 5, 21, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 21, 5, 21, 5 ], + "name" : "A" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 22, 1, 22, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 22, 1, 22, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "name" : "b" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 22, 5, 22, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 22, 5, 22, 5 ], + "name" : "B" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 23, 1, 23, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 23, 1, 23, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "name" : "c" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 23, 5, 23, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 23, 5, 23, 5 ], + "name" : "C" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 25, 1, 25, 15 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 25, 1, 25, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 25, 1, 25, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "name" : "b" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 25, 3, 25, 3 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 25, 7, 25, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 25, 7, 25, 13 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "A" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 25, 7, 25, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 25, 9, 25, 13 ], + "name" : "get_A" + } + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 26, 1, 26, 15 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 26, 1, 26, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 26, 1, 26, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 26, 3, 26, 3 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 26, 7, 26, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 26, 7, 26, 13 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "A" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 26, 7, 26, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "name" : "b" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 26, 9, 26, 13 ], + "name" : "get_A" + } + }, + "args" : [ ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 27, 1, 27, 10 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 27, 1, 27, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 27, 1, 27, 7 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "C" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 27, 1, 27, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "name" : "c" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 27, 3, 27, 7 ], + "name" : "set_A" + } + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 27, 9, 27, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/decl_global_forward.py b/pa2-tests/core/decl_global_forward.py new file mode 100644 index 0000000..b364535 --- /dev/null +++ b/pa2-tests/core/decl_global_forward.py @@ -0,0 +1,9 @@ +def set_x() -> int: + global x + x = 1 + return x + +x:int = 0 + +set_x() +print(x) diff --git a/pa2-tests/core/decl_global_forward.py.ast b/pa2-tests/core/decl_global_forward.py.ast new file mode 100644 index 0000000..a450fe6 --- /dev/null +++ b/pa2-tests/core/decl_global_forward.py.ast @@ -0,0 +1,108 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 9, 9 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 4, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 9 ], + "name" : "set_x" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 16, 1, 18 ], + "className" : "int" + }, + "declarations" : [ { + "kind" : "GlobalDecl", + "location" : [ 2, 5, 2, 12 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 2, 12, 2, 12 ], + "name" : "x" + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 3, 5, 3, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 5 ], + "name" : "x" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 9, 3, 9 ], + "value" : 1 + } + }, { + "kind" : "ReturnStmt", + "location" : [ 4, 5, 4, 12 ], + "value" : { + "kind" : "Identifier", + "location" : [ 4, 12, 4, 12 ], + "name" : "x" + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 6, 1, 6, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 1, 6, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 3, 6, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 9, 6, 9 ], + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 8, 1, 8, 7 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 8, 1, 8, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 5 ], + "name" : "set_x" + }, + "args" : [ ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 9, 1, 9, 8 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 9, 1, 9, 8 ], + "function" : { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 5 ], + "name" : "print" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 9, 7, 9, 7 ], + "name" : "x" + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/decl_global_forward.py.ast.typed b/pa2-tests/core/decl_global_forward.py.ast.typed new file mode 100644 index 0000000..4d32ce7 --- /dev/null +++ b/pa2-tests/core/decl_global_forward.py.ast.typed @@ -0,0 +1,155 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 9, 9 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 4, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 9 ], + "name" : "set_x" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 16, 1, 18 ], + "className" : "int" + }, + "declarations" : [ { + "kind" : "GlobalDecl", + "location" : [ 2, 5, 2, 12 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 2, 12, 2, 12 ], + "name" : "x" + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 3, 5, 3, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 9, 3, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "ReturnStmt", + "location" : [ 4, 5, 4, 12 ], + "value" : { + "kind" : "Identifier", + "location" : [ 4, 12, 4, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 6, 1, 6, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 1, 6, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 3, 6, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 9, 6, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 8, 1, 8, 7 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 8, 1, 8, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 5 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "set_x" + }, + "args" : [ ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 9, 1, 9, 8 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 9, 1, 9, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 5 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, + "name" : "print" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 9, 7, 9, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/decl_nonlocal_forward.py b/pa2-tests/core/decl_nonlocal_forward.py new file mode 100644 index 0000000..b1ff307 --- /dev/null +++ b/pa2-tests/core/decl_nonlocal_forward.py @@ -0,0 +1,10 @@ +def outer() -> int: + def inner() -> int: + nonlocal x + x = 1 + return x + x:int = 0 + inner() + return x + +print(outer()) diff --git a/pa2-tests/core/decl_nonlocal_forward.py.ast b/pa2-tests/core/decl_nonlocal_forward.py.ast new file mode 100644 index 0000000..1b5f11b --- /dev/null +++ b/pa2-tests/core/decl_nonlocal_forward.py.ast @@ -0,0 +1,137 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 10, 15 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 8, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 9 ], + "name" : "outer" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 16, 1, 18 ], + "className" : "int" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 2, 5, 5, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 9, 2, 13 ], + "name" : "inner" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 2, 20, 2, 22 ], + "className" : "int" + }, + "declarations" : [ { + "kind" : "NonLocalDecl", + "location" : [ 3, 9, 3, 18 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 3, 18, 3, 18 ], + "name" : "x" + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 4, 9, 4, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 9 ], + "name" : "x" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 13, 4, 13 ], + "value" : 1 + } + }, { + "kind" : "ReturnStmt", + "location" : [ 5, 9, 5, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 5, 16, 5, 16 ], + "name" : "x" + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 6, 5, 6, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 5, 6, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 7, 6, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 13, 6, 13 ], + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 7, 5, 7, 11 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 7, 5, 7, 11 ], + "function" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 9 ], + "name" : "inner" + }, + "args" : [ ] + } + }, { + "kind" : "ReturnStmt", + "location" : [ 8, 5, 8, 12 ], + "value" : { + "kind" : "Identifier", + "location" : [ 8, 12, 8, 12 ], + "name" : "x" + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 10, 1, 10, 14 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 10, 1, 10, 14 ], + "function" : { + "kind" : "Identifier", + "location" : [ 10, 1, 10, 5 ], + "name" : "print" + }, + "args" : [ { + "kind" : "CallExpr", + "location" : [ 10, 7, 10, 13 ], + "function" : { + "kind" : "Identifier", + "location" : [ 10, 7, 10, 11 ], + "name" : "outer" + }, + "args" : [ ] + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/decl_nonlocal_forward.py.ast.typed b/pa2-tests/core/decl_nonlocal_forward.py.ast.typed new file mode 100644 index 0000000..f5781a7 --- /dev/null +++ b/pa2-tests/core/decl_nonlocal_forward.py.ast.typed @@ -0,0 +1,196 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 10, 15 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 8, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 9 ], + "name" : "outer" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 16, 1, 18 ], + "className" : "int" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 2, 5, 5, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 9, 2, 13 ], + "name" : "inner" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 2, 20, 2, 22 ], + "className" : "int" + }, + "declarations" : [ { + "kind" : "NonLocalDecl", + "location" : [ 3, 9, 3, 18 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 3, 18, 3, 18 ], + "name" : "x" + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 4, 9, 4, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 13, 4, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "ReturnStmt", + "location" : [ 5, 9, 5, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 5, 16, 5, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 6, 5, 6, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 5, 6, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 7, 6, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 13, 6, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 7, 5, 7, 11 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 7, 5, 7, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 9 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "inner" + }, + "args" : [ ] + } + }, { + "kind" : "ReturnStmt", + "location" : [ 8, 5, 8, 12 ], + "value" : { + "kind" : "Identifier", + "location" : [ 8, 12, 8, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 10, 1, 10, 14 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 10, 1, 10, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 10, 1, 10, 5 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, + "name" : "print" + }, + "args" : [ { + "kind" : "CallExpr", + "location" : [ 10, 7, 10, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 10, 7, 10, 11 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "outer" + }, + "args" : [ ] + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/expr_binary.py b/pa2-tests/core/expr_binary.py new file mode 100644 index 0000000..b35b22d --- /dev/null +++ b/pa2-tests/core/expr_binary.py @@ -0,0 +1,2 @@ +1 + 2 * 3 > 13 // 3 % 2 or 1 != 1 and False == False + diff --git a/pa2-tests/core/expr_binary.py.ast b/pa2-tests/core/expr_binary.py.ast new file mode 100644 index 0000000..3e59d31 --- /dev/null +++ b/pa2-tests/core/expr_binary.py.ast @@ -0,0 +1,109 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 1, 53 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 52 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 52 ], + "left" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 23 ], + "left" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 9 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 1, 1, 1 ], + "value" : 1 + }, + "operator" : "+", + "right" : { + "kind" : "BinaryExpr", + "location" : [ 1, 5, 1, 9 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 5, 1, 5 ], + "value" : 2 + }, + "operator" : "*", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 3 + } + } + }, + "operator" : ">", + "right" : { + "kind" : "BinaryExpr", + "location" : [ 1, 13, 1, 23 ], + "left" : { + "kind" : "BinaryExpr", + "location" : [ 1, 13, 1, 19 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 13, 1, 14 ], + "value" : 13 + }, + "operator" : "//", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 19, 1, 19 ], + "value" : 3 + } + }, + "operator" : "%", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 23, 1, 23 ], + "value" : 2 + } + } + }, + "operator" : "or", + "right" : { + "kind" : "BinaryExpr", + "location" : [ 1, 28, 1, 52 ], + "left" : { + "kind" : "BinaryExpr", + "location" : [ 1, 28, 1, 33 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 28, 1, 28 ], + "value" : 1 + }, + "operator" : "!=", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 33, 1, 33 ], + "value" : 1 + } + }, + "operator" : "and", + "right" : { + "kind" : "BinaryExpr", + "location" : [ 1, 39, 1, 52 ], + "left" : { + "kind" : "BooleanLiteral", + "location" : [ 1, 39, 1, 43 ], + "value" : false + }, + "operator" : "==", + "right" : { + "kind" : "BooleanLiteral", + "location" : [ 1, 48, 1, 52 ], + "value" : false + } + } + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/expr_binary.py.ast.typed b/pa2-tests/core/expr_binary.py.ast.typed new file mode 100644 index 0000000..146d277 --- /dev/null +++ b/pa2-tests/core/expr_binary.py.ast.typed @@ -0,0 +1,185 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 1, 53 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 52 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 52 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 1, 1, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, + "operator" : "+", + "right" : { + "kind" : "BinaryExpr", + "location" : [ 1, 5, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 5, 1, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + }, + "operator" : "*", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } + } + }, + "operator" : ">", + "right" : { + "kind" : "BinaryExpr", + "location" : [ 1, 13, 1, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "BinaryExpr", + "location" : [ 1, 13, 1, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 13, 1, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 13 + }, + "operator" : "//", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 19, 1, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } + }, + "operator" : "%", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 23, 1, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } + } + }, + "operator" : "or", + "right" : { + "kind" : "BinaryExpr", + "location" : [ 1, 28, 1, 52 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "BinaryExpr", + "location" : [ 1, 28, 1, 33 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 28, 1, 28 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, + "operator" : "!=", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 33, 1, 33 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, + "operator" : "and", + "right" : { + "kind" : "BinaryExpr", + "location" : [ 1, 39, 1, 52 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "BooleanLiteral", + "location" : [ 1, 39, 1, 43 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + }, + "operator" : "==", + "right" : { + "kind" : "BooleanLiteral", + "location" : [ 1, 48, 1, 52 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } + } + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/expr_concat.py b/pa2-tests/core/expr_concat.py new file mode 100644 index 0000000..68c41a0 --- /dev/null +++ b/pa2-tests/core/expr_concat.py @@ -0,0 +1,3 @@ +[1, 2] + [3, 4] +"Hello " + "World" +[1, 2] + [True] diff --git a/pa2-tests/core/expr_concat.py.ast b/pa2-tests/core/expr_concat.py.ast new file mode 100644 index 0000000..064862b --- /dev/null +++ b/pa2-tests/core/expr_concat.py.ast @@ -0,0 +1,93 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 3, 16 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 15 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 15 ], + "left" : { + "kind" : "ListExpr", + "location" : [ 1, 1, 1, 6 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 1, 2, 1, 2 ], + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 1, 5, 1, 5 ], + "value" : 2 + } ] + }, + "operator" : "+", + "right" : { + "kind" : "ListExpr", + "location" : [ 1, 10, 1, 15 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 1, 11, 1, 11 ], + "value" : 3 + }, { + "kind" : "IntegerLiteral", + "location" : [ 1, 14, 1, 14 ], + "value" : 4 + } ] + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 2, 1, 2, 18 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 2, 1, 2, 18 ], + "left" : { + "kind" : "StringLiteral", + "location" : [ 2, 1, 2, 8 ], + "value" : "Hello " + }, + "operator" : "+", + "right" : { + "kind" : "StringLiteral", + "location" : [ 2, 12, 2, 18 ], + "value" : "World" + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 3, 1, 3, 15 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 3, 1, 3, 15 ], + "left" : { + "kind" : "ListExpr", + "location" : [ 3, 1, 3, 6 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 3, 2, 3, 2 ], + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 3, 5, 3, 5 ], + "value" : 2 + } ] + }, + "operator" : "+", + "right" : { + "kind" : "ListExpr", + "location" : [ 3, 10, 3, 15 ], + "elements" : [ { + "kind" : "BooleanLiteral", + "location" : [ 3, 11, 3, 14 ], + "value" : true + } ] + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/expr_concat.py.ast.typed b/pa2-tests/core/expr_concat.py.ast.typed new file mode 100644 index 0000000..4c61b0e --- /dev/null +++ b/pa2-tests/core/expr_concat.py.ast.typed @@ -0,0 +1,175 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 3, 16 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 15 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 15 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "left" : { + "kind" : "ListExpr", + "location" : [ 1, 1, 1, 6 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 1, 2, 1, 2 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 1, 5, 1, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } ] + }, + "operator" : "+", + "right" : { + "kind" : "ListExpr", + "location" : [ 1, 10, 1, 15 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 1, 11, 1, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + }, { + "kind" : "IntegerLiteral", + "location" : [ 1, 14, 1, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 4 + } ] + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 2, 1, 2, 18 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 2, 1, 2, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "left" : { + "kind" : "StringLiteral", + "location" : [ 2, 1, 2, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Hello " + }, + "operator" : "+", + "right" : { + "kind" : "StringLiteral", + "location" : [ 2, 12, 2, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "World" + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 3, 1, 3, 15 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 3, 1, 3, 15 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "left" : { + "kind" : "ListExpr", + "location" : [ 3, 1, 3, 6 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 3, 2, 3, 2 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 3, 5, 3, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } ] + }, + "operator" : "+", + "right" : { + "kind" : "ListExpr", + "location" : [ 3, 10, 3, 15 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "bool" + } + }, + "elements" : [ { + "kind" : "BooleanLiteral", + "location" : [ 3, 11, 3, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } ] + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/expr_id.py b/pa2-tests/core/expr_id.py new file mode 100644 index 0000000..c6fcd80 --- /dev/null +++ b/pa2-tests/core/expr_id.py @@ -0,0 +1,3 @@ +x:int = 1 + +x - 1 diff --git a/pa2-tests/core/expr_id.py.ast b/pa2-tests/core/expr_id.py.ast new file mode 100644 index 0000000..0f6ab04 --- /dev/null +++ b/pa2-tests/core/expr_id.py.ast @@ -0,0 +1,51 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 3, 6 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 1 + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 3, 1, 3, 5 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 3, 1, 3, 5 ], + "left" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "x" + }, + "operator" : "-", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 5, 3, 5 ], + "value" : 1 + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/expr_id.py.ast.typed b/pa2-tests/core/expr_id.py.ast.typed new file mode 100644 index 0000000..cdefa39 --- /dev/null +++ b/pa2-tests/core/expr_id.py.ast.typed @@ -0,0 +1,67 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 3, 6 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 3, 1, 3, 5 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 3, 1, 3, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "operator" : "-", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 5, 3, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/expr_if.py b/pa2-tests/core/expr_if.py new file mode 100644 index 0000000..e9e9c26 --- /dev/null +++ b/pa2-tests/core/expr_if.py @@ -0,0 +1 @@ +3 if 1 > 2 else 4 diff --git a/pa2-tests/core/expr_if.py.ast b/pa2-tests/core/expr_if.py.ast new file mode 100644 index 0000000..0ed9a55 --- /dev/null +++ b/pa2-tests/core/expr_if.py.ast @@ -0,0 +1,43 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 1, 18 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 17 ], + "expr" : { + "kind" : "IfExpr", + "location" : [ 1, 1, 1, 17 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 1, 6, 1, 10 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 6, 1, 6 ], + "value" : 1 + }, + "operator" : ">", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 10, 1, 10 ], + "value" : 2 + } + }, + "thenExpr" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 1, 1, 1 ], + "value" : 3 + }, + "elseExpr" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 17, 1, 17 ], + "value" : 4 + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/expr_if.py.ast.typed b/pa2-tests/core/expr_if.py.ast.typed new file mode 100644 index 0000000..3aa7a5f --- /dev/null +++ b/pa2-tests/core/expr_if.py.ast.typed @@ -0,0 +1,67 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 1, 18 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 17 ], + "expr" : { + "kind" : "IfExpr", + "location" : [ 1, 1, 1, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 1, 6, 1, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 6, 1, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, + "operator" : ">", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 10, 1, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } + }, + "thenExpr" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 1, 1, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + }, + "elseExpr" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 17, 1, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 4 + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/expr_int.py b/pa2-tests/core/expr_int.py new file mode 100644 index 0000000..f39d689 --- /dev/null +++ b/pa2-tests/core/expr_int.py @@ -0,0 +1 @@ +6 * 9 diff --git a/pa2-tests/core/expr_int.py.ast b/pa2-tests/core/expr_int.py.ast new file mode 100644 index 0000000..2eb3e50 --- /dev/null +++ b/pa2-tests/core/expr_int.py.ast @@ -0,0 +1,29 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 1, 6 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 5 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 5 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 1, 1, 1 ], + "value" : 6 + }, + "operator" : "*", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 5, 1, 5 ], + "value" : 9 + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/expr_int.py.ast.typed b/pa2-tests/core/expr_int.py.ast.typed new file mode 100644 index 0000000..55a6721 --- /dev/null +++ b/pa2-tests/core/expr_int.py.ast.typed @@ -0,0 +1,41 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 1, 6 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 5 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 1, 1, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 6 + }, + "operator" : "*", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 5, 1, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 9 + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/expr_list_index.py b/pa2-tests/core/expr_list_index.py new file mode 100644 index 0000000..b9d97e3 --- /dev/null +++ b/pa2-tests/core/expr_list_index.py @@ -0,0 +1,12 @@ +x:[int] = None +y:int = 0 +z:[bool] = None +o:object = None + +x = [1, 2, 3] +z = [False, True] + +y = x[0] +x[0] = 1 +z[1] = z[0] +o = x[1] diff --git a/pa2-tests/core/expr_list_index.py.ast b/pa2-tests/core/expr_list_index.py.ast new file mode 100644 index 0000000..5cb5c50 --- /dev/null +++ b/pa2-tests/core/expr_list_index.py.ast @@ -0,0 +1,247 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 12, 9 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ListType", + "location" : [ 1, 3, 1, 7 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 1, 4, 1, 6 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 1, 11, 1, 14 ] + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 9, 2, 9 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ListType", + "location" : [ 3, 3, 3, 8 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 3, 4, 3, 7 ], + "className" : "bool" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 3, 12, 3, 15 ] + } + }, { + "kind" : "VarDef", + "location" : [ 4, 1, 4, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 1, 4, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "o" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 3, 4, 8 ], + "className" : "object" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 4, 12, 4, 15 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 6, 5, 6, 13 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 6, 6, 6, 6 ], + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 6, 9, 6, 9 ], + "value" : 2 + }, { + "kind" : "IntegerLiteral", + "location" : [ 6, 12, 6, 12 ], + "value" : 3 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 17 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "name" : "z" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 7, 5, 7, 17 ], + "elements" : [ { + "kind" : "BooleanLiteral", + "location" : [ 7, 6, 7, 10 ], + "value" : false + }, { + "kind" : "BooleanLiteral", + "location" : [ 7, 13, 7, 16 ], + "value" : true + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 9, 1, 9, 8 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 1 ], + "name" : "y" + } ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 9, 5, 9, 8 ], + "list" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 9, 7, 9, 7 ], + "value" : 0 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 10, 1, 10, 8 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 10, 1, 10, 4 ], + "list" : { + "kind" : "Identifier", + "location" : [ 10, 1, 10, 1 ], + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 10, 3, 10, 3 ], + "value" : 0 + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 10, 8, 10, 8 ], + "value" : 1 + } + }, { + "kind" : "AssignStmt", + "location" : [ 11, 1, 11, 11 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 11, 1, 11, 4 ], + "list" : { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "name" : "z" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 11, 3, 11, 3 ], + "value" : 1 + } + } ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 11, 8, 11, 11 ], + "list" : { + "kind" : "Identifier", + "location" : [ 11, 8, 11, 8 ], + "name" : "z" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 11, 10, 11, 10 ], + "value" : 0 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 12, 1, 12, 8 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "name" : "o" + } ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 12, 5, 12, 8 ], + "list" : { + "kind" : "Identifier", + "location" : [ 12, 5, 12, 5 ], + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 12, 7, 12, 7 ], + "value" : 1 + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/expr_list_index.py.ast.typed b/pa2-tests/core/expr_list_index.py.ast.typed new file mode 100644 index 0000000..28fbe48 --- /dev/null +++ b/pa2-tests/core/expr_list_index.py.ast.typed @@ -0,0 +1,398 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 12, 9 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ListType", + "location" : [ 1, 3, 1, 7 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 1, 4, 1, 6 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 1, 11, 1, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 9, 2, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ListType", + "location" : [ 3, 3, 3, 8 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 3, 4, 3, 7 ], + "className" : "bool" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 3, 12, 3, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 4, 1, 4, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 1, 4, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "o" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 3, 4, 8 ], + "className" : "object" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 4, 12, 4, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 6, 5, 6, 13 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 6, 6, 6, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 6, 9, 6, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + }, { + "kind" : "IntegerLiteral", + "location" : [ 6, 12, 6, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 17 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "bool" + } + }, + "name" : "z" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 7, 5, 7, 17 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "bool" + } + }, + "elements" : [ { + "kind" : "BooleanLiteral", + "location" : [ 7, 6, 7, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + }, { + "kind" : "BooleanLiteral", + "location" : [ 7, 13, 7, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 9, 1, 9, 8 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "y" + } ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 9, 5, 9, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 9, 7, 9, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 10, 1, 10, 8 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 10, 1, 10, 4 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 10, 1, 10, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 10, 3, 10, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 10, 8, 10, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "AssignStmt", + "location" : [ 11, 1, 11, 11 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 11, 1, 11, 4 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "bool" + } + }, + "name" : "z" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 11, 3, 11, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 11, 8, 11, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 11, 8, 11, 8 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "bool" + } + }, + "name" : "z" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 11, 10, 11, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 12, 1, 12, 8 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "name" : "o" + } ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 12, 5, 12, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 12, 5, 12, 5 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 12, 7, 12, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/expr_lists.py b/pa2-tests/core/expr_lists.py new file mode 100644 index 0000000..2268a54 --- /dev/null +++ b/pa2-tests/core/expr_lists.py @@ -0,0 +1,12 @@ +x:[int] = None +y:[object] = None +z:[bool] = None +o:object = None + +x = [1, 2, 3] +x = [] +y = [1, True] +z = [False, True] +x = None +o = x +o = x = [1] diff --git a/pa2-tests/core/expr_lists.py.ast b/pa2-tests/core/expr_lists.py.ast new file mode 100644 index 0000000..5930b97 --- /dev/null +++ b/pa2-tests/core/expr_lists.py.ast @@ -0,0 +1,233 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 12, 12 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ListType", + "location" : [ 1, 3, 1, 7 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 1, 4, 1, 6 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 1, 11, 1, 14 ] + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ListType", + "location" : [ 2, 3, 2, 10 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 2, 4, 2, 9 ], + "className" : "object" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 2, 14, 2, 17 ] + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ListType", + "location" : [ 3, 3, 3, 8 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 3, 4, 3, 7 ], + "className" : "bool" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 3, 12, 3, 15 ] + } + }, { + "kind" : "VarDef", + "location" : [ 4, 1, 4, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 1, 4, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "o" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 3, 4, 8 ], + "className" : "object" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 4, 12, 4, 15 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 6, 5, 6, 13 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 6, 6, 6, 6 ], + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 6, 9, 6, 9 ], + "value" : 2 + }, { + "kind" : "IntegerLiteral", + "location" : [ 6, 12, 6, 12 ], + "value" : 3 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 6 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 7, 5, 7, 6 ], + "elements" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 8, 1, 8, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "name" : "y" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 8, 5, 8, 13 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 8, 6, 8, 6 ], + "value" : 1 + }, { + "kind" : "BooleanLiteral", + "location" : [ 8, 9, 8, 12 ], + "value" : true + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 9, 1, 9, 17 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 1 ], + "name" : "z" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 9, 5, 9, 17 ], + "elements" : [ { + "kind" : "BooleanLiteral", + "location" : [ 9, 6, 9, 10 ], + "value" : false + }, { + "kind" : "BooleanLiteral", + "location" : [ 9, 13, 9, 16 ], + "value" : true + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 10, 1, 10, 8 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 10, 1, 10, 1 ], + "name" : "x" + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 10, 5, 10, 8 ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 11, 1, 11, 5 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "name" : "o" + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 11, 5, 11, 5 ], + "name" : "x" + } + }, { + "kind" : "AssignStmt", + "location" : [ 12, 1, 12, 11 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "name" : "o" + }, { + "kind" : "Identifier", + "location" : [ 12, 5, 12, 5 ], + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 12, 9, 12, 11 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 12, 10, 12, 10 ], + "value" : 1 + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/expr_lists.py.ast.typed b/pa2-tests/core/expr_lists.py.ast.typed new file mode 100644 index 0000000..e8c37bd --- /dev/null +++ b/pa2-tests/core/expr_lists.py.ast.typed @@ -0,0 +1,374 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 12, 12 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ListType", + "location" : [ 1, 3, 1, 7 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 1, 4, 1, 6 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 1, 11, 1, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ListType", + "location" : [ 2, 3, 2, 10 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 2, 4, 2, 9 ], + "className" : "object" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 2, 14, 2, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ListType", + "location" : [ 3, 3, 3, 8 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 3, 4, 3, 7 ], + "className" : "bool" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 3, 12, 3, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 4, 1, 4, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 1, 4, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "o" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 3, 4, 8 ], + "className" : "object" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 4, 12, 4, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 6, 5, 6, 13 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 6, 6, 6, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 6, 9, 6, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + }, { + "kind" : "IntegerLiteral", + "location" : [ 6, 12, 6, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 6 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 7, 5, 7, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "elements" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 8, 1, 8, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "name" : "y" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 8, 5, 8, 13 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 8, 6, 8, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, { + "kind" : "BooleanLiteral", + "location" : [ 8, 9, 8, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 9, 1, 9, 17 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "bool" + } + }, + "name" : "z" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 9, 5, 9, 17 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "bool" + } + }, + "elements" : [ { + "kind" : "BooleanLiteral", + "location" : [ 9, 6, 9, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + }, { + "kind" : "BooleanLiteral", + "location" : [ 9, 13, 9, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 10, 1, 10, 8 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 10, 1, 10, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 10, 5, 10, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 11, 1, 11, 5 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "name" : "o" + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 11, 5, 11, 5 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + } + }, { + "kind" : "AssignStmt", + "location" : [ 12, 1, 12, 11 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "name" : "o" + }, { + "kind" : "Identifier", + "location" : [ 12, 5, 12, 5 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 12, 9, 12, 11 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 12, 10, 12, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/expr_unary.py b/pa2-tests/core/expr_unary.py new file mode 100644 index 0000000..58d9627 --- /dev/null +++ b/pa2-tests/core/expr_unary.py @@ -0,0 +1,2 @@ +-1 +not False diff --git a/pa2-tests/core/expr_unary.py.ast b/pa2-tests/core/expr_unary.py.ast new file mode 100644 index 0000000..4f1abf3 --- /dev/null +++ b/pa2-tests/core/expr_unary.py.ast @@ -0,0 +1,37 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 2, 10 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 2 ], + "expr" : { + "kind" : "UnaryExpr", + "location" : [ 1, 1, 1, 2 ], + "operator" : "-", + "operand" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 2, 1, 2 ], + "value" : 1 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 2, 1, 2, 9 ], + "expr" : { + "kind" : "UnaryExpr", + "location" : [ 2, 1, 2, 9 ], + "operator" : "not", + "operand" : { + "kind" : "BooleanLiteral", + "location" : [ 2, 5, 2, 9 ], + "value" : false + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/expr_unary.py.ast.typed b/pa2-tests/core/expr_unary.py.ast.typed new file mode 100644 index 0000000..77b0fd0 --- /dev/null +++ b/pa2-tests/core/expr_unary.py.ast.typed @@ -0,0 +1,53 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 2, 10 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 2 ], + "expr" : { + "kind" : "UnaryExpr", + "location" : [ 1, 1, 1, 2 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "operator" : "-", + "operand" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 2, 1, 2 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 2, 1, 2, 9 ], + "expr" : { + "kind" : "UnaryExpr", + "location" : [ 2, 1, 2, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "operator" : "not", + "operand" : { + "kind" : "BooleanLiteral", + "location" : [ 2, 5, 2, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/expr_var_assign.py b/pa2-tests/core/expr_var_assign.py new file mode 100644 index 0000000..3b8ebfe --- /dev/null +++ b/pa2-tests/core/expr_var_assign.py @@ -0,0 +1,4 @@ +x:int = 1 +o:object = None + +x = o = 42 diff --git a/pa2-tests/core/expr_var_assign.py.ast b/pa2-tests/core/expr_var_assign.py.ast new file mode 100644 index 0000000..5b8093e --- /dev/null +++ b/pa2-tests/core/expr_var_assign.py.ast @@ -0,0 +1,71 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 4, 11 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 1 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "o" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 8 ], + "className" : "object" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 2, 12, 2, 15 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 4, 1, 4, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 5 ], + "name" : "o" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 9, 4, 10 ], + "value" : 42 + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/expr_var_assign.py.ast.typed b/pa2-tests/core/expr_var_assign.py.ast.typed new file mode 100644 index 0000000..950866b --- /dev/null +++ b/pa2-tests/core/expr_var_assign.py.ast.typed @@ -0,0 +1,91 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 4, 11 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "o" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 8 ], + "className" : "object" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 2, 12, 2, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 4, 1, 4, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "name" : "o" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 9, 4, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 42 + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/func_def_call.py b/pa2-tests/core/func_def_call.py new file mode 100644 index 0000000..e5f4e8b --- /dev/null +++ b/pa2-tests/core/func_def_call.py @@ -0,0 +1,7 @@ +def foo(x:str, y:bool) -> int: + return bar() + +def bar() -> int: + return 1 + +foo("Hello", False) diff --git a/pa2-tests/core/func_def_call.py.ast b/pa2-tests/core/func_def_call.py.ast new file mode 100644 index 0000000..b6194bd --- /dev/null +++ b/pa2-tests/core/func_def_call.py.ast @@ -0,0 +1,111 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 7, 20 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 2, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 1, 9, 1, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 11, 1, 13 ], + "className" : "str" + } + }, { + "kind" : "TypedVar", + "location" : [ 1, 16, 1, 21 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 16, 1, 16 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 18, 1, 21 ], + "className" : "bool" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 27, 1, 29 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 2, 5, 2, 16 ], + "value" : { + "kind" : "CallExpr", + "location" : [ 2, 12, 2, 16 ], + "function" : { + "kind" : "Identifier", + "location" : [ 2, 12, 2, 14 ], + "name" : "bar" + }, + "args" : [ ] + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 4, 1, 5, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 7 ], + "name" : "bar" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 14, 4, 16 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 5, 5, 12 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 12, 5, 12 ], + "value" : 1 + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 7, 1, 7, 19 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 7, 1, 7, 19 ], + "function" : { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 3 ], + "name" : "foo" + }, + "args" : [ { + "kind" : "StringLiteral", + "location" : [ 7, 5, 7, 11 ], + "value" : "Hello" + }, { + "kind" : "BooleanLiteral", + "location" : [ 7, 14, 7, 18 ], + "value" : false + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/func_def_call.py.ast.typed b/pa2-tests/core/func_def_call.py.ast.typed new file mode 100644 index 0000000..20e0bde --- /dev/null +++ b/pa2-tests/core/func_def_call.py.ast.typed @@ -0,0 +1,153 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 7, 20 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 2, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 1, 9, 1, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 11, 1, 13 ], + "className" : "str" + } + }, { + "kind" : "TypedVar", + "location" : [ 1, 16, 1, 21 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 16, 1, 16 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 18, 1, 21 ], + "className" : "bool" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 27, 1, 29 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 2, 5, 2, 16 ], + "value" : { + "kind" : "CallExpr", + "location" : [ 2, 12, 2, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 2, 12, 2, 14 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "bar" + }, + "args" : [ ] + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 4, 1, 5, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 7 ], + "name" : "bar" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 14, 4, 16 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 5, 5, 12 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 12, 5, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 7, 1, 7, 19 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 7, 1, 7, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 3 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "str" + }, { + "kind" : "ClassValueType", + "className" : "bool" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "foo" + }, + "args" : [ { + "kind" : "StringLiteral", + "location" : [ 7, 5, 7, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Hello" + }, { + "kind" : "BooleanLiteral", + "location" : [ 7, 14, 7, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/stmt_for_lists.py b/pa2-tests/core/stmt_for_lists.py new file mode 100644 index 0000000..235fb2f --- /dev/null +++ b/pa2-tests/core/stmt_for_lists.py @@ -0,0 +1,4 @@ +x:int = 0 + +for x in [1, 2, 3]: + x + 1 diff --git a/pa2-tests/core/stmt_for_lists.py.ast b/pa2-tests/core/stmt_for_lists.py.ast new file mode 100644 index 0000000..3e6fb8f --- /dev/null +++ b/pa2-tests/core/stmt_for_lists.py.ast @@ -0,0 +1,77 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 5, 1 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "ForStmt", + "location" : [ 3, 1, 5, 1 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 5 ], + "name" : "x" + }, + "iterable" : { + "kind" : "ListExpr", + "location" : [ 3, 10, 3, 18 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 3, 11, 3, 11 ], + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 3, 14, 3, 14 ], + "value" : 2 + }, { + "kind" : "IntegerLiteral", + "location" : [ 3, 17, 3, 17 ], + "value" : 3 + } ] + }, + "body" : [ { + "kind" : "ExprStmt", + "location" : [ 4, 5, 4, 9 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 4, 5, 4, 9 ], + "left" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 5 ], + "name" : "x" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 9, 4, 9 ], + "value" : 1 + } + } + } ] + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/stmt_for_lists.py.ast.typed b/pa2-tests/core/stmt_for_lists.py.ast.typed new file mode 100644 index 0000000..9bd4123 --- /dev/null +++ b/pa2-tests/core/stmt_for_lists.py.ast.typed @@ -0,0 +1,116 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 5, 1 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "ForStmt", + "location" : [ 3, 1, 5, 1 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "iterable" : { + "kind" : "ListExpr", + "location" : [ 3, 10, 3, 18 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 3, 11, 3, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 3, 14, 3, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + }, { + "kind" : "IntegerLiteral", + "location" : [ 3, 17, 3, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } ] + }, + "body" : [ { + "kind" : "ExprStmt", + "location" : [ 4, 5, 4, 9 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 4, 5, 4, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 9, 4, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ] + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/stmt_for_strings.py b/pa2-tests/core/stmt_for_strings.py new file mode 100644 index 0000000..b135f8b --- /dev/null +++ b/pa2-tests/core/stmt_for_strings.py @@ -0,0 +1,4 @@ +s:str = "Hello" + +for s in s: + s[0] diff --git a/pa2-tests/core/stmt_for_strings.py.ast b/pa2-tests/core/stmt_for_strings.py.ast new file mode 100644 index 0000000..6e837a5 --- /dev/null +++ b/pa2-tests/core/stmt_for_strings.py.ast @@ -0,0 +1,64 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 5, 1 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 1, 9, 1, 15 ], + "value" : "Hello" + } + } ], + "statements" : [ { + "kind" : "ForStmt", + "location" : [ 3, 1, 5, 1 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 5 ], + "name" : "s" + }, + "iterable" : { + "kind" : "Identifier", + "location" : [ 3, 10, 3, 10 ], + "name" : "s" + }, + "body" : [ { + "kind" : "ExprStmt", + "location" : [ 4, 5, 4, 8 ], + "expr" : { + "kind" : "IndexExpr", + "location" : [ 4, 5, 4, 8 ], + "list" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 5 ], + "name" : "s" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 7, 4, 7 ], + "value" : 0 + } + } + } ] + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/stmt_for_strings.py.ast.typed b/pa2-tests/core/stmt_for_strings.py.ast.typed new file mode 100644 index 0000000..0f36ad0 --- /dev/null +++ b/pa2-tests/core/stmt_for_strings.py.ast.typed @@ -0,0 +1,88 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 5, 1 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 1, 9, 1, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Hello" + } + } ], + "statements" : [ { + "kind" : "ForStmt", + "location" : [ 3, 1, 5, 1 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "s" + }, + "iterable" : { + "kind" : "Identifier", + "location" : [ 3, 10, 3, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "s" + }, + "body" : [ { + "kind" : "ExprStmt", + "location" : [ 4, 5, 4, 8 ], + "expr" : { + "kind" : "IndexExpr", + "location" : [ 4, 5, 4, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "s" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 7, 4, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } + } ] + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/stmt_if.py b/pa2-tests/core/stmt_if.py new file mode 100644 index 0000000..d5053bf --- /dev/null +++ b/pa2-tests/core/stmt_if.py @@ -0,0 +1,7 @@ +if False: + pass +elif True: + if 1 == 1: + pass +else: + pass diff --git a/pa2-tests/core/stmt_if.py.ast b/pa2-tests/core/stmt_if.py.ast new file mode 100644 index 0000000..48c33f3 --- /dev/null +++ b/pa2-tests/core/stmt_if.py.ast @@ -0,0 +1,51 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 8, 1 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 1, 1, 8, 1 ], + "condition" : { + "kind" : "BooleanLiteral", + "location" : [ 1, 4, 1, 8 ], + "value" : false + }, + "thenBody" : [ ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 3, 1, 8, 1 ], + "condition" : { + "kind" : "BooleanLiteral", + "location" : [ 3, 6, 3, 9 ], + "value" : true + }, + "thenBody" : [ { + "kind" : "IfStmt", + "location" : [ 4, 5, 6, 0 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 4, 8, 4, 13 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 8, 4, 8 ], + "value" : 1 + }, + "operator" : "==", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 13, 4, 13 ], + "value" : 1 + } + }, + "thenBody" : [ ], + "elseBody" : [ ] + } ], + "elseBody" : [ ] + } ] + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/stmt_if.py.ast.typed b/pa2-tests/core/stmt_if.py.ast.typed new file mode 100644 index 0000000..3453f95 --- /dev/null +++ b/pa2-tests/core/stmt_if.py.ast.typed @@ -0,0 +1,71 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 8, 1 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 1, 1, 8, 1 ], + "condition" : { + "kind" : "BooleanLiteral", + "location" : [ 1, 4, 1, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + }, + "thenBody" : [ ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 3, 1, 8, 1 ], + "condition" : { + "kind" : "BooleanLiteral", + "location" : [ 3, 6, 3, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + }, + "thenBody" : [ { + "kind" : "IfStmt", + "location" : [ 4, 5, 6, 0 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 4, 8, 4, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 8, 4, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, + "operator" : "==", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 13, 4, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, + "thenBody" : [ ], + "elseBody" : [ ] + } ], + "elseBody" : [ ] + } ] + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/stmt_list_assign.py b/pa2-tests/core/stmt_list_assign.py new file mode 100644 index 0000000..34221dd --- /dev/null +++ b/pa2-tests/core/stmt_list_assign.py @@ -0,0 +1,7 @@ +x:[int] = None +y:[object] = None + +x = [1, 2] +y = [None] +x[0] = 3 +x[1] = y[0] = 4 diff --git a/pa2-tests/core/stmt_list_assign.py.ast b/pa2-tests/core/stmt_list_assign.py.ast new file mode 100644 index 0000000..cac7d91 --- /dev/null +++ b/pa2-tests/core/stmt_list_assign.py.ast @@ -0,0 +1,155 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 7, 16 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ListType", + "location" : [ 1, 3, 1, 7 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 1, 4, 1, 6 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 1, 11, 1, 14 ] + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ListType", + "location" : [ 2, 3, 2, 10 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 2, 4, 2, 9 ], + "className" : "object" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 2, 14, 2, 17 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 4, 1, 4, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 4, 5, 4, 10 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 4, 6, 4, 6 ], + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 4, 9, 4, 9 ], + "value" : 2 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 5, 1, 5, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "name" : "y" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 5, 5, 5, 10 ], + "elements" : [ { + "kind" : "NoneLiteral", + "location" : [ 5, 6, 5, 9 ] + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 8 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 6, 1, 6, 4 ], + "list" : { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 3, 6, 3 ], + "value" : 0 + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 8, 6, 8 ], + "value" : 3 + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 15 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 7, 1, 7, 4 ], + "list" : { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 3, 7, 3 ], + "value" : 1 + } + }, { + "kind" : "IndexExpr", + "location" : [ 7, 8, 7, 11 ], + "list" : { + "kind" : "Identifier", + "location" : [ 7, 8, 7, 8 ], + "name" : "y" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 10, 7, 10 ], + "value" : 0 + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 15, 7, 15 ], + "value" : 4 + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/stmt_list_assign.py.ast.typed b/pa2-tests/core/stmt_list_assign.py.ast.typed new file mode 100644 index 0000000..5fefc31 --- /dev/null +++ b/pa2-tests/core/stmt_list_assign.py.ast.typed @@ -0,0 +1,256 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 7, 16 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ListType", + "location" : [ 1, 3, 1, 7 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 1, 4, 1, 6 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 1, 11, 1, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ListType", + "location" : [ 2, 3, 2, 10 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 2, 4, 2, 9 ], + "className" : "object" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 2, 14, 2, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 4, 1, 4, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 4, 5, 4, 10 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 4, 6, 4, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 4, 9, 4, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 5, 1, 5, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "name" : "y" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 5, 5, 5, 10 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, + "elements" : [ { + "kind" : "NoneLiteral", + "location" : [ 5, 6, 5, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 8 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 6, 1, 6, 4 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 3, 6, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 8, 6, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 15 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 7, 1, 7, 4 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 3, 7, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "IndexExpr", + "location" : [ 7, 8, 7, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 7, 8, 7, 8 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "name" : "y" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 10, 7, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 15, 7, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 4 + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/stmt_var_assign.py b/pa2-tests/core/stmt_var_assign.py new file mode 100644 index 0000000..71e9795 --- /dev/null +++ b/pa2-tests/core/stmt_var_assign.py @@ -0,0 +1,9 @@ +x:int = 1 +y:bool = True +z:str = "" +o:object = None + +x = 2 +y = False +z = "Hello" +o = z diff --git a/pa2-tests/core/stmt_var_assign.py.ast b/pa2-tests/core/stmt_var_assign.py.ast new file mode 100644 index 0000000..4a474cd --- /dev/null +++ b/pa2-tests/core/stmt_var_assign.py.ast @@ -0,0 +1,150 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 9, 6 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 1 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 6 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 6 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 2, 10, 2, 13 ], + "value" : true + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 3, 9, 3, 10 ], + "value" : "" + } + }, { + "kind" : "VarDef", + "location" : [ 4, 1, 4, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 1, 4, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "o" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 3, 4, 8 ], + "className" : "object" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 4, 12, 4, 15 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 5 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "x" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 5, 6, 5 ], + "value" : 2 + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "name" : "y" + } ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 7, 5, 7, 9 ], + "value" : false + } + }, { + "kind" : "AssignStmt", + "location" : [ 8, 1, 8, 11 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "name" : "z" + } ], + "value" : { + "kind" : "StringLiteral", + "location" : [ 8, 5, 8, 11 ], + "value" : "Hello" + } + }, { + "kind" : "AssignStmt", + "location" : [ 9, 1, 9, 5 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 1 ], + "name" : "o" + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "name" : "z" + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/stmt_var_assign.py.ast.typed b/pa2-tests/core/stmt_var_assign.py.ast.typed new file mode 100644 index 0000000..cb529c2 --- /dev/null +++ b/pa2-tests/core/stmt_var_assign.py.ast.typed @@ -0,0 +1,198 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 9, 6 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 6 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 6 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 2, 10, 2, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 3, 9, 3, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "" + } + }, { + "kind" : "VarDef", + "location" : [ 4, 1, 4, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 1, 4, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "o" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 3, 4, 8 ], + "className" : "object" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 4, 12, 4, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 5 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 5, 6, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "name" : "y" + } ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 7, 5, 7, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } + }, { + "kind" : "AssignStmt", + "location" : [ 8, 1, 8, 11 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "z" + } ], + "value" : { + "kind" : "StringLiteral", + "location" : [ 8, 5, 8, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Hello" + } + }, { + "kind" : "AssignStmt", + "location" : [ 9, 1, 9, 5 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "name" : "o" + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "z" + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/stmt_while.py b/pa2-tests/core/stmt_while.py new file mode 100644 index 0000000..d45a4fc --- /dev/null +++ b/pa2-tests/core/stmt_while.py @@ -0,0 +1,3 @@ +x:int = 0 +while x < 100: + x = x + 1 diff --git a/pa2-tests/core/stmt_while.py.ast b/pa2-tests/core/stmt_while.py.ast new file mode 100644 index 0000000..10ae361 --- /dev/null +++ b/pa2-tests/core/stmt_while.py.ast @@ -0,0 +1,75 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 4, 1 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "WhileStmt", + "location" : [ 2, 1, 4, 1 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 2, 7, 2, 13 ], + "left" : { + "kind" : "Identifier", + "location" : [ 2, 7, 2, 7 ], + "name" : "x" + }, + "operator" : "<", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 11, 2, 13 ], + "value" : 100 + } + }, + "body" : [ { + "kind" : "AssignStmt", + "location" : [ 3, 5, 3, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 5 ], + "name" : "x" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 3, 9, 3, 13 ], + "left" : { + "kind" : "Identifier", + "location" : [ 3, 9, 3, 9 ], + "name" : "x" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 13, 3, 13 ], + "value" : 1 + } + } + } ] + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/stmt_while.py.ast.typed b/pa2-tests/core/stmt_while.py.ast.typed new file mode 100644 index 0000000..c928a9e --- /dev/null +++ b/pa2-tests/core/stmt_while.py.ast.typed @@ -0,0 +1,107 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 4, 1 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "WhileStmt", + "location" : [ 2, 1, 4, 1 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 2, 7, 2, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 2, 7, 2, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "operator" : "<", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 11, 2, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 100 + } + }, + "body" : [ { + "kind" : "AssignStmt", + "location" : [ 3, 5, 3, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 3, 9, 3, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 3, 9, 3, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 13, 3, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ] + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/strings.py b/pa2-tests/core/strings.py new file mode 100644 index 0000000..dd6a4ee --- /dev/null +++ b/pa2-tests/core/strings.py @@ -0,0 +1,8 @@ +x:str = "Hello" +y:str = "World" +z:str = "" + +z = x + y +z = x[0] +x = y = z + diff --git a/pa2-tests/core/strings.py.ast b/pa2-tests/core/strings.py.ast new file mode 100644 index 0000000..1ba2f58 --- /dev/null +++ b/pa2-tests/core/strings.py.ast @@ -0,0 +1,139 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 7, 10 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 1, 9, 1, 15 ], + "value" : "Hello" + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 2, 9, 2, 15 ], + "value" : "World" + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 3, 9, 3, 10 ], + "value" : "" + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 5, 1, 5, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "name" : "z" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 5, 5, 5, 9 ], + "left" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 5 ], + "name" : "x" + }, + "operator" : "+", + "right" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 9 ], + "name" : "y" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 8 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "z" + } ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 6, 5, 6, 8 ], + "list" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 7, 6, 7 ], + "value" : 0 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "name" : "y" + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 9 ], + "name" : "z" + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/core/strings.py.ast.typed b/pa2-tests/core/strings.py.ast.typed new file mode 100644 index 0000000..acff3ae --- /dev/null +++ b/pa2-tests/core/strings.py.ast.typed @@ -0,0 +1,195 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 7, 10 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 1, 9, 1, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Hello" + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 2, 9, 2, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "World" + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 3, 9, 3, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "" + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 5, 1, 5, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "z" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 5, 5, 5, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "x" + }, + "operator" : "+", + "right" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "y" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 8 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "z" + } ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 6, 5, 6, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 7, 6, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "y" + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "z" + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/extra/exp.py b/pa2-tests/extra/exp.py new file mode 100644 index 0000000..3915517 --- /dev/null +++ b/pa2-tests/extra/exp.py @@ -0,0 +1,25 @@ +# Compute x**y +def exp(x: int, y: int) -> int: + a: int = 0 + def f(i: int) -> int: + nonlocal a + def geta() -> int: + return a + if i <= 0: + return geta() + else: + a = a * x + return f(i-1) + a = 1 + return f(y) + +# Input parameter +n:int = 42 + +# Run [0, n] +i:int = 0 + +# Crunch +while i <= n: + print(exp(2, i % 31)) + i = i + 1 \ No newline at end of file diff --git a/pa2-tests/extra/exp.py.ast b/pa2-tests/extra/exp.py.ast new file mode 100644 index 0000000..bc8786c --- /dev/null +++ b/pa2-tests/extra/exp.py.ast @@ -0,0 +1,375 @@ +{ + "kind" : "Program", + "location" : [ 2, 1, 26, 1 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 2, 1, 14, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 7 ], + "name" : "exp" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 2, 9, 2, 14 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 9, 2, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 12, 2, 14 ], + "className" : "int" + } + }, { + "kind" : "TypedVar", + "location" : [ 2, 17, 2, 22 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 17, 2, 17 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 20, 2, 22 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 2, 28, 2, 30 ], + "className" : "int" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 3, 2, 3, 11 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 2, 3, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 2, 3, 2 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 5, 3, 7 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 11, 3, 11 ], + "value" : 0 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 2, 13, 1 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 6, 4, 6 ], + "name" : "f" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 8, 4, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 8, 4, 8 ], + "name" : "i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 11, 4, 13 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 19, 4, 21 ], + "className" : "int" + }, + "declarations" : [ { + "kind" : "NonLocalDecl", + "location" : [ 5, 3, 5, 12 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 5, 12, 5, 12 ], + "name" : "a" + } + }, { + "kind" : "FuncDef", + "location" : [ 6, 3, 7, 12 ], + "name" : { + "kind" : "Identifier", + "location" : [ 6, 7, 6, 10 ], + "name" : "geta" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 6, 17, 6, 19 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 7, 4, 7, 11 ], + "value" : { + "kind" : "Identifier", + "location" : [ 7, 11, 7, 11 ], + "name" : "a" + } + } ] + } ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 8, 3, 13, 1 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 8, 6, 8, 11 ], + "left" : { + "kind" : "Identifier", + "location" : [ 8, 6, 8, 6 ], + "name" : "i" + }, + "operator" : "<=", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 8, 11, 8, 11 ], + "value" : 0 + } + }, + "thenBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 9, 4, 9, 16 ], + "value" : { + "kind" : "CallExpr", + "location" : [ 9, 11, 9, 16 ], + "function" : { + "kind" : "Identifier", + "location" : [ 9, 11, 9, 14 ], + "name" : "geta" + }, + "args" : [ ] + } + } ], + "elseBody" : [ { + "kind" : "AssignStmt", + "location" : [ 11, 4, 11, 12 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 11, 4, 11, 4 ], + "name" : "a" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 11, 8, 11, 12 ], + "left" : { + "kind" : "Identifier", + "location" : [ 11, 8, 11, 8 ], + "name" : "a" + }, + "operator" : "*", + "right" : { + "kind" : "Identifier", + "location" : [ 11, 12, 11, 12 ], + "name" : "x" + } + } + }, { + "kind" : "ReturnStmt", + "location" : [ 12, 4, 12, 16 ], + "value" : { + "kind" : "CallExpr", + "location" : [ 12, 11, 12, 16 ], + "function" : { + "kind" : "Identifier", + "location" : [ 12, 11, 12, 11 ], + "name" : "f" + }, + "args" : [ { + "kind" : "BinaryExpr", + "location" : [ 12, 13, 12, 15 ], + "left" : { + "kind" : "Identifier", + "location" : [ 12, 13, 12, 13 ], + "name" : "i" + }, + "operator" : "-", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 12, 15, 12, 15 ], + "value" : 1 + } + } ] + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 13, 2, 13, 6 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 13, 2, 13, 2 ], + "name" : "a" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 13, 6, 13, 6 ], + "value" : 1 + } + }, { + "kind" : "ReturnStmt", + "location" : [ 14, 2, 14, 12 ], + "value" : { + "kind" : "CallExpr", + "location" : [ 14, 9, 14, 12 ], + "function" : { + "kind" : "Identifier", + "location" : [ 14, 9, 14, 9 ], + "name" : "f" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 14, 11, 14, 11 ], + "name" : "y" + } ] + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 17, 1, 17, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 17, 1, 17, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 17, 1, 17, 1 ], + "name" : "n" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 17, 3, 17, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 17, 9, 17, 10 ], + "value" : 42 + } + }, { + "kind" : "VarDef", + "location" : [ 20, 1, 20, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 20, 1, 20, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 20, 1, 20, 1 ], + "name" : "i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 20, 3, 20, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 20, 9, 20, 9 ], + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "WhileStmt", + "location" : [ 23, 1, 26, 1 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 23, 7, 23, 12 ], + "left" : { + "kind" : "Identifier", + "location" : [ 23, 7, 23, 7 ], + "name" : "i" + }, + "operator" : "<=", + "right" : { + "kind" : "Identifier", + "location" : [ 23, 12, 23, 12 ], + "name" : "n" + } + }, + "body" : [ { + "kind" : "ExprStmt", + "location" : [ 24, 2, 24, 22 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 24, 2, 24, 22 ], + "function" : { + "kind" : "Identifier", + "location" : [ 24, 2, 24, 6 ], + "name" : "print" + }, + "args" : [ { + "kind" : "CallExpr", + "location" : [ 24, 8, 24, 21 ], + "function" : { + "kind" : "Identifier", + "location" : [ 24, 8, 24, 10 ], + "name" : "exp" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 24, 12, 24, 12 ], + "value" : 2 + }, { + "kind" : "BinaryExpr", + "location" : [ 24, 15, 24, 20 ], + "left" : { + "kind" : "Identifier", + "location" : [ 24, 15, 24, 15 ], + "name" : "i" + }, + "operator" : "%", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 24, 19, 24, 20 ], + "value" : 31 + } + } ] + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 25, 2, 25, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 25, 2, 25, 2 ], + "name" : "i" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 25, 6, 25, 10 ], + "left" : { + "kind" : "Identifier", + "location" : [ 25, 6, 25, 6 ], + "name" : "i" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 25, 10, 25, 10 ], + "value" : 1 + } + } + } ] + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/extra/exp.py.ast.typed b/pa2-tests/extra/exp.py.ast.typed new file mode 100644 index 0000000..39a7fa1 --- /dev/null +++ b/pa2-tests/extra/exp.py.ast.typed @@ -0,0 +1,562 @@ +{ + "kind" : "Program", + "location" : [ 2, 1, 26, 1 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 2, 1, 14, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 7 ], + "name" : "exp" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 2, 9, 2, 14 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 9, 2, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 12, 2, 14 ], + "className" : "int" + } + }, { + "kind" : "TypedVar", + "location" : [ 2, 17, 2, 22 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 17, 2, 17 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 20, 2, 22 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 2, 28, 2, 30 ], + "className" : "int" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 3, 2, 3, 11 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 2, 3, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 2, 3, 2 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 5, 3, 7 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 11, 3, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 2, 13, 1 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 6, 4, 6 ], + "name" : "f" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 8, 4, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 8, 4, 8 ], + "name" : "i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 11, 4, 13 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 19, 4, 21 ], + "className" : "int" + }, + "declarations" : [ { + "kind" : "NonLocalDecl", + "location" : [ 5, 3, 5, 12 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 5, 12, 5, 12 ], + "name" : "a" + } + }, { + "kind" : "FuncDef", + "location" : [ 6, 3, 7, 12 ], + "name" : { + "kind" : "Identifier", + "location" : [ 6, 7, 6, 10 ], + "name" : "geta" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 6, 17, 6, 19 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 7, 4, 7, 11 ], + "value" : { + "kind" : "Identifier", + "location" : [ 7, 11, 7, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "a" + } + } ] + } ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 8, 3, 13, 1 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 8, 6, 8, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 8, 6, 8, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + }, + "operator" : "<=", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 8, 11, 8, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, + "thenBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 9, 4, 9, 16 ], + "value" : { + "kind" : "CallExpr", + "location" : [ 9, 11, 9, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 9, 11, 9, 14 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "geta" + }, + "args" : [ ] + } + } ], + "elseBody" : [ { + "kind" : "AssignStmt", + "location" : [ 11, 4, 11, 12 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 11, 4, 11, 4 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "a" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 11, 8, 11, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 11, 8, 11, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "a" + }, + "operator" : "*", + "right" : { + "kind" : "Identifier", + "location" : [ 11, 12, 11, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } + } + }, { + "kind" : "ReturnStmt", + "location" : [ 12, 4, 12, 16 ], + "value" : { + "kind" : "CallExpr", + "location" : [ 12, 11, 12, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 12, 11, 12, 11 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "f" + }, + "args" : [ { + "kind" : "BinaryExpr", + "location" : [ 12, 13, 12, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 12, 13, 12, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + }, + "operator" : "-", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 12, 15, 12, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ] + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 13, 2, 13, 6 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 13, 2, 13, 2 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "a" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 13, 6, 13, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "ReturnStmt", + "location" : [ 14, 2, 14, 12 ], + "value" : { + "kind" : "CallExpr", + "location" : [ 14, 9, 14, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 14, 9, 14, 9 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "f" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 14, 11, 14, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "y" + } ] + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 17, 1, 17, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 17, 1, 17, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 17, 1, 17, 1 ], + "name" : "n" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 17, 3, 17, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 17, 9, 17, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 42 + } + }, { + "kind" : "VarDef", + "location" : [ 20, 1, 20, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 20, 1, 20, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 20, 1, 20, 1 ], + "name" : "i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 20, 3, 20, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 20, 9, 20, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "WhileStmt", + "location" : [ 23, 1, 26, 1 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 23, 7, 23, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 23, 7, 23, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + }, + "operator" : "<=", + "right" : { + "kind" : "Identifier", + "location" : [ 23, 12, 23, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "n" + } + }, + "body" : [ { + "kind" : "ExprStmt", + "location" : [ 24, 2, 24, 22 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 24, 2, 24, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 24, 2, 24, 6 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, + "name" : "print" + }, + "args" : [ { + "kind" : "CallExpr", + "location" : [ 24, 8, 24, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 24, 8, 24, 10 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "int" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "exp" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 24, 12, 24, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + }, { + "kind" : "BinaryExpr", + "location" : [ 24, 15, 24, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 24, 15, 24, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + }, + "operator" : "%", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 24, 19, 24, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 31 + } + } ] + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 25, 2, 25, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 25, 2, 25, 2 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 25, 6, 25, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 25, 6, 25, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 25, 10, 25, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ] + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/extra/mergesort.py b/pa2-tests/extra/mergesort.py new file mode 100644 index 0000000..096c2c8 --- /dev/null +++ b/pa2-tests/extra/mergesort.py @@ -0,0 +1,62 @@ +def append(a: [int], k: int) -> [int]: + return a + [k] + + +def extend(a: [int], b: [int], b_start: int, b_end: int) -> [int]: + extended: [int] = None + i: int = 0 + + extended = a + i = b_start + while i < b_end: + extended = append(extended, b[i]) + i = i + 1 + return extended + + +def merge(left: [int], right: [int]) -> [int]: + merged: [int] = None + i: int = 0 + j: int = 0 + + merged = [] + while i < len(left) and j < len(right): + if left[i] < right[j]: + merged = append(merged, left[i]) + i = i + 1 + else: + merged = append(merged, right[j]) + j = j + 1 + + if i < len(left): + merged = extend(merged, left, i, len(left)) + if j < len(right): + merged = extend(merged, right, j, len(right)) + + return merged + + +def mergesort(a: [int]) -> [int]: + mid: int = 0 + left: [int] = None + right: [int] = None + + if len(a) < 2: + return a + + mid = len(a) // 2 + left = extend([], a, 0, mid) + right = extend([], a, mid, len(a)) + + left = mergesort(left) + right = mergesort(right) + return merge(left, right) + + +initial: [int] = None +ordered: [int] = None + +initial = [2, 7, 3, 11, 5] +ordered = mergesort(initial) + +print(ordered) diff --git a/pa2-tests/extra/mergesort.py.ast b/pa2-tests/extra/mergesort.py.ast new file mode 100644 index 0000000..f11bb0f --- /dev/null +++ b/pa2-tests/extra/mergesort.py.ast @@ -0,0 +1,1262 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 62, 15 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 2, 19 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 10 ], + "name" : "append" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 1, 12, 1, 19 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 12, 1, 12 ], + "name" : "a" + }, + "type" : { + "kind" : "ListType", + "location" : [ 1, 15, 1, 19 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 1, 16, 1, 18 ], + "className" : "int" + } + } + }, { + "kind" : "TypedVar", + "location" : [ 1, 22, 1, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 22, 1, 22 ], + "name" : "k" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 25, 1, 27 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ListType", + "location" : [ 1, 33, 1, 37 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 1, 34, 1, 36 ], + "className" : "int" + } + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 2, 5, 2, 18 ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 2, 12, 2, 18 ], + "left" : { + "kind" : "Identifier", + "location" : [ 2, 12, 2, 12 ], + "name" : "a" + }, + "operator" : "+", + "right" : { + "kind" : "ListExpr", + "location" : [ 2, 16, 2, 18 ], + "elements" : [ { + "kind" : "Identifier", + "location" : [ 2, 17, 2, 17 ], + "name" : "k" + } ] + } + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 5, 1, 14, 20 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 10 ], + "name" : "extend" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 12, 5, 19 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 12, 5, 12 ], + "name" : "a" + }, + "type" : { + "kind" : "ListType", + "location" : [ 5, 15, 5, 19 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 5, 16, 5, 18 ], + "className" : "int" + } + } + }, { + "kind" : "TypedVar", + "location" : [ 5, 22, 5, 29 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 22, 5, 22 ], + "name" : "b" + }, + "type" : { + "kind" : "ListType", + "location" : [ 5, 25, 5, 29 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 5, 26, 5, 28 ], + "className" : "int" + } + } + }, { + "kind" : "TypedVar", + "location" : [ 5, 32, 5, 43 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 32, 5, 38 ], + "name" : "b_start" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 41, 5, 43 ], + "className" : "int" + } + }, { + "kind" : "TypedVar", + "location" : [ 5, 46, 5, 55 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 46, 5, 50 ], + "name" : "b_end" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 53, 5, 55 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ListType", + "location" : [ 5, 61, 5, 65 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 5, 62, 5, 64 ], + "className" : "int" + } + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 6, 5, 6, 26 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 5, 6, 19 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 12 ], + "name" : "extended" + }, + "type" : { + "kind" : "ListType", + "location" : [ 6, 15, 6, 19 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 6, 16, 6, 18 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 6, 23, 6, 26 ] + } + }, { + "kind" : "VarDef", + "location" : [ 7, 5, 7, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 7, 5, 7, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "name" : "i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 7, 8, 7, 10 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 14, 7, 14 ], + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 9, 5, 9, 16 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 12 ], + "name" : "extended" + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 9, 16, 9, 16 ], + "name" : "a" + } + }, { + "kind" : "AssignStmt", + "location" : [ 10, 5, 10, 15 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 10, 5, 10, 5 ], + "name" : "i" + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 10, 9, 10, 15 ], + "name" : "b_start" + } + }, { + "kind" : "WhileStmt", + "location" : [ 11, 5, 14, 4 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 11, 11, 11, 19 ], + "left" : { + "kind" : "Identifier", + "location" : [ 11, 11, 11, 11 ], + "name" : "i" + }, + "operator" : "<", + "right" : { + "kind" : "Identifier", + "location" : [ 11, 15, 11, 19 ], + "name" : "b_end" + } + }, + "body" : [ { + "kind" : "AssignStmt", + "location" : [ 12, 9, 12, 41 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 12, 9, 12, 16 ], + "name" : "extended" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 12, 20, 12, 41 ], + "function" : { + "kind" : "Identifier", + "location" : [ 12, 20, 12, 25 ], + "name" : "append" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 12, 27, 12, 34 ], + "name" : "extended" + }, { + "kind" : "IndexExpr", + "location" : [ 12, 37, 12, 40 ], + "list" : { + "kind" : "Identifier", + "location" : [ 12, 37, 12, 37 ], + "name" : "b" + }, + "index" : { + "kind" : "Identifier", + "location" : [ 12, 39, 12, 39 ], + "name" : "i" + } + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 13, 9, 13, 17 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 13, 9, 13, 9 ], + "name" : "i" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 13, 13, 13, 17 ], + "left" : { + "kind" : "Identifier", + "location" : [ 13, 13, 13, 13 ], + "name" : "i" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 13, 17, 13, 17 ], + "value" : 1 + } + } + } ] + }, { + "kind" : "ReturnStmt", + "location" : [ 14, 5, 14, 19 ], + "value" : { + "kind" : "Identifier", + "location" : [ 14, 12, 14, 19 ], + "name" : "extended" + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 17, 1, 36, 18 ], + "name" : { + "kind" : "Identifier", + "location" : [ 17, 5, 17, 9 ], + "name" : "merge" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 17, 11, 17, 21 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 17, 11, 17, 14 ], + "name" : "left" + }, + "type" : { + "kind" : "ListType", + "location" : [ 17, 17, 17, 21 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 17, 18, 17, 20 ], + "className" : "int" + } + } + }, { + "kind" : "TypedVar", + "location" : [ 17, 24, 17, 35 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 17, 24, 17, 28 ], + "name" : "right" + }, + "type" : { + "kind" : "ListType", + "location" : [ 17, 31, 17, 35 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 17, 32, 17, 34 ], + "className" : "int" + } + } + } ], + "returnType" : { + "kind" : "ListType", + "location" : [ 17, 41, 17, 45 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 17, 42, 17, 44 ], + "className" : "int" + } + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 18, 5, 18, 24 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 18, 5, 18, 17 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 18, 5, 18, 10 ], + "name" : "merged" + }, + "type" : { + "kind" : "ListType", + "location" : [ 18, 13, 18, 17 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 18, 14, 18, 16 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 18, 21, 18, 24 ] + } + }, { + "kind" : "VarDef", + "location" : [ 19, 5, 19, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 19, 5, 19, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 19, 5, 19, 5 ], + "name" : "i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 19, 8, 19, 10 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 19, 14, 19, 14 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 20, 5, 20, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 20, 5, 20, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 20, 5, 20, 5 ], + "name" : "j" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 20, 8, 20, 10 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 20, 14, 20, 14 ], + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 22, 5, 22, 15 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 22, 5, 22, 10 ], + "name" : "merged" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 22, 14, 22, 15 ], + "elements" : [ ] + } + }, { + "kind" : "WhileStmt", + "location" : [ 23, 5, 31, 4 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 23, 11, 23, 42 ], + "left" : { + "kind" : "BinaryExpr", + "location" : [ 23, 11, 23, 23 ], + "left" : { + "kind" : "Identifier", + "location" : [ 23, 11, 23, 11 ], + "name" : "i" + }, + "operator" : "<", + "right" : { + "kind" : "CallExpr", + "location" : [ 23, 15, 23, 23 ], + "function" : { + "kind" : "Identifier", + "location" : [ 23, 15, 23, 17 ], + "name" : "len" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 23, 19, 23, 22 ], + "name" : "left" + } ] + } + }, + "operator" : "and", + "right" : { + "kind" : "BinaryExpr", + "location" : [ 23, 29, 23, 42 ], + "left" : { + "kind" : "Identifier", + "location" : [ 23, 29, 23, 29 ], + "name" : "j" + }, + "operator" : "<", + "right" : { + "kind" : "CallExpr", + "location" : [ 23, 33, 23, 42 ], + "function" : { + "kind" : "Identifier", + "location" : [ 23, 33, 23, 35 ], + "name" : "len" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 23, 37, 23, 41 ], + "name" : "right" + } ] + } + } + }, + "body" : [ { + "kind" : "IfStmt", + "location" : [ 24, 9, 31, 4 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 24, 12, 24, 29 ], + "left" : { + "kind" : "IndexExpr", + "location" : [ 24, 12, 24, 18 ], + "list" : { + "kind" : "Identifier", + "location" : [ 24, 12, 24, 15 ], + "name" : "left" + }, + "index" : { + "kind" : "Identifier", + "location" : [ 24, 17, 24, 17 ], + "name" : "i" + } + }, + "operator" : "<", + "right" : { + "kind" : "IndexExpr", + "location" : [ 24, 22, 24, 29 ], + "list" : { + "kind" : "Identifier", + "location" : [ 24, 22, 24, 26 ], + "name" : "right" + }, + "index" : { + "kind" : "Identifier", + "location" : [ 24, 28, 24, 28 ], + "name" : "j" + } + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 25, 13, 25, 44 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 25, 13, 25, 18 ], + "name" : "merged" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 25, 22, 25, 44 ], + "function" : { + "kind" : "Identifier", + "location" : [ 25, 22, 25, 27 ], + "name" : "append" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 25, 29, 25, 34 ], + "name" : "merged" + }, { + "kind" : "IndexExpr", + "location" : [ 25, 37, 25, 43 ], + "list" : { + "kind" : "Identifier", + "location" : [ 25, 37, 25, 40 ], + "name" : "left" + }, + "index" : { + "kind" : "Identifier", + "location" : [ 25, 42, 25, 42 ], + "name" : "i" + } + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 26, 13, 26, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 26, 13, 26, 13 ], + "name" : "i" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 26, 17, 26, 21 ], + "left" : { + "kind" : "Identifier", + "location" : [ 26, 17, 26, 17 ], + "name" : "i" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 26, 21, 26, 21 ], + "value" : 1 + } + } + } ], + "elseBody" : [ { + "kind" : "AssignStmt", + "location" : [ 28, 13, 28, 45 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 28, 13, 28, 18 ], + "name" : "merged" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 28, 22, 28, 45 ], + "function" : { + "kind" : "Identifier", + "location" : [ 28, 22, 28, 27 ], + "name" : "append" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 28, 29, 28, 34 ], + "name" : "merged" + }, { + "kind" : "IndexExpr", + "location" : [ 28, 37, 28, 44 ], + "list" : { + "kind" : "Identifier", + "location" : [ 28, 37, 28, 41 ], + "name" : "right" + }, + "index" : { + "kind" : "Identifier", + "location" : [ 28, 43, 28, 43 ], + "name" : "j" + } + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 29, 13, 29, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 29, 13, 29, 13 ], + "name" : "j" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 29, 17, 29, 21 ], + "left" : { + "kind" : "Identifier", + "location" : [ 29, 17, 29, 17 ], + "name" : "j" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 29, 21, 29, 21 ], + "value" : 1 + } + } + } ] + } ] + }, { + "kind" : "IfStmt", + "location" : [ 31, 5, 33, 4 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 31, 8, 31, 20 ], + "left" : { + "kind" : "Identifier", + "location" : [ 31, 8, 31, 8 ], + "name" : "i" + }, + "operator" : "<", + "right" : { + "kind" : "CallExpr", + "location" : [ 31, 12, 31, 20 ], + "function" : { + "kind" : "Identifier", + "location" : [ 31, 12, 31, 14 ], + "name" : "len" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 31, 16, 31, 19 ], + "name" : "left" + } ] + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 32, 9, 32, 51 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 32, 9, 32, 14 ], + "name" : "merged" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 32, 18, 32, 51 ], + "function" : { + "kind" : "Identifier", + "location" : [ 32, 18, 32, 23 ], + "name" : "extend" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 32, 25, 32, 30 ], + "name" : "merged" + }, { + "kind" : "Identifier", + "location" : [ 32, 33, 32, 36 ], + "name" : "left" + }, { + "kind" : "Identifier", + "location" : [ 32, 39, 32, 39 ], + "name" : "i" + }, { + "kind" : "CallExpr", + "location" : [ 32, 42, 32, 50 ], + "function" : { + "kind" : "Identifier", + "location" : [ 32, 42, 32, 44 ], + "name" : "len" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 32, 46, 32, 49 ], + "name" : "left" + } ] + } ] + } + } ], + "elseBody" : [ ] + }, { + "kind" : "IfStmt", + "location" : [ 33, 5, 36, 4 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 33, 8, 33, 21 ], + "left" : { + "kind" : "Identifier", + "location" : [ 33, 8, 33, 8 ], + "name" : "j" + }, + "operator" : "<", + "right" : { + "kind" : "CallExpr", + "location" : [ 33, 12, 33, 21 ], + "function" : { + "kind" : "Identifier", + "location" : [ 33, 12, 33, 14 ], + "name" : "len" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 33, 16, 33, 20 ], + "name" : "right" + } ] + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 34, 9, 34, 53 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 34, 9, 34, 14 ], + "name" : "merged" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 34, 18, 34, 53 ], + "function" : { + "kind" : "Identifier", + "location" : [ 34, 18, 34, 23 ], + "name" : "extend" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 34, 25, 34, 30 ], + "name" : "merged" + }, { + "kind" : "Identifier", + "location" : [ 34, 33, 34, 37 ], + "name" : "right" + }, { + "kind" : "Identifier", + "location" : [ 34, 40, 34, 40 ], + "name" : "j" + }, { + "kind" : "CallExpr", + "location" : [ 34, 43, 34, 52 ], + "function" : { + "kind" : "Identifier", + "location" : [ 34, 43, 34, 45 ], + "name" : "len" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 34, 47, 34, 51 ], + "name" : "right" + } ] + } ] + } + } ], + "elseBody" : [ ] + }, { + "kind" : "ReturnStmt", + "location" : [ 36, 5, 36, 17 ], + "value" : { + "kind" : "Identifier", + "location" : [ 36, 12, 36, 17 ], + "name" : "merged" + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 39, 1, 53, 30 ], + "name" : { + "kind" : "Identifier", + "location" : [ 39, 5, 39, 13 ], + "name" : "mergesort" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 39, 15, 39, 22 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 39, 15, 39, 15 ], + "name" : "a" + }, + "type" : { + "kind" : "ListType", + "location" : [ 39, 18, 39, 22 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 39, 19, 39, 21 ], + "className" : "int" + } + } + } ], + "returnType" : { + "kind" : "ListType", + "location" : [ 39, 28, 39, 32 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 39, 29, 39, 31 ], + "className" : "int" + } + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 40, 5, 40, 16 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 40, 5, 40, 12 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 40, 5, 40, 7 ], + "name" : "mid" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 40, 10, 40, 12 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 40, 16, 40, 16 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 41, 5, 41, 22 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 41, 5, 41, 15 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 41, 5, 41, 8 ], + "name" : "left" + }, + "type" : { + "kind" : "ListType", + "location" : [ 41, 11, 41, 15 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 41, 12, 41, 14 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 41, 19, 41, 22 ] + } + }, { + "kind" : "VarDef", + "location" : [ 42, 5, 42, 23 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 42, 5, 42, 16 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 42, 5, 42, 9 ], + "name" : "right" + }, + "type" : { + "kind" : "ListType", + "location" : [ 42, 12, 42, 16 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 42, 13, 42, 15 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 42, 20, 42, 23 ] + } + } ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 44, 5, 47, 4 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 44, 8, 44, 17 ], + "left" : { + "kind" : "CallExpr", + "location" : [ 44, 8, 44, 13 ], + "function" : { + "kind" : "Identifier", + "location" : [ 44, 8, 44, 10 ], + "name" : "len" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 44, 12, 44, 12 ], + "name" : "a" + } ] + }, + "operator" : "<", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 44, 17, 44, 17 ], + "value" : 2 + } + }, + "thenBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 45, 9, 45, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 45, 16, 45, 16 ], + "name" : "a" + } + } ], + "elseBody" : [ ] + }, { + "kind" : "AssignStmt", + "location" : [ 47, 5, 47, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 47, 5, 47, 7 ], + "name" : "mid" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 47, 11, 47, 21 ], + "left" : { + "kind" : "CallExpr", + "location" : [ 47, 11, 47, 16 ], + "function" : { + "kind" : "Identifier", + "location" : [ 47, 11, 47, 13 ], + "name" : "len" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 47, 15, 47, 15 ], + "name" : "a" + } ] + }, + "operator" : "//", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 47, 21, 47, 21 ], + "value" : 2 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 48, 5, 48, 32 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 48, 5, 48, 8 ], + "name" : "left" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 48, 12, 48, 32 ], + "function" : { + "kind" : "Identifier", + "location" : [ 48, 12, 48, 17 ], + "name" : "extend" + }, + "args" : [ { + "kind" : "ListExpr", + "location" : [ 48, 19, 48, 20 ], + "elements" : [ ] + }, { + "kind" : "Identifier", + "location" : [ 48, 23, 48, 23 ], + "name" : "a" + }, { + "kind" : "IntegerLiteral", + "location" : [ 48, 26, 48, 26 ], + "value" : 0 + }, { + "kind" : "Identifier", + "location" : [ 48, 29, 48, 31 ], + "name" : "mid" + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 49, 5, 49, 38 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 49, 5, 49, 9 ], + "name" : "right" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 49, 13, 49, 38 ], + "function" : { + "kind" : "Identifier", + "location" : [ 49, 13, 49, 18 ], + "name" : "extend" + }, + "args" : [ { + "kind" : "ListExpr", + "location" : [ 49, 20, 49, 21 ], + "elements" : [ ] + }, { + "kind" : "Identifier", + "location" : [ 49, 24, 49, 24 ], + "name" : "a" + }, { + "kind" : "Identifier", + "location" : [ 49, 27, 49, 29 ], + "name" : "mid" + }, { + "kind" : "CallExpr", + "location" : [ 49, 32, 49, 37 ], + "function" : { + "kind" : "Identifier", + "location" : [ 49, 32, 49, 34 ], + "name" : "len" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 49, 36, 49, 36 ], + "name" : "a" + } ] + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 51, 5, 51, 26 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 51, 5, 51, 8 ], + "name" : "left" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 51, 12, 51, 26 ], + "function" : { + "kind" : "Identifier", + "location" : [ 51, 12, 51, 20 ], + "name" : "mergesort" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 51, 22, 51, 25 ], + "name" : "left" + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 52, 5, 52, 28 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 52, 5, 52, 9 ], + "name" : "right" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 52, 13, 52, 28 ], + "function" : { + "kind" : "Identifier", + "location" : [ 52, 13, 52, 21 ], + "name" : "mergesort" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 52, 23, 52, 27 ], + "name" : "right" + } ] + } + }, { + "kind" : "ReturnStmt", + "location" : [ 53, 5, 53, 29 ], + "value" : { + "kind" : "CallExpr", + "location" : [ 53, 12, 53, 29 ], + "function" : { + "kind" : "Identifier", + "location" : [ 53, 12, 53, 16 ], + "name" : "merge" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 53, 18, 53, 21 ], + "name" : "left" + }, { + "kind" : "Identifier", + "location" : [ 53, 24, 53, 28 ], + "name" : "right" + } ] + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 56, 1, 56, 21 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 56, 1, 56, 14 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 56, 1, 56, 7 ], + "name" : "initial" + }, + "type" : { + "kind" : "ListType", + "location" : [ 56, 10, 56, 14 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 56, 11, 56, 13 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 56, 18, 56, 21 ] + } + }, { + "kind" : "VarDef", + "location" : [ 57, 1, 57, 21 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 57, 1, 57, 14 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 57, 1, 57, 7 ], + "name" : "ordered" + }, + "type" : { + "kind" : "ListType", + "location" : [ 57, 10, 57, 14 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 57, 11, 57, 13 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 57, 18, 57, 21 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 59, 1, 59, 26 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 59, 1, 59, 7 ], + "name" : "initial" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 59, 11, 59, 26 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 59, 12, 59, 12 ], + "value" : 2 + }, { + "kind" : "IntegerLiteral", + "location" : [ 59, 15, 59, 15 ], + "value" : 7 + }, { + "kind" : "IntegerLiteral", + "location" : [ 59, 18, 59, 18 ], + "value" : 3 + }, { + "kind" : "IntegerLiteral", + "location" : [ 59, 21, 59, 22 ], + "value" : 11 + }, { + "kind" : "IntegerLiteral", + "location" : [ 59, 25, 59, 25 ], + "value" : 5 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 60, 1, 60, 28 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 60, 1, 60, 7 ], + "name" : "ordered" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 60, 11, 60, 28 ], + "function" : { + "kind" : "Identifier", + "location" : [ 60, 11, 60, 19 ], + "name" : "mergesort" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 60, 21, 60, 27 ], + "name" : "initial" + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 62, 1, 62, 14 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 62, 1, 62, 14 ], + "function" : { + "kind" : "Identifier", + "location" : [ 62, 1, 62, 5 ], + "name" : "print" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 62, 7, 62, 13 ], + "name" : "ordered" + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/extra/mergesort.py.ast.typed b/pa2-tests/extra/mergesort.py.ast.typed new file mode 100644 index 0000000..734f0a2 --- /dev/null +++ b/pa2-tests/extra/mergesort.py.ast.typed @@ -0,0 +1,2353 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 62, 15 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 2, 19 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 10 ], + "name" : "append" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 1, 12, 1, 19 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 12, 1, 12 ], + "name" : "a" + }, + "type" : { + "kind" : "ListType", + "location" : [ 1, 15, 1, 19 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 1, 16, 1, 18 ], + "className" : "int" + } + } + }, { + "kind" : "TypedVar", + "location" : [ 1, 22, 1, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 22, 1, 22 ], + "name" : "k" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 25, 1, 27 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ListType", + "location" : [ 1, 33, 1, 37 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 1, 34, 1, 36 ], + "className" : "int" + } + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 2, 5, 2, 18 ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 2, 12, 2, 18 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "left" : { + "kind" : "Identifier", + "location" : [ 2, 12, 2, 12 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "a" + }, + "operator" : "+", + "right" : { + "kind" : "ListExpr", + "location" : [ 2, 16, 2, 18 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "Identifier", + "location" : [ 2, 17, 2, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "k" + } ] + } + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 5, 1, 14, 20 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 10 ], + "name" : "extend" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 12, 5, 19 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 12, 5, 12 ], + "name" : "a" + }, + "type" : { + "kind" : "ListType", + "location" : [ 5, 15, 5, 19 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 5, 16, 5, 18 ], + "className" : "int" + } + } + }, { + "kind" : "TypedVar", + "location" : [ 5, 22, 5, 29 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 22, 5, 22 ], + "name" : "b" + }, + "type" : { + "kind" : "ListType", + "location" : [ 5, 25, 5, 29 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 5, 26, 5, 28 ], + "className" : "int" + } + } + }, { + "kind" : "TypedVar", + "location" : [ 5, 32, 5, 43 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 32, 5, 38 ], + "name" : "b_start" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 41, 5, 43 ], + "className" : "int" + } + }, { + "kind" : "TypedVar", + "location" : [ 5, 46, 5, 55 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 46, 5, 50 ], + "name" : "b_end" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 53, 5, 55 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ListType", + "location" : [ 5, 61, 5, 65 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 5, 62, 5, 64 ], + "className" : "int" + } + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 6, 5, 6, 26 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 5, 6, 19 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 12 ], + "name" : "extended" + }, + "type" : { + "kind" : "ListType", + "location" : [ 6, 15, 6, 19 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 6, 16, 6, 18 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 6, 23, 6, 26 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 7, 5, 7, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 7, 5, 7, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "name" : "i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 7, 8, 7, 10 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 14, 7, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 9, 5, 9, 16 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 12 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "extended" + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 9, 16, 9, 16 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "a" + } + }, { + "kind" : "AssignStmt", + "location" : [ 10, 5, 10, 15 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 10, 5, 10, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 10, 9, 10, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "b_start" + } + }, { + "kind" : "WhileStmt", + "location" : [ 11, 5, 14, 4 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 11, 11, 11, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 11, 11, 11, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + }, + "operator" : "<", + "right" : { + "kind" : "Identifier", + "location" : [ 11, 15, 11, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "b_end" + } + }, + "body" : [ { + "kind" : "AssignStmt", + "location" : [ 12, 9, 12, 41 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 12, 9, 12, 16 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "extended" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 12, 20, 12, 41 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "function" : { + "kind" : "Identifier", + "location" : [ 12, 20, 12, 25 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + } + }, + "name" : "append" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 12, 27, 12, 34 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "extended" + }, { + "kind" : "IndexExpr", + "location" : [ 12, 37, 12, 40 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 12, 37, 12, 37 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "b" + }, + "index" : { + "kind" : "Identifier", + "location" : [ 12, 39, 12, 39 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + } + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 13, 9, 13, 17 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 13, 9, 13, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 13, 13, 13, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 13, 13, 13, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 13, 17, 13, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ] + }, { + "kind" : "ReturnStmt", + "location" : [ 14, 5, 14, 19 ], + "value" : { + "kind" : "Identifier", + "location" : [ 14, 12, 14, 19 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "extended" + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 17, 1, 36, 18 ], + "name" : { + "kind" : "Identifier", + "location" : [ 17, 5, 17, 9 ], + "name" : "merge" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 17, 11, 17, 21 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 17, 11, 17, 14 ], + "name" : "left" + }, + "type" : { + "kind" : "ListType", + "location" : [ 17, 17, 17, 21 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 17, 18, 17, 20 ], + "className" : "int" + } + } + }, { + "kind" : "TypedVar", + "location" : [ 17, 24, 17, 35 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 17, 24, 17, 28 ], + "name" : "right" + }, + "type" : { + "kind" : "ListType", + "location" : [ 17, 31, 17, 35 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 17, 32, 17, 34 ], + "className" : "int" + } + } + } ], + "returnType" : { + "kind" : "ListType", + "location" : [ 17, 41, 17, 45 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 17, 42, 17, 44 ], + "className" : "int" + } + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 18, 5, 18, 24 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 18, 5, 18, 17 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 18, 5, 18, 10 ], + "name" : "merged" + }, + "type" : { + "kind" : "ListType", + "location" : [ 18, 13, 18, 17 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 18, 14, 18, 16 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 18, 21, 18, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 19, 5, 19, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 19, 5, 19, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 19, 5, 19, 5 ], + "name" : "i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 19, 8, 19, 10 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 19, 14, 19, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 20, 5, 20, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 20, 5, 20, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 20, 5, 20, 5 ], + "name" : "j" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 20, 8, 20, 10 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 20, 14, 20, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 22, 5, 22, 15 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 22, 5, 22, 10 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "merged" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 22, 14, 22, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "elements" : [ ] + } + }, { + "kind" : "WhileStmt", + "location" : [ 23, 5, 31, 4 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 23, 11, 23, 42 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "BinaryExpr", + "location" : [ 23, 11, 23, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 23, 11, 23, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + }, + "operator" : "<", + "right" : { + "kind" : "CallExpr", + "location" : [ 23, 15, 23, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 23, 15, 23, 17 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "len" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 23, 19, 23, 22 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "left" + } ] + } + }, + "operator" : "and", + "right" : { + "kind" : "BinaryExpr", + "location" : [ 23, 29, 23, 42 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 23, 29, 23, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "j" + }, + "operator" : "<", + "right" : { + "kind" : "CallExpr", + "location" : [ 23, 33, 23, 42 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 23, 33, 23, 35 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "len" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 23, 37, 23, 41 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "right" + } ] + } + } + }, + "body" : [ { + "kind" : "IfStmt", + "location" : [ 24, 9, 31, 4 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 24, 12, 24, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "IndexExpr", + "location" : [ 24, 12, 24, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 24, 12, 24, 15 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "left" + }, + "index" : { + "kind" : "Identifier", + "location" : [ 24, 17, 24, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + } + }, + "operator" : "<", + "right" : { + "kind" : "IndexExpr", + "location" : [ 24, 22, 24, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 24, 22, 24, 26 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "right" + }, + "index" : { + "kind" : "Identifier", + "location" : [ 24, 28, 24, 28 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "j" + } + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 25, 13, 25, 44 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 25, 13, 25, 18 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "merged" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 25, 22, 25, 44 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "function" : { + "kind" : "Identifier", + "location" : [ 25, 22, 25, 27 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + } + }, + "name" : "append" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 25, 29, 25, 34 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "merged" + }, { + "kind" : "IndexExpr", + "location" : [ 25, 37, 25, 43 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 25, 37, 25, 40 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "left" + }, + "index" : { + "kind" : "Identifier", + "location" : [ 25, 42, 25, 42 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + } + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 26, 13, 26, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 26, 13, 26, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 26, 17, 26, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 26, 17, 26, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 26, 21, 26, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ], + "elseBody" : [ { + "kind" : "AssignStmt", + "location" : [ 28, 13, 28, 45 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 28, 13, 28, 18 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "merged" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 28, 22, 28, 45 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "function" : { + "kind" : "Identifier", + "location" : [ 28, 22, 28, 27 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + } + }, + "name" : "append" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 28, 29, 28, 34 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "merged" + }, { + "kind" : "IndexExpr", + "location" : [ 28, 37, 28, 44 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 28, 37, 28, 41 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "right" + }, + "index" : { + "kind" : "Identifier", + "location" : [ 28, 43, 28, 43 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "j" + } + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 29, 13, 29, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 29, 13, 29, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "j" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 29, 17, 29, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 29, 17, 29, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "j" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 29, 21, 29, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ] + } ] + }, { + "kind" : "IfStmt", + "location" : [ 31, 5, 33, 4 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 31, 8, 31, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 31, 8, 31, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + }, + "operator" : "<", + "right" : { + "kind" : "CallExpr", + "location" : [ 31, 12, 31, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 31, 12, 31, 14 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "len" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 31, 16, 31, 19 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "left" + } ] + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 32, 9, 32, 51 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 32, 9, 32, 14 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "merged" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 32, 18, 32, 51 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "function" : { + "kind" : "Identifier", + "location" : [ 32, 18, 32, 23 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, { + "kind" : "ClassValueType", + "className" : "int" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + } + }, + "name" : "extend" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 32, 25, 32, 30 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "merged" + }, { + "kind" : "Identifier", + "location" : [ 32, 33, 32, 36 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "left" + }, { + "kind" : "Identifier", + "location" : [ 32, 39, 32, 39 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + }, { + "kind" : "CallExpr", + "location" : [ 32, 42, 32, 50 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 32, 42, 32, 44 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "len" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 32, 46, 32, 49 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "left" + } ] + } ] + } + } ], + "elseBody" : [ ] + }, { + "kind" : "IfStmt", + "location" : [ 33, 5, 36, 4 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 33, 8, 33, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 33, 8, 33, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "j" + }, + "operator" : "<", + "right" : { + "kind" : "CallExpr", + "location" : [ 33, 12, 33, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 33, 12, 33, 14 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "len" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 33, 16, 33, 20 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "right" + } ] + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 34, 9, 34, 53 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 34, 9, 34, 14 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "merged" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 34, 18, 34, 53 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "function" : { + "kind" : "Identifier", + "location" : [ 34, 18, 34, 23 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, { + "kind" : "ClassValueType", + "className" : "int" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + } + }, + "name" : "extend" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 34, 25, 34, 30 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "merged" + }, { + "kind" : "Identifier", + "location" : [ 34, 33, 34, 37 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "right" + }, { + "kind" : "Identifier", + "location" : [ 34, 40, 34, 40 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "j" + }, { + "kind" : "CallExpr", + "location" : [ 34, 43, 34, 52 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 34, 43, 34, 45 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "len" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 34, 47, 34, 51 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "right" + } ] + } ] + } + } ], + "elseBody" : [ ] + }, { + "kind" : "ReturnStmt", + "location" : [ 36, 5, 36, 17 ], + "value" : { + "kind" : "Identifier", + "location" : [ 36, 12, 36, 17 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "merged" + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 39, 1, 53, 30 ], + "name" : { + "kind" : "Identifier", + "location" : [ 39, 5, 39, 13 ], + "name" : "mergesort" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 39, 15, 39, 22 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 39, 15, 39, 15 ], + "name" : "a" + }, + "type" : { + "kind" : "ListType", + "location" : [ 39, 18, 39, 22 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 39, 19, 39, 21 ], + "className" : "int" + } + } + } ], + "returnType" : { + "kind" : "ListType", + "location" : [ 39, 28, 39, 32 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 39, 29, 39, 31 ], + "className" : "int" + } + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 40, 5, 40, 16 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 40, 5, 40, 12 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 40, 5, 40, 7 ], + "name" : "mid" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 40, 10, 40, 12 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 40, 16, 40, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 41, 5, 41, 22 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 41, 5, 41, 15 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 41, 5, 41, 8 ], + "name" : "left" + }, + "type" : { + "kind" : "ListType", + "location" : [ 41, 11, 41, 15 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 41, 12, 41, 14 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 41, 19, 41, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 42, 5, 42, 23 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 42, 5, 42, 16 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 42, 5, 42, 9 ], + "name" : "right" + }, + "type" : { + "kind" : "ListType", + "location" : [ 42, 12, 42, 16 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 42, 13, 42, 15 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 42, 20, 42, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 44, 5, 47, 4 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 44, 8, 44, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "CallExpr", + "location" : [ 44, 8, 44, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 44, 8, 44, 10 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "len" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 44, 12, 44, 12 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "a" + } ] + }, + "operator" : "<", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 44, 17, 44, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } + }, + "thenBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 45, 9, 45, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 45, 16, 45, 16 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "a" + } + } ], + "elseBody" : [ ] + }, { + "kind" : "AssignStmt", + "location" : [ 47, 5, 47, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 47, 5, 47, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "mid" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 47, 11, 47, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "CallExpr", + "location" : [ 47, 11, 47, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 47, 11, 47, 13 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "len" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 47, 15, 47, 15 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "a" + } ] + }, + "operator" : "//", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 47, 21, 47, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 48, 5, 48, 32 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 48, 5, 48, 8 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "left" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 48, 12, 48, 32 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "function" : { + "kind" : "Identifier", + "location" : [ 48, 12, 48, 17 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, { + "kind" : "ClassValueType", + "className" : "int" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + } + }, + "name" : "extend" + }, + "args" : [ { + "kind" : "ListExpr", + "location" : [ 48, 19, 48, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "elements" : [ ] + }, { + "kind" : "Identifier", + "location" : [ 48, 23, 48, 23 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "a" + }, { + "kind" : "IntegerLiteral", + "location" : [ 48, 26, 48, 26 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + }, { + "kind" : "Identifier", + "location" : [ 48, 29, 48, 31 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "mid" + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 49, 5, 49, 38 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 49, 5, 49, 9 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "right" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 49, 13, 49, 38 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "function" : { + "kind" : "Identifier", + "location" : [ 49, 13, 49, 18 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, { + "kind" : "ClassValueType", + "className" : "int" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + } + }, + "name" : "extend" + }, + "args" : [ { + "kind" : "ListExpr", + "location" : [ 49, 20, 49, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "elements" : [ ] + }, { + "kind" : "Identifier", + "location" : [ 49, 24, 49, 24 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "a" + }, { + "kind" : "Identifier", + "location" : [ 49, 27, 49, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "mid" + }, { + "kind" : "CallExpr", + "location" : [ 49, 32, 49, 37 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 49, 32, 49, 34 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "len" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 49, 36, 49, 36 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "a" + } ] + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 51, 5, 51, 26 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 51, 5, 51, 8 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "left" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 51, 12, 51, 26 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "function" : { + "kind" : "Identifier", + "location" : [ 51, 12, 51, 20 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + } + }, + "name" : "mergesort" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 51, 22, 51, 25 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "left" + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 52, 5, 52, 28 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 52, 5, 52, 9 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "right" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 52, 13, 52, 28 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "function" : { + "kind" : "Identifier", + "location" : [ 52, 13, 52, 21 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + } + }, + "name" : "mergesort" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 52, 23, 52, 27 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "right" + } ] + } + }, { + "kind" : "ReturnStmt", + "location" : [ 53, 5, 53, 29 ], + "value" : { + "kind" : "CallExpr", + "location" : [ 53, 12, 53, 29 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "function" : { + "kind" : "Identifier", + "location" : [ 53, 12, 53, 16 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + } + }, + "name" : "merge" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 53, 18, 53, 21 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "left" + }, { + "kind" : "Identifier", + "location" : [ 53, 24, 53, 28 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "right" + } ] + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 56, 1, 56, 21 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 56, 1, 56, 14 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 56, 1, 56, 7 ], + "name" : "initial" + }, + "type" : { + "kind" : "ListType", + "location" : [ 56, 10, 56, 14 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 56, 11, 56, 13 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 56, 18, 56, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 57, 1, 57, 21 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 57, 1, 57, 14 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 57, 1, 57, 7 ], + "name" : "ordered" + }, + "type" : { + "kind" : "ListType", + "location" : [ 57, 10, 57, 14 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 57, 11, 57, 13 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 57, 18, 57, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 59, 1, 59, 26 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 59, 1, 59, 7 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "initial" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 59, 11, 59, 26 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 59, 12, 59, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + }, { + "kind" : "IntegerLiteral", + "location" : [ 59, 15, 59, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 7 + }, { + "kind" : "IntegerLiteral", + "location" : [ 59, 18, 59, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + }, { + "kind" : "IntegerLiteral", + "location" : [ 59, 21, 59, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 11 + }, { + "kind" : "IntegerLiteral", + "location" : [ 59, 25, 59, 25 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 5 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 60, 1, 60, 28 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 60, 1, 60, 7 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "ordered" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 60, 11, 60, 28 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "function" : { + "kind" : "Identifier", + "location" : [ 60, 11, 60, 19 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + } + }, + "name" : "mergesort" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 60, 21, 60, 27 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "initial" + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 62, 1, 62, 14 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 62, 1, 62, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 62, 1, 62, 5 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, + "name" : "print" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 62, 7, 62, 13 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "ordered" + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/extra/nested.py b/pa2-tests/extra/nested.py new file mode 100644 index 0000000..b193ecd --- /dev/null +++ b/pa2-tests/extra/nested.py @@ -0,0 +1,18 @@ +class A(object): + a:int = 42 + + def foo(self:"A", ignore:object) -> int: + return self.a + +class B(A): + b:bool = True + + def __init__(self:"B"): + print("B") + + def bar(self:"B") -> int: + def qux(p: bool) -> int: + return self.foo(p) + return qux(True) + +print(B().bar()) diff --git a/pa2-tests/extra/nested.py.ast b/pa2-tests/extra/nested.py.ast new file mode 100644 index 0000000..4c8945a --- /dev/null +++ b/pa2-tests/extra/nested.py.ast @@ -0,0 +1,325 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 18, 17 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 7, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 14 ], + "value" : 42 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 22 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 11 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 13, 4, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 13, 4, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 18, 4, 20 ], + "className" : "A" + } + }, { + "kind" : "TypedVar", + "location" : [ 4, 23, 4, 35 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 23, 4, 28 ], + "name" : "ignore" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 30, 4, 35 ], + "className" : "object" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 41, 4, 43 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 9, 5, 21 ], + "value" : { + "kind" : "MemberExpr", + "location" : [ 5, 16, 5, 21 ], + "object" : { + "kind" : "Identifier", + "location" : [ 5, 16, 5, 19 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 5, 21, 5, 21 ], + "name" : "a" + } + } + } ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 7, 1, 18, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 7, 7, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 8, 5, 8, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 8, 5, 8, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 5, 8, 5 ], + "name" : "b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 7, 8, 10 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 8, 14, 8, 17 ], + "value" : true + } + }, { + "kind" : "FuncDef", + "location" : [ 10, 5, 11, 19 ], + "name" : { + "kind" : "Identifier", + "location" : [ 10, 9, 10, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 10, 18, 10, 25 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 10, 18, 10, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 10, 23, 10, 25 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 10, 27, 10, 27 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 11, 9, 11, 18 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 11, 9, 11, 18 ], + "function" : { + "kind" : "Identifier", + "location" : [ 11, 9, 11, 13 ], + "name" : "print" + }, + "args" : [ { + "kind" : "StringLiteral", + "location" : [ 11, 15, 11, 17 ], + "value" : "B" + } ] + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 13, 5, 16, 25 ], + "name" : { + "kind" : "Identifier", + "location" : [ 13, 9, 13, 11 ], + "name" : "bar" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 13, 13, 13, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 13, 13, 13, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 13, 18, 13, 20 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 13, 26, 13, 28 ], + "className" : "int" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 14, 9, 15, 31 ], + "name" : { + "kind" : "Identifier", + "location" : [ 14, 13, 14, 15 ], + "name" : "qux" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 14, 17, 14, 23 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 14, 17, 14, 17 ], + "name" : "p" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 14, 20, 14, 23 ], + "className" : "bool" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 14, 29, 14, 31 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 15, 13, 15, 30 ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 15, 20, 15, 30 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 15, 20, 15, 27 ], + "object" : { + "kind" : "Identifier", + "location" : [ 15, 20, 15, 23 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 15, 25, 15, 27 ], + "name" : "foo" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 15, 29, 15, 29 ], + "name" : "p" + } ] + } + } ] + } ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 16, 9, 16, 24 ], + "value" : { + "kind" : "CallExpr", + "location" : [ 16, 16, 16, 24 ], + "function" : { + "kind" : "Identifier", + "location" : [ 16, 16, 16, 18 ], + "name" : "qux" + }, + "args" : [ { + "kind" : "BooleanLiteral", + "location" : [ 16, 20, 16, 23 ], + "value" : true + } ] + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 18, 1, 18, 16 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 18, 1, 18, 16 ], + "function" : { + "kind" : "Identifier", + "location" : [ 18, 1, 18, 5 ], + "name" : "print" + }, + "args" : [ { + "kind" : "MethodCallExpr", + "location" : [ 18, 7, 18, 15 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 18, 7, 18, 13 ], + "object" : { + "kind" : "CallExpr", + "location" : [ 18, 7, 18, 9 ], + "function" : { + "kind" : "Identifier", + "location" : [ 18, 7, 18, 7 ], + "name" : "B" + }, + "args" : [ ] + }, + "member" : { + "kind" : "Identifier", + "location" : [ 18, 11, 18, 13 ], + "name" : "bar" + } + }, + "args" : [ ] + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/extra/nested.py.ast.typed b/pa2-tests/extra/nested.py.ast.typed new file mode 100644 index 0000000..5480892 --- /dev/null +++ b/pa2-tests/extra/nested.py.ast.typed @@ -0,0 +1,439 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 18, 17 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 7, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 42 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 22 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 11 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 13, 4, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 13, 4, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 18, 4, 20 ], + "className" : "A" + } + }, { + "kind" : "TypedVar", + "location" : [ 4, 23, 4, 35 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 23, 4, 28 ], + "name" : "ignore" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 30, 4, 35 ], + "className" : "object" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 41, 4, 43 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 9, 5, 21 ], + "value" : { + "kind" : "MemberExpr", + "location" : [ 5, 16, 5, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 5, 16, 5, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 5, 21, 5, 21 ], + "name" : "a" + } + } + } ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 7, 1, 18, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 7, 7, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 8, 5, 8, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 8, 5, 8, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 5, 8, 5 ], + "name" : "b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 7, 8, 10 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 8, 14, 8, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + }, { + "kind" : "FuncDef", + "location" : [ 10, 5, 11, 19 ], + "name" : { + "kind" : "Identifier", + "location" : [ 10, 9, 10, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 10, 18, 10, 25 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 10, 18, 10, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 10, 23, 10, 25 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 10, 27, 10, 27 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 11, 9, 11, 18 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 11, 9, 11, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 11, 9, 11, 13 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, + "name" : "print" + }, + "args" : [ { + "kind" : "StringLiteral", + "location" : [ 11, 15, 11, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "B" + } ] + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 13, 5, 16, 25 ], + "name" : { + "kind" : "Identifier", + "location" : [ 13, 9, 13, 11 ], + "name" : "bar" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 13, 13, 13, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 13, 13, 13, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 13, 18, 13, 20 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 13, 26, 13, 28 ], + "className" : "int" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 14, 9, 15, 31 ], + "name" : { + "kind" : "Identifier", + "location" : [ 14, 13, 14, 15 ], + "name" : "qux" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 14, 17, 14, 23 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 14, 17, 14, 17 ], + "name" : "p" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 14, 20, 14, 23 ], + "className" : "bool" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 14, 29, 14, 31 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 15, 13, 15, 30 ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 15, 20, 15, 30 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 15, 20, 15, 27 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "A" + }, { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 15, 20, 15, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 15, 25, 15, 27 ], + "name" : "foo" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 15, 29, 15, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "name" : "p" + } ] + } + } ] + } ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 16, 9, 16, 24 ], + "value" : { + "kind" : "CallExpr", + "location" : [ 16, 16, 16, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 16, 16, 16, 18 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "bool" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "qux" + }, + "args" : [ { + "kind" : "BooleanLiteral", + "location" : [ 16, 20, 16, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } ] + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 18, 1, 18, 16 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 18, 1, 18, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 18, 1, 18, 5 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, + "name" : "print" + }, + "args" : [ { + "kind" : "MethodCallExpr", + "location" : [ 18, 7, 18, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 18, 7, 18, 13 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "B" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "CallExpr", + "location" : [ 18, 7, 18, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 18, 7, 18, 7 ], + "name" : "B" + }, + "args" : [ ] + }, + "member" : { + "kind" : "Identifier", + "location" : [ 18, 11, 18, 13 ], + "name" : "bar" + } + }, + "args" : [ ] + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/extra/prime.py b/pa2-tests/extra/prime.py new file mode 100644 index 0000000..7568705 --- /dev/null +++ b/pa2-tests/extra/prime.py @@ -0,0 +1,30 @@ +# Get the n-th prime starting from 2 +def get_prime(n:int) -> int: + candidate:int = 2 + found:int = 0 + while True: + if is_prime(candidate): + found = found + 1 + if found == n: + return candidate + candidate = candidate + 1 + return 0 # Never happens + +def is_prime(x:int) -> bool: + div:int = 2 + while div < x: + if x % div == 0: + return False + div = div + 1 + return True + +# Input parameter +n:int = 15 + +# Run [1, n] +i:int = 1 + +# Crunch +while i <= n: + print(get_prime(i)) + i = i + 1 diff --git a/pa2-tests/extra/prime.py.ast b/pa2-tests/extra/prime.py.ast new file mode 100644 index 0000000..209c50c --- /dev/null +++ b/pa2-tests/extra/prime.py.ast @@ -0,0 +1,445 @@ +{ + "kind" : "Program", + "location" : [ 2, 1, 31, 1 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 2, 1, 11, 29 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 13 ], + "name" : "get_prime" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 2, 15, 2, 19 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 15, 2, 15 ], + "name" : "n" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 17, 2, 19 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 2, 25, 2, 27 ], + "className" : "int" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 3, 5, 3, 21 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 5, 3, 17 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 13 ], + "name" : "candidate" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 15, 3, 17 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 21, 3, 21 ], + "value" : 2 + } + }, { + "kind" : "VarDef", + "location" : [ 4, 5, 4, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 5, 4, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 9 ], + "name" : "found" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 11, 4, 13 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 17, 4, 17 ], + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "WhileStmt", + "location" : [ 5, 5, 11, 4 ], + "condition" : { + "kind" : "BooleanLiteral", + "location" : [ 5, 11, 5, 14 ], + "value" : true + }, + "body" : [ { + "kind" : "IfStmt", + "location" : [ 6, 9, 10, 8 ], + "condition" : { + "kind" : "CallExpr", + "location" : [ 6, 12, 6, 30 ], + "function" : { + "kind" : "Identifier", + "location" : [ 6, 12, 6, 19 ], + "name" : "is_prime" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 6, 21, 6, 29 ], + "name" : "candidate" + } ] + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 7, 13, 7, 29 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 13, 7, 17 ], + "name" : "found" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 7, 21, 7, 29 ], + "left" : { + "kind" : "Identifier", + "location" : [ 7, 21, 7, 25 ], + "name" : "found" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 29, 7, 29 ], + "value" : 1 + } + } + }, { + "kind" : "IfStmt", + "location" : [ 8, 13, 10, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 8, 16, 8, 25 ], + "left" : { + "kind" : "Identifier", + "location" : [ 8, 16, 8, 20 ], + "name" : "found" + }, + "operator" : "==", + "right" : { + "kind" : "Identifier", + "location" : [ 8, 25, 8, 25 ], + "name" : "n" + } + }, + "thenBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 9, 17, 9, 32 ], + "value" : { + "kind" : "Identifier", + "location" : [ 9, 24, 9, 32 ], + "name" : "candidate" + } + } ], + "elseBody" : [ ] + } ], + "elseBody" : [ ] + }, { + "kind" : "AssignStmt", + "location" : [ 10, 9, 10, 33 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 10, 9, 10, 17 ], + "name" : "candidate" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 10, 21, 10, 33 ], + "left" : { + "kind" : "Identifier", + "location" : [ 10, 21, 10, 29 ], + "name" : "candidate" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 10, 33, 10, 33 ], + "value" : 1 + } + } + } ] + }, { + "kind" : "ReturnStmt", + "location" : [ 11, 5, 11, 12 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 11, 12, 11, 12 ], + "value" : 0 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 13, 1, 19, 16 ], + "name" : { + "kind" : "Identifier", + "location" : [ 13, 5, 13, 12 ], + "name" : "is_prime" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 13, 14, 13, 18 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 13, 14, 13, 14 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 13, 16, 13, 18 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 13, 24, 13, 27 ], + "className" : "bool" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 14, 5, 14, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 14, 5, 14, 11 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 14, 5, 14, 7 ], + "name" : "div" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 14, 9, 14, 11 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 14, 15, 14, 15 ], + "value" : 2 + } + } ], + "statements" : [ { + "kind" : "WhileStmt", + "location" : [ 15, 5, 19, 4 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 15, 11, 15, 17 ], + "left" : { + "kind" : "Identifier", + "location" : [ 15, 11, 15, 13 ], + "name" : "div" + }, + "operator" : "<", + "right" : { + "kind" : "Identifier", + "location" : [ 15, 17, 15, 17 ], + "name" : "x" + } + }, + "body" : [ { + "kind" : "IfStmt", + "location" : [ 16, 9, 18, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 16, 12, 16, 23 ], + "left" : { + "kind" : "BinaryExpr", + "location" : [ 16, 12, 16, 18 ], + "left" : { + "kind" : "Identifier", + "location" : [ 16, 12, 16, 12 ], + "name" : "x" + }, + "operator" : "%", + "right" : { + "kind" : "Identifier", + "location" : [ 16, 16, 16, 18 ], + "name" : "div" + } + }, + "operator" : "==", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 16, 23, 16, 23 ], + "value" : 0 + } + }, + "thenBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 17, 13, 17, 24 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 17, 20, 17, 24 ], + "value" : false + } + } ], + "elseBody" : [ ] + }, { + "kind" : "AssignStmt", + "location" : [ 18, 9, 18, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 18, 9, 18, 11 ], + "name" : "div" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 18, 15, 18, 21 ], + "left" : { + "kind" : "Identifier", + "location" : [ 18, 15, 18, 17 ], + "name" : "div" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 18, 21, 18, 21 ], + "value" : 1 + } + } + } ] + }, { + "kind" : "ReturnStmt", + "location" : [ 19, 5, 19, 15 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 19, 12, 19, 15 ], + "value" : true + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 22, 1, 22, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 22, 1, 22, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 22, 1, 22, 1 ], + "name" : "n" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 22, 3, 22, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 22, 9, 22, 10 ], + "value" : 15 + } + }, { + "kind" : "VarDef", + "location" : [ 25, 1, 25, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 25, 1, 25, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 25, 1, 25, 1 ], + "name" : "i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 25, 3, 25, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 25, 9, 25, 9 ], + "value" : 1 + } + } ], + "statements" : [ { + "kind" : "WhileStmt", + "location" : [ 28, 1, 31, 1 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 28, 7, 28, 12 ], + "left" : { + "kind" : "Identifier", + "location" : [ 28, 7, 28, 7 ], + "name" : "i" + }, + "operator" : "<=", + "right" : { + "kind" : "Identifier", + "location" : [ 28, 12, 28, 12 ], + "name" : "n" + } + }, + "body" : [ { + "kind" : "ExprStmt", + "location" : [ 29, 5, 29, 23 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 29, 5, 29, 23 ], + "function" : { + "kind" : "Identifier", + "location" : [ 29, 5, 29, 9 ], + "name" : "print" + }, + "args" : [ { + "kind" : "CallExpr", + "location" : [ 29, 11, 29, 22 ], + "function" : { + "kind" : "Identifier", + "location" : [ 29, 11, 29, 19 ], + "name" : "get_prime" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 29, 21, 29, 21 ], + "name" : "i" + } ] + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 30, 5, 30, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 30, 5, 30, 5 ], + "name" : "i" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 30, 9, 30, 13 ], + "left" : { + "kind" : "Identifier", + "location" : [ 30, 9, 30, 9 ], + "name" : "i" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 30, 13, 30, 13 ], + "value" : 1 + } + } + } ] + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/extra/prime.py.ast.typed b/pa2-tests/extra/prime.py.ast.typed new file mode 100644 index 0000000..a3062b6 --- /dev/null +++ b/pa2-tests/extra/prime.py.ast.typed @@ -0,0 +1,658 @@ +{ + "kind" : "Program", + "location" : [ 2, 1, 31, 1 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 2, 1, 11, 29 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 13 ], + "name" : "get_prime" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 2, 15, 2, 19 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 15, 2, 15 ], + "name" : "n" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 17, 2, 19 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 2, 25, 2, 27 ], + "className" : "int" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 3, 5, 3, 21 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 5, 3, 17 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 13 ], + "name" : "candidate" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 15, 3, 17 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 21, 3, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } + }, { + "kind" : "VarDef", + "location" : [ 4, 5, 4, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 5, 4, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 9 ], + "name" : "found" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 11, 4, 13 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 17, 4, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "WhileStmt", + "location" : [ 5, 5, 11, 4 ], + "condition" : { + "kind" : "BooleanLiteral", + "location" : [ 5, 11, 5, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + }, + "body" : [ { + "kind" : "IfStmt", + "location" : [ 6, 9, 10, 8 ], + "condition" : { + "kind" : "CallExpr", + "location" : [ 6, 12, 6, 30 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 6, 12, 6, 19 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "bool" + } + }, + "name" : "is_prime" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 6, 21, 6, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "candidate" + } ] + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 7, 13, 7, 29 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 13, 7, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "found" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 7, 21, 7, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 7, 21, 7, 25 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "found" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 29, 7, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + }, { + "kind" : "IfStmt", + "location" : [ 8, 13, 10, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 8, 16, 8, 25 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 8, 16, 8, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "found" + }, + "operator" : "==", + "right" : { + "kind" : "Identifier", + "location" : [ 8, 25, 8, 25 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "n" + } + }, + "thenBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 9, 17, 9, 32 ], + "value" : { + "kind" : "Identifier", + "location" : [ 9, 24, 9, 32 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "candidate" + } + } ], + "elseBody" : [ ] + } ], + "elseBody" : [ ] + }, { + "kind" : "AssignStmt", + "location" : [ 10, 9, 10, 33 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 10, 9, 10, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "candidate" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 10, 21, 10, 33 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 10, 21, 10, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "candidate" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 10, 33, 10, 33 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ] + }, { + "kind" : "ReturnStmt", + "location" : [ 11, 5, 11, 12 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 11, 12, 11, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 13, 1, 19, 16 ], + "name" : { + "kind" : "Identifier", + "location" : [ 13, 5, 13, 12 ], + "name" : "is_prime" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 13, 14, 13, 18 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 13, 14, 13, 14 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 13, 16, 13, 18 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 13, 24, 13, 27 ], + "className" : "bool" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 14, 5, 14, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 14, 5, 14, 11 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 14, 5, 14, 7 ], + "name" : "div" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 14, 9, 14, 11 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 14, 15, 14, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } + } ], + "statements" : [ { + "kind" : "WhileStmt", + "location" : [ 15, 5, 19, 4 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 15, 11, 15, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 15, 11, 15, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "div" + }, + "operator" : "<", + "right" : { + "kind" : "Identifier", + "location" : [ 15, 17, 15, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } + }, + "body" : [ { + "kind" : "IfStmt", + "location" : [ 16, 9, 18, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 16, 12, 16, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "BinaryExpr", + "location" : [ 16, 12, 16, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 16, 12, 16, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "operator" : "%", + "right" : { + "kind" : "Identifier", + "location" : [ 16, 16, 16, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "div" + } + }, + "operator" : "==", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 16, 23, 16, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, + "thenBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 17, 13, 17, 24 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 17, 20, 17, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } + } ], + "elseBody" : [ ] + }, { + "kind" : "AssignStmt", + "location" : [ 18, 9, 18, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 18, 9, 18, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "div" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 18, 15, 18, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 18, 15, 18, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "div" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 18, 21, 18, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ] + }, { + "kind" : "ReturnStmt", + "location" : [ 19, 5, 19, 15 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 19, 12, 19, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 22, 1, 22, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 22, 1, 22, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 22, 1, 22, 1 ], + "name" : "n" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 22, 3, 22, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 22, 9, 22, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 15 + } + }, { + "kind" : "VarDef", + "location" : [ 25, 1, 25, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 25, 1, 25, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 25, 1, 25, 1 ], + "name" : "i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 25, 3, 25, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 25, 9, 25, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ], + "statements" : [ { + "kind" : "WhileStmt", + "location" : [ 28, 1, 31, 1 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 28, 7, 28, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 28, 7, 28, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + }, + "operator" : "<=", + "right" : { + "kind" : "Identifier", + "location" : [ 28, 12, 28, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "n" + } + }, + "body" : [ { + "kind" : "ExprStmt", + "location" : [ 29, 5, 29, 23 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 29, 5, 29, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 29, 5, 29, 9 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, + "name" : "print" + }, + "args" : [ { + "kind" : "CallExpr", + "location" : [ 29, 11, 29, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 29, 11, 29, 19 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "get_prime" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 29, 21, 29, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + } ] + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 30, 5, 30, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 30, 5, 30, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 30, 9, 30, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 30, 9, 30, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 30, 13, 30, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ] + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/extra/sieve.py b/pa2-tests/extra/sieve.py new file mode 100644 index 0000000..b6aa977 --- /dev/null +++ b/pa2-tests/extra/sieve.py @@ -0,0 +1,107 @@ +# A resizable list of integers +class Vector(object): + items: [int] = None + size: int = 0 + + def __init__(self:"Vector"): + self.items = [0] + + # Returns current capacity + def capacity(self:"Vector") -> int: + return len(self.items) + + # Increases capacity of vector by one element + def increase_capacity(self:"Vector") -> int: + self.items = self.items + [0] + return self.capacity() + + # Appends one item to end of vector + def append(self:"Vector", item: int) -> object: + if self.size == self.capacity(): + self.increase_capacity() + + self.items[self.size] = item + self.size = self.size + 1 + + # Appends many items to end of vector + def append_all(self:"Vector", new_items: [int]) -> object: + item:int = 0 + for item in new_items: + self.append(item) + + # Removes an item from the middle of vector + def remove_at(self:"Vector", idx: int) -> object: + if idx < 0: + return + + while idx < self.size - 1: + self.items[idx] = self.items[idx + 1] + idx = idx + 1 + + self.size = self.size - 1 + + # Retrieves an item at a given index + def get(self:"Vector", idx: int) -> int: + return self.items[idx] + + # Retrieves the current size of the vector + def length(self:"Vector") -> int: + return self.size + +# A faster (but more memory-consuming) implementation of vector +class DoublingVector(Vector): + doubling_limit:int = 1000 + + # Overriding to do fewer resizes + def increase_capacity(self:"DoublingVector") -> int: + if (self.capacity() <= self.doubling_limit // 2): + self.items = self.items + self.items + else: + # If doubling limit has been reached, fall back to + # standard capacity increases + self.items = self.items + [0] + return self.capacity() + +# Makes a vector in the range [i, j) +def vrange(i:int, j:int) -> Vector: + v:Vector = None + v = DoublingVector() + + while i < j: + v.append(i) + i = i + 1 + + return v + +# Sieve of Eratosthenes (not really) +def sieve(v:Vector) -> object: + i:int = 0 + j:int = 0 + k:int = 0 + + while i < v.length(): + k = v.get(i) + j = i + 1 + while j < v.length(): + if v.get(j) % k == 0: + v.remove_at(j) + else: + j = j + 1 + i = i + 1 + +# Input parameter +n:int = 50 + +# Data +v:Vector = None +i:int = 0 + +# Crunch +v = vrange(2, n) +sieve(v) + +# Print +while i < v.length(): + print(v.get(i)) + i = i + 1 + diff --git a/pa2-tests/extra/sieve.py.ast b/pa2-tests/extra/sieve.py.ast new file mode 100644 index 0000000..82bad46 --- /dev/null +++ b/pa2-tests/extra/sieve.py.ast @@ -0,0 +1,1841 @@ +{ + "kind" : "Program", + "location" : [ 2, 1, 108, 1 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 2, 1, 52, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 7, 2, 12 ], + "name" : "Vector" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 2, 14, 2, 19 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 3, 5, 3, 23 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 5, 3, 16 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 9 ], + "name" : "items" + }, + "type" : { + "kind" : "ListType", + "location" : [ 3, 12, 3, 16 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 3, 13, 3, 15 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 3, 20, 3, 23 ] + } + }, { + "kind" : "VarDef", + "location" : [ 4, 5, 4, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 5, 4, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 8 ], + "name" : "size" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 11, 4, 13 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 17, 4, 17 ], + "value" : 0 + } + }, { + "kind" : "FuncDef", + "location" : [ 6, 5, 7, 25 ], + "name" : { + "kind" : "Identifier", + "location" : [ 6, 9, 6, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 6, 18, 6, 30 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 18, 6, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 23, 6, 30 ], + "className" : "Vector" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 6, 32, 6, 32 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 7, 9, 7, 24 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 7, 9, 7, 18 ], + "object" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 12 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 7, 14, 7, 18 ], + "name" : "items" + } + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 7, 22, 7, 24 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 7, 23, 7, 23 ], + "value" : 0 + } ] + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 10, 5, 11, 31 ], + "name" : { + "kind" : "Identifier", + "location" : [ 10, 9, 10, 16 ], + "name" : "capacity" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 10, 18, 10, 30 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 10, 18, 10, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 10, 23, 10, 30 ], + "className" : "Vector" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 10, 36, 10, 38 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 11, 9, 11, 30 ], + "value" : { + "kind" : "CallExpr", + "location" : [ 11, 16, 11, 30 ], + "function" : { + "kind" : "Identifier", + "location" : [ 11, 16, 11, 18 ], + "name" : "len" + }, + "args" : [ { + "kind" : "MemberExpr", + "location" : [ 11, 20, 11, 29 ], + "object" : { + "kind" : "Identifier", + "location" : [ 11, 20, 11, 23 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 11, 25, 11, 29 ], + "name" : "items" + } + } ] + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 14, 5, 16, 31 ], + "name" : { + "kind" : "Identifier", + "location" : [ 14, 9, 14, 25 ], + "name" : "increase_capacity" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 14, 27, 14, 39 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 14, 27, 14, 30 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 14, 32, 14, 39 ], + "className" : "Vector" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 14, 45, 14, 47 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 15, 9, 15, 37 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 15, 9, 15, 18 ], + "object" : { + "kind" : "Identifier", + "location" : [ 15, 9, 15, 12 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 15, 14, 15, 18 ], + "name" : "items" + } + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 15, 22, 15, 37 ], + "left" : { + "kind" : "MemberExpr", + "location" : [ 15, 22, 15, 31 ], + "object" : { + "kind" : "Identifier", + "location" : [ 15, 22, 15, 25 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 15, 27, 15, 31 ], + "name" : "items" + } + }, + "operator" : "+", + "right" : { + "kind" : "ListExpr", + "location" : [ 15, 35, 15, 37 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 15, 36, 15, 36 ], + "value" : 0 + } ] + } + } + }, { + "kind" : "ReturnStmt", + "location" : [ 16, 9, 16, 30 ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 16, 16, 16, 30 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 16, 16, 16, 28 ], + "object" : { + "kind" : "Identifier", + "location" : [ 16, 16, 16, 19 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 16, 21, 16, 28 ], + "name" : "capacity" + } + }, + "args" : [ ] + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 19, 5, 24, 34 ], + "name" : { + "kind" : "Identifier", + "location" : [ 19, 9, 19, 14 ], + "name" : "append" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 19, 16, 19, 28 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 19, 16, 19, 19 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 19, 21, 19, 28 ], + "className" : "Vector" + } + }, { + "kind" : "TypedVar", + "location" : [ 19, 31, 19, 39 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 19, 31, 19, 34 ], + "name" : "item" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 19, 37, 19, 39 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 19, 45, 19, 50 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 20, 9, 23, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 20, 12, 20, 39 ], + "left" : { + "kind" : "MemberExpr", + "location" : [ 20, 12, 20, 20 ], + "object" : { + "kind" : "Identifier", + "location" : [ 20, 12, 20, 15 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 20, 17, 20, 20 ], + "name" : "size" + } + }, + "operator" : "==", + "right" : { + "kind" : "MethodCallExpr", + "location" : [ 20, 25, 20, 39 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 20, 25, 20, 37 ], + "object" : { + "kind" : "Identifier", + "location" : [ 20, 25, 20, 28 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 20, 30, 20, 37 ], + "name" : "capacity" + } + }, + "args" : [ ] + } + }, + "thenBody" : [ { + "kind" : "ExprStmt", + "location" : [ 21, 13, 21, 36 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 21, 13, 21, 36 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 21, 13, 21, 34 ], + "object" : { + "kind" : "Identifier", + "location" : [ 21, 13, 21, 16 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 21, 18, 21, 34 ], + "name" : "increase_capacity" + } + }, + "args" : [ ] + } + } ], + "elseBody" : [ ] + }, { + "kind" : "AssignStmt", + "location" : [ 23, 9, 23, 36 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 23, 9, 23, 29 ], + "list" : { + "kind" : "MemberExpr", + "location" : [ 23, 9, 23, 18 ], + "object" : { + "kind" : "Identifier", + "location" : [ 23, 9, 23, 12 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 23, 14, 23, 18 ], + "name" : "items" + } + }, + "index" : { + "kind" : "MemberExpr", + "location" : [ 23, 20, 23, 28 ], + "object" : { + "kind" : "Identifier", + "location" : [ 23, 20, 23, 23 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 23, 25, 23, 28 ], + "name" : "size" + } + } + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 23, 33, 23, 36 ], + "name" : "item" + } + }, { + "kind" : "AssignStmt", + "location" : [ 24, 9, 24, 33 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 24, 9, 24, 17 ], + "object" : { + "kind" : "Identifier", + "location" : [ 24, 9, 24, 12 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 24, 14, 24, 17 ], + "name" : "size" + } + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 24, 21, 24, 33 ], + "left" : { + "kind" : "MemberExpr", + "location" : [ 24, 21, 24, 29 ], + "object" : { + "kind" : "Identifier", + "location" : [ 24, 21, 24, 24 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 24, 26, 24, 29 ], + "name" : "size" + } + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 24, 33, 24, 33 ], + "value" : 1 + } + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 27, 5, 33, 4 ], + "name" : { + "kind" : "Identifier", + "location" : [ 27, 9, 27, 18 ], + "name" : "append_all" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 27, 20, 27, 32 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 27, 20, 27, 23 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 27, 25, 27, 32 ], + "className" : "Vector" + } + }, { + "kind" : "TypedVar", + "location" : [ 27, 35, 27, 50 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 27, 35, 27, 43 ], + "name" : "new_items" + }, + "type" : { + "kind" : "ListType", + "location" : [ 27, 46, 27, 50 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 27, 47, 27, 49 ], + "className" : "int" + } + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 27, 56, 27, 61 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 28, 9, 28, 20 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 28, 9, 28, 16 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 28, 9, 28, 12 ], + "name" : "item" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 28, 14, 28, 16 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 28, 20, 28, 20 ], + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "ForStmt", + "location" : [ 29, 9, 33, 4 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 29, 13, 29, 16 ], + "name" : "item" + }, + "iterable" : { + "kind" : "Identifier", + "location" : [ 29, 21, 29, 29 ], + "name" : "new_items" + }, + "body" : [ { + "kind" : "ExprStmt", + "location" : [ 30, 13, 30, 29 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 30, 13, 30, 29 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 30, 13, 30, 23 ], + "object" : { + "kind" : "Identifier", + "location" : [ 30, 13, 30, 16 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 30, 18, 30, 23 ], + "name" : "append" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 30, 25, 30, 28 ], + "name" : "item" + } ] + } + } ] + } ] + }, { + "kind" : "FuncDef", + "location" : [ 33, 5, 41, 34 ], + "name" : { + "kind" : "Identifier", + "location" : [ 33, 9, 33, 17 ], + "name" : "remove_at" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 33, 19, 33, 31 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 33, 19, 33, 22 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 33, 24, 33, 31 ], + "className" : "Vector" + } + }, { + "kind" : "TypedVar", + "location" : [ 33, 34, 33, 41 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 33, 34, 33, 36 ], + "name" : "idx" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 33, 39, 33, 41 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 33, 47, 33, 52 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 34, 9, 37, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 34, 12, 34, 18 ], + "left" : { + "kind" : "Identifier", + "location" : [ 34, 12, 34, 14 ], + "name" : "idx" + }, + "operator" : "<", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 34, 18, 34, 18 ], + "value" : 0 + } + }, + "thenBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 35, 13, 35, 18 ], + "value" : null + } ], + "elseBody" : [ ] + }, { + "kind" : "WhileStmt", + "location" : [ 37, 9, 41, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 37, 15, 37, 33 ], + "left" : { + "kind" : "Identifier", + "location" : [ 37, 15, 37, 17 ], + "name" : "idx" + }, + "operator" : "<", + "right" : { + "kind" : "BinaryExpr", + "location" : [ 37, 21, 37, 33 ], + "left" : { + "kind" : "MemberExpr", + "location" : [ 37, 21, 37, 29 ], + "object" : { + "kind" : "Identifier", + "location" : [ 37, 21, 37, 24 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 37, 26, 37, 29 ], + "name" : "size" + } + }, + "operator" : "-", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 37, 33, 37, 33 ], + "value" : 1 + } + } + }, + "body" : [ { + "kind" : "AssignStmt", + "location" : [ 38, 13, 38, 49 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 38, 13, 38, 27 ], + "list" : { + "kind" : "MemberExpr", + "location" : [ 38, 13, 38, 22 ], + "object" : { + "kind" : "Identifier", + "location" : [ 38, 13, 38, 16 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 38, 18, 38, 22 ], + "name" : "items" + } + }, + "index" : { + "kind" : "Identifier", + "location" : [ 38, 24, 38, 26 ], + "name" : "idx" + } + } ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 38, 31, 38, 49 ], + "list" : { + "kind" : "MemberExpr", + "location" : [ 38, 31, 38, 40 ], + "object" : { + "kind" : "Identifier", + "location" : [ 38, 31, 38, 34 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 38, 36, 38, 40 ], + "name" : "items" + } + }, + "index" : { + "kind" : "BinaryExpr", + "location" : [ 38, 42, 38, 48 ], + "left" : { + "kind" : "Identifier", + "location" : [ 38, 42, 38, 44 ], + "name" : "idx" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 38, 48, 38, 48 ], + "value" : 1 + } + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 39, 13, 39, 25 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 39, 13, 39, 15 ], + "name" : "idx" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 39, 19, 39, 25 ], + "left" : { + "kind" : "Identifier", + "location" : [ 39, 19, 39, 21 ], + "name" : "idx" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 39, 25, 39, 25 ], + "value" : 1 + } + } + } ] + }, { + "kind" : "AssignStmt", + "location" : [ 41, 9, 41, 33 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 41, 9, 41, 17 ], + "object" : { + "kind" : "Identifier", + "location" : [ 41, 9, 41, 12 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 41, 14, 41, 17 ], + "name" : "size" + } + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 41, 21, 41, 33 ], + "left" : { + "kind" : "MemberExpr", + "location" : [ 41, 21, 41, 29 ], + "object" : { + "kind" : "Identifier", + "location" : [ 41, 21, 41, 24 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 41, 26, 41, 29 ], + "name" : "size" + } + }, + "operator" : "-", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 41, 33, 41, 33 ], + "value" : 1 + } + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 44, 5, 45, 31 ], + "name" : { + "kind" : "Identifier", + "location" : [ 44, 9, 44, 11 ], + "name" : "get" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 44, 13, 44, 25 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 44, 13, 44, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 44, 18, 44, 25 ], + "className" : "Vector" + } + }, { + "kind" : "TypedVar", + "location" : [ 44, 28, 44, 35 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 44, 28, 44, 30 ], + "name" : "idx" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 44, 33, 44, 35 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 44, 41, 44, 43 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 45, 9, 45, 30 ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 45, 16, 45, 30 ], + "list" : { + "kind" : "MemberExpr", + "location" : [ 45, 16, 45, 25 ], + "object" : { + "kind" : "Identifier", + "location" : [ 45, 16, 45, 19 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 45, 21, 45, 25 ], + "name" : "items" + } + }, + "index" : { + "kind" : "Identifier", + "location" : [ 45, 27, 45, 29 ], + "name" : "idx" + } + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 48, 5, 49, 25 ], + "name" : { + "kind" : "Identifier", + "location" : [ 48, 9, 48, 14 ], + "name" : "length" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 48, 16, 48, 28 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 48, 16, 48, 19 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 48, 21, 48, 28 ], + "className" : "Vector" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 48, 34, 48, 36 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 49, 9, 49, 24 ], + "value" : { + "kind" : "MemberExpr", + "location" : [ 49, 16, 49, 24 ], + "object" : { + "kind" : "Identifier", + "location" : [ 49, 16, 49, 19 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 49, 21, 49, 24 ], + "name" : "size" + } + } + } ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 52, 1, 66, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 52, 7, 52, 20 ], + "name" : "DoublingVector" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 52, 22, 52, 27 ], + "name" : "Vector" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 53, 5, 53, 29 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 53, 5, 53, 22 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 53, 5, 53, 18 ], + "name" : "doubling_limit" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 53, 20, 53, 22 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 53, 26, 53, 29 ], + "value" : 1000 + } + }, { + "kind" : "FuncDef", + "location" : [ 56, 5, 63, 31 ], + "name" : { + "kind" : "Identifier", + "location" : [ 56, 9, 56, 25 ], + "name" : "increase_capacity" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 56, 27, 56, 47 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 56, 27, 56, 30 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 56, 32, 56, 47 ], + "className" : "DoublingVector" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 56, 53, 56, 55 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 57, 9, 63, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 57, 13, 57, 55 ], + "left" : { + "kind" : "MethodCallExpr", + "location" : [ 57, 13, 57, 27 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 57, 13, 57, 25 ], + "object" : { + "kind" : "Identifier", + "location" : [ 57, 13, 57, 16 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 57, 18, 57, 25 ], + "name" : "capacity" + } + }, + "args" : [ ] + }, + "operator" : "<=", + "right" : { + "kind" : "BinaryExpr", + "location" : [ 57, 32, 57, 55 ], + "left" : { + "kind" : "MemberExpr", + "location" : [ 57, 32, 57, 50 ], + "object" : { + "kind" : "Identifier", + "location" : [ 57, 32, 57, 35 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 57, 37, 57, 50 ], + "name" : "doubling_limit" + } + }, + "operator" : "//", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 57, 55, 57, 55 ], + "value" : 2 + } + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 58, 13, 58, 48 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 58, 13, 58, 22 ], + "object" : { + "kind" : "Identifier", + "location" : [ 58, 13, 58, 16 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 58, 18, 58, 22 ], + "name" : "items" + } + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 58, 26, 58, 48 ], + "left" : { + "kind" : "MemberExpr", + "location" : [ 58, 26, 58, 35 ], + "object" : { + "kind" : "Identifier", + "location" : [ 58, 26, 58, 29 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 58, 31, 58, 35 ], + "name" : "items" + } + }, + "operator" : "+", + "right" : { + "kind" : "MemberExpr", + "location" : [ 58, 39, 58, 48 ], + "object" : { + "kind" : "Identifier", + "location" : [ 58, 39, 58, 42 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 58, 44, 58, 48 ], + "name" : "items" + } + } + } + } ], + "elseBody" : [ { + "kind" : "AssignStmt", + "location" : [ 62, 13, 62, 41 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 62, 13, 62, 22 ], + "object" : { + "kind" : "Identifier", + "location" : [ 62, 13, 62, 16 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 62, 18, 62, 22 ], + "name" : "items" + } + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 62, 26, 62, 41 ], + "left" : { + "kind" : "MemberExpr", + "location" : [ 62, 26, 62, 35 ], + "object" : { + "kind" : "Identifier", + "location" : [ 62, 26, 62, 29 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 62, 31, 62, 35 ], + "name" : "items" + } + }, + "operator" : "+", + "right" : { + "kind" : "ListExpr", + "location" : [ 62, 39, 62, 41 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 62, 40, 62, 40 ], + "value" : 0 + } ] + } + } + } ] + }, { + "kind" : "ReturnStmt", + "location" : [ 63, 9, 63, 30 ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 63, 16, 63, 30 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 63, 16, 63, 28 ], + "object" : { + "kind" : "Identifier", + "location" : [ 63, 16, 63, 19 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 63, 21, 63, 28 ], + "name" : "capacity" + } + }, + "args" : [ ] + } + } ] + } ] + }, { + "kind" : "FuncDef", + "location" : [ 66, 1, 74, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 66, 5, 66, 10 ], + "name" : "vrange" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 66, 12, 66, 16 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 66, 12, 66, 12 ], + "name" : "i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 66, 14, 66, 16 ], + "className" : "int" + } + }, { + "kind" : "TypedVar", + "location" : [ 66, 19, 66, 23 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 66, 19, 66, 19 ], + "name" : "j" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 66, 21, 66, 23 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 66, 29, 66, 34 ], + "className" : "Vector" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 67, 5, 67, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 67, 5, 67, 12 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 67, 5, 67, 5 ], + "name" : "v" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 67, 7, 67, 12 ], + "className" : "Vector" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 67, 16, 67, 19 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 68, 5, 68, 24 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 68, 5, 68, 5 ], + "name" : "v" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 68, 9, 68, 24 ], + "function" : { + "kind" : "Identifier", + "location" : [ 68, 9, 68, 22 ], + "name" : "DoublingVector" + }, + "args" : [ ] + } + }, { + "kind" : "WhileStmt", + "location" : [ 70, 5, 74, 4 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 70, 11, 70, 15 ], + "left" : { + "kind" : "Identifier", + "location" : [ 70, 11, 70, 11 ], + "name" : "i" + }, + "operator" : "<", + "right" : { + "kind" : "Identifier", + "location" : [ 70, 15, 70, 15 ], + "name" : "j" + } + }, + "body" : [ { + "kind" : "ExprStmt", + "location" : [ 71, 9, 71, 19 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 71, 9, 71, 19 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 71, 9, 71, 16 ], + "object" : { + "kind" : "Identifier", + "location" : [ 71, 9, 71, 9 ], + "name" : "v" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 71, 11, 71, 16 ], + "name" : "append" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 71, 18, 71, 18 ], + "name" : "i" + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 72, 9, 72, 17 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 72, 9, 72, 9 ], + "name" : "i" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 72, 13, 72, 17 ], + "left" : { + "kind" : "Identifier", + "location" : [ 72, 13, 72, 13 ], + "name" : "i" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 72, 17, 72, 17 ], + "value" : 1 + } + } + } ] + }, { + "kind" : "ReturnStmt", + "location" : [ 74, 5, 74, 12 ], + "value" : { + "kind" : "Identifier", + "location" : [ 74, 12, 74, 12 ], + "name" : "v" + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 77, 1, 93, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 77, 5, 77, 9 ], + "name" : "sieve" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 77, 11, 77, 18 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 77, 11, 77, 11 ], + "name" : "v" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 77, 13, 77, 18 ], + "className" : "Vector" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 77, 24, 77, 29 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 78, 5, 78, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 78, 5, 78, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 78, 5, 78, 5 ], + "name" : "i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 78, 7, 78, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 78, 13, 78, 13 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 79, 5, 79, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 79, 5, 79, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 79, 5, 79, 5 ], + "name" : "j" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 79, 7, 79, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 79, 13, 79, 13 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 80, 5, 80, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 80, 5, 80, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 80, 5, 80, 5 ], + "name" : "k" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 80, 7, 80, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 80, 13, 80, 13 ], + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "WhileStmt", + "location" : [ 82, 5, 93, 0 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 82, 11, 82, 24 ], + "left" : { + "kind" : "Identifier", + "location" : [ 82, 11, 82, 11 ], + "name" : "i" + }, + "operator" : "<", + "right" : { + "kind" : "MethodCallExpr", + "location" : [ 82, 15, 82, 24 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 82, 15, 82, 22 ], + "object" : { + "kind" : "Identifier", + "location" : [ 82, 15, 82, 15 ], + "name" : "v" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 82, 17, 82, 22 ], + "name" : "length" + } + }, + "args" : [ ] + } + }, + "body" : [ { + "kind" : "AssignStmt", + "location" : [ 83, 9, 83, 20 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 83, 9, 83, 9 ], + "name" : "k" + } ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 83, 13, 83, 20 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 83, 13, 83, 17 ], + "object" : { + "kind" : "Identifier", + "location" : [ 83, 13, 83, 13 ], + "name" : "v" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 83, 15, 83, 17 ], + "name" : "get" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 83, 19, 83, 19 ], + "name" : "i" + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 84, 9, 84, 17 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 84, 9, 84, 9 ], + "name" : "j" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 84, 13, 84, 17 ], + "left" : { + "kind" : "Identifier", + "location" : [ 84, 13, 84, 13 ], + "name" : "i" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 84, 17, 84, 17 ], + "value" : 1 + } + } + }, { + "kind" : "WhileStmt", + "location" : [ 85, 9, 90, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 85, 15, 85, 28 ], + "left" : { + "kind" : "Identifier", + "location" : [ 85, 15, 85, 15 ], + "name" : "j" + }, + "operator" : "<", + "right" : { + "kind" : "MethodCallExpr", + "location" : [ 85, 19, 85, 28 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 85, 19, 85, 26 ], + "object" : { + "kind" : "Identifier", + "location" : [ 85, 19, 85, 19 ], + "name" : "v" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 85, 21, 85, 26 ], + "name" : "length" + } + }, + "args" : [ ] + } + }, + "body" : [ { + "kind" : "IfStmt", + "location" : [ 86, 13, 90, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 86, 16, 86, 32 ], + "left" : { + "kind" : "BinaryExpr", + "location" : [ 86, 16, 86, 27 ], + "left" : { + "kind" : "MethodCallExpr", + "location" : [ 86, 16, 86, 23 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 86, 16, 86, 20 ], + "object" : { + "kind" : "Identifier", + "location" : [ 86, 16, 86, 16 ], + "name" : "v" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 86, 18, 86, 20 ], + "name" : "get" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 86, 22, 86, 22 ], + "name" : "j" + } ] + }, + "operator" : "%", + "right" : { + "kind" : "Identifier", + "location" : [ 86, 27, 86, 27 ], + "name" : "k" + } + }, + "operator" : "==", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 86, 32, 86, 32 ], + "value" : 0 + } + }, + "thenBody" : [ { + "kind" : "ExprStmt", + "location" : [ 87, 17, 87, 30 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 87, 17, 87, 30 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 87, 17, 87, 27 ], + "object" : { + "kind" : "Identifier", + "location" : [ 87, 17, 87, 17 ], + "name" : "v" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 87, 19, 87, 27 ], + "name" : "remove_at" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 87, 29, 87, 29 ], + "name" : "j" + } ] + } + } ], + "elseBody" : [ { + "kind" : "AssignStmt", + "location" : [ 89, 17, 89, 25 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 89, 17, 89, 17 ], + "name" : "j" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 89, 21, 89, 25 ], + "left" : { + "kind" : "Identifier", + "location" : [ 89, 21, 89, 21 ], + "name" : "j" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 89, 25, 89, 25 ], + "value" : 1 + } + } + } ] + } ] + }, { + "kind" : "AssignStmt", + "location" : [ 90, 9, 90, 17 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 90, 9, 90, 9 ], + "name" : "i" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 90, 13, 90, 17 ], + "left" : { + "kind" : "Identifier", + "location" : [ 90, 13, 90, 13 ], + "name" : "i" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 90, 17, 90, 17 ], + "value" : 1 + } + } + } ] + } ] + }, { + "kind" : "VarDef", + "location" : [ 93, 1, 93, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 93, 1, 93, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 93, 1, 93, 1 ], + "name" : "n" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 93, 3, 93, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 93, 9, 93, 10 ], + "value" : 50 + } + }, { + "kind" : "VarDef", + "location" : [ 96, 1, 96, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 96, 1, 96, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 96, 1, 96, 1 ], + "name" : "v" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 96, 3, 96, 8 ], + "className" : "Vector" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 96, 12, 96, 15 ] + } + }, { + "kind" : "VarDef", + "location" : [ 97, 1, 97, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 97, 1, 97, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 97, 1, 97, 1 ], + "name" : "i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 97, 3, 97, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 97, 9, 97, 9 ], + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 100, 1, 100, 16 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 100, 1, 100, 1 ], + "name" : "v" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 100, 5, 100, 16 ], + "function" : { + "kind" : "Identifier", + "location" : [ 100, 5, 100, 10 ], + "name" : "vrange" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 100, 12, 100, 12 ], + "value" : 2 + }, { + "kind" : "Identifier", + "location" : [ 100, 15, 100, 15 ], + "name" : "n" + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 101, 1, 101, 8 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 101, 1, 101, 8 ], + "function" : { + "kind" : "Identifier", + "location" : [ 101, 1, 101, 5 ], + "name" : "sieve" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 101, 7, 101, 7 ], + "name" : "v" + } ] + } + }, { + "kind" : "WhileStmt", + "location" : [ 104, 1, 108, 1 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 104, 7, 104, 20 ], + "left" : { + "kind" : "Identifier", + "location" : [ 104, 7, 104, 7 ], + "name" : "i" + }, + "operator" : "<", + "right" : { + "kind" : "MethodCallExpr", + "location" : [ 104, 11, 104, 20 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 104, 11, 104, 18 ], + "object" : { + "kind" : "Identifier", + "location" : [ 104, 11, 104, 11 ], + "name" : "v" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 104, 13, 104, 18 ], + "name" : "length" + } + }, + "args" : [ ] + } + }, + "body" : [ { + "kind" : "ExprStmt", + "location" : [ 105, 5, 105, 19 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 105, 5, 105, 19 ], + "function" : { + "kind" : "Identifier", + "location" : [ 105, 5, 105, 9 ], + "name" : "print" + }, + "args" : [ { + "kind" : "MethodCallExpr", + "location" : [ 105, 11, 105, 18 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 105, 11, 105, 15 ], + "object" : { + "kind" : "Identifier", + "location" : [ 105, 11, 105, 11 ], + "name" : "v" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 105, 13, 105, 15 ], + "name" : "get" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 105, 17, 105, 17 ], + "name" : "i" + } ] + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 106, 5, 106, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 106, 5, 106, 5 ], + "name" : "i" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 106, 9, 106, 13 ], + "left" : { + "kind" : "Identifier", + "location" : [ 106, 9, 106, 9 ], + "name" : "i" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 106, 13, 106, 13 ], + "value" : 1 + } + } + } ] + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/extra/sieve.py.ast.typed b/pa2-tests/extra/sieve.py.ast.typed new file mode 100644 index 0000000..1c0eb6c --- /dev/null +++ b/pa2-tests/extra/sieve.py.ast.typed @@ -0,0 +1,2816 @@ +{ + "kind" : "Program", + "location" : [ 2, 1, 108, 1 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 2, 1, 52, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 7, 2, 12 ], + "name" : "Vector" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 2, 14, 2, 19 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 3, 5, 3, 23 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 5, 3, 16 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 9 ], + "name" : "items" + }, + "type" : { + "kind" : "ListType", + "location" : [ 3, 12, 3, 16 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 3, 13, 3, 15 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 3, 20, 3, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 4, 5, 4, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 5, 4, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 8 ], + "name" : "size" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 11, 4, 13 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 17, 4, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, { + "kind" : "FuncDef", + "location" : [ 6, 5, 7, 25 ], + "name" : { + "kind" : "Identifier", + "location" : [ 6, 9, 6, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 6, 18, 6, 30 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 18, 6, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 23, 6, 30 ], + "className" : "Vector" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 6, 32, 6, 32 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 7, 9, 7, 24 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 7, 9, 7, 18 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 7, 14, 7, 18 ], + "name" : "items" + } + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 7, 22, 7, 24 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 7, 23, 7, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } ] + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 10, 5, 11, 31 ], + "name" : { + "kind" : "Identifier", + "location" : [ 10, 9, 10, 16 ], + "name" : "capacity" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 10, 18, 10, 30 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 10, 18, 10, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 10, 23, 10, 30 ], + "className" : "Vector" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 10, 36, 10, 38 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 11, 9, 11, 30 ], + "value" : { + "kind" : "CallExpr", + "location" : [ 11, 16, 11, 30 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 11, 16, 11, 18 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "len" + }, + "args" : [ { + "kind" : "MemberExpr", + "location" : [ 11, 20, 11, 29 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 11, 20, 11, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 11, 25, 11, 29 ], + "name" : "items" + } + } ] + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 14, 5, 16, 31 ], + "name" : { + "kind" : "Identifier", + "location" : [ 14, 9, 14, 25 ], + "name" : "increase_capacity" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 14, 27, 14, 39 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 14, 27, 14, 30 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 14, 32, 14, 39 ], + "className" : "Vector" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 14, 45, 14, 47 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 15, 9, 15, 37 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 15, 9, 15, 18 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 15, 9, 15, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 15, 14, 15, 18 ], + "name" : "items" + } + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 15, 22, 15, 37 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "left" : { + "kind" : "MemberExpr", + "location" : [ 15, 22, 15, 31 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 15, 22, 15, 25 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 15, 27, 15, 31 ], + "name" : "items" + } + }, + "operator" : "+", + "right" : { + "kind" : "ListExpr", + "location" : [ 15, 35, 15, 37 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 15, 36, 15, 36 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } ] + } + } + }, { + "kind" : "ReturnStmt", + "location" : [ 16, 9, 16, 30 ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 16, 16, 16, 30 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 16, 16, 16, 28 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "Vector" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 16, 16, 16, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 16, 21, 16, 28 ], + "name" : "capacity" + } + }, + "args" : [ ] + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 19, 5, 24, 34 ], + "name" : { + "kind" : "Identifier", + "location" : [ 19, 9, 19, 14 ], + "name" : "append" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 19, 16, 19, 28 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 19, 16, 19, 19 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 19, 21, 19, 28 ], + "className" : "Vector" + } + }, { + "kind" : "TypedVar", + "location" : [ 19, 31, 19, 39 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 19, 31, 19, 34 ], + "name" : "item" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 19, 37, 19, 39 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 19, 45, 19, 50 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 20, 9, 23, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 20, 12, 20, 39 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "MemberExpr", + "location" : [ 20, 12, 20, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 20, 12, 20, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 20, 17, 20, 20 ], + "name" : "size" + } + }, + "operator" : "==", + "right" : { + "kind" : "MethodCallExpr", + "location" : [ 20, 25, 20, 39 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 20, 25, 20, 37 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "Vector" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 20, 25, 20, 28 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 20, 30, 20, 37 ], + "name" : "capacity" + } + }, + "args" : [ ] + } + }, + "thenBody" : [ { + "kind" : "ExprStmt", + "location" : [ 21, 13, 21, 36 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 21, 13, 21, 36 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 21, 13, 21, 34 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "Vector" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 21, 13, 21, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 21, 18, 21, 34 ], + "name" : "increase_capacity" + } + }, + "args" : [ ] + } + } ], + "elseBody" : [ ] + }, { + "kind" : "AssignStmt", + "location" : [ 23, 9, 23, 36 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 23, 9, 23, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "MemberExpr", + "location" : [ 23, 9, 23, 18 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 23, 9, 23, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 23, 14, 23, 18 ], + "name" : "items" + } + }, + "index" : { + "kind" : "MemberExpr", + "location" : [ 23, 20, 23, 28 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 23, 20, 23, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 23, 25, 23, 28 ], + "name" : "size" + } + } + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 23, 33, 23, 36 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "item" + } + }, { + "kind" : "AssignStmt", + "location" : [ 24, 9, 24, 33 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 24, 9, 24, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 24, 9, 24, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 24, 14, 24, 17 ], + "name" : "size" + } + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 24, 21, 24, 33 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "MemberExpr", + "location" : [ 24, 21, 24, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 24, 21, 24, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 24, 26, 24, 29 ], + "name" : "size" + } + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 24, 33, 24, 33 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 27, 5, 33, 4 ], + "name" : { + "kind" : "Identifier", + "location" : [ 27, 9, 27, 18 ], + "name" : "append_all" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 27, 20, 27, 32 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 27, 20, 27, 23 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 27, 25, 27, 32 ], + "className" : "Vector" + } + }, { + "kind" : "TypedVar", + "location" : [ 27, 35, 27, 50 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 27, 35, 27, 43 ], + "name" : "new_items" + }, + "type" : { + "kind" : "ListType", + "location" : [ 27, 46, 27, 50 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 27, 47, 27, 49 ], + "className" : "int" + } + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 27, 56, 27, 61 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 28, 9, 28, 20 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 28, 9, 28, 16 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 28, 9, 28, 12 ], + "name" : "item" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 28, 14, 28, 16 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 28, 20, 28, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "ForStmt", + "location" : [ 29, 9, 33, 4 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 29, 13, 29, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "item" + }, + "iterable" : { + "kind" : "Identifier", + "location" : [ 29, 21, 29, 29 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "new_items" + }, + "body" : [ { + "kind" : "ExprStmt", + "location" : [ 30, 13, 30, 29 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 30, 13, 30, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 30, 13, 30, 23 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "Vector" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 30, 13, 30, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 30, 18, 30, 23 ], + "name" : "append" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 30, 25, 30, 28 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "item" + } ] + } + } ] + } ] + }, { + "kind" : "FuncDef", + "location" : [ 33, 5, 41, 34 ], + "name" : { + "kind" : "Identifier", + "location" : [ 33, 9, 33, 17 ], + "name" : "remove_at" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 33, 19, 33, 31 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 33, 19, 33, 22 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 33, 24, 33, 31 ], + "className" : "Vector" + } + }, { + "kind" : "TypedVar", + "location" : [ 33, 34, 33, 41 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 33, 34, 33, 36 ], + "name" : "idx" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 33, 39, 33, 41 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 33, 47, 33, 52 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 34, 9, 37, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 34, 12, 34, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 34, 12, 34, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "idx" + }, + "operator" : "<", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 34, 18, 34, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, + "thenBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 35, 13, 35, 18 ], + "value" : null + } ], + "elseBody" : [ ] + }, { + "kind" : "WhileStmt", + "location" : [ 37, 9, 41, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 37, 15, 37, 33 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 37, 15, 37, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "idx" + }, + "operator" : "<", + "right" : { + "kind" : "BinaryExpr", + "location" : [ 37, 21, 37, 33 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "MemberExpr", + "location" : [ 37, 21, 37, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 37, 21, 37, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 37, 26, 37, 29 ], + "name" : "size" + } + }, + "operator" : "-", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 37, 33, 37, 33 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + }, + "body" : [ { + "kind" : "AssignStmt", + "location" : [ 38, 13, 38, 49 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 38, 13, 38, 27 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "MemberExpr", + "location" : [ 38, 13, 38, 22 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 38, 13, 38, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 38, 18, 38, 22 ], + "name" : "items" + } + }, + "index" : { + "kind" : "Identifier", + "location" : [ 38, 24, 38, 26 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "idx" + } + } ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 38, 31, 38, 49 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "MemberExpr", + "location" : [ 38, 31, 38, 40 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 38, 31, 38, 34 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 38, 36, 38, 40 ], + "name" : "items" + } + }, + "index" : { + "kind" : "BinaryExpr", + "location" : [ 38, 42, 38, 48 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 38, 42, 38, 44 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "idx" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 38, 48, 38, 48 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 39, 13, 39, 25 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 39, 13, 39, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "idx" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 39, 19, 39, 25 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 39, 19, 39, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "idx" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 39, 25, 39, 25 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ] + }, { + "kind" : "AssignStmt", + "location" : [ 41, 9, 41, 33 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 41, 9, 41, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 41, 9, 41, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 41, 14, 41, 17 ], + "name" : "size" + } + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 41, 21, 41, 33 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "MemberExpr", + "location" : [ 41, 21, 41, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 41, 21, 41, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 41, 26, 41, 29 ], + "name" : "size" + } + }, + "operator" : "-", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 41, 33, 41, 33 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 44, 5, 45, 31 ], + "name" : { + "kind" : "Identifier", + "location" : [ 44, 9, 44, 11 ], + "name" : "get" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 44, 13, 44, 25 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 44, 13, 44, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 44, 18, 44, 25 ], + "className" : "Vector" + } + }, { + "kind" : "TypedVar", + "location" : [ 44, 28, 44, 35 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 44, 28, 44, 30 ], + "name" : "idx" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 44, 33, 44, 35 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 44, 41, 44, 43 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 45, 9, 45, 30 ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 45, 16, 45, 30 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "MemberExpr", + "location" : [ 45, 16, 45, 25 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 45, 16, 45, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 45, 21, 45, 25 ], + "name" : "items" + } + }, + "index" : { + "kind" : "Identifier", + "location" : [ 45, 27, 45, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "idx" + } + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 48, 5, 49, 25 ], + "name" : { + "kind" : "Identifier", + "location" : [ 48, 9, 48, 14 ], + "name" : "length" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 48, 16, 48, 28 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 48, 16, 48, 19 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 48, 21, 48, 28 ], + "className" : "Vector" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 48, 34, 48, 36 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 49, 9, 49, 24 ], + "value" : { + "kind" : "MemberExpr", + "location" : [ 49, 16, 49, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 49, 16, 49, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 49, 21, 49, 24 ], + "name" : "size" + } + } + } ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 52, 1, 66, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 52, 7, 52, 20 ], + "name" : "DoublingVector" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 52, 22, 52, 27 ], + "name" : "Vector" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 53, 5, 53, 29 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 53, 5, 53, 22 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 53, 5, 53, 18 ], + "name" : "doubling_limit" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 53, 20, 53, 22 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 53, 26, 53, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1000 + } + }, { + "kind" : "FuncDef", + "location" : [ 56, 5, 63, 31 ], + "name" : { + "kind" : "Identifier", + "location" : [ 56, 9, 56, 25 ], + "name" : "increase_capacity" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 56, 27, 56, 47 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 56, 27, 56, 30 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 56, 32, 56, 47 ], + "className" : "DoublingVector" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 56, 53, 56, 55 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 57, 9, 63, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 57, 13, 57, 55 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "MethodCallExpr", + "location" : [ 57, 13, 57, 27 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 57, 13, 57, 25 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "Vector" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 57, 13, 57, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "DoublingVector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 57, 18, 57, 25 ], + "name" : "capacity" + } + }, + "args" : [ ] + }, + "operator" : "<=", + "right" : { + "kind" : "BinaryExpr", + "location" : [ 57, 32, 57, 55 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "MemberExpr", + "location" : [ 57, 32, 57, 50 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 57, 32, 57, 35 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "DoublingVector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 57, 37, 57, 50 ], + "name" : "doubling_limit" + } + }, + "operator" : "//", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 57, 55, 57, 55 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 58, 13, 58, 48 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 58, 13, 58, 22 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 58, 13, 58, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "DoublingVector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 58, 18, 58, 22 ], + "name" : "items" + } + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 58, 26, 58, 48 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "left" : { + "kind" : "MemberExpr", + "location" : [ 58, 26, 58, 35 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 58, 26, 58, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "DoublingVector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 58, 31, 58, 35 ], + "name" : "items" + } + }, + "operator" : "+", + "right" : { + "kind" : "MemberExpr", + "location" : [ 58, 39, 58, 48 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 58, 39, 58, 42 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "DoublingVector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 58, 44, 58, 48 ], + "name" : "items" + } + } + } + } ], + "elseBody" : [ { + "kind" : "AssignStmt", + "location" : [ 62, 13, 62, 41 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 62, 13, 62, 22 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 62, 13, 62, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "DoublingVector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 62, 18, 62, 22 ], + "name" : "items" + } + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 62, 26, 62, 41 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "left" : { + "kind" : "MemberExpr", + "location" : [ 62, 26, 62, 35 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 62, 26, 62, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "DoublingVector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 62, 31, 62, 35 ], + "name" : "items" + } + }, + "operator" : "+", + "right" : { + "kind" : "ListExpr", + "location" : [ 62, 39, 62, 41 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 62, 40, 62, 40 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } ] + } + } + } ] + }, { + "kind" : "ReturnStmt", + "location" : [ 63, 9, 63, 30 ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 63, 16, 63, 30 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 63, 16, 63, 28 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "Vector" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 63, 16, 63, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "DoublingVector" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 63, 21, 63, 28 ], + "name" : "capacity" + } + }, + "args" : [ ] + } + } ] + } ] + }, { + "kind" : "FuncDef", + "location" : [ 66, 1, 74, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 66, 5, 66, 10 ], + "name" : "vrange" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 66, 12, 66, 16 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 66, 12, 66, 12 ], + "name" : "i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 66, 14, 66, 16 ], + "className" : "int" + } + }, { + "kind" : "TypedVar", + "location" : [ 66, 19, 66, 23 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 66, 19, 66, 19 ], + "name" : "j" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 66, 21, 66, 23 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 66, 29, 66, 34 ], + "className" : "Vector" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 67, 5, 67, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 67, 5, 67, 12 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 67, 5, 67, 5 ], + "name" : "v" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 67, 7, 67, 12 ], + "className" : "Vector" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 67, 16, 67, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 68, 5, 68, 24 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 68, 5, 68, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "v" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 68, 9, 68, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "DoublingVector" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 68, 9, 68, 22 ], + "name" : "DoublingVector" + }, + "args" : [ ] + } + }, { + "kind" : "WhileStmt", + "location" : [ 70, 5, 74, 4 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 70, 11, 70, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 70, 11, 70, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + }, + "operator" : "<", + "right" : { + "kind" : "Identifier", + "location" : [ 70, 15, 70, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "j" + } + }, + "body" : [ { + "kind" : "ExprStmt", + "location" : [ 71, 9, 71, 19 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 71, 9, 71, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 71, 9, 71, 16 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "Vector" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 71, 9, 71, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "v" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 71, 11, 71, 16 ], + "name" : "append" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 71, 18, 71, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 72, 9, 72, 17 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 72, 9, 72, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 72, 13, 72, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 72, 13, 72, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 72, 17, 72, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ] + }, { + "kind" : "ReturnStmt", + "location" : [ 74, 5, 74, 12 ], + "value" : { + "kind" : "Identifier", + "location" : [ 74, 12, 74, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "v" + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 77, 1, 93, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 77, 5, 77, 9 ], + "name" : "sieve" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 77, 11, 77, 18 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 77, 11, 77, 11 ], + "name" : "v" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 77, 13, 77, 18 ], + "className" : "Vector" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 77, 24, 77, 29 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 78, 5, 78, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 78, 5, 78, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 78, 5, 78, 5 ], + "name" : "i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 78, 7, 78, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 78, 13, 78, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 79, 5, 79, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 79, 5, 79, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 79, 5, 79, 5 ], + "name" : "j" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 79, 7, 79, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 79, 13, 79, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 80, 5, 80, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 80, 5, 80, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 80, 5, 80, 5 ], + "name" : "k" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 80, 7, 80, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 80, 13, 80, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "WhileStmt", + "location" : [ 82, 5, 93, 0 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 82, 11, 82, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 82, 11, 82, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + }, + "operator" : "<", + "right" : { + "kind" : "MethodCallExpr", + "location" : [ 82, 15, 82, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 82, 15, 82, 22 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "Vector" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 82, 15, 82, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "v" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 82, 17, 82, 22 ], + "name" : "length" + } + }, + "args" : [ ] + } + }, + "body" : [ { + "kind" : "AssignStmt", + "location" : [ 83, 9, 83, 20 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 83, 9, 83, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "k" + } ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 83, 13, 83, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 83, 13, 83, 17 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "Vector" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 83, 13, 83, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "v" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 83, 15, 83, 17 ], + "name" : "get" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 83, 19, 83, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 84, 9, 84, 17 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 84, 9, 84, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "j" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 84, 13, 84, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 84, 13, 84, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 84, 17, 84, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + }, { + "kind" : "WhileStmt", + "location" : [ 85, 9, 90, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 85, 15, 85, 28 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 85, 15, 85, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "j" + }, + "operator" : "<", + "right" : { + "kind" : "MethodCallExpr", + "location" : [ 85, 19, 85, 28 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 85, 19, 85, 26 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "Vector" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 85, 19, 85, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "v" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 85, 21, 85, 26 ], + "name" : "length" + } + }, + "args" : [ ] + } + }, + "body" : [ { + "kind" : "IfStmt", + "location" : [ 86, 13, 90, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 86, 16, 86, 32 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "BinaryExpr", + "location" : [ 86, 16, 86, 27 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "MethodCallExpr", + "location" : [ 86, 16, 86, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 86, 16, 86, 20 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "Vector" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 86, 16, 86, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "v" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 86, 18, 86, 20 ], + "name" : "get" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 86, 22, 86, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "j" + } ] + }, + "operator" : "%", + "right" : { + "kind" : "Identifier", + "location" : [ 86, 27, 86, 27 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "k" + } + }, + "operator" : "==", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 86, 32, 86, 32 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, + "thenBody" : [ { + "kind" : "ExprStmt", + "location" : [ 87, 17, 87, 30 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 87, 17, 87, 30 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 87, 17, 87, 27 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "Vector" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 87, 17, 87, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "v" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 87, 19, 87, 27 ], + "name" : "remove_at" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 87, 29, 87, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "j" + } ] + } + } ], + "elseBody" : [ { + "kind" : "AssignStmt", + "location" : [ 89, 17, 89, 25 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 89, 17, 89, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "j" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 89, 21, 89, 25 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 89, 21, 89, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "j" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 89, 25, 89, 25 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ] + } ] + }, { + "kind" : "AssignStmt", + "location" : [ 90, 9, 90, 17 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 90, 9, 90, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 90, 13, 90, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 90, 13, 90, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 90, 17, 90, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ] + } ] + }, { + "kind" : "VarDef", + "location" : [ 93, 1, 93, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 93, 1, 93, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 93, 1, 93, 1 ], + "name" : "n" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 93, 3, 93, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 93, 9, 93, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 50 + } + }, { + "kind" : "VarDef", + "location" : [ 96, 1, 96, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 96, 1, 96, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 96, 1, 96, 1 ], + "name" : "v" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 96, 3, 96, 8 ], + "className" : "Vector" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 96, 12, 96, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 97, 1, 97, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 97, 1, 97, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 97, 1, 97, 1 ], + "name" : "i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 97, 3, 97, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 97, 9, 97, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 100, 1, 100, 16 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 100, 1, 100, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "v" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 100, 5, 100, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 100, 5, 100, 10 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "int" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "Vector" + } + }, + "name" : "vrange" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 100, 12, 100, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + }, { + "kind" : "Identifier", + "location" : [ 100, 15, 100, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "n" + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 101, 1, 101, 8 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 101, 1, 101, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 101, 1, 101, 5 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "Vector" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "name" : "sieve" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 101, 7, 101, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "v" + } ] + } + }, { + "kind" : "WhileStmt", + "location" : [ 104, 1, 108, 1 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 104, 7, 104, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 104, 7, 104, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + }, + "operator" : "<", + "right" : { + "kind" : "MethodCallExpr", + "location" : [ 104, 11, 104, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 104, 11, 104, 18 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "Vector" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 104, 11, 104, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "v" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 104, 13, 104, 18 ], + "name" : "length" + } + }, + "args" : [ ] + } + }, + "body" : [ { + "kind" : "ExprStmt", + "location" : [ 105, 5, 105, 19 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 105, 5, 105, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 105, 5, 105, 9 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, + "name" : "print" + }, + "args" : [ { + "kind" : "MethodCallExpr", + "location" : [ 105, 11, 105, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 105, 11, 105, 15 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "Vector" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 105, 11, 105, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Vector" + }, + "name" : "v" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 105, 13, 105, 15 ], + "name" : "get" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 105, 17, 105, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + } ] + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 106, 5, 106, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 106, 5, 106, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 106, 9, 106, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 106, 9, 106, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 106, 13, 106, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ] + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/extra/stdlib.py b/pa2-tests/extra/stdlib.py new file mode 100644 index 0000000..e7323bd --- /dev/null +++ b/pa2-tests/extra/stdlib.py @@ -0,0 +1,77 @@ +# ChocoPy library functions +def int_to_str(x: int) -> str: + digits:[str] = None + result:str = "" + + # Set-up digit mapping + digits = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + + # Write sign if necessary + if x < 0: + result = "-" + x = -x + + # Write digits using a recursive call + if x >= 10: + result = result + int_to_str(x // 10) + result = result + digits[x % 10] + return result + +def str_to_int(x: str) -> int: + result:int = 0 + digit:int = 0 + char:str = "" + sign:int = 1 + first_char:bool = True + + # Parse digits + for char in x: + if char == "-": + if not first_char: + return 0 # Error + sign = -1 + elif char == "0": + digit = 0 + elif char == "1": + digit = 1 + elif char == "2": + digit = 2 + elif char == "3": + digit = 3 + elif char == "3": + digit = 3 + elif char == "4": + digit = 4 + elif char == "5": + digit = 5 + elif char == "6": + digit = 6 + elif char == "7": + digit = 7 + elif char == "8": + digit = 8 + elif char == "9": + digit = 9 + else: + return 0 # On error + first_char = False + result = result * 10 + digit + + # Compute result + return result * sign + +# Input parameters +c:int = 42 +n:int = 10 + +# Run [-nc, nc] with step size c +s:str = "" +i:int = 0 +i = -n * c + +# Crunch +while i <= n * c: + s = int_to_str(i) + print(s) + i = str_to_int(s) + c + diff --git a/pa2-tests/extra/stdlib.py.ast b/pa2-tests/extra/stdlib.py.ast new file mode 100644 index 0000000..f08e906 --- /dev/null +++ b/pa2-tests/extra/stdlib.py.ast @@ -0,0 +1,1168 @@ +{ + "kind" : "Program", + "location" : [ 2, 1, 78, 1 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 2, 1, 18, 18 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 14 ], + "name" : "int_to_str" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 2, 16, 2, 21 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 16, 2, 16 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 19, 2, 21 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 2, 27, 2, 29 ], + "className" : "str" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 3, 5, 3, 23 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 5, 3, 16 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 10 ], + "name" : "digits" + }, + "type" : { + "kind" : "ListType", + "location" : [ 3, 12, 3, 16 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 3, 13, 3, 15 ], + "className" : "str" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 3, 20, 3, 23 ] + } + }, { + "kind" : "VarDef", + "location" : [ 4, 5, 4, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 5, 4, 14 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 10 ], + "name" : "result" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 12, 4, 14 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 4, 18, 4, 19 ], + "value" : "" + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 7, 5, 7, 63 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 10 ], + "name" : "digits" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 7, 14, 7, 63 ], + "elements" : [ { + "kind" : "StringLiteral", + "location" : [ 7, 15, 7, 17 ], + "value" : "0" + }, { + "kind" : "StringLiteral", + "location" : [ 7, 20, 7, 22 ], + "value" : "1" + }, { + "kind" : "StringLiteral", + "location" : [ 7, 25, 7, 27 ], + "value" : "2" + }, { + "kind" : "StringLiteral", + "location" : [ 7, 30, 7, 32 ], + "value" : "3" + }, { + "kind" : "StringLiteral", + "location" : [ 7, 35, 7, 37 ], + "value" : "4" + }, { + "kind" : "StringLiteral", + "location" : [ 7, 40, 7, 42 ], + "value" : "5" + }, { + "kind" : "StringLiteral", + "location" : [ 7, 45, 7, 47 ], + "value" : "6" + }, { + "kind" : "StringLiteral", + "location" : [ 7, 50, 7, 52 ], + "value" : "7" + }, { + "kind" : "StringLiteral", + "location" : [ 7, 55, 7, 57 ], + "value" : "8" + }, { + "kind" : "StringLiteral", + "location" : [ 7, 60, 7, 62 ], + "value" : "9" + } ] + } + }, { + "kind" : "IfStmt", + "location" : [ 10, 5, 15, 4 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 10, 8, 10, 12 ], + "left" : { + "kind" : "Identifier", + "location" : [ 10, 8, 10, 8 ], + "name" : "x" + }, + "operator" : "<", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 10, 12, 10, 12 ], + "value" : 0 + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 11, 9, 11, 20 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 11, 9, 11, 14 ], + "name" : "result" + } ], + "value" : { + "kind" : "StringLiteral", + "location" : [ 11, 18, 11, 20 ], + "value" : "-" + } + }, { + "kind" : "AssignStmt", + "location" : [ 12, 9, 12, 14 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 12, 9, 12, 9 ], + "name" : "x" + } ], + "value" : { + "kind" : "UnaryExpr", + "location" : [ 12, 13, 12, 14 ], + "operator" : "-", + "operand" : { + "kind" : "Identifier", + "location" : [ 12, 14, 12, 14 ], + "name" : "x" + } + } + } ], + "elseBody" : [ ] + }, { + "kind" : "IfStmt", + "location" : [ 15, 5, 17, 4 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 15, 8, 15, 14 ], + "left" : { + "kind" : "Identifier", + "location" : [ 15, 8, 15, 8 ], + "name" : "x" + }, + "operator" : ">=", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 15, 13, 15, 14 ], + "value" : 10 + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 16, 9, 16, 45 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 16, 9, 16, 14 ], + "name" : "result" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 16, 18, 16, 45 ], + "left" : { + "kind" : "Identifier", + "location" : [ 16, 18, 16, 23 ], + "name" : "result" + }, + "operator" : "+", + "right" : { + "kind" : "CallExpr", + "location" : [ 16, 27, 16, 45 ], + "function" : { + "kind" : "Identifier", + "location" : [ 16, 27, 16, 36 ], + "name" : "int_to_str" + }, + "args" : [ { + "kind" : "BinaryExpr", + "location" : [ 16, 38, 16, 44 ], + "left" : { + "kind" : "Identifier", + "location" : [ 16, 38, 16, 38 ], + "name" : "x" + }, + "operator" : "//", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 16, 43, 16, 44 ], + "value" : 10 + } + } ] + } + } + } ], + "elseBody" : [ ] + }, { + "kind" : "AssignStmt", + "location" : [ 17, 5, 17, 36 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 17, 5, 17, 10 ], + "name" : "result" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 17, 14, 17, 36 ], + "left" : { + "kind" : "Identifier", + "location" : [ 17, 14, 17, 19 ], + "name" : "result" + }, + "operator" : "+", + "right" : { + "kind" : "IndexExpr", + "location" : [ 17, 23, 17, 36 ], + "list" : { + "kind" : "Identifier", + "location" : [ 17, 23, 17, 28 ], + "name" : "digits" + }, + "index" : { + "kind" : "BinaryExpr", + "location" : [ 17, 30, 17, 35 ], + "left" : { + "kind" : "Identifier", + "location" : [ 17, 30, 17, 30 ], + "name" : "x" + }, + "operator" : "%", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 17, 34, 17, 35 ], + "value" : 10 + } + } + } + } + }, { + "kind" : "ReturnStmt", + "location" : [ 18, 5, 18, 17 ], + "value" : { + "kind" : "Identifier", + "location" : [ 18, 12, 18, 17 ], + "name" : "result" + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 20, 1, 61, 25 ], + "name" : { + "kind" : "Identifier", + "location" : [ 20, 5, 20, 14 ], + "name" : "str_to_int" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 20, 16, 20, 21 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 20, 16, 20, 16 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 20, 19, 20, 21 ], + "className" : "str" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 20, 27, 20, 29 ], + "className" : "int" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 21, 5, 21, 18 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 21, 5, 21, 14 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 21, 5, 21, 10 ], + "name" : "result" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 21, 12, 21, 14 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 21, 18, 21, 18 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 22, 5, 22, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 22, 5, 22, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 22, 5, 22, 9 ], + "name" : "digit" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 22, 11, 22, 13 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 22, 17, 22, 17 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 23, 5, 23, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 23, 5, 23, 12 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 23, 5, 23, 8 ], + "name" : "char" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 23, 10, 23, 12 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 23, 16, 23, 17 ], + "value" : "" + } + }, { + "kind" : "VarDef", + "location" : [ 24, 5, 24, 16 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 24, 5, 24, 12 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 24, 5, 24, 8 ], + "name" : "sign" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 24, 10, 24, 12 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 24, 16, 24, 16 ], + "value" : 1 + } + }, { + "kind" : "VarDef", + "location" : [ 25, 5, 25, 26 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 25, 5, 25, 19 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 25, 5, 25, 14 ], + "name" : "first_char" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 25, 16, 25, 19 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 25, 23, 25, 26 ], + "value" : true + } + } ], + "statements" : [ { + "kind" : "ForStmt", + "location" : [ 28, 5, 61, 4 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 28, 9, 28, 12 ], + "name" : "char" + }, + "iterable" : { + "kind" : "Identifier", + "location" : [ 28, 17, 28, 17 ], + "name" : "x" + }, + "body" : [ { + "kind" : "IfStmt", + "location" : [ 29, 9, 57, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 29, 12, 29, 22 ], + "left" : { + "kind" : "Identifier", + "location" : [ 29, 12, 29, 15 ], + "name" : "char" + }, + "operator" : "==", + "right" : { + "kind" : "StringLiteral", + "location" : [ 29, 20, 29, 22 ], + "value" : "-" + } + }, + "thenBody" : [ { + "kind" : "IfStmt", + "location" : [ 30, 13, 32, 12 ], + "condition" : { + "kind" : "UnaryExpr", + "location" : [ 30, 16, 30, 29 ], + "operator" : "not", + "operand" : { + "kind" : "Identifier", + "location" : [ 30, 20, 30, 29 ], + "name" : "first_char" + } + }, + "thenBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 31, 17, 31, 24 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 31, 24, 31, 24 ], + "value" : 0 + } + } ], + "elseBody" : [ ] + }, { + "kind" : "AssignStmt", + "location" : [ 32, 13, 32, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 32, 13, 32, 16 ], + "name" : "sign" + } ], + "value" : { + "kind" : "UnaryExpr", + "location" : [ 32, 20, 32, 21 ], + "operator" : "-", + "operand" : { + "kind" : "IntegerLiteral", + "location" : [ 32, 21, 32, 21 ], + "value" : 1 + } + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 33, 9, 57, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 33, 14, 33, 24 ], + "left" : { + "kind" : "Identifier", + "location" : [ 33, 14, 33, 17 ], + "name" : "char" + }, + "operator" : "==", + "right" : { + "kind" : "StringLiteral", + "location" : [ 33, 22, 33, 24 ], + "value" : "0" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 34, 13, 34, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 34, 13, 34, 17 ], + "name" : "digit" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 34, 21, 34, 21 ], + "value" : 0 + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 35, 9, 57, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 35, 14, 35, 24 ], + "left" : { + "kind" : "Identifier", + "location" : [ 35, 14, 35, 17 ], + "name" : "char" + }, + "operator" : "==", + "right" : { + "kind" : "StringLiteral", + "location" : [ 35, 22, 35, 24 ], + "value" : "1" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 36, 13, 36, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 36, 13, 36, 17 ], + "name" : "digit" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 36, 21, 36, 21 ], + "value" : 1 + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 37, 9, 57, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 37, 14, 37, 24 ], + "left" : { + "kind" : "Identifier", + "location" : [ 37, 14, 37, 17 ], + "name" : "char" + }, + "operator" : "==", + "right" : { + "kind" : "StringLiteral", + "location" : [ 37, 22, 37, 24 ], + "value" : "2" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 38, 13, 38, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 38, 13, 38, 17 ], + "name" : "digit" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 38, 21, 38, 21 ], + "value" : 2 + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 39, 9, 57, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 39, 14, 39, 24 ], + "left" : { + "kind" : "Identifier", + "location" : [ 39, 14, 39, 17 ], + "name" : "char" + }, + "operator" : "==", + "right" : { + "kind" : "StringLiteral", + "location" : [ 39, 22, 39, 24 ], + "value" : "3" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 40, 13, 40, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 40, 13, 40, 17 ], + "name" : "digit" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 40, 21, 40, 21 ], + "value" : 3 + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 41, 9, 57, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 41, 14, 41, 24 ], + "left" : { + "kind" : "Identifier", + "location" : [ 41, 14, 41, 17 ], + "name" : "char" + }, + "operator" : "==", + "right" : { + "kind" : "StringLiteral", + "location" : [ 41, 22, 41, 24 ], + "value" : "3" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 42, 13, 42, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 42, 13, 42, 17 ], + "name" : "digit" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 42, 21, 42, 21 ], + "value" : 3 + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 43, 9, 57, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 43, 14, 43, 24 ], + "left" : { + "kind" : "Identifier", + "location" : [ 43, 14, 43, 17 ], + "name" : "char" + }, + "operator" : "==", + "right" : { + "kind" : "StringLiteral", + "location" : [ 43, 22, 43, 24 ], + "value" : "4" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 44, 13, 44, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 44, 13, 44, 17 ], + "name" : "digit" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 44, 21, 44, 21 ], + "value" : 4 + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 45, 9, 57, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 45, 14, 45, 24 ], + "left" : { + "kind" : "Identifier", + "location" : [ 45, 14, 45, 17 ], + "name" : "char" + }, + "operator" : "==", + "right" : { + "kind" : "StringLiteral", + "location" : [ 45, 22, 45, 24 ], + "value" : "5" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 46, 13, 46, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 46, 13, 46, 17 ], + "name" : "digit" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 46, 21, 46, 21 ], + "value" : 5 + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 47, 9, 57, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 47, 14, 47, 24 ], + "left" : { + "kind" : "Identifier", + "location" : [ 47, 14, 47, 17 ], + "name" : "char" + }, + "operator" : "==", + "right" : { + "kind" : "StringLiteral", + "location" : [ 47, 22, 47, 24 ], + "value" : "6" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 48, 13, 48, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 48, 13, 48, 17 ], + "name" : "digit" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 48, 21, 48, 21 ], + "value" : 6 + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 49, 9, 57, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 49, 14, 49, 24 ], + "left" : { + "kind" : "Identifier", + "location" : [ 49, 14, 49, 17 ], + "name" : "char" + }, + "operator" : "==", + "right" : { + "kind" : "StringLiteral", + "location" : [ 49, 22, 49, 24 ], + "value" : "7" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 50, 13, 50, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 50, 13, 50, 17 ], + "name" : "digit" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 50, 21, 50, 21 ], + "value" : 7 + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 51, 9, 57, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 51, 14, 51, 24 ], + "left" : { + "kind" : "Identifier", + "location" : [ 51, 14, 51, 17 ], + "name" : "char" + }, + "operator" : "==", + "right" : { + "kind" : "StringLiteral", + "location" : [ 51, 22, 51, 24 ], + "value" : "8" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 52, 13, 52, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 52, 13, 52, 17 ], + "name" : "digit" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 52, 21, 52, 21 ], + "value" : 8 + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 53, 9, 57, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 53, 14, 53, 24 ], + "left" : { + "kind" : "Identifier", + "location" : [ 53, 14, 53, 17 ], + "name" : "char" + }, + "operator" : "==", + "right" : { + "kind" : "StringLiteral", + "location" : [ 53, 22, 53, 24 ], + "value" : "9" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 54, 13, 54, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 54, 13, 54, 17 ], + "name" : "digit" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 54, 21, 54, 21 ], + "value" : 9 + } + } ], + "elseBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 56, 13, 56, 20 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 56, 20, 56, 20 ], + "value" : 0 + } + } ] + } ] + } ] + } ] + } ] + } ] + } ] + } ] + } ] + } ] + } ] + } ] + }, { + "kind" : "AssignStmt", + "location" : [ 57, 9, 57, 26 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 57, 9, 57, 18 ], + "name" : "first_char" + } ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 57, 22, 57, 26 ], + "value" : false + } + }, { + "kind" : "AssignStmt", + "location" : [ 58, 9, 58, 36 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 58, 9, 58, 14 ], + "name" : "result" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 58, 18, 58, 36 ], + "left" : { + "kind" : "BinaryExpr", + "location" : [ 58, 18, 58, 28 ], + "left" : { + "kind" : "Identifier", + "location" : [ 58, 18, 58, 23 ], + "name" : "result" + }, + "operator" : "*", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 58, 27, 58, 28 ], + "value" : 10 + } + }, + "operator" : "+", + "right" : { + "kind" : "Identifier", + "location" : [ 58, 32, 58, 36 ], + "name" : "digit" + } + } + } ] + }, { + "kind" : "ReturnStmt", + "location" : [ 61, 5, 61, 24 ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 61, 12, 61, 24 ], + "left" : { + "kind" : "Identifier", + "location" : [ 61, 12, 61, 17 ], + "name" : "result" + }, + "operator" : "*", + "right" : { + "kind" : "Identifier", + "location" : [ 61, 21, 61, 24 ], + "name" : "sign" + } + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 64, 1, 64, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 64, 1, 64, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 64, 1, 64, 1 ], + "name" : "c" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 64, 3, 64, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 64, 9, 64, 10 ], + "value" : 42 + } + }, { + "kind" : "VarDef", + "location" : [ 65, 1, 65, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 65, 1, 65, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 65, 1, 65, 1 ], + "name" : "n" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 65, 3, 65, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 65, 9, 65, 10 ], + "value" : 10 + } + }, { + "kind" : "VarDef", + "location" : [ 68, 1, 68, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 68, 1, 68, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 68, 1, 68, 1 ], + "name" : "s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 68, 3, 68, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 68, 9, 68, 10 ], + "value" : "" + } + }, { + "kind" : "VarDef", + "location" : [ 69, 1, 69, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 69, 1, 69, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 69, 1, 69, 1 ], + "name" : "i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 69, 3, 69, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 69, 9, 69, 9 ], + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 70, 1, 70, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 70, 1, 70, 1 ], + "name" : "i" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 70, 5, 70, 10 ], + "left" : { + "kind" : "UnaryExpr", + "location" : [ 70, 5, 70, 6 ], + "operator" : "-", + "operand" : { + "kind" : "Identifier", + "location" : [ 70, 6, 70, 6 ], + "name" : "n" + } + }, + "operator" : "*", + "right" : { + "kind" : "Identifier", + "location" : [ 70, 10, 70, 10 ], + "name" : "c" + } + } + }, { + "kind" : "WhileStmt", + "location" : [ 73, 1, 78, 1 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 73, 7, 73, 16 ], + "left" : { + "kind" : "Identifier", + "location" : [ 73, 7, 73, 7 ], + "name" : "i" + }, + "operator" : "<=", + "right" : { + "kind" : "BinaryExpr", + "location" : [ 73, 12, 73, 16 ], + "left" : { + "kind" : "Identifier", + "location" : [ 73, 12, 73, 12 ], + "name" : "n" + }, + "operator" : "*", + "right" : { + "kind" : "Identifier", + "location" : [ 73, 16, 73, 16 ], + "name" : "c" + } + } + }, + "body" : [ { + "kind" : "AssignStmt", + "location" : [ 74, 5, 74, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 74, 5, 74, 5 ], + "name" : "s" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 74, 9, 74, 21 ], + "function" : { + "kind" : "Identifier", + "location" : [ 74, 9, 74, 18 ], + "name" : "int_to_str" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 74, 20, 74, 20 ], + "name" : "i" + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 75, 5, 75, 12 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 75, 5, 75, 12 ], + "function" : { + "kind" : "Identifier", + "location" : [ 75, 5, 75, 9 ], + "name" : "print" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 75, 11, 75, 11 ], + "name" : "s" + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 76, 5, 76, 25 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 76, 5, 76, 5 ], + "name" : "i" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 76, 9, 76, 25 ], + "left" : { + "kind" : "CallExpr", + "location" : [ 76, 9, 76, 21 ], + "function" : { + "kind" : "Identifier", + "location" : [ 76, 9, 76, 18 ], + "name" : "str_to_int" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 76, 20, 76, 20 ], + "name" : "s" + } ] + }, + "operator" : "+", + "right" : { + "kind" : "Identifier", + "location" : [ 76, 25, 76, 25 ], + "name" : "c" + } + } + } ] + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/extra/stdlib.py.ast.typed b/pa2-tests/extra/stdlib.py.ast.typed new file mode 100644 index 0000000..72079ff --- /dev/null +++ b/pa2-tests/extra/stdlib.py.ast.typed @@ -0,0 +1,1813 @@ +{ + "kind" : "Program", + "location" : [ 2, 1, 78, 1 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 2, 1, 18, 18 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 14 ], + "name" : "int_to_str" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 2, 16, 2, 21 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 16, 2, 16 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 19, 2, 21 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 2, 27, 2, 29 ], + "className" : "str" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 3, 5, 3, 23 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 5, 3, 16 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 10 ], + "name" : "digits" + }, + "type" : { + "kind" : "ListType", + "location" : [ 3, 12, 3, 16 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 3, 13, 3, 15 ], + "className" : "str" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 3, 20, 3, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 4, 5, 4, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 5, 4, 14 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 10 ], + "name" : "result" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 12, 4, 14 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 4, 18, 4, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "" + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 7, 5, 7, 63 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 10 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "str" + } + }, + "name" : "digits" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 7, 14, 7, 63 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "str" + } + }, + "elements" : [ { + "kind" : "StringLiteral", + "location" : [ 7, 15, 7, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "0" + }, { + "kind" : "StringLiteral", + "location" : [ 7, 20, 7, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "1" + }, { + "kind" : "StringLiteral", + "location" : [ 7, 25, 7, 27 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "2" + }, { + "kind" : "StringLiteral", + "location" : [ 7, 30, 7, 32 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "3" + }, { + "kind" : "StringLiteral", + "location" : [ 7, 35, 7, 37 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "4" + }, { + "kind" : "StringLiteral", + "location" : [ 7, 40, 7, 42 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "5" + }, { + "kind" : "StringLiteral", + "location" : [ 7, 45, 7, 47 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "6" + }, { + "kind" : "StringLiteral", + "location" : [ 7, 50, 7, 52 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "7" + }, { + "kind" : "StringLiteral", + "location" : [ 7, 55, 7, 57 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "8" + }, { + "kind" : "StringLiteral", + "location" : [ 7, 60, 7, 62 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "9" + } ] + } + }, { + "kind" : "IfStmt", + "location" : [ 10, 5, 15, 4 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 10, 8, 10, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 10, 8, 10, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "operator" : "<", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 10, 12, 10, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 11, 9, 11, 20 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 11, 9, 11, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "result" + } ], + "value" : { + "kind" : "StringLiteral", + "location" : [ 11, 18, 11, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "-" + } + }, { + "kind" : "AssignStmt", + "location" : [ 12, 9, 12, 14 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 12, 9, 12, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ], + "value" : { + "kind" : "UnaryExpr", + "location" : [ 12, 13, 12, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "operator" : "-", + "operand" : { + "kind" : "Identifier", + "location" : [ 12, 14, 12, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } + } + } ], + "elseBody" : [ ] + }, { + "kind" : "IfStmt", + "location" : [ 15, 5, 17, 4 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 15, 8, 15, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 15, 8, 15, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "operator" : ">=", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 15, 13, 15, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 10 + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 16, 9, 16, 45 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 16, 9, 16, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "result" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 16, 18, 16, 45 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 16, 18, 16, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "result" + }, + "operator" : "+", + "right" : { + "kind" : "CallExpr", + "location" : [ 16, 27, 16, 45 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 16, 27, 16, 36 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "str" + } + }, + "name" : "int_to_str" + }, + "args" : [ { + "kind" : "BinaryExpr", + "location" : [ 16, 38, 16, 44 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 16, 38, 16, 38 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "operator" : "//", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 16, 43, 16, 44 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 10 + } + } ] + } + } + } ], + "elseBody" : [ ] + }, { + "kind" : "AssignStmt", + "location" : [ 17, 5, 17, 36 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 17, 5, 17, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "result" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 17, 14, 17, 36 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 17, 14, 17, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "result" + }, + "operator" : "+", + "right" : { + "kind" : "IndexExpr", + "location" : [ 17, 23, 17, 36 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 17, 23, 17, 28 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "str" + } + }, + "name" : "digits" + }, + "index" : { + "kind" : "BinaryExpr", + "location" : [ 17, 30, 17, 35 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 17, 30, 17, 30 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "operator" : "%", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 17, 34, 17, 35 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 10 + } + } + } + } + }, { + "kind" : "ReturnStmt", + "location" : [ 18, 5, 18, 17 ], + "value" : { + "kind" : "Identifier", + "location" : [ 18, 12, 18, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "result" + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 20, 1, 61, 25 ], + "name" : { + "kind" : "Identifier", + "location" : [ 20, 5, 20, 14 ], + "name" : "str_to_int" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 20, 16, 20, 21 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 20, 16, 20, 16 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 20, 19, 20, 21 ], + "className" : "str" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 20, 27, 20, 29 ], + "className" : "int" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 21, 5, 21, 18 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 21, 5, 21, 14 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 21, 5, 21, 10 ], + "name" : "result" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 21, 12, 21, 14 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 21, 18, 21, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 22, 5, 22, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 22, 5, 22, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 22, 5, 22, 9 ], + "name" : "digit" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 22, 11, 22, 13 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 22, 17, 22, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 23, 5, 23, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 23, 5, 23, 12 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 23, 5, 23, 8 ], + "name" : "char" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 23, 10, 23, 12 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 23, 16, 23, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "" + } + }, { + "kind" : "VarDef", + "location" : [ 24, 5, 24, 16 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 24, 5, 24, 12 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 24, 5, 24, 8 ], + "name" : "sign" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 24, 10, 24, 12 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 24, 16, 24, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "VarDef", + "location" : [ 25, 5, 25, 26 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 25, 5, 25, 19 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 25, 5, 25, 14 ], + "name" : "first_char" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 25, 16, 25, 19 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 25, 23, 25, 26 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + } ], + "statements" : [ { + "kind" : "ForStmt", + "location" : [ 28, 5, 61, 4 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 28, 9, 28, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "char" + }, + "iterable" : { + "kind" : "Identifier", + "location" : [ 28, 17, 28, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "x" + }, + "body" : [ { + "kind" : "IfStmt", + "location" : [ 29, 9, 57, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 29, 12, 29, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 29, 12, 29, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "char" + }, + "operator" : "==", + "right" : { + "kind" : "StringLiteral", + "location" : [ 29, 20, 29, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "-" + } + }, + "thenBody" : [ { + "kind" : "IfStmt", + "location" : [ 30, 13, 32, 12 ], + "condition" : { + "kind" : "UnaryExpr", + "location" : [ 30, 16, 30, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "operator" : "not", + "operand" : { + "kind" : "Identifier", + "location" : [ 30, 20, 30, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "name" : "first_char" + } + }, + "thenBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 31, 17, 31, 24 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 31, 24, 31, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "elseBody" : [ ] + }, { + "kind" : "AssignStmt", + "location" : [ 32, 13, 32, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 32, 13, 32, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "sign" + } ], + "value" : { + "kind" : "UnaryExpr", + "location" : [ 32, 20, 32, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "operator" : "-", + "operand" : { + "kind" : "IntegerLiteral", + "location" : [ 32, 21, 32, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 33, 9, 57, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 33, 14, 33, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 33, 14, 33, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "char" + }, + "operator" : "==", + "right" : { + "kind" : "StringLiteral", + "location" : [ 33, 22, 33, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "0" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 34, 13, 34, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 34, 13, 34, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "digit" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 34, 21, 34, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 35, 9, 57, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 35, 14, 35, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 35, 14, 35, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "char" + }, + "operator" : "==", + "right" : { + "kind" : "StringLiteral", + "location" : [ 35, 22, 35, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "1" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 36, 13, 36, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 36, 13, 36, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "digit" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 36, 21, 36, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 37, 9, 57, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 37, 14, 37, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 37, 14, 37, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "char" + }, + "operator" : "==", + "right" : { + "kind" : "StringLiteral", + "location" : [ 37, 22, 37, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "2" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 38, 13, 38, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 38, 13, 38, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "digit" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 38, 21, 38, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 39, 9, 57, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 39, 14, 39, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 39, 14, 39, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "char" + }, + "operator" : "==", + "right" : { + "kind" : "StringLiteral", + "location" : [ 39, 22, 39, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "3" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 40, 13, 40, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 40, 13, 40, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "digit" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 40, 21, 40, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 41, 9, 57, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 41, 14, 41, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 41, 14, 41, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "char" + }, + "operator" : "==", + "right" : { + "kind" : "StringLiteral", + "location" : [ 41, 22, 41, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "3" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 42, 13, 42, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 42, 13, 42, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "digit" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 42, 21, 42, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 43, 9, 57, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 43, 14, 43, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 43, 14, 43, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "char" + }, + "operator" : "==", + "right" : { + "kind" : "StringLiteral", + "location" : [ 43, 22, 43, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "4" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 44, 13, 44, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 44, 13, 44, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "digit" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 44, 21, 44, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 4 + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 45, 9, 57, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 45, 14, 45, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 45, 14, 45, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "char" + }, + "operator" : "==", + "right" : { + "kind" : "StringLiteral", + "location" : [ 45, 22, 45, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "5" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 46, 13, 46, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 46, 13, 46, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "digit" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 46, 21, 46, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 5 + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 47, 9, 57, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 47, 14, 47, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 47, 14, 47, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "char" + }, + "operator" : "==", + "right" : { + "kind" : "StringLiteral", + "location" : [ 47, 22, 47, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "6" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 48, 13, 48, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 48, 13, 48, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "digit" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 48, 21, 48, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 6 + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 49, 9, 57, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 49, 14, 49, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 49, 14, 49, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "char" + }, + "operator" : "==", + "right" : { + "kind" : "StringLiteral", + "location" : [ 49, 22, 49, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "7" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 50, 13, 50, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 50, 13, 50, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "digit" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 50, 21, 50, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 7 + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 51, 9, 57, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 51, 14, 51, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 51, 14, 51, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "char" + }, + "operator" : "==", + "right" : { + "kind" : "StringLiteral", + "location" : [ 51, 22, 51, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "8" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 52, 13, 52, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 52, 13, 52, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "digit" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 52, 21, 52, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 8 + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 53, 9, 57, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 53, 14, 53, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 53, 14, 53, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "char" + }, + "operator" : "==", + "right" : { + "kind" : "StringLiteral", + "location" : [ 53, 22, 53, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "9" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 54, 13, 54, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 54, 13, 54, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "digit" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 54, 21, 54, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 9 + } + } ], + "elseBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 56, 13, 56, 20 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 56, 20, 56, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ] + } ] + } ] + } ] + } ] + } ] + } ] + } ] + } ] + } ] + } ] + } ] + }, { + "kind" : "AssignStmt", + "location" : [ 57, 9, 57, 26 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 57, 9, 57, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "name" : "first_char" + } ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 57, 22, 57, 26 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } + }, { + "kind" : "AssignStmt", + "location" : [ 58, 9, 58, 36 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 58, 9, 58, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "result" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 58, 18, 58, 36 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "BinaryExpr", + "location" : [ 58, 18, 58, 28 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 58, 18, 58, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "result" + }, + "operator" : "*", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 58, 27, 58, 28 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 10 + } + }, + "operator" : "+", + "right" : { + "kind" : "Identifier", + "location" : [ 58, 32, 58, 36 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "digit" + } + } + } ] + }, { + "kind" : "ReturnStmt", + "location" : [ 61, 5, 61, 24 ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 61, 12, 61, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 61, 12, 61, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "result" + }, + "operator" : "*", + "right" : { + "kind" : "Identifier", + "location" : [ 61, 21, 61, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "sign" + } + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 64, 1, 64, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 64, 1, 64, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 64, 1, 64, 1 ], + "name" : "c" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 64, 3, 64, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 64, 9, 64, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 42 + } + }, { + "kind" : "VarDef", + "location" : [ 65, 1, 65, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 65, 1, 65, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 65, 1, 65, 1 ], + "name" : "n" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 65, 3, 65, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 65, 9, 65, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 10 + } + }, { + "kind" : "VarDef", + "location" : [ 68, 1, 68, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 68, 1, 68, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 68, 1, 68, 1 ], + "name" : "s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 68, 3, 68, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 68, 9, 68, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "" + } + }, { + "kind" : "VarDef", + "location" : [ 69, 1, 69, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 69, 1, 69, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 69, 1, 69, 1 ], + "name" : "i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 69, 3, 69, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 69, 9, 69, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 70, 1, 70, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 70, 1, 70, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 70, 5, 70, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "UnaryExpr", + "location" : [ 70, 5, 70, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "operator" : "-", + "operand" : { + "kind" : "Identifier", + "location" : [ 70, 6, 70, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "n" + } + }, + "operator" : "*", + "right" : { + "kind" : "Identifier", + "location" : [ 70, 10, 70, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "c" + } + } + }, { + "kind" : "WhileStmt", + "location" : [ 73, 1, 78, 1 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 73, 7, 73, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 73, 7, 73, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + }, + "operator" : "<=", + "right" : { + "kind" : "BinaryExpr", + "location" : [ 73, 12, 73, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 73, 12, 73, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "n" + }, + "operator" : "*", + "right" : { + "kind" : "Identifier", + "location" : [ 73, 16, 73, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "c" + } + } + }, + "body" : [ { + "kind" : "AssignStmt", + "location" : [ 74, 5, 74, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 74, 5, 74, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "s" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 74, 9, 74, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 74, 9, 74, 18 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "str" + } + }, + "name" : "int_to_str" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 74, 20, 74, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 75, 5, 75, 12 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 75, 5, 75, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 75, 5, 75, 9 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, + "name" : "print" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 75, 11, 75, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "s" + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 76, 5, 76, 25 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 76, 5, 76, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 76, 9, 76, 25 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "CallExpr", + "location" : [ 76, 9, 76, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 76, 9, 76, 18 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "str" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "str_to_int" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 76, 20, 76, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "s" + } ] + }, + "operator" : "+", + "right" : { + "kind" : "Identifier", + "location" : [ 76, 25, 76, 25 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "c" + } + } + } ] + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/extra/tree.py b/pa2-tests/extra/tree.py new file mode 100644 index 0000000..9f337fd --- /dev/null +++ b/pa2-tests/extra/tree.py @@ -0,0 +1,83 @@ +# Binary-search trees +class TreeNode(object): + value:int = 0 + left:"TreeNode" = None + right:"TreeNode" = None + + def insert(self:"TreeNode", x:int) -> bool: + if x < self.value: + if self.left is None: + self.left = makeNode(x) + return True + else: + return self.left.insert(x) + elif x > self.value: + if self.right is None: + self.right = makeNode(x) + return True + else: + return self.right.insert(x) + return False + + def contains(self:"TreeNode", x:int) -> bool: + if x < self.value: + if self.left is None: + return False + else: + return self.left.contains(x) + elif x > self.value: + if self.right is None: + return False + else: + return self.right.contains(x) + else: + return True + +class Tree(object): + root:TreeNode = None + size:int = 0 + + def insert(self:"Tree", x:int) -> object: + if self.root is None: + self.root = makeNode(x) + self.size = 1 + else: + if self.root.insert(x): + self.size = self.size + 1 + + def contains(self:"Tree", x:int) -> bool: + if self.root is None: + return False + else: + return self.root.contains(x) + +def makeNode(x: int) -> TreeNode: + b:TreeNode = None + b = TreeNode() + b.value = x + return b + + +# Input parameters +n:int = 100 +c:int = 4 + +# Data +t:Tree = None +i:int = 0 +k:int = 37813 + +# Crunch +t = Tree() +while i < n: + t.insert(k) + k = (k * 37813) % 37831 + if i % c != 0: + t.insert(i) + i = i + 1 + +print(t.size) + +for i in [4, 8, 15, 16, 23, 42]: + if t.contains(i): + print(i) diff --git a/pa2-tests/extra/tree.py.ast b/pa2-tests/extra/tree.py.ast new file mode 100644 index 0000000..bbee694 --- /dev/null +++ b/pa2-tests/extra/tree.py.ast @@ -0,0 +1,1513 @@ +{ + "kind" : "Program", + "location" : [ 2, 1, 84, 2 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 2, 1, 36, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 7, 2, 14 ], + "name" : "TreeNode" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 2, 16, 2, 21 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 3, 2, 3, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 2, 3, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 2, 3, 6 ], + "name" : "value" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 8, 3, 10 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 14, 3, 14 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 4, 2, 4, 23 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 2, 4, 16 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 2, 4, 5 ], + "name" : "left" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 7, 4, 16 ], + "className" : "TreeNode" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 4, 20, 4, 23 ] + } + }, { + "kind" : "VarDef", + "location" : [ 5, 2, 5, 24 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 5, 2, 5, 17 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 2, 5, 6 ], + "name" : "right" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 8, 5, 17 ], + "className" : "TreeNode" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 5, 21, 5, 24 ] + } + }, { + "kind" : "FuncDef", + "location" : [ 7, 2, 20, 15 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 6, 7, 11 ], + "name" : "insert" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 7, 13, 7, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 7, 13, 7, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 7, 18, 7, 27 ], + "className" : "TreeNode" + } + }, { + "kind" : "TypedVar", + "location" : [ 7, 30, 7, 34 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 7, 30, 7, 30 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 7, 32, 7, 34 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 7, 40, 7, 43 ], + "className" : "bool" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 8, 3, 20, 2 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 8, 6, 8, 19 ], + "left" : { + "kind" : "Identifier", + "location" : [ 8, 6, 8, 6 ], + "name" : "x" + }, + "operator" : "<", + "right" : { + "kind" : "MemberExpr", + "location" : [ 8, 10, 8, 19 ], + "object" : { + "kind" : "Identifier", + "location" : [ 8, 10, 8, 13 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 8, 15, 8, 19 ], + "name" : "value" + } + } + }, + "thenBody" : [ { + "kind" : "IfStmt", + "location" : [ 9, 4, 14, 2 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 9, 7, 9, 23 ], + "left" : { + "kind" : "MemberExpr", + "location" : [ 9, 7, 9, 15 ], + "object" : { + "kind" : "Identifier", + "location" : [ 9, 7, 9, 10 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 9, 12, 9, 15 ], + "name" : "left" + } + }, + "operator" : "is", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 9, 20, 9, 23 ] + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 10, 5, 10, 27 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 10, 5, 10, 13 ], + "object" : { + "kind" : "Identifier", + "location" : [ 10, 5, 10, 8 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 10, 10, 10, 13 ], + "name" : "left" + } + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 10, 17, 10, 27 ], + "function" : { + "kind" : "Identifier", + "location" : [ 10, 17, 10, 24 ], + "name" : "makeNode" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 10, 26, 10, 26 ], + "name" : "x" + } ] + } + }, { + "kind" : "ReturnStmt", + "location" : [ 11, 5, 11, 15 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 11, 12, 11, 15 ], + "value" : true + } + } ], + "elseBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 13, 5, 13, 30 ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 13, 12, 13, 30 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 13, 12, 13, 27 ], + "object" : { + "kind" : "MemberExpr", + "location" : [ 13, 12, 13, 20 ], + "object" : { + "kind" : "Identifier", + "location" : [ 13, 12, 13, 15 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 13, 17, 13, 20 ], + "name" : "left" + } + }, + "member" : { + "kind" : "Identifier", + "location" : [ 13, 22, 13, 27 ], + "name" : "insert" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 13, 29, 13, 29 ], + "name" : "x" + } ] + } + } ] + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 14, 3, 20, 2 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 14, 8, 14, 21 ], + "left" : { + "kind" : "Identifier", + "location" : [ 14, 8, 14, 8 ], + "name" : "x" + }, + "operator" : ">", + "right" : { + "kind" : "MemberExpr", + "location" : [ 14, 12, 14, 21 ], + "object" : { + "kind" : "Identifier", + "location" : [ 14, 12, 14, 15 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 14, 17, 14, 21 ], + "name" : "value" + } + } + }, + "thenBody" : [ { + "kind" : "IfStmt", + "location" : [ 15, 4, 20, 2 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 15, 7, 15, 24 ], + "left" : { + "kind" : "MemberExpr", + "location" : [ 15, 7, 15, 16 ], + "object" : { + "kind" : "Identifier", + "location" : [ 15, 7, 15, 10 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 15, 12, 15, 16 ], + "name" : "right" + } + }, + "operator" : "is", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 15, 21, 15, 24 ] + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 16, 5, 16, 28 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 16, 5, 16, 14 ], + "object" : { + "kind" : "Identifier", + "location" : [ 16, 5, 16, 8 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 16, 10, 16, 14 ], + "name" : "right" + } + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 16, 18, 16, 28 ], + "function" : { + "kind" : "Identifier", + "location" : [ 16, 18, 16, 25 ], + "name" : "makeNode" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 16, 27, 16, 27 ], + "name" : "x" + } ] + } + }, { + "kind" : "ReturnStmt", + "location" : [ 17, 5, 17, 15 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 17, 12, 17, 15 ], + "value" : true + } + } ], + "elseBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 19, 5, 19, 31 ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 19, 12, 19, 31 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 19, 12, 19, 28 ], + "object" : { + "kind" : "MemberExpr", + "location" : [ 19, 12, 19, 21 ], + "object" : { + "kind" : "Identifier", + "location" : [ 19, 12, 19, 15 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 19, 17, 19, 21 ], + "name" : "right" + } + }, + "member" : { + "kind" : "Identifier", + "location" : [ 19, 23, 19, 28 ], + "name" : "insert" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 19, 30, 19, 30 ], + "name" : "x" + } ] + } + } ] + } ], + "elseBody" : [ ] + } ] + }, { + "kind" : "ReturnStmt", + "location" : [ 20, 3, 20, 14 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 20, 10, 20, 14 ], + "value" : false + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 22, 2, 36, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 22, 6, 22, 13 ], + "name" : "contains" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 22, 15, 22, 29 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 22, 15, 22, 18 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 22, 20, 22, 29 ], + "className" : "TreeNode" + } + }, { + "kind" : "TypedVar", + "location" : [ 22, 32, 22, 36 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 22, 32, 22, 32 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 22, 34, 22, 36 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 22, 42, 22, 45 ], + "className" : "bool" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 23, 3, 36, 0 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 23, 6, 23, 19 ], + "left" : { + "kind" : "Identifier", + "location" : [ 23, 6, 23, 6 ], + "name" : "x" + }, + "operator" : "<", + "right" : { + "kind" : "MemberExpr", + "location" : [ 23, 10, 23, 19 ], + "object" : { + "kind" : "Identifier", + "location" : [ 23, 10, 23, 13 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 23, 15, 23, 19 ], + "name" : "value" + } + } + }, + "thenBody" : [ { + "kind" : "IfStmt", + "location" : [ 24, 4, 28, 2 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 24, 7, 24, 23 ], + "left" : { + "kind" : "MemberExpr", + "location" : [ 24, 7, 24, 15 ], + "object" : { + "kind" : "Identifier", + "location" : [ 24, 7, 24, 10 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 24, 12, 24, 15 ], + "name" : "left" + } + }, + "operator" : "is", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 24, 20, 24, 23 ] + } + }, + "thenBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 25, 5, 25, 16 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 25, 12, 25, 16 ], + "value" : false + } + } ], + "elseBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 27, 5, 27, 32 ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 27, 12, 27, 32 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 27, 12, 27, 29 ], + "object" : { + "kind" : "MemberExpr", + "location" : [ 27, 12, 27, 20 ], + "object" : { + "kind" : "Identifier", + "location" : [ 27, 12, 27, 15 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 27, 17, 27, 20 ], + "name" : "left" + } + }, + "member" : { + "kind" : "Identifier", + "location" : [ 27, 22, 27, 29 ], + "name" : "contains" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 27, 31, 27, 31 ], + "name" : "x" + } ] + } + } ] + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 28, 3, 36, 0 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 28, 8, 28, 21 ], + "left" : { + "kind" : "Identifier", + "location" : [ 28, 8, 28, 8 ], + "name" : "x" + }, + "operator" : ">", + "right" : { + "kind" : "MemberExpr", + "location" : [ 28, 12, 28, 21 ], + "object" : { + "kind" : "Identifier", + "location" : [ 28, 12, 28, 15 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 28, 17, 28, 21 ], + "name" : "value" + } + } + }, + "thenBody" : [ { + "kind" : "IfStmt", + "location" : [ 29, 4, 33, 2 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 29, 7, 29, 24 ], + "left" : { + "kind" : "MemberExpr", + "location" : [ 29, 7, 29, 16 ], + "object" : { + "kind" : "Identifier", + "location" : [ 29, 7, 29, 10 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 29, 12, 29, 16 ], + "name" : "right" + } + }, + "operator" : "is", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 29, 21, 29, 24 ] + } + }, + "thenBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 30, 5, 30, 16 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 30, 12, 30, 16 ], + "value" : false + } + } ], + "elseBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 32, 5, 32, 33 ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 32, 12, 32, 33 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 32, 12, 32, 30 ], + "object" : { + "kind" : "MemberExpr", + "location" : [ 32, 12, 32, 21 ], + "object" : { + "kind" : "Identifier", + "location" : [ 32, 12, 32, 15 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 32, 17, 32, 21 ], + "name" : "right" + } + }, + "member" : { + "kind" : "Identifier", + "location" : [ 32, 23, 32, 30 ], + "name" : "contains" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 32, 32, 32, 32 ], + "name" : "x" + } ] + } + } ] + } ], + "elseBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 34, 4, 34, 14 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 34, 11, 34, 14 ], + "value" : true + } + } ] + } ] + } ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 36, 1, 54, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 36, 7, 36, 10 ], + "name" : "Tree" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 36, 12, 36, 17 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 37, 2, 37, 21 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 37, 2, 37, 14 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 37, 2, 37, 5 ], + "name" : "root" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 37, 7, 37, 14 ], + "className" : "TreeNode" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 37, 18, 37, 21 ] + } + }, { + "kind" : "VarDef", + "location" : [ 38, 2, 38, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 38, 2, 38, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 38, 2, 38, 5 ], + "name" : "size" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 38, 7, 38, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 38, 13, 38, 13 ], + "value" : 0 + } + }, { + "kind" : "FuncDef", + "location" : [ 40, 2, 48, 1 ], + "name" : { + "kind" : "Identifier", + "location" : [ 40, 6, 40, 11 ], + "name" : "insert" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 40, 13, 40, 23 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 40, 13, 40, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 40, 18, 40, 23 ], + "className" : "Tree" + } + }, { + "kind" : "TypedVar", + "location" : [ 40, 26, 40, 30 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 40, 26, 40, 26 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 40, 28, 40, 30 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 40, 36, 40, 41 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 41, 3, 48, 1 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 41, 6, 41, 22 ], + "left" : { + "kind" : "MemberExpr", + "location" : [ 41, 6, 41, 14 ], + "object" : { + "kind" : "Identifier", + "location" : [ 41, 6, 41, 9 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 41, 11, 41, 14 ], + "name" : "root" + } + }, + "operator" : "is", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 41, 19, 41, 22 ] + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 42, 4, 42, 26 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 42, 4, 42, 12 ], + "object" : { + "kind" : "Identifier", + "location" : [ 42, 4, 42, 7 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 42, 9, 42, 12 ], + "name" : "root" + } + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 42, 16, 42, 26 ], + "function" : { + "kind" : "Identifier", + "location" : [ 42, 16, 42, 23 ], + "name" : "makeNode" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 42, 25, 42, 25 ], + "name" : "x" + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 43, 4, 43, 16 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 43, 4, 43, 12 ], + "object" : { + "kind" : "Identifier", + "location" : [ 43, 4, 43, 7 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 43, 9, 43, 12 ], + "name" : "size" + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 43, 16, 43, 16 ], + "value" : 1 + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 45, 4, 48, 1 ], + "condition" : { + "kind" : "MethodCallExpr", + "location" : [ 45, 7, 45, 25 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 45, 7, 45, 22 ], + "object" : { + "kind" : "MemberExpr", + "location" : [ 45, 7, 45, 15 ], + "object" : { + "kind" : "Identifier", + "location" : [ 45, 7, 45, 10 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 45, 12, 45, 15 ], + "name" : "root" + } + }, + "member" : { + "kind" : "Identifier", + "location" : [ 45, 17, 45, 22 ], + "name" : "insert" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 45, 24, 45, 24 ], + "name" : "x" + } ] + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 46, 5, 46, 29 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 46, 5, 46, 13 ], + "object" : { + "kind" : "Identifier", + "location" : [ 46, 5, 46, 8 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 46, 10, 46, 13 ], + "name" : "size" + } + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 46, 17, 46, 29 ], + "left" : { + "kind" : "MemberExpr", + "location" : [ 46, 17, 46, 25 ], + "object" : { + "kind" : "Identifier", + "location" : [ 46, 17, 46, 20 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 46, 22, 46, 25 ], + "name" : "size" + } + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 46, 29, 46, 29 ], + "value" : 1 + } + } + } ], + "elseBody" : [ ] + } ] + } ] + }, { + "kind" : "FuncDef", + "location" : [ 48, 2, 54, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 48, 6, 48, 13 ], + "name" : "contains" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 48, 15, 48, 25 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 48, 15, 48, 18 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 48, 20, 48, 25 ], + "className" : "Tree" + } + }, { + "kind" : "TypedVar", + "location" : [ 48, 28, 48, 32 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 48, 28, 48, 28 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 48, 30, 48, 32 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 48, 38, 48, 41 ], + "className" : "bool" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 49, 3, 54, 0 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 49, 6, 49, 22 ], + "left" : { + "kind" : "MemberExpr", + "location" : [ 49, 6, 49, 14 ], + "object" : { + "kind" : "Identifier", + "location" : [ 49, 6, 49, 9 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 49, 11, 49, 14 ], + "name" : "root" + } + }, + "operator" : "is", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 49, 19, 49, 22 ] + } + }, + "thenBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 50, 4, 50, 15 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 50, 11, 50, 15 ], + "value" : false + } + } ], + "elseBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 52, 4, 52, 31 ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 52, 11, 52, 31 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 52, 11, 52, 28 ], + "object" : { + "kind" : "MemberExpr", + "location" : [ 52, 11, 52, 19 ], + "object" : { + "kind" : "Identifier", + "location" : [ 52, 11, 52, 14 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 52, 16, 52, 19 ], + "name" : "root" + } + }, + "member" : { + "kind" : "Identifier", + "location" : [ 52, 21, 52, 28 ], + "name" : "contains" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 52, 30, 52, 30 ], + "name" : "x" + } ] + } + } ] + } ] + } ] + }, { + "kind" : "FuncDef", + "location" : [ 54, 1, 58, 10 ], + "name" : { + "kind" : "Identifier", + "location" : [ 54, 5, 54, 12 ], + "name" : "makeNode" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 54, 14, 54, 19 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 54, 14, 54, 14 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 54, 17, 54, 19 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 54, 25, 54, 32 ], + "className" : "TreeNode" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 55, 2, 55, 18 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 55, 2, 55, 11 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 55, 2, 55, 2 ], + "name" : "b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 55, 4, 55, 11 ], + "className" : "TreeNode" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 55, 15, 55, 18 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 56, 2, 56, 15 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 56, 2, 56, 2 ], + "name" : "b" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 56, 6, 56, 15 ], + "function" : { + "kind" : "Identifier", + "location" : [ 56, 6, 56, 13 ], + "name" : "TreeNode" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 57, 2, 57, 12 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 57, 2, 57, 8 ], + "object" : { + "kind" : "Identifier", + "location" : [ 57, 2, 57, 2 ], + "name" : "b" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 57, 4, 57, 8 ], + "name" : "value" + } + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 57, 12, 57, 12 ], + "name" : "x" + } + }, { + "kind" : "ReturnStmt", + "location" : [ 58, 2, 58, 9 ], + "value" : { + "kind" : "Identifier", + "location" : [ 58, 9, 58, 9 ], + "name" : "b" + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 62, 1, 62, 11 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 62, 1, 62, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 62, 1, 62, 1 ], + "name" : "n" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 62, 3, 62, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 62, 9, 62, 11 ], + "value" : 100 + } + }, { + "kind" : "VarDef", + "location" : [ 63, 1, 63, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 63, 1, 63, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 63, 1, 63, 1 ], + "name" : "c" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 63, 3, 63, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 63, 9, 63, 9 ], + "value" : 4 + } + }, { + "kind" : "VarDef", + "location" : [ 66, 1, 66, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 66, 1, 66, 6 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 66, 1, 66, 1 ], + "name" : "t" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 66, 3, 66, 6 ], + "className" : "Tree" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 66, 10, 66, 13 ] + } + }, { + "kind" : "VarDef", + "location" : [ 67, 1, 67, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 67, 1, 67, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 67, 1, 67, 1 ], + "name" : "i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 67, 3, 67, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 67, 9, 67, 9 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 68, 1, 68, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 68, 1, 68, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 68, 1, 68, 1 ], + "name" : "k" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 68, 3, 68, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 68, 9, 68, 13 ], + "value" : 37813 + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 71, 1, 71, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 71, 1, 71, 1 ], + "name" : "t" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 71, 5, 71, 10 ], + "function" : { + "kind" : "Identifier", + "location" : [ 71, 5, 71, 8 ], + "name" : "Tree" + }, + "args" : [ ] + } + }, { + "kind" : "WhileStmt", + "location" : [ 72, 1, 79, 0 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 72, 7, 72, 11 ], + "left" : { + "kind" : "Identifier", + "location" : [ 72, 7, 72, 7 ], + "name" : "i" + }, + "operator" : "<", + "right" : { + "kind" : "Identifier", + "location" : [ 72, 11, 72, 11 ], + "name" : "n" + } + }, + "body" : [ { + "kind" : "ExprStmt", + "location" : [ 73, 2, 73, 12 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 73, 2, 73, 12 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 73, 2, 73, 9 ], + "object" : { + "kind" : "Identifier", + "location" : [ 73, 2, 73, 2 ], + "name" : "t" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 73, 4, 73, 9 ], + "name" : "insert" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 73, 11, 73, 11 ], + "name" : "k" + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 74, 2, 74, 24 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 74, 2, 74, 2 ], + "name" : "k" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 74, 6, 74, 24 ], + "left" : { + "kind" : "BinaryExpr", + "location" : [ 74, 7, 74, 15 ], + "left" : { + "kind" : "Identifier", + "location" : [ 74, 7, 74, 7 ], + "name" : "k" + }, + "operator" : "*", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 74, 11, 74, 15 ], + "value" : 37813 + } + }, + "operator" : "%", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 74, 20, 74, 24 ], + "value" : 37831 + } + } + }, { + "kind" : "IfStmt", + "location" : [ 75, 2, 77, 1 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 75, 5, 75, 14 ], + "left" : { + "kind" : "BinaryExpr", + "location" : [ 75, 5, 75, 9 ], + "left" : { + "kind" : "Identifier", + "location" : [ 75, 5, 75, 5 ], + "name" : "i" + }, + "operator" : "%", + "right" : { + "kind" : "Identifier", + "location" : [ 75, 9, 75, 9 ], + "name" : "c" + } + }, + "operator" : "!=", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 75, 14, 75, 14 ], + "value" : 0 + } + }, + "thenBody" : [ { + "kind" : "ExprStmt", + "location" : [ 76, 3, 76, 13 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 76, 3, 76, 13 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 76, 3, 76, 10 ], + "object" : { + "kind" : "Identifier", + "location" : [ 76, 3, 76, 3 ], + "name" : "t" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 76, 5, 76, 10 ], + "name" : "insert" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 76, 12, 76, 12 ], + "name" : "i" + } ] + } + } ], + "elseBody" : [ ] + }, { + "kind" : "AssignStmt", + "location" : [ 77, 2, 77, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 77, 2, 77, 2 ], + "name" : "i" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 77, 6, 77, 10 ], + "left" : { + "kind" : "Identifier", + "location" : [ 77, 6, 77, 6 ], + "name" : "i" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 77, 10, 77, 10 ], + "value" : 1 + } + } + } ] + }, { + "kind" : "ExprStmt", + "location" : [ 79, 1, 79, 13 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 79, 1, 79, 13 ], + "function" : { + "kind" : "Identifier", + "location" : [ 79, 1, 79, 5 ], + "name" : "print" + }, + "args" : [ { + "kind" : "MemberExpr", + "location" : [ 79, 7, 79, 12 ], + "object" : { + "kind" : "Identifier", + "location" : [ 79, 7, 79, 7 ], + "name" : "t" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 79, 9, 79, 12 ], + "name" : "size" + } + } ] + } + }, { + "kind" : "ForStmt", + "location" : [ 81, 1, 84, 2 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 81, 5, 81, 5 ], + "name" : "i" + }, + "iterable" : { + "kind" : "ListExpr", + "location" : [ 81, 10, 81, 31 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 81, 11, 81, 11 ], + "value" : 4 + }, { + "kind" : "IntegerLiteral", + "location" : [ 81, 14, 81, 14 ], + "value" : 8 + }, { + "kind" : "IntegerLiteral", + "location" : [ 81, 17, 81, 18 ], + "value" : 15 + }, { + "kind" : "IntegerLiteral", + "location" : [ 81, 21, 81, 22 ], + "value" : 16 + }, { + "kind" : "IntegerLiteral", + "location" : [ 81, 25, 81, 26 ], + "value" : 23 + }, { + "kind" : "IntegerLiteral", + "location" : [ 81, 29, 81, 30 ], + "value" : 42 + } ] + }, + "body" : [ { + "kind" : "IfStmt", + "location" : [ 82, 2, 84, 1 ], + "condition" : { + "kind" : "MethodCallExpr", + "location" : [ 82, 5, 82, 17 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 82, 5, 82, 14 ], + "object" : { + "kind" : "Identifier", + "location" : [ 82, 5, 82, 5 ], + "name" : "t" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 82, 7, 82, 14 ], + "name" : "contains" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 82, 16, 82, 16 ], + "name" : "i" + } ] + }, + "thenBody" : [ { + "kind" : "ExprStmt", + "location" : [ 83, 3, 83, 10 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 83, 3, 83, 10 ], + "function" : { + "kind" : "Identifier", + "location" : [ 83, 3, 83, 7 ], + "name" : "print" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 83, 9, 83, 9 ], + "name" : "i" + } ] + } + } ], + "elseBody" : [ ] + } ] + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/extra/tree.py.ast.typed b/pa2-tests/extra/tree.py.ast.typed new file mode 100644 index 0000000..a8d3cb3 --- /dev/null +++ b/pa2-tests/extra/tree.py.ast.typed @@ -0,0 +1,2301 @@ +{ + "kind" : "Program", + "location" : [ 2, 1, 84, 2 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 2, 1, 36, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 7, 2, 14 ], + "name" : "TreeNode" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 2, 16, 2, 21 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 3, 2, 3, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 2, 3, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 2, 3, 6 ], + "name" : "value" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 8, 3, 10 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 14, 3, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 4, 2, 4, 23 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 2, 4, 16 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 2, 4, 5 ], + "name" : "left" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 7, 4, 16 ], + "className" : "TreeNode" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 4, 20, 4, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 5, 2, 5, 24 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 5, 2, 5, 17 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 2, 5, 6 ], + "name" : "right" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 8, 5, 17 ], + "className" : "TreeNode" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 5, 21, 5, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "FuncDef", + "location" : [ 7, 2, 20, 15 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 6, 7, 11 ], + "name" : "insert" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 7, 13, 7, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 7, 13, 7, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 7, 18, 7, 27 ], + "className" : "TreeNode" + } + }, { + "kind" : "TypedVar", + "location" : [ 7, 30, 7, 34 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 7, 30, 7, 30 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 7, 32, 7, 34 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 7, 40, 7, 43 ], + "className" : "bool" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 8, 3, 20, 2 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 8, 6, 8, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 8, 6, 8, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "operator" : "<", + "right" : { + "kind" : "MemberExpr", + "location" : [ 8, 10, 8, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 8, 10, 8, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 8, 15, 8, 19 ], + "name" : "value" + } + } + }, + "thenBody" : [ { + "kind" : "IfStmt", + "location" : [ 9, 4, 14, 2 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 9, 7, 9, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "MemberExpr", + "location" : [ 9, 7, 9, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 9, 7, 9, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 9, 12, 9, 15 ], + "name" : "left" + } + }, + "operator" : "is", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 9, 20, 9, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 10, 5, 10, 27 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 10, 5, 10, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 10, 5, 10, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 10, 10, 10, 13 ], + "name" : "left" + } + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 10, 17, 10, 27 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 10, 17, 10, 24 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + } + }, + "name" : "makeNode" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 10, 26, 10, 26 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ] + } + }, { + "kind" : "ReturnStmt", + "location" : [ 11, 5, 11, 15 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 11, 12, 11, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + } ], + "elseBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 13, 5, 13, 30 ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 13, 12, 13, 30 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 13, 12, 13, 27 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "bool" + } + }, + "object" : { + "kind" : "MemberExpr", + "location" : [ 13, 12, 13, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 13, 12, 13, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 13, 17, 13, 20 ], + "name" : "left" + } + }, + "member" : { + "kind" : "Identifier", + "location" : [ 13, 22, 13, 27 ], + "name" : "insert" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 13, 29, 13, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ] + } + } ] + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 14, 3, 20, 2 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 14, 8, 14, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 14, 8, 14, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "operator" : ">", + "right" : { + "kind" : "MemberExpr", + "location" : [ 14, 12, 14, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 14, 12, 14, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 14, 17, 14, 21 ], + "name" : "value" + } + } + }, + "thenBody" : [ { + "kind" : "IfStmt", + "location" : [ 15, 4, 20, 2 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 15, 7, 15, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "MemberExpr", + "location" : [ 15, 7, 15, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 15, 7, 15, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 15, 12, 15, 16 ], + "name" : "right" + } + }, + "operator" : "is", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 15, 21, 15, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 16, 5, 16, 28 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 16, 5, 16, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 16, 5, 16, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 16, 10, 16, 14 ], + "name" : "right" + } + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 16, 18, 16, 28 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 16, 18, 16, 25 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + } + }, + "name" : "makeNode" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 16, 27, 16, 27 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ] + } + }, { + "kind" : "ReturnStmt", + "location" : [ 17, 5, 17, 15 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 17, 12, 17, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + } ], + "elseBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 19, 5, 19, 31 ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 19, 12, 19, 31 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 19, 12, 19, 28 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "bool" + } + }, + "object" : { + "kind" : "MemberExpr", + "location" : [ 19, 12, 19, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 19, 12, 19, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 19, 17, 19, 21 ], + "name" : "right" + } + }, + "member" : { + "kind" : "Identifier", + "location" : [ 19, 23, 19, 28 ], + "name" : "insert" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 19, 30, 19, 30 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ] + } + } ] + } ], + "elseBody" : [ ] + } ] + }, { + "kind" : "ReturnStmt", + "location" : [ 20, 3, 20, 14 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 20, 10, 20, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 22, 2, 36, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 22, 6, 22, 13 ], + "name" : "contains" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 22, 15, 22, 29 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 22, 15, 22, 18 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 22, 20, 22, 29 ], + "className" : "TreeNode" + } + }, { + "kind" : "TypedVar", + "location" : [ 22, 32, 22, 36 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 22, 32, 22, 32 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 22, 34, 22, 36 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 22, 42, 22, 45 ], + "className" : "bool" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 23, 3, 36, 0 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 23, 6, 23, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 23, 6, 23, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "operator" : "<", + "right" : { + "kind" : "MemberExpr", + "location" : [ 23, 10, 23, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 23, 10, 23, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 23, 15, 23, 19 ], + "name" : "value" + } + } + }, + "thenBody" : [ { + "kind" : "IfStmt", + "location" : [ 24, 4, 28, 2 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 24, 7, 24, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "MemberExpr", + "location" : [ 24, 7, 24, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 24, 7, 24, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 24, 12, 24, 15 ], + "name" : "left" + } + }, + "operator" : "is", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 24, 20, 24, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, + "thenBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 25, 5, 25, 16 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 25, 12, 25, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } + } ], + "elseBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 27, 5, 27, 32 ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 27, 12, 27, 32 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 27, 12, 27, 29 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "bool" + } + }, + "object" : { + "kind" : "MemberExpr", + "location" : [ 27, 12, 27, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 27, 12, 27, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 27, 17, 27, 20 ], + "name" : "left" + } + }, + "member" : { + "kind" : "Identifier", + "location" : [ 27, 22, 27, 29 ], + "name" : "contains" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 27, 31, 27, 31 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ] + } + } ] + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 28, 3, 36, 0 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 28, 8, 28, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 28, 8, 28, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "operator" : ">", + "right" : { + "kind" : "MemberExpr", + "location" : [ 28, 12, 28, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 28, 12, 28, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 28, 17, 28, 21 ], + "name" : "value" + } + } + }, + "thenBody" : [ { + "kind" : "IfStmt", + "location" : [ 29, 4, 33, 2 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 29, 7, 29, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "MemberExpr", + "location" : [ 29, 7, 29, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 29, 7, 29, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 29, 12, 29, 16 ], + "name" : "right" + } + }, + "operator" : "is", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 29, 21, 29, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, + "thenBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 30, 5, 30, 16 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 30, 12, 30, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } + } ], + "elseBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 32, 5, 32, 33 ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 32, 12, 32, 33 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 32, 12, 32, 30 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "bool" + } + }, + "object" : { + "kind" : "MemberExpr", + "location" : [ 32, 12, 32, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 32, 12, 32, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 32, 17, 32, 21 ], + "name" : "right" + } + }, + "member" : { + "kind" : "Identifier", + "location" : [ 32, 23, 32, 30 ], + "name" : "contains" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 32, 32, 32, 32 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ] + } + } ] + } ], + "elseBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 34, 4, 34, 14 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 34, 11, 34, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + } ] + } ] + } ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 36, 1, 54, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 36, 7, 36, 10 ], + "name" : "Tree" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 36, 12, 36, 17 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 37, 2, 37, 21 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 37, 2, 37, 14 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 37, 2, 37, 5 ], + "name" : "root" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 37, 7, 37, 14 ], + "className" : "TreeNode" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 37, 18, 37, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 38, 2, 38, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 38, 2, 38, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 38, 2, 38, 5 ], + "name" : "size" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 38, 7, 38, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 38, 13, 38, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, { + "kind" : "FuncDef", + "location" : [ 40, 2, 48, 1 ], + "name" : { + "kind" : "Identifier", + "location" : [ 40, 6, 40, 11 ], + "name" : "insert" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 40, 13, 40, 23 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 40, 13, 40, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 40, 18, 40, 23 ], + "className" : "Tree" + } + }, { + "kind" : "TypedVar", + "location" : [ 40, 26, 40, 30 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 40, 26, 40, 26 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 40, 28, 40, 30 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 40, 36, 40, 41 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 41, 3, 48, 1 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 41, 6, 41, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "MemberExpr", + "location" : [ 41, 6, 41, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 41, 6, 41, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Tree" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 41, 11, 41, 14 ], + "name" : "root" + } + }, + "operator" : "is", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 41, 19, 41, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 42, 4, 42, 26 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 42, 4, 42, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 42, 4, 42, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Tree" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 42, 9, 42, 12 ], + "name" : "root" + } + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 42, 16, 42, 26 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 42, 16, 42, 23 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + } + }, + "name" : "makeNode" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 42, 25, 42, 25 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 43, 4, 43, 16 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 43, 4, 43, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 43, 4, 43, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Tree" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 43, 9, 43, 12 ], + "name" : "size" + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 43, 16, 43, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 45, 4, 48, 1 ], + "condition" : { + "kind" : "MethodCallExpr", + "location" : [ 45, 7, 45, 25 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 45, 7, 45, 22 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "bool" + } + }, + "object" : { + "kind" : "MemberExpr", + "location" : [ 45, 7, 45, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 45, 7, 45, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Tree" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 45, 12, 45, 15 ], + "name" : "root" + } + }, + "member" : { + "kind" : "Identifier", + "location" : [ 45, 17, 45, 22 ], + "name" : "insert" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 45, 24, 45, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ] + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 46, 5, 46, 29 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 46, 5, 46, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 46, 5, 46, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Tree" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 46, 10, 46, 13 ], + "name" : "size" + } + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 46, 17, 46, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "MemberExpr", + "location" : [ 46, 17, 46, 25 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 46, 17, 46, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Tree" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 46, 22, 46, 25 ], + "name" : "size" + } + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 46, 29, 46, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ], + "elseBody" : [ ] + } ] + } ] + }, { + "kind" : "FuncDef", + "location" : [ 48, 2, 54, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 48, 6, 48, 13 ], + "name" : "contains" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 48, 15, 48, 25 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 48, 15, 48, 18 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 48, 20, 48, 25 ], + "className" : "Tree" + } + }, { + "kind" : "TypedVar", + "location" : [ 48, 28, 48, 32 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 48, 28, 48, 28 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 48, 30, 48, 32 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 48, 38, 48, 41 ], + "className" : "bool" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 49, 3, 54, 0 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 49, 6, 49, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "MemberExpr", + "location" : [ 49, 6, 49, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 49, 6, 49, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Tree" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 49, 11, 49, 14 ], + "name" : "root" + } + }, + "operator" : "is", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 49, 19, 49, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, + "thenBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 50, 4, 50, 15 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 50, 11, 50, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } + } ], + "elseBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 52, 4, 52, 31 ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 52, 11, 52, 31 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 52, 11, 52, 28 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "bool" + } + }, + "object" : { + "kind" : "MemberExpr", + "location" : [ 52, 11, 52, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 52, 11, 52, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Tree" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 52, 16, 52, 19 ], + "name" : "root" + } + }, + "member" : { + "kind" : "Identifier", + "location" : [ 52, 21, 52, 28 ], + "name" : "contains" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 52, 30, 52, 30 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ] + } + } ] + } ] + } ] + }, { + "kind" : "FuncDef", + "location" : [ 54, 1, 58, 10 ], + "name" : { + "kind" : "Identifier", + "location" : [ 54, 5, 54, 12 ], + "name" : "makeNode" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 54, 14, 54, 19 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 54, 14, 54, 14 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 54, 17, 54, 19 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 54, 25, 54, 32 ], + "className" : "TreeNode" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 55, 2, 55, 18 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 55, 2, 55, 11 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 55, 2, 55, 2 ], + "name" : "b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 55, 4, 55, 11 ], + "className" : "TreeNode" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 55, 15, 55, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 56, 2, 56, 15 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 56, 2, 56, 2 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "name" : "b" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 56, 6, 56, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 56, 6, 56, 13 ], + "name" : "TreeNode" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 57, 2, 57, 12 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 57, 2, 57, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 57, 2, 57, 2 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "name" : "b" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 57, 4, 57, 8 ], + "name" : "value" + } + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 57, 12, 57, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } + }, { + "kind" : "ReturnStmt", + "location" : [ 58, 2, 58, 9 ], + "value" : { + "kind" : "Identifier", + "location" : [ 58, 9, 58, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "TreeNode" + }, + "name" : "b" + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 62, 1, 62, 11 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 62, 1, 62, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 62, 1, 62, 1 ], + "name" : "n" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 62, 3, 62, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 62, 9, 62, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 100 + } + }, { + "kind" : "VarDef", + "location" : [ 63, 1, 63, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 63, 1, 63, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 63, 1, 63, 1 ], + "name" : "c" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 63, 3, 63, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 63, 9, 63, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 4 + } + }, { + "kind" : "VarDef", + "location" : [ 66, 1, 66, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 66, 1, 66, 6 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 66, 1, 66, 1 ], + "name" : "t" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 66, 3, 66, 6 ], + "className" : "Tree" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 66, 10, 66, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 67, 1, 67, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 67, 1, 67, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 67, 1, 67, 1 ], + "name" : "i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 67, 3, 67, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 67, 9, 67, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 68, 1, 68, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 68, 1, 68, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 68, 1, 68, 1 ], + "name" : "k" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 68, 3, 68, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 68, 9, 68, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 37813 + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 71, 1, 71, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 71, 1, 71, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Tree" + }, + "name" : "t" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 71, 5, 71, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Tree" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 71, 5, 71, 8 ], + "name" : "Tree" + }, + "args" : [ ] + } + }, { + "kind" : "WhileStmt", + "location" : [ 72, 1, 79, 0 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 72, 7, 72, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 72, 7, 72, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + }, + "operator" : "<", + "right" : { + "kind" : "Identifier", + "location" : [ 72, 11, 72, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "n" + } + }, + "body" : [ { + "kind" : "ExprStmt", + "location" : [ 73, 2, 73, 12 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 73, 2, 73, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 73, 2, 73, 9 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "Tree" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 73, 2, 73, 2 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Tree" + }, + "name" : "t" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 73, 4, 73, 9 ], + "name" : "insert" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 73, 11, 73, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "k" + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 74, 2, 74, 24 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 74, 2, 74, 2 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "k" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 74, 6, 74, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "BinaryExpr", + "location" : [ 74, 7, 74, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 74, 7, 74, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "k" + }, + "operator" : "*", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 74, 11, 74, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 37813 + } + }, + "operator" : "%", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 74, 20, 74, 24 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 37831 + } + } + }, { + "kind" : "IfStmt", + "location" : [ 75, 2, 77, 1 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 75, 5, 75, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "BinaryExpr", + "location" : [ 75, 5, 75, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 75, 5, 75, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + }, + "operator" : "%", + "right" : { + "kind" : "Identifier", + "location" : [ 75, 9, 75, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "c" + } + }, + "operator" : "!=", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 75, 14, 75, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, + "thenBody" : [ { + "kind" : "ExprStmt", + "location" : [ 76, 3, 76, 13 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 76, 3, 76, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 76, 3, 76, 10 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "Tree" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 76, 3, 76, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Tree" + }, + "name" : "t" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 76, 5, 76, 10 ], + "name" : "insert" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 76, 12, 76, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + } ] + } + } ], + "elseBody" : [ ] + }, { + "kind" : "AssignStmt", + "location" : [ 77, 2, 77, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 77, 2, 77, 2 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 77, 6, 77, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 77, 6, 77, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 77, 10, 77, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ] + }, { + "kind" : "ExprStmt", + "location" : [ 79, 1, 79, 13 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 79, 1, 79, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 79, 1, 79, 5 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, + "name" : "print" + }, + "args" : [ { + "kind" : "MemberExpr", + "location" : [ 79, 7, 79, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 79, 7, 79, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Tree" + }, + "name" : "t" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 79, 9, 79, 12 ], + "name" : "size" + } + } ] + } + }, { + "kind" : "ForStmt", + "location" : [ 81, 1, 84, 2 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 81, 5, 81, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + }, + "iterable" : { + "kind" : "ListExpr", + "location" : [ 81, 10, 81, 31 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 81, 11, 81, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 4 + }, { + "kind" : "IntegerLiteral", + "location" : [ 81, 14, 81, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 8 + }, { + "kind" : "IntegerLiteral", + "location" : [ 81, 17, 81, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 15 + }, { + "kind" : "IntegerLiteral", + "location" : [ 81, 21, 81, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 16 + }, { + "kind" : "IntegerLiteral", + "location" : [ 81, 25, 81, 26 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 23 + }, { + "kind" : "IntegerLiteral", + "location" : [ 81, 29, 81, 30 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 42 + } ] + }, + "body" : [ { + "kind" : "IfStmt", + "location" : [ 82, 2, 84, 1 ], + "condition" : { + "kind" : "MethodCallExpr", + "location" : [ 82, 5, 82, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 82, 5, 82, 14 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "Tree" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "bool" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 82, 5, 82, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "Tree" + }, + "name" : "t" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 82, 7, 82, 14 ], + "name" : "contains" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 82, 16, 82, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + } ] + }, + "thenBody" : [ { + "kind" : "ExprStmt", + "location" : [ 83, 3, 83, 10 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 83, 3, 83, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 83, 3, 83, 7 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, + "name" : "print" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 83, 9, 83, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "i" + } ] + } + } ], + "elseBody" : [ ] + } ] + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/pa2-tests/run-tests.sh b/pa2-tests/run-tests.sh new file mode 100755 index 0000000..9dac916 --- /dev/null +++ b/pa2-tests/run-tests.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +set -o errexit +set -o nounset +set -o pipefail + +JAVA="java -cp pa2-tests/chocopy-ref.jar:target/assignment.jar chocopy.ChocoPy" + +echo "# CORE TESTS" +${JAVA} --pass=.s --test --dir pa2-tests/core + +echo +echo "# EXTRA TESTS" +${JAVA} --pass=.s --test --dir pa2-tests/extra + +echo +echo "# STUDENT TESTS" +function regen_and_test { + ${JAVA} --pass=r "${1}" --out "${1}.ast" 2>/dev/null 1>&2 + ${JAVA} --pass=.r "${1}.ast" --out "${1}.ast.typed" 2>/dev/null 1>&2 + ${JAVA} --pass=.s --test "${1}.ast" +} +regen_and_test "src/test/data/pa2/student_contributed/bad_semantic.py" +regen_and_test "src/test/data/pa2/student_contributed/bad_types.py" +regen_and_test "src/test/data/pa2/student_contributed/good.py" diff --git a/src/test/data/pa2/student_contributed/bad_semantic.py.ast b/src/test/data/pa2/student_contributed/bad_semantic.py.ast index ca884e5..2b648b0 100644 --- a/src/test/data/pa2/student_contributed/bad_semantic.py.ast +++ b/src/test/data/pa2/student_contributed/bad_semantic.py.ast @@ -1,116 +1,1017 @@ { "kind" : "Program", - "location" : [ 1, 1, 13, 8 ], + "location" : [ 2, 1, 92, 11 ], "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 2, 1, 12, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 7, 2, 13 ], + "name" : "A_CLASS" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 2, 15, 2, 20 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 3, 5, 3, 21 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 5, 3, 17 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 13 ], + "name" : "a_class_i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 15, 3, 17 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 21, 3, 21 ], + "value" : 0 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 19 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 18, 4, 31 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 18, 4, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 23, 4, 31 ], + "className" : "A_CLASS" + } + }, { + "kind" : "TypedVar", + "location" : [ 4, 34, 4, 38 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 34, 4, 34 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 36, 4, 38 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 40, 4, 40 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 5, 9, 5, 18 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 5, 9, 5, 14 ], + "object" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 12 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 5, 14, 5, 14 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 5, 18, 5, 18 ], + "name" : "x" + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 8, 5, 10, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 11 ], + "name" : "add" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 8, 13, 8, 17 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 13, 8, 13 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 15, 8, 17 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 8, 23, 8, 25 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 9, 9, 9, 20 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 9, 9, 9, 9 ], + "name" : "y" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 9, 13, 9, 20 ], + "left" : { + "kind" : "Identifier", + "location" : [ 9, 13, 9, 13 ], + "name" : "y" + }, + "operator" : "+", + "right" : { + "kind" : "MemberExpr", + "location" : [ 9, 15, 9, 20 ], + "object" : { + "kind" : "Identifier", + "location" : [ 9, 15, 9, 18 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 9, 20, 9, 20 ], + "name" : "x" + } + } + } + }, { + "kind" : "ReturnStmt", + "location" : [ 10, 9, 10, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 10, 16, 10, 16 ], + "name" : "y" + } + } ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 12, 1, 13, 22 ], + "name" : { + "kind" : "Identifier", + "location" : [ 12, 7, 12, 13 ], + "name" : "B_CLASS" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 12, 15, 12, 20 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 13, 5, 13, 21 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 13, 5, 13, 17 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 13, 5, 13, 13 ], + "name" : "b_class_i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 13, 15, 13, 17 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 13, 21, 13, 21 ], + "value" : 0 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 15, 1, 16, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 15, 7, 15, 13 ], + "name" : "C_CLASS" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 15, 15, 15, 21 ], + "name" : "B_CLASS" + }, + "declarations" : [ ] + }, { + "kind" : "ClassDef", + "location" : [ 19, 1, 20, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 19, 7, 19, 13 ], + "name" : "A_CLASS" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 19, 15, 19, 20 ], + "name" : "object" + }, + "declarations" : [ ] + }, { + "kind" : "ClassDef", + "location" : [ 23, 1, 24, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 23, 7, 23, 13 ], + "name" : "D_CLASS" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 23, 15, 23, 21 ], + "name" : "E_CLASS" + }, + "declarations" : [ ] + }, { "kind" : "VarDef", - "location" : [ 1, 1, 1, 9 ], + "location" : [ 28, 1, 28, 15 ], "var" : { "kind" : "TypedVar", - "location" : [ 1, 1, 1, 5 ], + "location" : [ 28, 1, 28, 7 ], "identifier" : { "kind" : "Identifier", - "location" : [ 1, 1, 1, 1 ], - "name" : "x" + "location" : [ 28, 1, 28, 3 ], + "name" : "a_s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 28, 5, 28, 7 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 28, 11, 28, 15 ], + "value" : "a_s" + } + }, { + "kind" : "VarDef", + "location" : [ 29, 1, 29, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 29, 1, 29, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 29, 1, 29, 3 ], + "name" : "b_s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 29, 5, 29, 7 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 29, 11, 29, 15 ], + "value" : "b_s" + } + }, { + "kind" : "VarDef", + "location" : [ 30, 1, 30, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 30, 1, 30, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 30, 1, 30, 3 ], + "name" : "c_s" }, "type" : { "kind" : "ClassType", - "location" : [ 1, 3, 1, 5 ], + "location" : [ 30, 5, 30, 7 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 30, 11, 30, 15 ], + "value" : "c_s" + } + }, { + "kind" : "VarDef", + "location" : [ 32, 1, 32, 11 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 32, 1, 32, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 32, 1, 32, 3 ], + "name" : "a_i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 32, 5, 32, 7 ], "className" : "int" } }, "value" : { "kind" : "IntegerLiteral", - "location" : [ 1, 9, 1, 9 ], - "value" : 1 + "location" : [ 32, 11, 32, 11 ], + "value" : 0 } }, { "kind" : "VarDef", - "location" : [ 2, 1, 2, 9 ], + "location" : [ 33, 1, 33, 11 ], "var" : { "kind" : "TypedVar", - "location" : [ 2, 1, 2, 5 ], + "location" : [ 33, 1, 33, 7 ], "identifier" : { "kind" : "Identifier", - "location" : [ 2, 1, 2, 1 ], - "name" : "x" + "location" : [ 33, 1, 33, 3 ], + "name" : "b_i" }, "type" : { "kind" : "ClassType", - "location" : [ 2, 3, 2, 5 ], + "location" : [ 33, 5, 33, 7 ], "className" : "int" } }, "value" : { "kind" : "IntegerLiteral", - "location" : [ 2, 9, 2, 9 ], - "value" : 2 + "location" : [ 33, 11, 33, 11 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 34, 1, 34, 11 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 34, 1, 34, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 34, 1, 34, 3 ], + "name" : "c_i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 34, 5, 34, 7 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 34, 11, 34, 11 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 36, 1, 36, 16 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 36, 1, 36, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 36, 1, 36, 3 ], + "name" : "a_b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 36, 5, 36, 8 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 36, 12, 36, 16 ], + "value" : false + } + }, { + "kind" : "VarDef", + "location" : [ 37, 1, 37, 16 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 37, 1, 37, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 37, 1, 37, 3 ], + "name" : "b_b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 37, 5, 37, 8 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 37, 12, 37, 16 ], + "value" : false + } + }, { + "kind" : "VarDef", + "location" : [ 38, 1, 38, 16 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 38, 1, 38, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 38, 1, 38, 3 ], + "name" : "c_b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 38, 5, 38, 8 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 38, 12, 38, 16 ], + "value" : false + } + }, { + "kind" : "VarDef", + "location" : [ 40, 1, 40, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 40, 1, 40, 12 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 40, 1, 40, 6 ], + "name" : "a_list" + }, + "type" : { + "kind" : "ListType", + "location" : [ 40, 8, 40, 12 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 40, 9, 40, 11 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 40, 16, 40, 19 ] + } + }, { + "kind" : "VarDef", + "location" : [ 41, 1, 41, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 41, 1, 41, 12 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 41, 1, 41, 6 ], + "name" : "b_list" + }, + "type" : { + "kind" : "ListType", + "location" : [ 41, 8, 41, 12 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 41, 9, 41, 11 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 41, 16, 41, 19 ] } + }, { + "kind" : "VarDef", + "location" : [ 42, 1, 42, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 42, 1, 42, 12 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 42, 1, 42, 6 ], + "name" : "c_list" + }, + "type" : { + "kind" : "ListType", + "location" : [ 42, 8, 42, 12 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 42, 9, 42, 11 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 42, 16, 42, 19 ] + } + }, { + "kind" : "VarDef", + "location" : [ 44, 1, 44, 22 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 44, 1, 44, 15 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 44, 1, 44, 7 ], + "name" : "a_class" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 44, 9, 44, 15 ], + "className" : "A_CLASS" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 44, 19, 44, 22 ] + } + }, { + "kind" : "VarDef", + "location" : [ 45, 1, 45, 22 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 45, 1, 45, 15 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 45, 1, 45, 7 ], + "name" : "b_class" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 45, 9, 45, 15 ], + "className" : "B_CLASS" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 45, 19, 45, 22 ] + } + }, { + "kind" : "VarDef", + "location" : [ 46, 1, 46, 22 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 46, 1, 46, 15 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 46, 1, 46, 7 ], + "name" : "c_class" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 46, 9, 46, 15 ], + "className" : "C_CLASS" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 46, 19, 46, 22 ] + } + }, { + "kind" : "FuncDef", + "location" : [ 50, 1, 56, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 50, 5, 50, 7 ], + "name" : "f_1" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 50, 14, 50, 19 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 51, 5, 55, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 51, 9, 51, 13 ], + "name" : "f_f_1" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 51, 20, 51, 25 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "GlobalDecl", + "location" : [ 53, 9, 53, 18 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 53, 16, 53, 18 ], + "name" : "a_s" + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 54, 9, 54, 18 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 54, 9, 54, 18 ], + "function" : { + "kind" : "Identifier", + "location" : [ 54, 9, 54, 13 ], + "name" : "print" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 54, 15, 54, 17 ], + "name" : "a_s" + } ] + } + } ] + } ], + "statements" : [ ] }, { "kind" : "FuncDef", - "location" : [ 6, 1, 13, 0 ], + "location" : [ 58, 1, 64, 9 ], "name" : { "kind" : "Identifier", - "location" : [ 6, 5, 6, 9 ], - "name" : "fun_1" + "location" : [ 58, 5, 58, 7 ], + "name" : "f_2" }, "params" : [ ], "returnType" : { "kind" : "ClassType", - "location" : [ 6, 16, 6, 19 ], + "location" : [ 58, 14, 58, 19 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 59, 5, 59, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 59, 5, 59, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 59, 5, 59, 9 ], + "name" : "f_a_s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 59, 11, 59, 13 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 59, 17, 59, 19 ], + "value" : "s" + } + }, { + "kind" : "FuncDef", + "location" : [ 60, 5, 63, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 60, 9, 60, 13 ], + "name" : "f_f_2" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 60, 20, 60, 25 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "NonLocalDecl", + "location" : [ 61, 9, 61, 22 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 61, 18, 61, 22 ], + "name" : "f_a_s" + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 62, 9, 62, 20 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 62, 9, 62, 20 ], + "function" : { + "kind" : "Identifier", + "location" : [ 62, 9, 62, 13 ], + "name" : "print" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 62, 15, 62, 19 ], + "name" : "f_a_s" + } ] + } + } ] + } ], + "statements" : [ ] + }, { + "kind" : "FuncDef", + "location" : [ 66, 1, 72, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 66, 5, 66, 7 ], + "name" : "f_3" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 66, 9, 66, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 66, 9, 66, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 66, 11, 66, 13 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 66, 19, 66, 22 ], "className" : "bool" }, - "declarations" : [ ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 67, 5, 67, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 67, 5, 67, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 67, 5, 67, 9 ], + "name" : "f_b_s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 67, 11, 67, 13 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 67, 17, 67, 17 ], + "value" : 3 + } + } ], "statements" : [ { "kind" : "IfStmt", - "location" : [ 7, 5, 13, 0 ], + "location" : [ 68, 5, 72, 4 ], "condition" : { - "kind" : "BooleanLiteral", - "location" : [ 7, 8, 7, 11 ], - "value" : true + "kind" : "BinaryExpr", + "location" : [ 68, 9, 68, 21 ], + "left" : { + "kind" : "BinaryExpr", + "location" : [ 68, 9, 68, 17 ], + "left" : { + "kind" : "Identifier", + "location" : [ 68, 9, 68, 9 ], + "name" : "x" + }, + "operator" : "+", + "right" : { + "kind" : "Identifier", + "location" : [ 68, 13, 68, 17 ], + "name" : "f_b_s" + } + }, + "operator" : ">", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 68, 21, 68, 21 ], + "value" : 3 + } }, "thenBody" : [ { - "kind" : "IfStmt", - "location" : [ 8, 9, 13, 0 ], - "condition" : { + "kind" : "ReturnStmt", + "location" : [ 69, 9, 69, 19 ], + "value" : { "kind" : "BooleanLiteral", - "location" : [ 8, 12, 8, 15 ], + "location" : [ 69, 16, 69, 19 ], "value" : true + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 70, 5, 72, 4 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 70, 11, 70, 24 ], + "left" : { + "kind" : "BinaryExpr", + "location" : [ 70, 11, 70, 19 ], + "left" : { + "kind" : "Identifier", + "location" : [ 70, 11, 70, 11 ], + "name" : "x" + }, + "operator" : "+", + "right" : { + "kind" : "Identifier", + "location" : [ 70, 15, 70, 19 ], + "name" : "f_b_s" + } + }, + "operator" : "==", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 70, 24, 70, 24 ], + "value" : 3 + } }, "thenBody" : [ { - "kind" : "ReturnStmt", - "location" : [ 9, 13, 9, 23 ], - "value" : { - "kind" : "BooleanLiteral", - "location" : [ 9, 20, 9, 23 ], - "value" : true + "kind" : "ExprStmt", + "location" : [ 71, 9, 71, 22 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 71, 9, 71, 22 ], + "function" : { + "kind" : "Identifier", + "location" : [ 71, 9, 71, 13 ], + "name" : "print" + }, + "args" : [ { + "kind" : "StringLiteral", + "location" : [ 71, 15, 71, 21 ], + "value" : "Equal" + } ] } } ], "elseBody" : [ ] + } ] + }, { + "kind" : "ReturnStmt", + "location" : [ 72, 5, 72, 16 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 72, 12, 72, 16 ], + "value" : false + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 74, 1, 77, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 74, 5, 74, 7 ], + "name" : "f_4" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 74, 14, 74, 19 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 75, 5, 75, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 75, 5, 75, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 75, 5, 75, 9 ], + "name" : "f_a_i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 75, 11, 75, 13 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 75, 17, 75, 17 ], + "value" : 2 + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 76, 5, 76, 19 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 76, 5, 76, 7 ], + "name" : "a_i" } ], - "elseBody" : [ ] + "value" : { + "kind" : "BinaryExpr", + "location" : [ 76, 11, 76, 19 ], + "left" : { + "kind" : "Identifier", + "location" : [ 76, 11, 76, 15 ], + "name" : "f_a_i" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 76, 19, 76, 19 ], + "value" : 1 + } + } + }, { + "kind" : "ReturnStmt", + "location" : [ 77, 5, 77, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 77, 12, 77, 16 ], + "name" : "f_a_i" + } } ] - } ], - "statements" : [ { - "kind" : "ExprStmt", - "location" : [ 13, 1, 13, 7 ], - "expr" : { - "kind" : "CallExpr", - "location" : [ 13, 1, 13, 7 ], - "function" : { + }, { + "kind" : "FuncDef", + "location" : [ 81, 1, 82, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 81, 5, 81, 7 ], + "name" : "f_2" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 81, 14, 81, 19 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ ] + }, { + "kind" : "FuncDef", + "location" : [ 85, 1, 86, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 85, 5, 85, 9 ], + "name" : "print" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 85, 11, 85, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 85, 11, 85, 13 ], + "name" : "val" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 85, 15, 85, 20 ], + "className" : "object" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 85, 26, 85, 31 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ ] + }, { + "kind" : "VarDef", + "location" : [ 89, 1, 89, 11 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 89, 1, 89, 7 ], + "identifier" : { "kind" : "Identifier", - "location" : [ 13, 1, 13, 5 ], - "name" : "fun_1" + "location" : [ 89, 1, 89, 3 ], + "name" : "a_i" }, - "args" : [ ] + "type" : { + "kind" : "ClassType", + "location" : [ 89, 5, 89, 7 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 89, 11, 89, 11 ], + "value" : 2 + } + } ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 92, 1, 92, 10 ], + "value" : { + "kind" : "Identifier", + "location" : [ 92, 8, 92, 10 ], + "name" : "a_i" } } ], "errors" : { - "errors" : [ { - "kind" : "CompilerError", - "location" : [ 6, 1, 6, 3 ], - "message" : "Parse error near token DEF: def", - "syntax" : true - } ], + "errors" : [ ], "kind" : "Errors", "location" : [ 0, 0, 0, 0 ] } diff --git a/src/test/data/pa2/student_contributed/bad_semantic.py.ast.typed b/src/test/data/pa2/student_contributed/bad_semantic.py.ast.typed index bd84531..89bb0d3 100644 --- a/src/test/data/pa2/student_contributed/bad_semantic.py.ast.typed +++ b/src/test/data/pa2/student_contributed/bad_semantic.py.ast.typed @@ -3,7 +3,7 @@ "location" : [ 2, 1, 92, 11 ], "declarations" : [ { "kind" : "ClassDef", - "location" : [ 2, 1, 10, 16 ], + "location" : [ 2, 1, 12, 0 ], "name" : { "kind" : "Identifier", "location" : [ 2, 7, 2, 13 ], @@ -38,7 +38,7 @@ } }, { "kind" : "FuncDef", - "location" : [ 4, 5, 5, 18 ], + "location" : [ 4, 5, 5, 19 ], "name" : { "kind" : "Identifier", "location" : [ 4, 9, 4, 16 ], @@ -103,7 +103,7 @@ } ] }, { "kind" : "FuncDef", - "location" : [ 8, 5, 10, 16 ], + "location" : [ 8, 5, 10, 17 ], "name" : { "kind" : "Identifier", "location" : [ 8, 9, 8, 11 ], @@ -174,7 +174,7 @@ } ] }, { "kind" : "ClassDef", - "location" : [ 12, 1, 13, 21 ], + "location" : [ 12, 1, 13, 22 ], "name" : { "kind" : "Identifier", "location" : [ 12, 7, 12, 13 ], @@ -210,7 +210,7 @@ } ] }, { "kind" : "ClassDef", - "location" : [ 15, 1, 0, 0 ], + "location" : [ 15, 1, 16, 9 ], "name" : { "kind" : "Identifier", "location" : [ 15, 7, 15, 13 ], @@ -224,7 +224,7 @@ "declarations" : [ ] }, { "kind" : "ClassDef", - "location" : [ 19, 1, 0, 0 ], + "location" : [ 19, 1, 20, 9 ], "name" : { "kind" : "Identifier", "location" : [ 19, 7, 19, 13 ], @@ -239,7 +239,7 @@ "declarations" : [ ] }, { "kind" : "ClassDef", - "location" : [ 23, 1, 0, 0 ], + "location" : [ 23, 1, 24, 9 ], "name" : { "kind" : "Identifier", "location" : [ 23, 7, 23, 13 ], @@ -590,7 +590,7 @@ } }, { "kind" : "FuncDef", - "location" : [ 50, 1, 0, 0 ], + "location" : [ 50, 1, 56, 9 ], "name" : { "kind" : "Identifier", "location" : [ 50, 5, 50, 7 ], @@ -604,7 +604,7 @@ }, "declarations" : [ { "kind" : "FuncDef", - "location" : [ 51, 5, 54, 18 ], + "location" : [ 51, 5, 55, 13 ], "name" : { "kind" : "Identifier", "location" : [ 51, 9, 51, 13 ], @@ -647,7 +647,7 @@ "statements" : [ ] }, { "kind" : "FuncDef", - "location" : [ 58, 1, 0, 0 ], + "location" : [ 58, 1, 64, 9 ], "name" : { "kind" : "Identifier", "location" : [ 58, 5, 58, 7 ], @@ -683,7 +683,7 @@ } }, { "kind" : "FuncDef", - "location" : [ 60, 5, 62, 20 ], + "location" : [ 60, 5, 63, 13 ], "name" : { "kind" : "Identifier", "location" : [ 60, 9, 60, 13 ], @@ -726,7 +726,7 @@ "statements" : [ ] }, { "kind" : "FuncDef", - "location" : [ 66, 1, 72, 16 ], + "location" : [ 66, 1, 72, 17 ], "name" : { "kind" : "Identifier", "location" : [ 66, 5, 66, 7 ], @@ -776,7 +776,7 @@ } ], "statements" : [ { "kind" : "IfStmt", - "location" : [ 68, 5, 0, 0 ], + "location" : [ 68, 5, 72, 4 ], "condition" : { "kind" : "BinaryExpr", "location" : [ 68, 9, 68, 21 ], @@ -813,7 +813,7 @@ } ], "elseBody" : [ { "kind" : "IfStmt", - "location" : [ 70, 5, 0, 0 ], + "location" : [ 70, 5, 72, 4 ], "condition" : { "kind" : "BinaryExpr", "location" : [ 70, 11, 70, 24 ], @@ -870,7 +870,7 @@ } ] }, { "kind" : "FuncDef", - "location" : [ 74, 1, 77, 16 ], + "location" : [ 74, 1, 77, 17 ], "name" : { "kind" : "Identifier", "location" : [ 74, 5, 74, 7 ], @@ -939,7 +939,7 @@ } ] }, { "kind" : "FuncDef", - "location" : [ 81, 1, 0, 0 ], + "location" : [ 81, 1, 82, 9 ], "name" : { "kind" : "Identifier", "location" : [ 81, 5, 81, 7 ], @@ -956,7 +956,7 @@ "statements" : [ ] }, { "kind" : "FuncDef", - "location" : [ 85, 1, 0, 0 ], + "location" : [ 85, 1, 86, 9 ], "name" : { "kind" : "Identifier", "location" : [ 85, 5, 85, 9 ], diff --git a/src/test/data/pa2/student_contributed/bad_types.py.ast b/src/test/data/pa2/student_contributed/bad_types.py.ast index c85de99..508c754 100644 --- a/src/test/data/pa2/student_contributed/bad_types.py.ast +++ b/src/test/data/pa2/student_contributed/bad_types.py.ast @@ -1,93 +1,1301 @@ { "kind" : "Program", - "location" : [ 1, 1, 5, 20 ], + "location" : [ 2, 1, 105, 70 ], "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 2, 1, 11, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 7, 2, 13 ], + "name" : "A_CLASS" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 2, 15, 2, 20 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 3, 5, 3, 21 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 5, 3, 17 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 13 ], + "name" : "a_class_i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 15, 3, 17 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 21, 3, 21 ], + "value" : 0 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 19 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 18, 4, 31 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 18, 4, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 23, 4, 31 ], + "className" : "A_CLASS" + } + }, { + "kind" : "TypedVar", + "location" : [ 4, 34, 4, 38 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 34, 4, 34 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 36, 4, 38 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 40, 4, 40 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 5, 9, 5, 18 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 5, 9, 5, 14 ], + "object" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 12 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 5, 14, 5, 14 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 5, 18, 5, 18 ], + "name" : "x" + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 7, 5, 9, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 11 ], + "name" : "add" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 7, 13, 7, 26 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 7, 13, 7, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 7, 18, 7, 26 ], + "className" : "A_CLASS" + } + }, { + "kind" : "TypedVar", + "location" : [ 7, 29, 7, 33 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 7, 29, 7, 29 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 7, 31, 7, 33 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 7, 39, 7, 41 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 8, 9, 8, 20 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 9 ], + "name" : "y" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 8, 13, 8, 20 ], + "left" : { + "kind" : "Identifier", + "location" : [ 8, 13, 8, 13 ], + "name" : "y" + }, + "operator" : "+", + "right" : { + "kind" : "MemberExpr", + "location" : [ 8, 15, 8, 20 ], + "object" : { + "kind" : "Identifier", + "location" : [ 8, 15, 8, 18 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 8, 20, 8, 20 ], + "name" : "x" + } + } + } + }, { + "kind" : "ReturnStmt", + "location" : [ 9, 9, 9, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 9, 16, 9, 16 ], + "name" : "y" + } + } ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 11, 1, 12, 22 ], + "name" : { + "kind" : "Identifier", + "location" : [ 11, 7, 11, 13 ], + "name" : "B_CLASS" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 11, 15, 11, 20 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 12, 5, 12, 21 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 5, 12, 17 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 5, 12, 13 ], + "name" : "b_class_i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 15, 12, 17 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 12, 21, 12, 21 ], + "value" : 0 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 14, 1, 15, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 14, 7, 14, 13 ], + "name" : "C_CLASS" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 14, 15, 14, 21 ], + "name" : "B_CLASS" + }, + "declarations" : [ ] + }, { "kind" : "VarDef", - "location" : [ 1, 1, 1, 12 ], + "location" : [ 18, 1, 18, 15 ], "var" : { "kind" : "TypedVar", - "location" : [ 1, 1, 1, 5 ], + "location" : [ 18, 1, 18, 7 ], "identifier" : { "kind" : "Identifier", - "location" : [ 1, 1, 1, 1 ], - "name" : "x" + "location" : [ 18, 1, 18, 3 ], + "name" : "a_s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 18, 5, 18, 7 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 18, 11, 18, 15 ], + "value" : "a_s" + } + }, { + "kind" : "VarDef", + "location" : [ 19, 1, 19, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 19, 1, 19, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 19, 1, 19, 3 ], + "name" : "b_s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 19, 5, 19, 7 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 19, 11, 19, 15 ], + "value" : "b_s" + } + }, { + "kind" : "VarDef", + "location" : [ 20, 1, 20, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 20, 1, 20, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 20, 1, 20, 3 ], + "name" : "c_s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 20, 5, 20, 7 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 20, 11, 20, 15 ], + "value" : "c_s" + } + }, { + "kind" : "VarDef", + "location" : [ 22, 1, 22, 11 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 22, 1, 22, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 22, 1, 22, 3 ], + "name" : "a_i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 22, 5, 22, 7 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 22, 11, 22, 11 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 23, 1, 23, 11 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 23, 1, 23, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 23, 1, 23, 3 ], + "name" : "b_i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 23, 5, 23, 7 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 23, 11, 23, 11 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 24, 1, 24, 11 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 24, 1, 24, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 24, 1, 24, 3 ], + "name" : "c_i" }, "type" : { "kind" : "ClassType", - "location" : [ 1, 3, 1, 5 ], + "location" : [ 24, 5, 24, 7 ], "className" : "int" } }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 24, 11, 24, 11 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 26, 1, 26, 16 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 26, 1, 26, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 26, 1, 26, 3 ], + "name" : "a_b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 26, 5, 26, 8 ], + "className" : "bool" + } + }, "value" : { "kind" : "BooleanLiteral", - "location" : [ 1, 9, 1, 12 ], - "value" : true + "location" : [ 26, 12, 26, 16 ], + "value" : false } + }, { + "kind" : "VarDef", + "location" : [ 27, 1, 27, 16 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 27, 1, 27, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 27, 1, 27, 3 ], + "name" : "b_b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 27, 5, 27, 8 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 27, 12, 27, 16 ], + "value" : false + } + }, { + "kind" : "VarDef", + "location" : [ 28, 1, 28, 16 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 28, 1, 28, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 28, 1, 28, 3 ], + "name" : "c_b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 28, 5, 28, 8 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 28, 12, 28, 16 ], + "value" : false + } + }, { + "kind" : "VarDef", + "location" : [ 30, 1, 30, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 30, 1, 30, 12 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 30, 1, 30, 6 ], + "name" : "a_list" + }, + "type" : { + "kind" : "ListType", + "location" : [ 30, 8, 30, 12 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 30, 9, 30, 11 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 30, 16, 30, 19 ] + } + }, { + "kind" : "VarDef", + "location" : [ 31, 1, 31, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 31, 1, 31, 12 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 31, 1, 31, 6 ], + "name" : "b_list" + }, + "type" : { + "kind" : "ListType", + "location" : [ 31, 8, 31, 12 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 31, 9, 31, 11 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 31, 16, 31, 19 ] + } + }, { + "kind" : "VarDef", + "location" : [ 32, 1, 32, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 32, 1, 32, 12 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 32, 1, 32, 6 ], + "name" : "c_list" + }, + "type" : { + "kind" : "ListType", + "location" : [ 32, 8, 32, 12 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 32, 9, 32, 11 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 32, 16, 32, 19 ] + } + }, { + "kind" : "VarDef", + "location" : [ 34, 1, 34, 22 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 34, 1, 34, 15 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 34, 1, 34, 7 ], + "name" : "a_class" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 34, 9, 34, 15 ], + "className" : "A_CLASS" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 34, 19, 34, 22 ] + } + }, { + "kind" : "VarDef", + "location" : [ 35, 1, 35, 22 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 35, 1, 35, 15 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 35, 1, 35, 7 ], + "name" : "b_class" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 35, 9, 35, 15 ], + "className" : "B_CLASS" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 35, 19, 35, 22 ] + } + }, { + "kind" : "VarDef", + "location" : [ 36, 1, 36, 22 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 36, 1, 36, 15 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 36, 1, 36, 7 ], + "name" : "c_class" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 36, 9, 36, 15 ], + "className" : "C_CLASS" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 36, 19, 36, 22 ] + } + }, { + "kind" : "FuncDef", + "location" : [ 40, 1, 44, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 40, 5, 40, 7 ], + "name" : "f_1" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 40, 14, 40, 19 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 41, 5, 43, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 41, 9, 41, 13 ], + "name" : "f_f_1" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 41, 20, 41, 25 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "GlobalDecl", + "location" : [ 42, 9, 42, 18 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 42, 16, 42, 18 ], + "name" : "a_s" + } + } ], + "statements" : [ ] + } ], + "statements" : [ ] + }, { + "kind" : "FuncDef", + "location" : [ 46, 1, 51, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 46, 5, 46, 7 ], + "name" : "f_2" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 46, 14, 46, 19 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 47, 5, 47, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 47, 5, 47, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 47, 5, 47, 9 ], + "name" : "f_a_s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 47, 11, 47, 13 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 47, 17, 47, 19 ], + "value" : "s" + } + }, { + "kind" : "FuncDef", + "location" : [ 48, 5, 50, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 48, 9, 48, 13 ], + "name" : "f_f_2" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 48, 20, 48, 25 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "NonLocalDecl", + "location" : [ 49, 9, 49, 22 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 49, 18, 49, 22 ], + "name" : "f_a_s" + } + } ], + "statements" : [ ] + } ], + "statements" : [ ] + }, { + "kind" : "FuncDef", + "location" : [ 53, 1, 55, 19 ], + "name" : { + "kind" : "Identifier", + "location" : [ 53, 5, 53, 7 ], + "name" : "f_3" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 53, 9, 53, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 53, 9, 53, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 53, 11, 53, 13 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 53, 19, 53, 21 ], + "className" : "str" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 54, 5, 54, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 54, 5, 54, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 54, 5, 54, 9 ], + "name" : "f_b_s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 54, 11, 54, 13 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 54, 17, 54, 17 ], + "value" : 3 + } + } ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 55, 5, 55, 18 ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 55, 12, 55, 18 ], + "left" : { + "kind" : "Identifier", + "location" : [ 55, 12, 55, 12 ], + "name" : "x" + }, + "operator" : "*", + "right" : { + "kind" : "Identifier", + "location" : [ 55, 14, 55, 18 ], + "name" : "f_b_s" + } + } + } ] } ], "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 59, 1, 59, 18 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 59, 1, 59, 6 ], + "name" : "a_list" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 59, 10, 59, 18 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 59, 11, 59, 11 ], + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 59, 14, 59, 14 ], + "value" : 2 + }, { + "kind" : "IntegerLiteral", + "location" : [ 59, 17, 59, 17 ], + "value" : 3 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 60, 1, 60, 18 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 60, 1, 60, 6 ], + "name" : "b_list" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 60, 10, 60, 18 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 60, 11, 60, 11 ], + "value" : 0 + }, { + "kind" : "IntegerLiteral", + "location" : [ 60, 14, 60, 14 ], + "value" : 0 + }, { + "kind" : "IntegerLiteral", + "location" : [ 60, 17, 60, 17 ], + "value" : 0 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 61, 1, 61, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 61, 1, 61, 6 ], + "name" : "c_list" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 61, 10, 61, 21 ], + "elements" : [ { + "kind" : "UnaryExpr", + "location" : [ 61, 11, 61, 12 ], + "operator" : "-", + "operand" : { + "kind" : "IntegerLiteral", + "location" : [ 61, 12, 61, 12 ], + "value" : 1 + } + }, { + "kind" : "UnaryExpr", + "location" : [ 61, 15, 61, 16 ], + "operator" : "-", + "operand" : { + "kind" : "IntegerLiteral", + "location" : [ 61, 16, 61, 16 ], + "value" : 2 + } + }, { + "kind" : "UnaryExpr", + "location" : [ 61, 19, 61, 20 ], + "operator" : "-", + "operand" : { + "kind" : "IntegerLiteral", + "location" : [ 61, 20, 61, 20 ], + "value" : 3 + } + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 63, 1, 63, 20 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 63, 1, 63, 7 ], + "name" : "a_class" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 63, 11, 63, 20 ], + "function" : { + "kind" : "Identifier", + "location" : [ 63, 11, 63, 17 ], + "name" : "A_CLASS" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 63, 19, 63, 19 ], + "value" : 5 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 64, 1, 64, 19 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 64, 1, 64, 7 ], + "name" : "b_class" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 64, 11, 64, 19 ], + "function" : { + "kind" : "Identifier", + "location" : [ 64, 11, 64, 17 ], + "name" : "B_CLASS" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 65, 1, 65, 19 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 65, 1, 65, 7 ], + "name" : "c_class" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 65, 11, 65, 19 ], + "function" : { + "kind" : "Identifier", + "location" : [ 65, 11, 65, 17 ], + "name" : "C_CLASS" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 69, 1, 69, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 69, 1, 69, 3 ], + "name" : "c_i" + } ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 69, 7, 69, 10 ], + "value" : true + } + }, { "kind" : "ExprStmt", - "location" : [ 2, 1, 2, 7 ], + "location" : [ 71, 1, 71, 9 ], "expr" : { "kind" : "BinaryExpr", - "location" : [ 2, 1, 2, 7 ], + "location" : [ 71, 1, 71, 9 ], "left" : { "kind" : "Identifier", - "location" : [ 2, 1, 2, 1 ], - "name" : "x" + "location" : [ 71, 1, 71, 3 ], + "name" : "c_i" }, "operator" : "+", "right" : { "kind" : "ListExpr", - "location" : [ 2, 5, 2, 7 ], + "location" : [ 71, 7, 71, 9 ], "elements" : [ { "kind" : "IntegerLiteral", - "location" : [ 2, 6, 2, 6 ], + "location" : [ 71, 8, 71, 8 ], "value" : 1 } ] } } }, { "kind" : "AssignStmt", - "location" : [ 4, 3, 4, 14 ], + "location" : [ 73, 1, 73, 23 ], "targets" : [ { "kind" : "Identifier", - "location" : [ 4, 3, 4, 6 ], - "name" : "bool" + "location" : [ 73, 1, 73, 3 ], + "name" : "a_i" + }, { + "kind" : "Identifier", + "location" : [ 73, 7, 73, 9 ], + "name" : "a_b" + }, { + "kind" : "Identifier", + "location" : [ 73, 13, 73, 13 ], + "name" : "z" } ], "value" : { - "kind" : "BooleanLiteral", - "location" : [ 4, 10, 4, 14 ], - "value" : false + "kind" : "StringLiteral", + "location" : [ 73, 17, 73, 23 ], + "value" : "Error" } }, { "kind" : "AssignStmt", - "location" : [ 5, 1, 5, 19 ], + "location" : [ 75, 1, 75, 13 ], "targets" : [ { "kind" : "Identifier", - "location" : [ 5, 1, 5, 1 ], - "name" : "x" - }, { + "location" : [ 75, 1, 75, 3 ], + "name" : "a_s" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 75, 7, 75, 13 ], + "left" : { + "kind" : "Identifier", + "location" : [ 75, 7, 75, 9 ], + "name" : "a_s" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 75, 13, 75, 13 ], + "value" : 1 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 77, 1, 77, 14 ], + "targets" : [ { "kind" : "Identifier", - "location" : [ 5, 5, 5, 5 ], - "name" : "y" + "location" : [ 77, 1, 77, 3 ], + "name" : "c_s" + } ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 77, 7, 77, 14 ], + "list" : { + "kind" : "Identifier", + "location" : [ 77, 7, 77, 9 ], + "name" : "a_s" + }, + "index" : { + "kind" : "Identifier", + "location" : [ 77, 11, 77, 13 ], + "name" : "a_s" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 79, 1, 79, 21 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 79, 1, 79, 17 ], + "object" : { + "kind" : "Identifier", + "location" : [ 79, 1, 79, 7 ], + "name" : "b_class" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 79, 9, 79, 17 ], + "name" : "b_class_i" + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 79, 21, 79, 21 ], + "value" : 2 + } + }, { + "kind" : "AssignStmt", + "location" : [ 81, 1, 81, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 81, 1, 81, 3 ], + "name" : "f_1" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 81, 7, 81, 7 ], + "value" : 5 + } + }, { + "kind" : "AssignStmt", + "location" : [ 83, 1, 83, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 83, 1, 83, 3 ], + "name" : "f_2" + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 83, 7, 83, 9 ], + "name" : "f_1" + } + }, { + "kind" : "AssignStmt", + "location" : [ 85, 1, 85, 31 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 85, 1, 85, 3 ], + "name" : "a_i" + }, { + "kind" : "MemberExpr", + "location" : [ 85, 7, 85, 23 ], + "object" : { + "kind" : "Identifier", + "location" : [ 85, 7, 85, 13 ], + "name" : "b_class" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 85, 15, 85, 23 ], + "name" : "b_class_i" + } }, { "kind" : "Identifier", - "location" : [ 5, 9, 5, 9 ], + "location" : [ 85, 27, 85, 27 ], "name" : "z" } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 85, 31, 85, 31 ], + "value" : 5 + } + }, { + "kind" : "AssignStmt", + "location" : [ 87, 1, 87, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 87, 1, 87, 3 ], + "name" : "x_i" + } ], "value" : { "kind" : "StringLiteral", - "location" : [ 5, 13, 5, 19 ], - "value" : "Error" + "location" : [ 87, 7, 87, 10 ], + "value" : "ss" + } + }, { + "kind" : "AssignStmt", + "location" : [ 89, 1, 89, 15 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 89, 1, 89, 3 ], + "name" : "a_s" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 89, 7, 89, 15 ], + "left" : { + "kind" : "Identifier", + "location" : [ 89, 7, 89, 9 ], + "name" : "a_i" + }, + "operator" : "+", + "right" : { + "kind" : "Identifier", + "location" : [ 89, 13, 89, 15 ], + "name" : "b_i" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 91, 1, 91, 25 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 91, 1, 91, 3 ], + "name" : "a_s" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 91, 7, 91, 25 ], + "left" : { + "kind" : "BinaryExpr", + "location" : [ 91, 7, 91, 16 ], + "left" : { + "kind" : "Identifier", + "location" : [ 91, 7, 91, 9 ], + "name" : "a_i" + }, + "operator" : "==", + "right" : { + "kind" : "Identifier", + "location" : [ 91, 14, 91, 16 ], + "name" : "b_i" + } + }, + "operator" : "and", + "right" : { + "kind" : "BooleanLiteral", + "location" : [ 91, 22, 91, 25 ], + "value" : true + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 93, 1, 93, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 93, 1, 93, 6 ], + "name" : "a_list" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 93, 10, 93, 21 ], + "left" : { + "kind" : "Identifier", + "location" : [ 93, 10, 93, 15 ], + "name" : "a_list" + }, + "operator" : "+", + "right" : { + "kind" : "Identifier", + "location" : [ 93, 19, 93, 21 ], + "name" : "a_s" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 95, 1, 95, 17 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 95, 1, 95, 3 ], + "name" : "a_s" + } ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 95, 7, 95, 17 ], + "list" : { + "kind" : "Identifier", + "location" : [ 95, 7, 95, 12 ], + "name" : "a_list" + }, + "index" : { + "kind" : "Identifier", + "location" : [ 95, 14, 95, 16 ], + "name" : "a_s" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 97, 1, 97, 15 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 97, 1, 97, 9 ], + "list" : { + "kind" : "Identifier", + "location" : [ 97, 1, 97, 6 ], + "name" : "a_list" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 97, 8, 97, 8 ], + "value" : 1 + } + } ], + "value" : { + "kind" : "StringLiteral", + "location" : [ 97, 13, 97, 15 ], + "value" : "a" + } + }, { + "kind" : "AssignStmt", + "location" : [ 99, 1, 99, 16 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 99, 1, 99, 3 ], + "name" : "a_i" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 99, 7, 99, 16 ], + "left" : { + "kind" : "CallExpr", + "location" : [ 99, 7, 99, 12 ], + "function" : { + "kind" : "Identifier", + "location" : [ 99, 7, 99, 9 ], + "name" : "f_3" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 99, 11, 99, 11 ], + "value" : 3 + } ] + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 99, 16, 99, 16 ], + "value" : 5 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 101, 1, 101, 5 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 101, 1, 101, 5 ], + "function" : { + "kind" : "Identifier", + "location" : [ 101, 1, 101, 3 ], + "name" : "f_1" + }, + "args" : [ ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 103, 1, 103, 5 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 103, 1, 103, 5 ], + "function" : { + "kind" : "Identifier", + "location" : [ 103, 1, 103, 3 ], + "name" : "f_2" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 105, 1, 105, 22 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 105, 1, 105, 3 ], + "name" : "a_i" + } ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 105, 7, 105, 22 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 105, 7, 105, 17 ], + "object" : { + "kind" : "Identifier", + "location" : [ 105, 7, 105, 13 ], + "name" : "a_class" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 105, 15, 105, 17 ], + "name" : "add" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 105, 19, 105, 21 ], + "name" : "a_s" + } ] } } ], "errors" : { - "errors" : [ { - "kind" : "CompilerError", - "location" : [ 4, 2, 4, 2 ], - "message" : "Parse error near token COLON: :", - "syntax" : true - } ], + "errors" : [ ], "kind" : "Errors", "location" : [ 0, 0, 0, 0 ] } diff --git a/src/test/data/pa2/student_contributed/bad_types.py.ast.typed b/src/test/data/pa2/student_contributed/bad_types.py.ast.typed index b5c130f..a85b212 100644 --- a/src/test/data/pa2/student_contributed/bad_types.py.ast.typed +++ b/src/test/data/pa2/student_contributed/bad_types.py.ast.typed @@ -3,7 +3,7 @@ "location" : [ 2, 1, 105, 70 ], "declarations" : [ { "kind" : "ClassDef", - "location" : [ 2, 1, 9, 16 ], + "location" : [ 2, 1, 11, 0 ], "name" : { "kind" : "Identifier", "location" : [ 2, 7, 2, 13 ], @@ -38,7 +38,7 @@ } }, { "kind" : "FuncDef", - "location" : [ 4, 5, 5, 18 ], + "location" : [ 4, 5, 5, 19 ], "name" : { "kind" : "Identifier", "location" : [ 4, 9, 4, 16 ], @@ -103,7 +103,7 @@ } ] }, { "kind" : "FuncDef", - "location" : [ 7, 5, 9, 16 ], + "location" : [ 7, 5, 9, 17 ], "name" : { "kind" : "Identifier", "location" : [ 7, 9, 7, 11 ], @@ -186,7 +186,7 @@ } ] }, { "kind" : "ClassDef", - "location" : [ 11, 1, 12, 21 ], + "location" : [ 11, 1, 12, 22 ], "name" : { "kind" : "Identifier", "location" : [ 11, 7, 11, 13 ], @@ -222,7 +222,7 @@ } ] }, { "kind" : "ClassDef", - "location" : [ 14, 1, 0, 0 ], + "location" : [ 14, 1, 15, 9 ], "name" : { "kind" : "Identifier", "location" : [ 14, 7, 14, 13 ], @@ -572,7 +572,7 @@ } }, { "kind" : "FuncDef", - "location" : [ 40, 1, 0, 0 ], + "location" : [ 40, 1, 44, 9 ], "name" : { "kind" : "Identifier", "location" : [ 40, 5, 40, 7 ], @@ -586,7 +586,7 @@ }, "declarations" : [ { "kind" : "FuncDef", - "location" : [ 41, 5, 0, 0 ], + "location" : [ 41, 5, 43, 13 ], "name" : { "kind" : "Identifier", "location" : [ 41, 9, 41, 13 ], @@ -612,7 +612,7 @@ "statements" : [ ] }, { "kind" : "FuncDef", - "location" : [ 46, 1, 0, 0 ], + "location" : [ 46, 1, 51, 9 ], "name" : { "kind" : "Identifier", "location" : [ 46, 5, 46, 7 ], @@ -648,7 +648,7 @@ } }, { "kind" : "FuncDef", - "location" : [ 48, 5, 0, 0 ], + "location" : [ 48, 5, 50, 13 ], "name" : { "kind" : "Identifier", "location" : [ 48, 9, 48, 13 ], @@ -674,7 +674,7 @@ "statements" : [ ] }, { "kind" : "FuncDef", - "location" : [ 53, 1, 55, 18 ], + "location" : [ 53, 1, 55, 19 ], "name" : { "kind" : "Identifier", "location" : [ 53, 5, 53, 7 ], diff --git a/src/test/data/pa2/student_contributed/good.py.ast b/src/test/data/pa2/student_contributed/good.py.ast index b95160b..32b037c 100644 --- a/src/test/data/pa2/student_contributed/good.py.ast +++ b/src/test/data/pa2/student_contributed/good.py.ast @@ -1,44 +1,66 @@ { "kind" : "Program", - "location" : [ 2, 1, 83, 25 ], + "location" : [ 2, 1, 110, 11 ], "declarations" : [ { "kind" : "ClassDef", - "location" : [ 2, 1, 10, 14 ], + "location" : [ 2, 1, 12, 0 ], "name" : { "kind" : "Identifier", - "location" : [ 2, 7, 2, 9 ], - "name" : "Foo" + "location" : [ 2, 7, 2, 13 ], + "name" : "A_CLASS" }, "superClass" : { "kind" : "Identifier", - "location" : [ 2, 11, 2, 16 ], + "location" : [ 2, 15, 2, 20 ], "name" : "object" }, "declarations" : [ { "kind" : "VarDef", - "location" : [ 3, 5, 3, 13 ], + "location" : [ 3, 5, 3, 21 ], "var" : { "kind" : "TypedVar", - "location" : [ 3, 5, 3, 9 ], + "location" : [ 3, 5, 3, 17 ], "identifier" : { "kind" : "Identifier", - "location" : [ 3, 5, 3, 5 ], + "location" : [ 3, 5, 3, 13 ], + "name" : "a_class_i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 15, 3, 17 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 21, 3, 21 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 4, 5, 4, 11 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 5, 4, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 5 ], "name" : "x" }, "type" : { "kind" : "ClassType", - "location" : [ 3, 7, 3, 9 ], + "location" : [ 4, 7, 4, 9 ], "className" : "int" } }, "value" : { "kind" : "IntegerLiteral", - "location" : [ 3, 13, 3, 13 ], + "location" : [ 4, 11, 4, 11 ], "value" : 0 } }, { "kind" : "FuncDef", - "location" : [ 5, 5, 6, 18 ], + "location" : [ 5, 5, 6, 19 ], "name" : { "kind" : "Identifier", "location" : [ 5, 9, 5, 16 ], @@ -46,7 +68,7 @@ }, "params" : [ { "kind" : "TypedVar", - "location" : [ 5, 18, 5, 27 ], + "location" : [ 5, 18, 5, 31 ], "identifier" : { "kind" : "Identifier", "location" : [ 5, 18, 5, 21 ], @@ -54,26 +76,13 @@ }, "type" : { "kind" : "ClassType", - "location" : [ 5, 23, 5, 27 ], - "className" : "Foo" - } - }, { - "kind" : "TypedVar", - "location" : [ 5, 30, 5, 34 ], - "identifier" : { - "kind" : "Identifier", - "location" : [ 5, 30, 5, 30 ], - "name" : "x" - }, - "type" : { - "kind" : "ClassType", - "location" : [ 5, 32, 5, 34 ], - "className" : "int" + "location" : [ 5, 23, 5, 31 ], + "className" : "A_CLASS" } } ], "returnType" : { "kind" : "ClassType", - "location" : [ 5, 36, 5, 36 ], + "location" : [ 5, 33, 5, 33 ], "className" : "" }, "declarations" : [ ], @@ -95,1092 +104,1192 @@ } } ], "value" : { - "kind" : "Identifier", + "kind" : "IntegerLiteral", "location" : [ 6, 18, 6, 18 ], - "name" : "x" + "value" : 0 } } ] }, { "kind" : "FuncDef", - "location" : [ 8, 5, 10, 14 ], + "location" : [ 8, 5, 10, 17 ], "name" : { "kind" : "Identifier", "location" : [ 8, 9, 8, 11 ], - "name" : "bar" + "name" : "add" }, "params" : [ { "kind" : "TypedVar", - "location" : [ 8, 13, 8, 17 ], + "location" : [ 8, 13, 8, 26 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 13, 8, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 18, 8, 26 ], + "className" : "A_CLASS" + } + }, { + "kind" : "TypedVar", + "location" : [ 8, 29, 8, 33 ], "identifier" : { "kind" : "Identifier", - "location" : [ 8, 13, 8, 13 ], + "location" : [ 8, 29, 8, 29 ], "name" : "y" }, "type" : { "kind" : "ClassType", - "location" : [ 8, 15, 8, 17 ], + "location" : [ 8, 31, 8, 33 ], "className" : "int" } } ], "returnType" : { "kind" : "ClassType", - "location" : [ 8, 19, 8, 19 ], - "className" : "" + "location" : [ 8, 39, 8, 41 ], + "className" : "int" }, "declarations" : [ ], "statements" : [ { - "kind" : "ExprStmt", - "location" : [ 9, 9, 9, 38 ], - "expr" : { - "kind" : "CallExpr", - "location" : [ 9, 9, 9, 38 ], - "function" : { + "kind" : "AssignStmt", + "location" : [ 9, 9, 9, 20 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 9, 9, 9, 9 ], + "name" : "y" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 9, 13, 9, 20 ], + "left" : { "kind" : "Identifier", - "location" : [ 9, 9, 9, 13 ], - "name" : "print" + "location" : [ 9, 13, 9, 13 ], + "name" : "y" }, - "args" : [ { - "kind" : "StringLiteral", - "location" : [ 9, 15, 9, 28 ], - "value" : "Hello World!" - }, { - "kind" : "BinaryExpr", - "location" : [ 9, 30, 9, 37 ], - "left" : { - "kind" : "MemberExpr", - "location" : [ 9, 30, 9, 35 ], - "object" : { - "kind" : "Identifier", - "location" : [ 9, 30, 9, 33 ], - "name" : "self" - }, - "member" : { - "kind" : "Identifier", - "location" : [ 9, 35, 9, 35 ], - "name" : "x" - } + "operator" : "+", + "right" : { + "kind" : "MemberExpr", + "location" : [ 9, 15, 9, 20 ], + "object" : { + "kind" : "Identifier", + "location" : [ 9, 15, 9, 18 ], + "name" : "self" }, - "operator" : "+", - "right" : { + "member" : { "kind" : "Identifier", - "location" : [ 9, 37, 9, 37 ], - "name" : "y" + "location" : [ 9, 20, 9, 20 ], + "name" : "x" } - } ] + } } }, { - "kind" : "AssignStmt", - "location" : [ 10, 9, 10, 14 ], - "targets" : [ { + "kind" : "ReturnStmt", + "location" : [ 10, 9, 10, 16 ], + "value" : { "kind" : "Identifier", - "location" : [ 10, 9, 10, 9 ], + "location" : [ 10, 16, 10, 16 ], "name" : "y" - } ], - "value" : { - "kind" : "IntegerLiteral", - "location" : [ 10, 13, 10, 14 ], - "value" : 10 } } ] } ] }, { - "kind" : "FuncDef", - "location" : [ 12, 1, 17, 25 ], + "kind" : "ClassDef", + "location" : [ 12, 1, 13, 22 ], "name" : { "kind" : "Identifier", - "location" : [ 12, 5, 12, 14 ], - "name" : "get_stones" + "location" : [ 12, 7, 12, 13 ], + "name" : "B_CLASS" }, - "params" : [ { - "kind" : "TypedVar", - "location" : [ 12, 16, 12, 23 ], - "identifier" : { - "kind" : "Identifier", - "location" : [ 12, 16, 12, 19 ], - "name" : "name" - }, - "type" : { - "kind" : "ClassType", - "location" : [ 12, 21, 12, 23 ], - "className" : "str" - } - } ], - "returnType" : { - "kind" : "ClassType", - "location" : [ 12, 27, 12, 29 ], - "className" : "str" + "superClass" : { + "kind" : "Identifier", + "location" : [ 12, 15, 12, 20 ], + "name" : "object" }, "declarations" : [ { - "kind" : "FuncDef", - "location" : [ 13, 5, 14, 38 ], - "name" : { - "kind" : "Identifier", - "location" : [ 13, 9, 13, 16 ], - "name" : "map_name" - }, - "params" : [ { + "kind" : "VarDef", + "location" : [ 13, 5, 13, 21 ], + "var" : { "kind" : "TypedVar", - "location" : [ 13, 18, 13, 23 ], + "location" : [ 13, 5, 13, 17 ], "identifier" : { "kind" : "Identifier", - "location" : [ 13, 18, 13, 19 ], - "name" : "nm" + "location" : [ 13, 5, 13, 13 ], + "name" : "b_class_i" }, "type" : { "kind" : "ClassType", - "location" : [ 13, 21, 13, 23 ], - "className" : "str" + "location" : [ 13, 15, 13, 17 ], + "className" : "int" } - } ], - "returnType" : { - "kind" : "ClassType", - "location" : [ 13, 27, 13, 29 ], - "className" : "str" }, - "declarations" : [ ], - "statements" : [ { - "kind" : "ReturnStmt", - "location" : [ 14, 9, 14, 38 ], - "value" : { - "kind" : "IndexExpr", - "location" : [ 14, 16, 14, 38 ], - "list" : { - "kind" : "Identifier", - "location" : [ 14, 16, 14, 21 ], - "name" : "stones" - }, - "index" : { - "kind" : "MethodCallExpr", - "location" : [ 14, 23, 14, 37 ], - "method" : { - "kind" : "MemberExpr", - "location" : [ 14, 23, 14, 33 ], - "object" : { - "kind" : "Identifier", - "location" : [ 14, 23, 14, 27 ], - "name" : "color" - }, - "member" : { - "kind" : "Identifier", - "location" : [ 14, 29, 14, 33 ], - "name" : "index" - } - }, - "args" : [ { - "kind" : "Identifier", - "location" : [ 14, 35, 14, 36 ], - "name" : "nm" - } ] - } - } - } ] - } ], - "statements" : [ { - "kind" : "AssignStmt", - "location" : [ 15, 5, 15, 24 ], - "targets" : [ { - "kind" : "Identifier", - "location" : [ 15, 5, 15, 9 ], - "name" : "color" - } ], - "value" : { - "kind" : "ListExpr", - "location" : [ 15, 11, 15, 24 ], - "elements" : [ { - "kind" : "StringLiteral", - "location" : [ 15, 12, 15, 16 ], - "value" : "Red" - }, { - "kind" : "StringLiteral", - "location" : [ 15, 18, 15, 23 ], - "value" : "Blue" - } ] - } - }, { - "kind" : "AssignStmt", - "location" : [ 16, 5, 16, 26 ], - "targets" : [ { - "kind" : "Identifier", - "location" : [ 16, 5, 16, 10 ], - "name" : "stones" - } ], - "value" : { - "kind" : "ListExpr", - "location" : [ 16, 12, 16, 26 ], - "elements" : [ { - "kind" : "StringLiteral", - "location" : [ 16, 13, 16, 18 ], - "value" : "Mind" - }, { - "kind" : "StringLiteral", - "location" : [ 16, 20, 16, 25 ], - "value" : "Soul" - } ] - } - }, { - "kind" : "ReturnStmt", - "location" : [ 17, 5, 17, 25 ], "value" : { - "kind" : "CallExpr", - "location" : [ 17, 12, 17, 25 ], - "function" : { - "kind" : "Identifier", - "location" : [ 17, 12, 17, 19 ], - "name" : "map_name" - }, - "args" : [ { - "kind" : "Identifier", - "location" : [ 17, 21, 17, 24 ], - "name" : "name" - } ] + "kind" : "IntegerLiteral", + "location" : [ 13, 21, 13, 21 ], + "value" : 0 } } ] }, { - "kind" : "FuncDef", - "location" : [ 19, 1, 22, 10 ], + "kind" : "ClassDef", + "location" : [ 15, 1, 16, 9 ], "name" : { "kind" : "Identifier", - "location" : [ 19, 5, 19, 8 ], - "name" : "funa" + "location" : [ 15, 7, 15, 13 ], + "name" : "C_CLASS" }, - "params" : [ ], - "returnType" : { - "kind" : "ClassType", - "location" : [ 19, 11, 19, 11 ], - "className" : "" + "superClass" : { + "kind" : "Identifier", + "location" : [ 15, 15, 15, 21 ], + "name" : "B_CLASS" }, - "declarations" : [ { - "kind" : "FuncDef", - "location" : [ 20, 5, 21, 22 ], - "name" : { + "declarations" : [ ] + }, { + "kind" : "VarDef", + "location" : [ 19, 1, 19, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 19, 1, 19, 7 ], + "identifier" : { "kind" : "Identifier", - "location" : [ 20, 9, 20, 12 ], - "name" : "funb" + "location" : [ 19, 1, 19, 3 ], + "name" : "a_s" }, - "params" : [ ], - "returnType" : { + "type" : { "kind" : "ClassType", - "location" : [ 20, 15, 20, 15 ], - "className" : "" - }, - "declarations" : [ ], - "statements" : [ { - "kind" : "ExprStmt", - "location" : [ 21, 9, 21, 22 ], - "expr" : { - "kind" : "CallExpr", - "location" : [ 21, 9, 21, 22 ], - "function" : { - "kind" : "Identifier", - "location" : [ 21, 9, 21, 13 ], - "name" : "print" - }, - "args" : [ { - "kind" : "StringLiteral", - "location" : [ 21, 15, 21, 21 ], - "value" : "Hello" - } ] - } - } ] - } ], - "statements" : [ { - "kind" : "ExprStmt", - "location" : [ 22, 5, 22, 10 ], - "expr" : { - "kind" : "CallExpr", - "location" : [ 22, 5, 22, 10 ], - "function" : { - "kind" : "Identifier", - "location" : [ 22, 5, 22, 8 ], - "name" : "funb" - }, - "args" : [ ] + "location" : [ 19, 5, 19, 7 ], + "className" : "str" } - } ] - }, { - "kind" : "FuncDef", - "location" : [ 24, 1, 27, 13 ], - "name" : { - "kind" : "Identifier", - "location" : [ 24, 5, 24, 8 ], - "name" : "fund" - }, - "params" : [ ], - "returnType" : { - "kind" : "ClassType", - "location" : [ 24, 11, 24, 11 ], - "className" : "" }, - "declarations" : [ { - "kind" : "FuncDef", - "location" : [ 25, 5, 26, 22 ], - "name" : { + "value" : { + "kind" : "StringLiteral", + "location" : [ 19, 11, 19, 15 ], + "value" : "a_s" + } + }, { + "kind" : "VarDef", + "location" : [ 20, 1, 20, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 20, 1, 20, 7 ], + "identifier" : { "kind" : "Identifier", - "location" : [ 25, 9, 25, 12 ], - "name" : "fune" + "location" : [ 20, 1, 20, 3 ], + "name" : "b_s" }, - "params" : [ ], - "returnType" : { + "type" : { "kind" : "ClassType", - "location" : [ 25, 15, 25, 15 ], - "className" : "" - }, - "declarations" : [ ], - "statements" : [ { - "kind" : "ExprStmt", - "location" : [ 26, 9, 26, 22 ], - "expr" : { - "kind" : "CallExpr", - "location" : [ 26, 9, 26, 22 ], - "function" : { - "kind" : "Identifier", - "location" : [ 26, 9, 26, 13 ], - "name" : "print" - }, - "args" : [ { - "kind" : "StringLiteral", - "location" : [ 26, 15, 26, 21 ], - "value" : "Hello" - } ] - } - } ] - } ], - "statements" : [ { - "kind" : "AssignStmt", - "location" : [ 27, 5, 27, 13 ], - "targets" : [ { - "kind" : "Identifier", - "location" : [ 27, 5, 27, 5 ], - "name" : "c" - } ], - "value" : { - "kind" : "BinaryExpr", - "location" : [ 27, 9, 27, 13 ], - "left" : { - "kind" : "IntegerLiteral", - "location" : [ 27, 9, 27, 9 ], - "value" : 4 - }, - "operator" : "+", - "right" : { - "kind" : "IntegerLiteral", - "location" : [ 27, 13, 27, 13 ], - "value" : 5 - } + "location" : [ 20, 5, 20, 7 ], + "className" : "str" } - } ] - }, { - "kind" : "FuncDef", - "location" : [ 29, 1, 33, 13 ], - "name" : { - "kind" : "Identifier", - "location" : [ 29, 5, 29, 8 ], - "name" : "funf" - }, - "params" : [ ], - "returnType" : { - "kind" : "ClassType", - "location" : [ 29, 11, 29, 11 ], - "className" : "" }, - "declarations" : [ { - "kind" : "FuncDef", - "location" : [ 30, 5, 31, 22 ], - "name" : { + "value" : { + "kind" : "StringLiteral", + "location" : [ 20, 11, 20, 15 ], + "value" : "b_s" + } + }, { + "kind" : "VarDef", + "location" : [ 21, 1, 21, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 21, 1, 21, 7 ], + "identifier" : { "kind" : "Identifier", - "location" : [ 30, 9, 30, 12 ], - "name" : "fung" + "location" : [ 21, 1, 21, 3 ], + "name" : "c_s" }, - "params" : [ ], - "returnType" : { + "type" : { "kind" : "ClassType", - "location" : [ 30, 15, 30, 15 ], - "className" : "" + "location" : [ 21, 5, 21, 7 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 21, 11, 21, 15 ], + "value" : "c_s" + } + }, { + "kind" : "VarDef", + "location" : [ 23, 1, 23, 11 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 23, 1, 23, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 23, 1, 23, 3 ], + "name" : "a_i" }, - "declarations" : [ ], - "statements" : [ { - "kind" : "ExprStmt", - "location" : [ 31, 9, 31, 22 ], - "expr" : { - "kind" : "CallExpr", - "location" : [ 31, 9, 31, 22 ], - "function" : { + "type" : { + "kind" : "ClassType", + "location" : [ 23, 5, 23, 7 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 23, 11, 23, 11 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 24, 1, 24, 11 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 24, 1, 24, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 24, 1, 24, 3 ], + "name" : "b_i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 24, 5, 24, 7 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 24, 11, 24, 11 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 25, 1, 25, 11 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 25, 1, 25, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 25, 1, 25, 3 ], + "name" : "c_i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 25, 5, 25, 7 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 25, 11, 25, 11 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 27, 1, 27, 16 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 27, 1, 27, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 27, 1, 27, 3 ], + "name" : "a_b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 27, 5, 27, 8 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 27, 12, 27, 16 ], + "value" : false + } + }, { + "kind" : "VarDef", + "location" : [ 28, 1, 28, 16 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 28, 1, 28, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 28, 1, 28, 3 ], + "name" : "b_b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 28, 5, 28, 8 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 28, 12, 28, 16 ], + "value" : false + } + }, { + "kind" : "VarDef", + "location" : [ 29, 1, 29, 16 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 29, 1, 29, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 29, 1, 29, 3 ], + "name" : "c_b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 29, 5, 29, 8 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 29, 12, 29, 16 ], + "value" : false + } + }, { + "kind" : "VarDef", + "location" : [ 31, 1, 31, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 31, 1, 31, 12 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 31, 1, 31, 6 ], + "name" : "a_list" + }, + "type" : { + "kind" : "ListType", + "location" : [ 31, 8, 31, 12 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 31, 9, 31, 11 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 31, 16, 31, 19 ] + } + }, { + "kind" : "VarDef", + "location" : [ 32, 1, 32, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 32, 1, 32, 12 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 32, 1, 32, 6 ], + "name" : "b_list" + }, + "type" : { + "kind" : "ListType", + "location" : [ 32, 8, 32, 12 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 32, 9, 32, 11 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 32, 16, 32, 19 ] + } + }, { + "kind" : "VarDef", + "location" : [ 33, 1, 33, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 33, 1, 33, 12 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 33, 1, 33, 6 ], + "name" : "c_list" + }, + "type" : { + "kind" : "ListType", + "location" : [ 33, 8, 33, 12 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 33, 9, 33, 11 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 33, 16, 33, 19 ] + } + }, { + "kind" : "VarDef", + "location" : [ 35, 1, 35, 22 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 35, 1, 35, 15 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 35, 1, 35, 7 ], + "name" : "a_class" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 35, 9, 35, 15 ], + "className" : "A_CLASS" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 35, 19, 35, 22 ] + } + }, { + "kind" : "VarDef", + "location" : [ 36, 1, 36, 22 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 36, 1, 36, 15 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 36, 1, 36, 7 ], + "name" : "b_class" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 36, 9, 36, 15 ], + "className" : "B_CLASS" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 36, 19, 36, 22 ] + } + }, { + "kind" : "VarDef", + "location" : [ 37, 1, 37, 22 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 37, 1, 37, 15 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 37, 1, 37, 7 ], + "name" : "c_class" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 37, 9, 37, 15 ], + "className" : "C_CLASS" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 37, 19, 37, 22 ] + } + }, { + "kind" : "FuncDef", + "location" : [ 41, 1, 46, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 41, 5, 41, 7 ], + "name" : "f_1" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 41, 14, 41, 19 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 42, 5, 45, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 42, 9, 42, 13 ], + "name" : "f_f_1" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 42, 20, 42, 25 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "GlobalDecl", + "location" : [ 43, 9, 43, 18 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 43, 16, 43, 18 ], + "name" : "a_s" + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 44, 9, 44, 18 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 44, 9, 44, 18 ], + "function" : { "kind" : "Identifier", - "location" : [ 31, 9, 31, 13 ], + "location" : [ 44, 9, 44, 13 ], "name" : "print" }, "args" : [ { - "kind" : "StringLiteral", - "location" : [ 31, 15, 31, 21 ], - "value" : "Hello" + "kind" : "Identifier", + "location" : [ 44, 15, 44, 17 ], + "name" : "a_s" } ] } } ] } ], - "statements" : [ { - "kind" : "AssignStmt", - "location" : [ 32, 5, 32, 9 ], - "targets" : [ { - "kind" : "Identifier", - "location" : [ 32, 5, 32, 5 ], - "name" : "c" - } ], + "statements" : [ ] + }, { + "kind" : "FuncDef", + "location" : [ 48, 1, 54, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 48, 5, 48, 7 ], + "name" : "f_2" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 48, 14, 48, 19 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 49, 5, 49, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 49, 5, 49, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 49, 5, 49, 9 ], + "name" : "f_a_s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 49, 11, 49, 13 ], + "className" : "str" + } + }, "value" : { - "kind" : "IntegerLiteral", - "location" : [ 32, 9, 32, 9 ], - "value" : 6 + "kind" : "StringLiteral", + "location" : [ 49, 17, 49, 19 ], + "value" : "s" } }, { - "kind" : "AssignStmt", - "location" : [ 33, 5, 33, 13 ], - "targets" : [ { + "kind" : "FuncDef", + "location" : [ 50, 5, 53, 13 ], + "name" : { "kind" : "Identifier", - "location" : [ 33, 5, 33, 5 ], - "name" : "c" + "location" : [ 50, 9, 50, 13 ], + "name" : "f_f_2" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 50, 20, 50, 25 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "NonLocalDecl", + "location" : [ 51, 9, 51, 22 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 51, 18, 51, 22 ], + "name" : "f_a_s" + } } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 52, 9, 52, 20 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 52, 9, 52, 20 ], + "function" : { + "kind" : "Identifier", + "location" : [ 52, 9, 52, 13 ], + "name" : "print" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 52, 15, 52, 19 ], + "name" : "f_a_s" + } ] + } + } ] + } ], + "statements" : [ ] + }, { + "kind" : "FuncDef", + "location" : [ 56, 1, 58, 19 ], + "name" : { + "kind" : "Identifier", + "location" : [ 56, 5, 56, 7 ], + "name" : "f_3" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 56, 9, 56, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 56, 9, 56, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 56, 11, 56, 13 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 56, 19, 56, 21 ], + "className" : "int" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 57, 5, 57, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 57, 5, 57, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 57, 5, 57, 9 ], + "name" : "f_b_s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 57, 11, 57, 13 ], + "className" : "int" + } + }, "value" : { + "kind" : "IntegerLiteral", + "location" : [ 57, 17, 57, 17 ], + "value" : 3 + } + } ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 58, 5, 58, 18 ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 58, 12, 58, 18 ], + "left" : { + "kind" : "Identifier", + "location" : [ 58, 12, 58, 12 ], + "name" : "x" + }, + "operator" : "*", + "right" : { + "kind" : "Identifier", + "location" : [ 58, 14, 58, 18 ], + "name" : "f_b_s" + } + } + } ] + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 61, 1, 61, 18 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 61, 1, 61, 6 ], + "name" : "a_list" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 61, 10, 61, 18 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 61, 11, 61, 11 ], + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 61, 14, 61, 14 ], + "value" : 2 + }, { + "kind" : "IntegerLiteral", + "location" : [ 61, 17, 61, 17 ], + "value" : 3 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 62, 1, 62, 18 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 62, 1, 62, 6 ], + "name" : "b_list" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 62, 10, 62, 18 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 62, 11, 62, 11 ], + "value" : 0 + }, { + "kind" : "IntegerLiteral", + "location" : [ 62, 14, 62, 14 ], + "value" : 0 + }, { + "kind" : "IntegerLiteral", + "location" : [ 62, 17, 62, 17 ], + "value" : 0 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 63, 1, 63, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 63, 1, 63, 6 ], + "name" : "c_list" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 63, 10, 63, 21 ], + "elements" : [ { + "kind" : "UnaryExpr", + "location" : [ 63, 11, 63, 12 ], + "operator" : "-", + "operand" : { + "kind" : "IntegerLiteral", + "location" : [ 63, 12, 63, 12 ], + "value" : 1 + } + }, { + "kind" : "UnaryExpr", + "location" : [ 63, 15, 63, 16 ], + "operator" : "-", + "operand" : { + "kind" : "IntegerLiteral", + "location" : [ 63, 16, 63, 16 ], + "value" : 2 + } + }, { + "kind" : "UnaryExpr", + "location" : [ 63, 19, 63, 20 ], + "operator" : "-", + "operand" : { + "kind" : "IntegerLiteral", + "location" : [ 63, 20, 63, 20 ], + "value" : 3 + } + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 65, 1, 65, 19 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 65, 1, 65, 7 ], + "name" : "a_class" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 65, 11, 65, 19 ], + "function" : { + "kind" : "Identifier", + "location" : [ 65, 11, 65, 17 ], + "name" : "A_CLASS" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 66, 1, 66, 19 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 66, 1, 66, 7 ], + "name" : "b_class" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 66, 11, 66, 19 ], + "function" : { + "kind" : "Identifier", + "location" : [ 66, 11, 66, 17 ], + "name" : "B_CLASS" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 67, 1, 67, 19 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 67, 1, 67, 7 ], + "name" : "c_class" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 67, 11, 67, 19 ], + "function" : { + "kind" : "Identifier", + "location" : [ 67, 11, 67, 17 ], + "name" : "C_CLASS" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 75, 1, 75, 15 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 75, 1, 75, 3 ], + "name" : "a_s" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 75, 7, 75, 15 ], + "left" : { + "kind" : "Identifier", + "location" : [ 75, 7, 75, 9 ], + "name" : "a_s" + }, + "operator" : "+", + "right" : { + "kind" : "Identifier", + "location" : [ 75, 13, 75, 15 ], + "name" : "b_s" + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 76, 1, 76, 10 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 76, 1, 76, 10 ], + "function" : { + "kind" : "Identifier", + "location" : [ 76, 1, 76, 5 ], + "name" : "print" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 76, 7, 76, 9 ], + "name" : "a_s" + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 79, 1, 79, 12 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 79, 1, 79, 3 ], + "name" : "c_s" + } ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 79, 7, 79, 12 ], + "list" : { + "kind" : "Identifier", + "location" : [ 79, 7, 79, 9 ], + "name" : "a_s" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 79, 11, 79, 11 ], + "value" : 0 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 80, 1, 80, 10 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 80, 1, 80, 10 ], + "function" : { + "kind" : "Identifier", + "location" : [ 80, 1, 80, 5 ], + "name" : "print" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 80, 7, 80, 9 ], + "name" : "c_s" + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 85, 1, 85, 28 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 85, 1, 85, 3 ], + "name" : "a_b" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 85, 7, 85, 28 ], + "left" : { "kind" : "BinaryExpr", - "location" : [ 33, 9, 33, 13 ], + "location" : [ 85, 7, 85, 16 ], "left" : { - "kind" : "IntegerLiteral", - "location" : [ 33, 9, 33, 9 ], - "value" : 4 + "kind" : "Identifier", + "location" : [ 85, 7, 85, 9 ], + "name" : "a_i" }, - "operator" : "+", + "operator" : "==", "right" : { - "kind" : "IntegerLiteral", - "location" : [ 33, 13, 33, 13 ], - "value" : 5 + "kind" : "Identifier", + "location" : [ 85, 14, 85, 16 ], + "name" : "b_i" } - } - } ] - } ], - "statements" : [ { - "kind" : "IfStmt", - "location" : [ 36, 1, 0, 0 ], - "condition" : { - "kind" : "BooleanLiteral", - "location" : [ 36, 4, 36, 7 ], - "value" : true - }, - "thenBody" : [ { - "kind" : "IfStmt", - "location" : [ 37, 5, 0, 0 ], - "condition" : { - "kind" : "BooleanLiteral", - "location" : [ 37, 8, 37, 11 ], - "value" : true }, - "thenBody" : [ { - "kind" : "IfStmt", - "location" : [ 38, 9, 0, 0 ], - "condition" : { - "kind" : "BooleanLiteral", - "location" : [ 38, 12, 38, 15 ], - "value" : true - }, - "thenBody" : [ { - "kind" : "ExprStmt", - "location" : [ 39, 13, 39, 26 ], - "expr" : { - "kind" : "CallExpr", - "location" : [ 39, 13, 39, 26 ], - "function" : { - "kind" : "Identifier", - "location" : [ 39, 13, 39, 17 ], - "name" : "print" - }, - "args" : [ { - "kind" : "StringLiteral", - "location" : [ 39, 19, 39, 25 ], - "value" : "Hello" - } ] - } - } ], - "elseBody" : [ ] - } ], - "elseBody" : [ ] - } ], - "elseBody" : [ ] + "operator" : "and", + "right" : { + "kind" : "UnaryExpr", + "location" : [ 85, 22, 85, 28 ], + "operator" : "not", + "operand" : { + "kind" : "Identifier", + "location" : [ 85, 26, 85, 28 ], + "name" : "b_b" + } + } + } }, { "kind" : "ExprStmt", - "location" : [ 40, 1, 40, 14 ], + "location" : [ 86, 1, 86, 10 ], "expr" : { "kind" : "CallExpr", - "location" : [ 40, 1, 40, 14 ], + "location" : [ 86, 1, 86, 10 ], "function" : { "kind" : "Identifier", - "location" : [ 40, 1, 40, 5 ], + "location" : [ 86, 1, 86, 5 ], "name" : "print" }, "args" : [ { - "kind" : "StringLiteral", - "location" : [ 40, 7, 40, 13 ], - "value" : "World" + "kind" : "Identifier", + "location" : [ 86, 7, 86, 9 ], + "name" : "a_b" } ] } }, { - "kind" : "IfStmt", - "location" : [ 42, 1, 0, 0 ], - "condition" : { - "kind" : "BooleanLiteral", - "location" : [ 42, 4, 42, 7 ], - "value" : true - }, - "thenBody" : [ { - "kind" : "IfStmt", - "location" : [ 43, 5, 0, 0 ], - "condition" : { - "kind" : "BooleanLiteral", - "location" : [ 43, 8, 43, 11 ], - "value" : true - }, - "thenBody" : [ { - "kind" : "IfStmt", - "location" : [ 44, 9, 0, 0 ], - "condition" : { - "kind" : "BooleanLiteral", - "location" : [ 44, 12, 44, 15 ], - "value" : true - }, - "thenBody" : [ { - "kind" : "ExprStmt", - "location" : [ 45, 13, 45, 26 ], - "expr" : { - "kind" : "CallExpr", - "location" : [ 45, 13, 45, 26 ], - "function" : { - "kind" : "Identifier", - "location" : [ 45, 13, 45, 17 ], - "name" : "print" - }, - "args" : [ { - "kind" : "StringLiteral", - "location" : [ 45, 19, 45, 25 ], - "value" : "Hello" - } ] - } - } ], - "elseBody" : [ ] - }, { - "kind" : "ExprStmt", - "location" : [ 46, 9, 46, 22 ], - "expr" : { - "kind" : "CallExpr", - "location" : [ 46, 9, 46, 22 ], - "function" : { - "kind" : "Identifier", - "location" : [ 46, 9, 46, 13 ], - "name" : "print" - }, - "args" : [ { - "kind" : "StringLiteral", - "location" : [ 46, 15, 46, 21 ], - "value" : "World" - } ] - } - } ], - "elseBody" : [ ] + "kind" : "AssignStmt", + "location" : [ 91, 1, 91, 24 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 91, 1, 91, 6 ], + "name" : "a_list" } ], - "elseBody" : [ ] - }, { - "kind" : "IfStmt", - "location" : [ 48, 1, 0, 0 ], - "condition" : { - "kind" : "BooleanLiteral", - "location" : [ 48, 4, 48, 7 ], - "value" : true - }, - "thenBody" : [ { - "kind" : "IfStmt", - "location" : [ 49, 5, 0, 0 ], - "condition" : { - "kind" : "BooleanLiteral", - "location" : [ 49, 8, 49, 11 ], - "value" : true + "value" : { + "kind" : "BinaryExpr", + "location" : [ 91, 10, 91, 24 ], + "left" : { + "kind" : "Identifier", + "location" : [ 91, 10, 91, 15 ], + "name" : "a_list" }, - "thenBody" : [ { - "kind" : "IfStmt", - "location" : [ 50, 9, 0, 0 ], - "condition" : { - "kind" : "BooleanLiteral", - "location" : [ 50, 12, 50, 15 ], - "value" : true - }, - "thenBody" : [ { - "kind" : "ExprStmt", - "location" : [ 51, 13, 51, 26 ], - "expr" : { - "kind" : "CallExpr", - "location" : [ 51, 13, 51, 26 ], - "function" : { - "kind" : "Identifier", - "location" : [ 51, 13, 51, 17 ], - "name" : "print" - }, - "args" : [ { - "kind" : "StringLiteral", - "location" : [ 51, 19, 51, 25 ], - "value" : "Hello" - } ] - } - } ], - "elseBody" : [ ] - } ], - "elseBody" : [ ] - }, { - "kind" : "ExprStmt", - "location" : [ 52, 5, 52, 18 ], - "expr" : { - "kind" : "CallExpr", - "location" : [ 52, 5, 52, 18 ], - "function" : { - "kind" : "Identifier", - "location" : [ 52, 5, 52, 9 ], - "name" : "print" - }, - "args" : [ { - "kind" : "StringLiteral", - "location" : [ 52, 11, 52, 17 ], - "value" : "World" - } ] + "operator" : "+", + "right" : { + "kind" : "Identifier", + "location" : [ 91, 19, 91, 24 ], + "name" : "b_list" } + } + }, { + "kind" : "AssignStmt", + "location" : [ 92, 1, 92, 15 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 92, 1, 92, 3 ], + "name" : "c_i" } ], - "elseBody" : [ ] + "value" : { + "kind" : "IndexExpr", + "location" : [ 92, 7, 92, 15 ], + "list" : { + "kind" : "Identifier", + "location" : [ 92, 7, 92, 12 ], + "name" : "a_list" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 92, 14, 92, 14 ], + "value" : 0 + } + } }, { - "kind" : "IfStmt", - "location" : [ 54, 1, 0, 0 ], - "condition" : { - "kind" : "BooleanLiteral", - "location" : [ 54, 4, 54, 7 ], - "value" : true - }, - "thenBody" : [ { - "kind" : "IfStmt", - "location" : [ 55, 5, 59, 22 ], - "condition" : { - "kind" : "BooleanLiteral", - "location" : [ 55, 8, 55, 11 ], - "value" : true + "kind" : "AssignStmt", + "location" : [ 93, 1, 93, 13 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 93, 1, 93, 9 ], + "list" : { + "kind" : "Identifier", + "location" : [ 93, 1, 93, 6 ], + "name" : "a_list" }, - "thenBody" : [ { - "kind" : "IfStmt", - "location" : [ 56, 9, 0, 0 ], - "condition" : { - "kind" : "BooleanLiteral", - "location" : [ 56, 12, 56, 15 ], - "value" : true - }, - "thenBody" : [ { - "kind" : "ExprStmt", - "location" : [ 57, 13, 57, 26 ], - "expr" : { - "kind" : "CallExpr", - "location" : [ 57, 13, 57, 26 ], - "function" : { - "kind" : "Identifier", - "location" : [ 57, 13, 57, 17 ], - "name" : "print" - }, - "args" : [ { - "kind" : "StringLiteral", - "location" : [ 57, 19, 57, 25 ], - "value" : "Hello" - } ] - } - } ], - "elseBody" : [ ] - } ], - "elseBody" : [ { - "kind" : "ExprStmt", - "location" : [ 59, 9, 59, 22 ], - "expr" : { - "kind" : "CallExpr", - "location" : [ 59, 9, 59, 22 ], - "function" : { - "kind" : "Identifier", - "location" : [ 59, 9, 59, 13 ], - "name" : "print" - }, - "args" : [ { - "kind" : "StringLiteral", - "location" : [ 59, 15, 59, 21 ], - "value" : "World" - } ] - } - } ] + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 93, 8, 93, 8 ], + "value" : 1 + } } ], - "elseBody" : [ ] + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 93, 13, 93, 13 ], + "value" : 2 + } }, { - "kind" : "IfStmt", - "location" : [ 61, 1, 66, 18 ], - "condition" : { - "kind" : "BooleanLiteral", - "location" : [ 61, 4, 61, 7 ], - "value" : true - }, - "thenBody" : [ { - "kind" : "IfStmt", - "location" : [ 62, 5, 0, 0 ], - "condition" : { - "kind" : "BooleanLiteral", - "location" : [ 62, 8, 62, 11 ], - "value" : true - }, - "thenBody" : [ { - "kind" : "IfStmt", - "location" : [ 63, 9, 0, 0 ], - "condition" : { - "kind" : "BooleanLiteral", - "location" : [ 63, 12, 63, 15 ], - "value" : true - }, - "thenBody" : [ { - "kind" : "ExprStmt", - "location" : [ 64, 13, 64, 26 ], - "expr" : { - "kind" : "CallExpr", - "location" : [ 64, 13, 64, 26 ], - "function" : { - "kind" : "Identifier", - "location" : [ 64, 13, 64, 17 ], - "name" : "print" - }, - "args" : [ { - "kind" : "StringLiteral", - "location" : [ 64, 19, 64, 25 ], - "value" : "Hello" - } ] - } - } ], - "elseBody" : [ ] - } ], - "elseBody" : [ ] + "kind" : "AssignStmt", + "location" : [ 98, 1, 98, 16 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 98, 1, 98, 3 ], + "name" : "a_i" } ], - "elseBody" : [ { - "kind" : "ExprStmt", - "location" : [ 66, 5, 66, 18 ], - "expr" : { + "value" : { + "kind" : "BinaryExpr", + "location" : [ 98, 7, 98, 16 ], + "left" : { "kind" : "CallExpr", - "location" : [ 66, 5, 66, 18 ], + "location" : [ 98, 7, 98, 12 ], "function" : { "kind" : "Identifier", - "location" : [ 66, 5, 66, 9 ], - "name" : "print" + "location" : [ 98, 7, 98, 9 ], + "name" : "f_3" }, "args" : [ { - "kind" : "StringLiteral", - "location" : [ 66, 11, 66, 17 ], - "value" : "World" + "kind" : "IntegerLiteral", + "location" : [ 98, 11, 98, 11 ], + "value" : 3 } ] + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 98, 16, 98, 16 ], + "value" : 5 } - } ] + } }, { - "kind" : "AssignStmt", - "location" : [ 70, 1, 70, 10 ], - "targets" : [ { - "kind" : "Identifier", - "location" : [ 70, 1, 70, 1 ], - "name" : "f" - } ], - "value" : { + "kind" : "ExprStmt", + "location" : [ 99, 1, 99, 5 ], + "expr" : { "kind" : "CallExpr", - "location" : [ 70, 5, 70, 10 ], + "location" : [ 99, 1, 99, 5 ], "function" : { "kind" : "Identifier", - "location" : [ 70, 5, 70, 7 ], - "name" : "Foo" + "location" : [ 99, 1, 99, 3 ], + "name" : "f_1" }, - "args" : [ { - "kind" : "IntegerLiteral", - "location" : [ 70, 9, 70, 9 ], - "value" : 1 - } ] + "args" : [ ] } }, { "kind" : "ExprStmt", - "location" : [ 71, 1, 71, 10 ], + "location" : [ 100, 1, 100, 5 ], "expr" : { "kind" : "CallExpr", - "location" : [ 71, 1, 71, 10 ], + "location" : [ 100, 1, 100, 5 ], "function" : { "kind" : "Identifier", - "location" : [ 71, 1, 71, 5 ], - "name" : "print" + "location" : [ 100, 1, 100, 3 ], + "name" : "f_2" }, - "args" : [ { - "kind" : "MemberExpr", - "location" : [ 71, 7, 71, 9 ], - "object" : { - "kind" : "Identifier", - "location" : [ 71, 7, 71, 7 ], - "name" : "f" - }, - "member" : { - "kind" : "Identifier", - "location" : [ 71, 9, 71, 9 ], - "name" : "x" - } - } ] + "args" : [ ] } }, { - "kind" : "ExprStmt", - "location" : [ 72, 1, 72, 8 ], - "expr" : { + "kind" : "AssignStmt", + "location" : [ 105, 1, 105, 20 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 105, 1, 105, 3 ], + "name" : "a_i" + } ], + "value" : { "kind" : "MethodCallExpr", - "location" : [ 72, 1, 72, 8 ], + "location" : [ 105, 7, 105, 20 ], "method" : { "kind" : "MemberExpr", - "location" : [ 72, 1, 72, 5 ], + "location" : [ 105, 7, 105, 17 ], "object" : { "kind" : "Identifier", - "location" : [ 72, 1, 72, 1 ], - "name" : "f" + "location" : [ 105, 7, 105, 13 ], + "name" : "a_class" }, "member" : { "kind" : "Identifier", - "location" : [ 72, 3, 72, 5 ], - "name" : "bar" + "location" : [ 105, 15, 105, 17 ], + "name" : "add" } }, "args" : [ { "kind" : "IntegerLiteral", - "location" : [ 72, 7, 72, 7 ], - "value" : 4 - } ] - } - }, { - "kind" : "AssignStmt", - "location" : [ 74, 1, 74, 23 ], - "targets" : [ { - "kind" : "Identifier", - "location" : [ 74, 1, 74, 1 ], - "name" : "a" - } ], - "value" : { - "kind" : "ListExpr", - "location" : [ 74, 3, 74, 23 ], - "elements" : [ { - "kind" : "ListExpr", - "location" : [ 74, 4, 74, 12 ], - "elements" : [ { - "kind" : "ListExpr", - "location" : [ 74, 5, 74, 7 ], - "elements" : [ { - "kind" : "IntegerLiteral", - "location" : [ 74, 6, 74, 6 ], - "value" : 1 - } ] - }, { - "kind" : "ListExpr", - "location" : [ 74, 9, 74, 11 ], - "elements" : [ { - "kind" : "IntegerLiteral", - "location" : [ 74, 10, 74, 10 ], - "value" : 2 - } ] - } ] - }, { - "kind" : "ListExpr", - "location" : [ 74, 14, 74, 22 ], - "elements" : [ { - "kind" : "ListExpr", - "location" : [ 74, 15, 74, 17 ], - "elements" : [ { - "kind" : "IntegerLiteral", - "location" : [ 74, 16, 74, 16 ], - "value" : 3 - } ] - }, { - "kind" : "ListExpr", - "location" : [ 74, 19, 74, 21 ], - "elements" : [ { - "kind" : "IntegerLiteral", - "location" : [ 74, 20, 74, 20 ], - "value" : 4 - } ] - } ] + "location" : [ 105, 19, 105, 19 ], + "value" : 2 } ] } }, { "kind" : "ExprStmt", - "location" : [ 75, 1, 75, 28 ], + "location" : [ 106, 1, 106, 10 ], "expr" : { "kind" : "CallExpr", - "location" : [ 75, 1, 75, 28 ], + "location" : [ 106, 1, 106, 10 ], "function" : { "kind" : "Identifier", - "location" : [ 75, 1, 75, 5 ], + "location" : [ 106, 1, 106, 5 ], "name" : "print" }, "args" : [ { - "kind" : "BinaryExpr", - "location" : [ 75, 7, 75, 27 ], - "left" : { - "kind" : "IndexExpr", - "location" : [ 75, 7, 75, 16 ], - "list" : { - "kind" : "IndexExpr", - "location" : [ 75, 7, 75, 13 ], - "list" : { - "kind" : "IndexExpr", - "location" : [ 75, 7, 75, 10 ], - "list" : { - "kind" : "Identifier", - "location" : [ 75, 7, 75, 7 ], - "name" : "a" - }, - "index" : { - "kind" : "IntegerLiteral", - "location" : [ 75, 9, 75, 9 ], - "value" : 0 - } - }, - "index" : { - "kind" : "IntegerLiteral", - "location" : [ 75, 12, 75, 12 ], - "value" : 0 - } - }, - "index" : { - "kind" : "IntegerLiteral", - "location" : [ 75, 15, 75, 15 ], - "value" : 1 - } - }, - "operator" : "*", - "right" : { - "kind" : "IndexExpr", - "location" : [ 75, 18, 75, 27 ], - "list" : { - "kind" : "IndexExpr", - "location" : [ 75, 18, 75, 24 ], - "list" : { - "kind" : "IndexExpr", - "location" : [ 75, 18, 75, 21 ], - "list" : { - "kind" : "Identifier", - "location" : [ 75, 18, 75, 18 ], - "name" : "a" - }, - "index" : { - "kind" : "IntegerLiteral", - "location" : [ 75, 20, 75, 20 ], - "value" : 1 - } - }, - "index" : { - "kind" : "IntegerLiteral", - "location" : [ 75, 23, 75, 23 ], - "value" : 1 - } - }, - "index" : { - "kind" : "IntegerLiteral", - "location" : [ 75, 26, 75, 26 ], - "value" : 0 - } - } + "kind" : "Identifier", + "location" : [ 106, 7, 106, 9 ], + "name" : "a_i" } ] } }, { "kind" : "AssignStmt", - "location" : [ 77, 1, 78, 10 ], - "targets" : [ { - "kind" : "Identifier", - "location" : [ 77, 1, 77, 16 ], - "name" : "multiline_string" - } ], - "value" : { - "kind" : "StringLiteral", - "location" : [ 77, 18, 78, 10 ], - "value" : "Hi World,\nHere I am" - } - }, { - "kind" : "AssignStmt", - "location" : [ 80, 1, 80, 34 ], + "location" : [ 109, 1, 109, 36 ], "targets" : [ { "kind" : "Identifier", - "location" : [ 80, 1, 80, 15 ], - "name" : "expr_precedence" + "location" : [ 109, 1, 109, 3 ], + "name" : "a_i" } ], "value" : { - "kind" : "BinaryExpr", - "location" : [ 80, 19, 80, 34 ], - "left" : { - "kind" : "UnaryExpr", - "location" : [ 80, 19, 80, 20 ], - "operator" : "-", - "operand" : { + "kind" : "MethodCallExpr", + "location" : [ 109, 7, 109, 36 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 109, 7, 109, 17 ], + "object" : { "kind" : "Identifier", - "location" : [ 80, 20, 80, 20 ], - "name" : "a" + "location" : [ 109, 7, 109, 13 ], + "name" : "a_class" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 109, 15, 109, 17 ], + "name" : "add" } }, - "operator" : "+", - "right" : { - "kind" : "BinaryExpr", - "location" : [ 80, 24, 80, 34 ], - "left" : { + "args" : [ { + "kind" : "MemberExpr", + "location" : [ 109, 19, 109, 35 ], + "object" : { "kind" : "Identifier", - "location" : [ 80, 24, 80, 24 ], - "name" : "b" + "location" : [ 109, 19, 109, 25 ], + "name" : "c_class" }, - "operator" : "*", - "right" : { - "kind" : "BinaryExpr", - "location" : [ 80, 29, 80, 33 ], - "left" : { - "kind" : "Identifier", - "location" : [ 80, 29, 80, 29 ], - "name" : "c" - }, - "operator" : "+", - "right" : { - "kind" : "Identifier", - "location" : [ 80, 33, 80, 33 ], - "name" : "d" - } + "member" : { + "kind" : "Identifier", + "location" : [ 109, 27, 109, 35 ], + "name" : "b_class_i" } - } - } - }, { - "kind" : "AssignStmt", - "location" : [ 82, 1, 82, 12 ], - "targets" : [ { - "kind" : "Identifier", - "location" : [ 82, 1, 82, 5 ], - "name" : "stone" - } ], - "value" : { - "kind" : "StringLiteral", - "location" : [ 82, 7, 82, 12 ], - "value" : "Blue" + } ] } }, { "kind" : "ExprStmt", - "location" : [ 83, 1, 83, 24 ], + "location" : [ 110, 1, 110, 10 ], "expr" : { "kind" : "CallExpr", - "location" : [ 83, 1, 83, 24 ], + "location" : [ 110, 1, 110, 10 ], "function" : { "kind" : "Identifier", - "location" : [ 83, 1, 83, 5 ], + "location" : [ 110, 1, 110, 5 ], "name" : "print" }, "args" : [ { - "kind" : "CallExpr", - "location" : [ 83, 7, 83, 23 ], - "function" : { - "kind" : "Identifier", - "location" : [ 83, 7, 83, 16 ], - "name" : "get_stones" - }, - "args" : [ { - "kind" : "Identifier", - "location" : [ 83, 18, 83, 22 ], - "name" : "stone" - } ] + "kind" : "Identifier", + "location" : [ 110, 7, 110, 9 ], + "name" : "a_i" } ] } } ], diff --git a/src/test/data/pa2/student_contributed/good.py.ast.typed b/src/test/data/pa2/student_contributed/good.py.ast.typed index f6a2fc6..9401bb9 100644 --- a/src/test/data/pa2/student_contributed/good.py.ast.typed +++ b/src/test/data/pa2/student_contributed/good.py.ast.typed @@ -3,7 +3,7 @@ "location" : [ 2, 1, 110, 11 ], "declarations" : [ { "kind" : "ClassDef", - "location" : [ 2, 1, 10, 16 ], + "location" : [ 2, 1, 12, 0 ], "name" : { "kind" : "Identifier", "location" : [ 2, 7, 2, 13 ], @@ -68,7 +68,7 @@ } }, { "kind" : "FuncDef", - "location" : [ 5, 5, 6, 18 ], + "location" : [ 5, 5, 6, 19 ], "name" : { "kind" : "Identifier", "location" : [ 5, 9, 5, 16 ], @@ -131,7 +131,7 @@ } ] }, { "kind" : "FuncDef", - "location" : [ 8, 5, 10, 16 ], + "location" : [ 8, 5, 10, 17 ], "name" : { "kind" : "Identifier", "location" : [ 8, 9, 8, 11 ], @@ -238,7 +238,7 @@ } ] }, { "kind" : "ClassDef", - "location" : [ 12, 1, 13, 21 ], + "location" : [ 12, 1, 13, 22 ], "name" : { "kind" : "Identifier", "location" : [ 12, 7, 12, 13 ], @@ -278,7 +278,7 @@ } ] }, { "kind" : "ClassDef", - "location" : [ 15, 1, 0, 0 ], + "location" : [ 15, 1, 16, 9 ], "name" : { "kind" : "Identifier", "location" : [ 15, 7, 15, 13 ], @@ -688,7 +688,7 @@ } }, { "kind" : "FuncDef", - "location" : [ 41, 1, 0, 0 ], + "location" : [ 41, 1, 46, 9 ], "name" : { "kind" : "Identifier", "location" : [ 41, 5, 41, 7 ], @@ -702,7 +702,7 @@ }, "declarations" : [ { "kind" : "FuncDef", - "location" : [ 42, 5, 44, 18 ], + "location" : [ 42, 5, 45, 13 ], "name" : { "kind" : "Identifier", "location" : [ 42, 9, 42, 13 ], @@ -764,7 +764,7 @@ "statements" : [ ] }, { "kind" : "FuncDef", - "location" : [ 48, 1, 0, 0 ], + "location" : [ 48, 1, 54, 9 ], "name" : { "kind" : "Identifier", "location" : [ 48, 5, 48, 7 ], @@ -804,7 +804,7 @@ } }, { "kind" : "FuncDef", - "location" : [ 50, 5, 52, 20 ], + "location" : [ 50, 5, 53, 13 ], "name" : { "kind" : "Identifier", "location" : [ 50, 9, 50, 13 ], @@ -866,7 +866,7 @@ "statements" : [ ] }, { "kind" : "FuncDef", - "location" : [ 56, 1, 58, 18 ], + "location" : [ 56, 1, 58, 19 ], "name" : { "kind" : "Identifier", "location" : [ 56, 5, 56, 7 ],