From 680cf049f24aad54eb3d2061ea85bc707a8a0b35 Mon Sep 17 00:00:00 2001 From: Thirumalai-Shaktivel Date: Fri, 23 Sep 2022 12:25:49 +0530 Subject: [PATCH 1/5] Parse tuple's in AugAssignment --- src/lpython/parser/parser.yy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lpython/parser/parser.yy b/src/lpython/parser/parser.yy index 99c9f3bd86..41b7dff114 100644 --- a/src/lpython/parser/parser.yy +++ b/src/lpython/parser/parser.yy @@ -442,7 +442,7 @@ assignment_statement ; augassign_statement - : expr augassign_op expr { $$ = AUGASSIGN_01($1, $2, $3, @$); } + : expr augassign_op tuple_list { $$ = AUGASSIGN_01($1, $2, $3, @$); } ; augassign_op From c89c28198327accddadeb4ab4e7ff59b60ef2937 Mon Sep 17 00:00:00 2001 From: Thirumalai-Shaktivel Date: Fri, 23 Sep 2022 13:03:15 +0530 Subject: [PATCH 2/5] Recognize Type_Ignore inside the parentheses of the function call --- src/lpython/parser/parser.yy | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lpython/parser/parser.yy b/src/lpython/parser/parser.yy index 41b7dff114..b6317ad7b1 100644 --- a/src/lpython/parser/parser.yy +++ b/src/lpython/parser/parser.yy @@ -879,6 +879,8 @@ primary function_call : primary "(" call_arguement_list ")" { $$ = CALL_01($1, $3, @$); } + | primary "(" TK_TYPE_IGNORE call_arguement_list ")" { + $$ = CALL_01($1, $4, @$); extract_type_comment(p, @$, $3); } | primary "(" expr comp_for_items ")" { $$ = CALL_02($1, A2LIST(p.m_a, GENERATOR_EXPR($3, $4, @$)), @$); } | function_call "(" call_arguement_list ")" { $$ = CALL_01($1, $3, @$); } From 3c6bc7e9987fc379b1639608070f6abde2b3e07b Mon Sep 17 00:00:00 2001 From: Thirumalai-Shaktivel Date: Fri, 23 Sep 2022 14:10:10 +0530 Subject: [PATCH 3/5] Fix tuple issue in the subscript slice --- src/lpython/parser/parser.yy | 3 ++- src/lpython/parser/semantics.h | 12 +----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/lpython/parser/parser.yy b/src/lpython/parser/parser.yy index b6317ad7b1..d117647499 100644 --- a/src/lpython/parser/parser.yy +++ b/src/lpython/parser/parser.yy @@ -914,7 +914,8 @@ slice_items ; slice_item - : slice_item_list comma_opt { $$ = TUPLE($1, @$); } + : slice_item_list { $$ = TUPLE_01($1, @$); } + | slice_item_list "," { $$ = TUPLE_03($1, @$); } ; subscript diff --git a/src/lpython/parser/semantics.h b/src/lpython/parser/semantics.h index 5311b930f9..f4a3e31c20 100644 --- a/src/lpython/parser/semantics.h +++ b/src/lpython/parser/semantics.h @@ -905,22 +905,12 @@ static inline ast_t* ID_TUPLE_02(Allocator &al, Location &l, Vec elts) { #define COMP_EXPR_1(expr, generators, l) make_GeneratorExp_t(p.m_a, l, \ EXPR(expr), generators.p, generators.n) -expr_t* CHECK_TUPLE(expr_t *x) { - if(is_a(*x) && down_cast(x)->n_elts == 1) { - return down_cast(x)->m_elts[0]; - } else { - return x; - } -} - #define ELLIPSIS(l) make_ConstantEllipsis_t(p.m_a, l, nullptr) #define NONE(l) make_ConstantNone_t(p.m_a, l, nullptr) -#define TUPLE(elts, l) make_Tuple_t(p.m_a, l, \ - EXPRS(elts), elts.size(), expr_contextType::Load) #define SUBSCRIPT_01(value, slice, l) make_Subscript_t(p.m_a, l, \ - EXPR(value), CHECK_TUPLE(EXPR(slice)), expr_contextType::Load) + EXPR(value), EXPR(slice), expr_contextType::Load) static inline ast_t* SLICE(Allocator &al, Location &l, ast_t *lower, ast_t *upper, ast_t *_step) { From c6a6648a53ceddb99b64e4c0c53a1c2a58c7bbbe Mon Sep 17 00:00:00 2001 From: Thirumalai-Shaktivel Date: Fri, 23 Sep 2022 19:21:19 +0530 Subject: [PATCH 4/5] Store None for the default kwonlyargs in function definition --- src/lpython/parser/semantics.h | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/lpython/parser/semantics.h b/src/lpython/parser/semantics.h index f4a3e31c20..bbef42f32d 100644 --- a/src/lpython/parser/semantics.h +++ b/src/lpython/parser/semantics.h @@ -367,10 +367,17 @@ Arg** ARG2LIST(Allocator &al, Arg *x) { if(n_##x > 0) { \ for(size_t i = 0; i < n_##x; i++) { \ _m_##x.push_back(al, m_##x[i]->_arg); \ - if(m_##x[i]->default_value && !kw) { \ - defaults.push_back(al, m_##x[i]->defaults); \ - } else if (m_##x[i]->default_value){ \ - kw_defaults.push_back(al, m_##x[i]->defaults); \ + if(m_##x[i]->default_value) { \ + if (kw == 0) { \ + defaults.push_back(al, m_##x[i]->defaults); \ + } else { \ + kw_defaults.push_back(al, m_##x[i]->defaults); \ + } \ + } else { \ + if (kw == 1) { \ + kw_defaults.push_back(al, \ + (expr_t*)make_ConstantNone_t(al, l, nullptr)); \ + } \ } \ } \ r->arguments.m_##x = _m_##x.p; \ @@ -394,25 +401,25 @@ static inline Args *FUNC_ARGS_01(Allocator &al, Location &l, Fn_Arg *parameters) if(parameters != nullptr) { Arg** m_posonlyargs = parameters->posonlyargs.p; size_t n_posonlyargs = parameters->posonlyargs.n; - FUNC_ARGS_(posonlyargs, false); + FUNC_ARGS_(posonlyargs, 0); } if(parameters != nullptr && parameters->args_val) { Arg** m_args = parameters->args->args.p; size_t n_args = parameters->args->args.n; - FUNC_ARGS_(args, false); + FUNC_ARGS_(args, 0); if(parameters->args->var_kw_val) { Arg** m_vararg = parameters->args->var_kw->vararg.p; size_t n_vararg = parameters->args->var_kw->vararg.n; - FUNC_ARGS_(vararg, false); + FUNC_ARGS_(vararg, 0); Arg** m_kwonlyargs = parameters->args->var_kw->kwonlyargs.p; size_t n_kwonlyargs = parameters->args->var_kw->kwonlyargs.n; - FUNC_ARGS_(kwonlyargs, true); + FUNC_ARGS_(kwonlyargs, 1); Arg** m_kwarg = parameters->args->var_kw->kwarg.p; size_t n_kwarg = parameters->args->var_kw->kwarg.n; - FUNC_ARGS_(kwarg, true); + FUNC_ARGS_(kwarg, 2); } } r->arguments.m_kw_defaults = kw_defaults.p; From 64ef2fa6c8c4b9e58ded8c0bb58b9e30a63aead9 Mon Sep 17 00:00:00 2001 From: Thirumalai-Shaktivel Date: Fri, 23 Sep 2022 19:23:19 +0530 Subject: [PATCH 5/5] Add the tests and update refs. --- tests/parser/statements1.py | 2 ++ tests/parser/type_comment1.py | 3 +++ tests/reference/ast_new-function_def2-52c4587.json | 2 +- tests/reference/ast_new-function_def2-52c4587.stdout | 2 +- tests/reference/ast_new-function_def3-f66064a.json | 2 +- tests/reference/ast_new-function_def3-f66064a.stdout | 2 +- tests/reference/ast_new-lambda2-d84336e.json | 2 +- tests/reference/ast_new-lambda2-d84336e.stdout | 2 +- tests/reference/ast_new-statements1-e081093.json | 4 ++-- tests/reference/ast_new-statements1-e081093.stdout | 2 +- tests/reference/ast_new-type_comment1-710ea6c.json | 4 ++-- tests/reference/ast_new-type_comment1-710ea6c.stdout | 2 +- 12 files changed, 17 insertions(+), 12 deletions(-) diff --git a/tests/parser/statements1.py b/tests/parser/statements1.py index 847ee1edc8..45a16a0fc0 100644 --- a/tests/parser/statements1.py +++ b/tests/parser/statements1.py @@ -23,6 +23,8 @@ obj = obj, x += 1 +x += y, z +x += (y, z), x: i64 y: i32 = 1 diff --git a/tests/parser/type_comment1.py b/tests/parser/type_comment1.py index 42005307d0..458ca47377 100644 --- a/tests/parser/type_comment1.py +++ b/tests/parser/type_comment1.py @@ -32,3 +32,6 @@ def main(): from sympy.simplify import (collect, powsimp, # type: ignore separatevars, simplify) + +await test( # type: ignore +x, y, z) diff --git a/tests/reference/ast_new-function_def2-52c4587.json b/tests/reference/ast_new-function_def2-52c4587.json index 656911b546..6ef3ef9568 100644 --- a/tests/reference/ast_new-function_def2-52c4587.json +++ b/tests/reference/ast_new-function_def2-52c4587.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "ast_new-function_def2-52c4587.stdout", - "stdout_hash": "f94b525c239bede5185c86dbf285f82e9a4ec3708e307c191f6270eb", + "stdout_hash": "487f9f6f7ee1f07bfceae82a4dcff7b35d1861d587cd1f1f5d156912", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/ast_new-function_def2-52c4587.stdout b/tests/reference/ast_new-function_def2-52c4587.stdout index 9044cebd7d..534ca081b7 100644 --- a/tests/reference/ast_new-function_def2-52c4587.stdout +++ b/tests/reference/ast_new-function_def2-52c4587.stdout @@ -1 +1 @@ -(Module [(FunctionDef test_01 ([] [] [] [] [] [] []) [(Pass)] [] () ()) (FunctionDef test_02 ([] [] [(x (Name i32 Load) ())] [] [] [] []) [(Pass)] [] () ()) (FunctionDef test_03 ([] [] [(x () ())] [(y () ()) (z () ())] [] [] []) [(Pass)] [] () ()) (FunctionDef test_04 ([] [] [(x () ())] [(y () ()) (z () ())] [] [(args () ())] []) [(Pass)] [] () ()) (FunctionDef test_05 ([] [] [(x () ())] [] [] [(args () ())] []) [(Pass)] [] () ()) (FunctionDef test_06 ([] [] [] [] [] [(args () ())] []) [(Pass)] [] () ()) (FunctionDef test_07 ([] [(x (Name i32 Load) ()) (y () ())] [] [] [] [] []) [(Pass)] [] () ()) (FunctionDef test_08 ([] [(x () ())] [(y () ())] [] [] [] []) [(Pass)] [] () ()) (FunctionDef test_09 ([] [(x () ())] [(y () ())] [(z () ())] [] [] []) [(Pass)] [] () ()) (FunctionDef test_10 ([] [(x () ())] [(y () ())] [(z () ())] [] [(args (Name i32 Load) ())] []) [(Pass)] [] () ()) (FunctionDef test_11 ([] [(x () ())] [(y () ())] [] [] [(args () ())] []) [(Pass)] [] () ()) (FunctionDef test_12 ([] [(x () ())] [] [] [] [(args () ())] []) [(Pass)] [] () ()) (FunctionDef test_13 ([] [(x (Name i32 Load) ()) (y (Name i32 Load) ())] [] [] [] [] [(ConstantInt 1 ()) (ConstantInt 1 ())]) [(Pass)] [] () ()) (FunctionDef test_14 ([] [(x () ())] [(y () ())] [(z () ())] [] [(args (Name i32 Load) ())] []) [(Pass)] [] (Name i32 Load) ()) (FunctionDef test_15 ([(a () ())] [] [] [] [] [] []) [(Pass)] [] () ()) (FunctionDef test_16 ([(a () ())] [(b () ()) (c () ())] [] [] [] [] []) [(Pass)] [] () ()) (FunctionDef test_17 ([(a () ())] [] [(b () ())] [] [] [] []) [(Pass)] [] () ()) (FunctionDef test_18 ([(a (Name i32 Load) ())] [] [(b (Name i64 Load) ())] [(c (Name i32 Load) ()) (d (Name i32 Load) ())] [] [] []) [(Pass)] [] () ()) (FunctionDef test_19 ([(a () ())] [] [(b () ())] [(c () ())] [] [(d () ())] []) [(Pass)] [] () ()) (FunctionDef test_20 ([(a () ())] [] [] [] [] [(b () ())] []) [(Pass)] [] () ()) (FunctionDef test_21 ([(a () ())] [] [(b () ())] [] [] [(c () ())] []) [(Pass)] [] () ()) (FunctionDef test_22 ([(a () ())] [(b () ()) (c () ())] [(d () ())] [] [] [] []) [(Pass)] [] () ()) (FunctionDef test_23 ([(a () ())] [(b () ()) (c () ())] [] [] [] [(d () ())] []) [(Pass)] [] () ()) (FunctionDef test_24 ([(a () ())] [(b () ()) (c () ())] [(d () ())] [] [] [(e () ())] []) [(Pass)] [] () ()) (FunctionDef test_25 ([(a () ())] [(b () ()) (c () ())] [(d () ())] [(e () ())] [] [(f () ())] []) [(Pass)] [] () ()) (FunctionDef test_26 ([] [] [] [(a () ())] [] [] []) [(Pass)] [] () ()) (FunctionDef test_27 ([] [] [] [(a () ())] [] [(b () ())] []) [(Pass)] [] () ()) (FunctionDef test_28 ([] [(a () ())] [] [(b () ())] [] [] []) [(Pass)] [] () ()) (FunctionDef test_29 ([] [(a () ())] [] [(b () ())] [] [(c () ())] []) [(Pass)] [] () ()) (FunctionDef test_30 ([(a () ())] [] [] [(b () ())] [] [] []) [(Pass)] [] () ()) (FunctionDef test_31 ([(a () ())] [(b () ())] [] [(c () ())] [] [] []) [(Pass)] [] () ()) (FunctionDef test_32 ([(a () ())] [] [] [(c () ())] [] [(d () ())] []) [(Pass)] [] () ()) (FunctionDef test_33 ([(a () ())] [(b () ())] [] [(c () ())] [] [(d () ())] []) [(Pass)] [] () ()) (Expr (Call (Name test Load) [] [])) (Expr (Call (Name test Load) [(Name x Load) (Name y Load)] [])) (Expr (Call (Name test Load) [(Name x Load)] [(y (ConstantInt 1 ())) (z (ConstantStr "123" ()))])) (Expr (Call (Name test Load) [(ConstantInt 100 ())] [(() (Name x Load))])) (Expr (Call (Name test Load) [(Starred (Name x Load) Load)] [(() (Name y Load))])) (Expr (Call (Name test Load) [(Starred (Name x Load) Load) (Name y Load)] [])) (Expr (Call (Name test Load) [(Starred (Name x Load) Load) (Starred (Name y Load) Load)] [])) (Expr (Call (Name test Load) [] [(() (Name x Load)) (() (Name y Load))])) (Expr (Call (Name test Load) [(Starred (Name x Load) Load)] [(y (ConstantInt 1 ())) (z (ConstantInt 2 ())) (() (Name a Load)) (b (ConstantInt 1 ()))])) (Expr (Call (Name test Load) [(Starred (Name x Load) Load)] [(() (Name a Load)) (b (ConstantStr "1" ()))])) (Expr (Call (Name test Load) [(Starred (Name y Load) Load)] [(x (ConstantInt 1 ())) (z (ConstantInt 2 ())) (() (Name a Load)) (b (ConstantStr "1" ()))])) (Expr (Call (Attribute (Name lp Load) test Load) [] [])) (Expr (Call (Attribute (Name lp Load) test Load) [(Name x Load) (Name y Load)] [])) (Expr (Call (Attribute (Name lp Load) test Load) [(Name x Load)] [(y (ConstantInt 1 ())) (z (ConstantStr "123" ()))])) (Expr (Subscript (Call (Name test Load) [] []) (ConstantStr "version" ()) Load)) (Expr (Subscript (Call (Name test Load) [(Name x Load) (Name y Load)] []) (ConstantStr "version" ()) Load)) (Expr (Subscript (Call (Name test Load) [(Name x Load) (Starred (Name y Load) Load)] []) (Slice () (UnaryOp USub (ConstantInt 1 ())) ()) Load)) (Expr (Subscript (Subscript (Call (Name test Load) [] []) (ConstantInt 1 ()) Load) (ConstantInt 1 ()) Load)) (Expr (Call (Subscript (Name x Load) (ConstantStr "numpystr" ()) Load) [] [])) (Expr (Call (Subscript (Name x Load) (ConstantStr "int" ()) Load) [] [])) (Expr (Call (Subscript (Name x Load) (Name func Load) Load) [(Starred (Name args Load) Load)] [(() (Name kwargs Load))])) (Expr (Call (Subscript (Name test Load) (ConstantInt 0 ()) Load) [(Starred (Subscript (Name test Load) (Slice (ConstantInt 1 ()) () ()) Load) Load)] [])) (Expr (Call (BinOp (Name obj Load) Mult (Attribute (Attribute (Name self Load) _arr Load) ndim Load)) [(Starred (Attribute (Attribute (Name self Load) _arr Load) shape Load) Load)] [])) (Expr (Call (Name traverse Load) [(Tuple [(Name index Load) (Name value Load)] Load) (Name visit Load) (Starred (Name args Load) Load)] [(result (Name result Load)) (() (Name kwargs Load))]))] []) +(Module [(FunctionDef test_01 ([] [] [] [] [] [] []) [(Pass)] [] () ()) (FunctionDef test_02 ([] [] [(x (Name i32 Load) ())] [] [] [] []) [(Pass)] [] () ()) (FunctionDef test_03 ([] [] [(x () ())] [(y () ()) (z () ())] [(ConstantNone ()) (ConstantNone ())] [] []) [(Pass)] [] () ()) (FunctionDef test_04 ([] [] [(x () ())] [(y () ()) (z () ())] [(ConstantNone ()) (ConstantNone ())] [(args () ())] []) [(Pass)] [] () ()) (FunctionDef test_05 ([] [] [(x () ())] [] [] [(args () ())] []) [(Pass)] [] () ()) (FunctionDef test_06 ([] [] [] [] [] [(args () ())] []) [(Pass)] [] () ()) (FunctionDef test_07 ([] [(x (Name i32 Load) ()) (y () ())] [] [] [] [] []) [(Pass)] [] () ()) (FunctionDef test_08 ([] [(x () ())] [(y () ())] [] [] [] []) [(Pass)] [] () ()) (FunctionDef test_09 ([] [(x () ())] [(y () ())] [(z () ())] [(ConstantNone ())] [] []) [(Pass)] [] () ()) (FunctionDef test_10 ([] [(x () ())] [(y () ())] [(z () ())] [(ConstantNone ())] [(args (Name i32 Load) ())] []) [(Pass)] [] () ()) (FunctionDef test_11 ([] [(x () ())] [(y () ())] [] [] [(args () ())] []) [(Pass)] [] () ()) (FunctionDef test_12 ([] [(x () ())] [] [] [] [(args () ())] []) [(Pass)] [] () ()) (FunctionDef test_13 ([] [(x (Name i32 Load) ()) (y (Name i32 Load) ())] [] [] [] [] [(ConstantInt 1 ()) (ConstantInt 1 ())]) [(Pass)] [] () ()) (FunctionDef test_14 ([] [(x () ())] [(y () ())] [(z () ())] [(ConstantNone ())] [(args (Name i32 Load) ())] []) [(Pass)] [] (Name i32 Load) ()) (FunctionDef test_15 ([(a () ())] [] [] [] [] [] []) [(Pass)] [] () ()) (FunctionDef test_16 ([(a () ())] [(b () ()) (c () ())] [] [] [] [] []) [(Pass)] [] () ()) (FunctionDef test_17 ([(a () ())] [] [(b () ())] [] [] [] []) [(Pass)] [] () ()) (FunctionDef test_18 ([(a (Name i32 Load) ())] [] [(b (Name i64 Load) ())] [(c (Name i32 Load) ()) (d (Name i32 Load) ())] [(ConstantNone ()) (ConstantNone ())] [] []) [(Pass)] [] () ()) (FunctionDef test_19 ([(a () ())] [] [(b () ())] [(c () ())] [(ConstantNone ())] [(d () ())] []) [(Pass)] [] () ()) (FunctionDef test_20 ([(a () ())] [] [] [] [] [(b () ())] []) [(Pass)] [] () ()) (FunctionDef test_21 ([(a () ())] [] [(b () ())] [] [] [(c () ())] []) [(Pass)] [] () ()) (FunctionDef test_22 ([(a () ())] [(b () ()) (c () ())] [(d () ())] [] [] [] []) [(Pass)] [] () ()) (FunctionDef test_23 ([(a () ())] [(b () ()) (c () ())] [] [] [] [(d () ())] []) [(Pass)] [] () ()) (FunctionDef test_24 ([(a () ())] [(b () ()) (c () ())] [(d () ())] [] [] [(e () ())] []) [(Pass)] [] () ()) (FunctionDef test_25 ([(a () ())] [(b () ()) (c () ())] [(d () ())] [(e () ())] [(ConstantNone ())] [(f () ())] []) [(Pass)] [] () ()) (FunctionDef test_26 ([] [] [] [(a () ())] [(ConstantNone ())] [] []) [(Pass)] [] () ()) (FunctionDef test_27 ([] [] [] [(a () ())] [(ConstantNone ())] [(b () ())] []) [(Pass)] [] () ()) (FunctionDef test_28 ([] [(a () ())] [] [(b () ())] [(ConstantNone ())] [] []) [(Pass)] [] () ()) (FunctionDef test_29 ([] [(a () ())] [] [(b () ())] [(ConstantNone ())] [(c () ())] []) [(Pass)] [] () ()) (FunctionDef test_30 ([(a () ())] [] [] [(b () ())] [(ConstantNone ())] [] []) [(Pass)] [] () ()) (FunctionDef test_31 ([(a () ())] [(b () ())] [] [(c () ())] [(ConstantNone ())] [] []) [(Pass)] [] () ()) (FunctionDef test_32 ([(a () ())] [] [] [(c () ())] [(ConstantNone ())] [(d () ())] []) [(Pass)] [] () ()) (FunctionDef test_33 ([(a () ())] [(b () ())] [] [(c () ())] [(ConstantNone ())] [(d () ())] []) [(Pass)] [] () ()) (Expr (Call (Name test Load) [] [])) (Expr (Call (Name test Load) [(Name x Load) (Name y Load)] [])) (Expr (Call (Name test Load) [(Name x Load)] [(y (ConstantInt 1 ())) (z (ConstantStr "123" ()))])) (Expr (Call (Name test Load) [(ConstantInt 100 ())] [(() (Name x Load))])) (Expr (Call (Name test Load) [(Starred (Name x Load) Load)] [(() (Name y Load))])) (Expr (Call (Name test Load) [(Starred (Name x Load) Load) (Name y Load)] [])) (Expr (Call (Name test Load) [(Starred (Name x Load) Load) (Starred (Name y Load) Load)] [])) (Expr (Call (Name test Load) [] [(() (Name x Load)) (() (Name y Load))])) (Expr (Call (Name test Load) [(Starred (Name x Load) Load)] [(y (ConstantInt 1 ())) (z (ConstantInt 2 ())) (() (Name a Load)) (b (ConstantInt 1 ()))])) (Expr (Call (Name test Load) [(Starred (Name x Load) Load)] [(() (Name a Load)) (b (ConstantStr "1" ()))])) (Expr (Call (Name test Load) [(Starred (Name y Load) Load)] [(x (ConstantInt 1 ())) (z (ConstantInt 2 ())) (() (Name a Load)) (b (ConstantStr "1" ()))])) (Expr (Call (Attribute (Name lp Load) test Load) [] [])) (Expr (Call (Attribute (Name lp Load) test Load) [(Name x Load) (Name y Load)] [])) (Expr (Call (Attribute (Name lp Load) test Load) [(Name x Load)] [(y (ConstantInt 1 ())) (z (ConstantStr "123" ()))])) (Expr (Subscript (Call (Name test Load) [] []) (ConstantStr "version" ()) Load)) (Expr (Subscript (Call (Name test Load) [(Name x Load) (Name y Load)] []) (ConstantStr "version" ()) Load)) (Expr (Subscript (Call (Name test Load) [(Name x Load) (Starred (Name y Load) Load)] []) (Slice () (UnaryOp USub (ConstantInt 1 ())) ()) Load)) (Expr (Subscript (Subscript (Call (Name test Load) [] []) (ConstantInt 1 ()) Load) (ConstantInt 1 ()) Load)) (Expr (Call (Subscript (Name x Load) (ConstantStr "numpystr" ()) Load) [] [])) (Expr (Call (Subscript (Name x Load) (ConstantStr "int" ()) Load) [] [])) (Expr (Call (Subscript (Name x Load) (Name func Load) Load) [(Starred (Name args Load) Load)] [(() (Name kwargs Load))])) (Expr (Call (Subscript (Name test Load) (ConstantInt 0 ()) Load) [(Starred (Subscript (Name test Load) (Slice (ConstantInt 1 ()) () ()) Load) Load)] [])) (Expr (Call (BinOp (Name obj Load) Mult (Attribute (Attribute (Name self Load) _arr Load) ndim Load)) [(Starred (Attribute (Attribute (Name self Load) _arr Load) shape Load) Load)] [])) (Expr (Call (Name traverse Load) [(Tuple [(Name index Load) (Name value Load)] Load) (Name visit Load) (Starred (Name args Load) Load)] [(result (Name result Load)) (() (Name kwargs Load))]))] []) diff --git a/tests/reference/ast_new-function_def3-f66064a.json b/tests/reference/ast_new-function_def3-f66064a.json index 3e14fe33d6..f97b9b0722 100644 --- a/tests/reference/ast_new-function_def3-f66064a.json +++ b/tests/reference/ast_new-function_def3-f66064a.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "ast_new-function_def3-f66064a.stdout", - "stdout_hash": "6eadb50ca8a83c6fb88e758234d91cceab17ee0177d97fc2bc04d503", + "stdout_hash": "926e7c2dba8ad4f0536cb81c654f3ace4d4edce1b719da3dccc35f51", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/ast_new-function_def3-f66064a.stdout b/tests/reference/ast_new-function_def3-f66064a.stdout index 1083b29869..9077050528 100644 --- a/tests/reference/ast_new-function_def3-f66064a.stdout +++ b/tests/reference/ast_new-function_def3-f66064a.stdout @@ -1 +1 @@ -(Module [(FunctionDef main0 ([] [(i () ())] [] [] [] [] []) [(Pass)] [] () ()) (FunctionDef example ([] [(text () ()) (width () ()) (fill_char () ())] [] [] [] [] [(ConstantInt 80 ()) (ConstantStr "-" ())]) [(Return ())] [] () "(...) -> str") (Expr (Call (Name example Load) [(Name text Load)] [(width (ConstantInt 80 ())) (fill_char (ConstantStr "-" ()))])) (FunctionDef test_1 ([] [(x () ())] [] [] [] [] []) [(Pass)] [] () ()) (FunctionDef test_2 ([] [(y () ())] [] [] [] [] []) [(Pass)] [] () ()) (FunctionDef func ([] [(a () "str") (b () "int") (c (Name str Load) "str")] [] [] [] [] [(ConstantInt 80 ()) (ConstantStr "-" ())]) [(Pass)] [] () ()) (FunctionDef abc ([] [(a () ()) (b () "int") (c () "list[str]")] [] [] [] [] [(List [(ConstantStr "-" ())] Load)]) [(Return ())] [] () "(...) -> str") (FunctionDef test_01 ([] [(a () "int") (b () ())] [] [] [] [] [(ConstantInt 0 ())]) [(Pass)] [] () ()) (FunctionDef test_02 ([] [(a () "int") (b () ())] [] [] [] [] []) [(Pass)] [] () ()) (FunctionDef quantiles ([(dist () ())] [] [] [(n () ())] [] [] []) [(Expr (ConstantEllipsis ()))] [] () ()) (FunctionDef quantiles ([(dist () ())] [] [] [(n () ()) (method () ())] [(ConstantInt 4 ()) (ConstantStr "exclusive" ())] [] []) [(Expr (ConstantEllipsis ()))] [] () ()) (FunctionDef func ([(self () ()) (param1 () ()) (param2 () ())] [(param3 () ())] [] [(param4 () ()) (param5 () ())] [] [] []) [(Expr (ConstantEllipsis ()))] [] () ()) (FunctionDef func ([(self () ()) (param1 () ()) (param2 () ())] [(param3 () ())] [] [(param4 () ()) (param5 () ())] [] [] [(ConstantInt 7 ())]) [(Expr (ConstantEllipsis ()))] [] () ()) (FunctionDef func ([(self () ()) (param1 () ()) (param2 () ())] [(param3 () ()) (param3_1 () ())] [] [(param4 () ()) (param5 () ())] [] [] [(ConstantInt 2 ())]) [(Expr (ConstantEllipsis ()))] [] () ()) (FunctionDef add ([] [(a () ()) (b () ())] [] [(c () ()) (d () ())] [] [] []) [(Expr (ConstantEllipsis ()))] [] () ()) (FunctionDef func ([] [] [] [(param4 () ()) (param5 () ())] [] [] []) [(Expr (ConstantEllipsis ()))] [] () ()) (FunctionDef func ([] [] [] [(param4 () ()) (param5 () ())] [] [] []) [(Expr (ConstantEllipsis ()))] [] () ()) (AsyncFunctionDef main ([] [] [] [] [] [] []) [(Assign [(Name a Store)] (Name b Load) ()) (Return (Tuple [(Name a Load)] Load))] [] () ()) (FunctionDef dtype ([] [(self () ())] [] [] [] [] []) [(Expr (ConstantEllipsis ()))] [] (Name _DType_co Load) ())] [(TypeIgnore 0 "[misc]") (TypeIgnore 0 "")]) +(Module [(FunctionDef main0 ([] [(i () ())] [] [] [] [] []) [(Pass)] [] () ()) (FunctionDef example ([] [(text () ()) (width () ()) (fill_char () ())] [] [] [] [] [(ConstantInt 80 ()) (ConstantStr "-" ())]) [(Return ())] [] () "(...) -> str") (Expr (Call (Name example Load) [(Name text Load)] [(width (ConstantInt 80 ())) (fill_char (ConstantStr "-" ()))])) (FunctionDef test_1 ([] [(x () ())] [] [] [] [] []) [(Pass)] [] () ()) (FunctionDef test_2 ([] [(y () ())] [] [] [] [] []) [(Pass)] [] () ()) (FunctionDef func ([] [(a () "str") (b () "int") (c (Name str Load) "str")] [] [] [] [] [(ConstantInt 80 ()) (ConstantStr "-" ())]) [(Pass)] [] () ()) (FunctionDef abc ([] [(a () ()) (b () "int") (c () "list[str]")] [] [] [] [] [(List [(ConstantStr "-" ())] Load)]) [(Return ())] [] () "(...) -> str") (FunctionDef test_01 ([] [(a () "int") (b () ())] [] [] [] [] [(ConstantInt 0 ())]) [(Pass)] [] () ()) (FunctionDef test_02 ([] [(a () "int") (b () ())] [] [] [] [] []) [(Pass)] [] () ()) (FunctionDef quantiles ([(dist () ())] [] [] [(n () ())] [(ConstantNone ())] [] []) [(Expr (ConstantEllipsis ()))] [] () ()) (FunctionDef quantiles ([(dist () ())] [] [] [(n () ()) (method () ())] [(ConstantInt 4 ()) (ConstantStr "exclusive" ())] [] []) [(Expr (ConstantEllipsis ()))] [] () ()) (FunctionDef func ([(self () ()) (param1 () ()) (param2 () ())] [(param3 () ())] [] [(param4 () ()) (param5 () ())] [(ConstantNone ()) (ConstantNone ())] [] []) [(Expr (ConstantEllipsis ()))] [] () ()) (FunctionDef func ([(self () ()) (param1 () ()) (param2 () ())] [(param3 () ())] [] [(param4 () ()) (param5 () ())] [(ConstantNone ()) (ConstantNone ())] [] [(ConstantInt 7 ())]) [(Expr (ConstantEllipsis ()))] [] () ()) (FunctionDef func ([(self () ()) (param1 () ()) (param2 () ())] [(param3 () ()) (param3_1 () ())] [] [(param4 () ()) (param5 () ())] [(ConstantNone ()) (ConstantNone ())] [] [(ConstantInt 2 ())]) [(Expr (ConstantEllipsis ()))] [] () ()) (FunctionDef add ([] [(a () ()) (b () ())] [] [(c () ()) (d () ())] [(ConstantNone ()) (ConstantNone ())] [] []) [(Expr (ConstantEllipsis ()))] [] () ()) (FunctionDef func ([] [] [] [(param4 () ()) (param5 () ())] [(ConstantNone ()) (ConstantNone ())] [] []) [(Expr (ConstantEllipsis ()))] [] () ()) (FunctionDef func ([] [] [] [(param4 () ()) (param5 () ())] [(ConstantNone ()) (ConstantNone ())] [] []) [(Expr (ConstantEllipsis ()))] [] () ()) (AsyncFunctionDef main ([] [] [] [] [] [] []) [(Assign [(Name a Store)] (Name b Load) ()) (Return (Tuple [(Name a Load)] Load))] [] () ()) (FunctionDef dtype ([] [(self () ())] [] [] [] [] []) [(Expr (ConstantEllipsis ()))] [] (Name _DType_co Load) ())] [(TypeIgnore 0 "[misc]") (TypeIgnore 0 "")]) diff --git a/tests/reference/ast_new-lambda2-d84336e.json b/tests/reference/ast_new-lambda2-d84336e.json index dca54aa236..d1d12837a8 100644 --- a/tests/reference/ast_new-lambda2-d84336e.json +++ b/tests/reference/ast_new-lambda2-d84336e.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "ast_new-lambda2-d84336e.stdout", - "stdout_hash": "9afafe60d361be9afe05313a10c45df76c014765750ab67cb0d1afef", + "stdout_hash": "6a7f8d092211440e7307db947c4ec0869e27c0a3b28de94d4681294e", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/ast_new-lambda2-d84336e.stdout b/tests/reference/ast_new-lambda2-d84336e.stdout index 307fccf562..86922de21c 100644 --- a/tests/reference/ast_new-lambda2-d84336e.stdout +++ b/tests/reference/ast_new-lambda2-d84336e.stdout @@ -1 +1 @@ -(Module [(Expr (Call (Name verify_matching_signatures Load) [(Lambda ([] [(x () ())] [] [] [] [] [(ConstantInt 0 ())]) (ConstantInt 0 ())) (Lambda ([] [(x () ())] [] [] [] [] [(ConstantInt 0 ())]) (ConstantInt 0 ()))] [])) (Assign [(Name input_func Store)] (Lambda ([] [(prompt () ())] [] [] [] [] [(ConstantStr "" ())]) (Call (Name next Load) [(Name gen Load)] [])) ()) (Assign [(Subscript (Name cast Load) (Name key Load) Store)] (Lambda ([] [(x () ()) (k () ())] [] [] [] [] [(Name key Load)]) (Call (Attribute (Call (Name array Load) [(Name x Load)] [(copy (ConstantBool .false. ()))]) astype Load) [(Name k Load)] [])) ()) (Assign [(Name x Store)] (Lambda ([] [(func () ()) (attr () ())] [] [] [] [] [(Attribute (Name self Load) _try_call Load) (Name attr Load)]) (Call (Name func Load) [(Name attr Load)] [])) ()) (Assign [(Name fpos32 Store)] (Lambda ([] [(x () ())] [] [] [] [(k () ())] []) (Call (Attribute (Name np Load) format_float_positional Load) [(Call (Attribute (Name np Load) float32 Load) [(Name x Load)] [])] [(() (Name k Load))])) ()) (Assign [(Name m Store)] (Lambda ([] [(self () ())] [(args () ())] [] [] [(kw () ())] []) (Call (Name func Load) [(Name self Load) (Starred (Name args Load) Load)] [(() (Name kw Load))])) ()) (Expr (Call (Attribute (Name stack Load) push Load) [(Lambda ([] [] [(exc () ())] [] [] [] []) (Subscript (Dict [] []) (ConstantInt 1 ()) Load))] [])) (Expr (Lambda ([] [] [(x () ())] [(y () ()) (z () ())] [] [] []) (Name test Load))) (Expr (Lambda ([] [] [(x () ())] [(y () ()) (z () ())] [] [(args () ())] []) (Name test Load))) (Expr (Lambda ([] [] [(x () ())] [] [] [(args () ())] []) (Name test Load))) (Expr (Lambda ([] [] [] [] [] [(args () ())] []) (Name test Load))) (Expr (Lambda ([] [(x () ()) (y () ())] [] [] [] [] []) (Name test Load))) (Expr (Lambda ([] [(x () ())] [(y () ())] [] [] [] []) (Name test Load))) (Expr (Lambda ([] [(x () ())] [(y () ())] [(z () ())] [] [] []) (Name test Load))) (Expr (Lambda ([] [(x () ())] [(y () ())] [(z () ())] [] [(args () ())] []) (Name test Load))) (Expr (Lambda ([] [(x () ())] [(y () ())] [] [] [(args () ())] []) (Name test Load))) (Expr (Lambda ([] [(x () ())] [] [] [] [(args () ())] []) (Name test Load))) (Expr (Lambda ([] [(x () ())] [(y () ())] [(z () ())] [] [(args () ())] []) (Name test Load))) (Expr (Lambda ([(a () ())] [(b () ()) (c () ())] [] [] [] [] []) (Name test Load))) (Expr (Lambda ([(a () ())] [] [(b () ())] [] [] [] []) (Name test Load))) (Expr (Lambda ([(a () ())] [] [(b () ())] [(c () ()) (d () ())] [] [] []) (Name test Load))) (Expr (Lambda ([(a () ())] [] [(b () ())] [(c () ())] [] [(d () ())] []) (Name test Load))) (Expr (Lambda ([(a () ())] [] [] [] [] [(b () ())] []) (Name test Load))) (Expr (Lambda ([(a () ())] [] [(b () ())] [] [] [(c () ())] []) (Name test Load))) (Expr (Lambda ([(a () ())] [(b () ()) (c () ())] [(d () ())] [] [] [] []) (Name test Load))) (Expr (Lambda ([(a () ())] [(b () ()) (c () ())] [] [] [] [(d () ())] []) (Name test Load))) (Expr (Lambda ([(a () ())] [(b () ()) (c () ())] [(d () ())] [] [] [(e () ())] []) (Name test Load))) (Expr (Lambda ([(a () ())] [(b () ()) (c () ())] [(d () ())] [(e () ())] [] [(f () ())] []) (Name test Load))) (Expr (Lambda ([] [] [] [(a () ())] [] [] []) (Name test Load))) (Expr (Lambda ([] [] [] [(a () ())] [] [(b () ())] []) (Name test Load))) (Expr (Lambda ([] [(a () ())] [] [(b () ())] [] [] []) (Name test Load))) (Expr (Lambda ([] [(a () ())] [] [(b () ())] [] [(c () ())] []) (Name test Load))) (Expr (Lambda ([(a () ())] [] [] [(b () ())] [] [] []) (Name test Load))) (Expr (Lambda ([(a () ())] [(b () ())] [] [(c () ())] [] [] []) (Name test Load))) (Expr (Lambda ([(a () ())] [] [] [(c () ())] [] [(d () ())] []) (Name test Load))) (Expr (Lambda ([(a () ())] [(b () ())] [] [(c () ())] [] [(d () ())] []) (Name test Load)))] []) +(Module [(Expr (Call (Name verify_matching_signatures Load) [(Lambda ([] [(x () ())] [] [] [] [] [(ConstantInt 0 ())]) (ConstantInt 0 ())) (Lambda ([] [(x () ())] [] [] [] [] [(ConstantInt 0 ())]) (ConstantInt 0 ()))] [])) (Assign [(Name input_func Store)] (Lambda ([] [(prompt () ())] [] [] [] [] [(ConstantStr "" ())]) (Call (Name next Load) [(Name gen Load)] [])) ()) (Assign [(Subscript (Name cast Load) (Name key Load) Store)] (Lambda ([] [(x () ()) (k () ())] [] [] [] [] [(Name key Load)]) (Call (Attribute (Call (Name array Load) [(Name x Load)] [(copy (ConstantBool .false. ()))]) astype Load) [(Name k Load)] [])) ()) (Assign [(Name x Store)] (Lambda ([] [(func () ()) (attr () ())] [] [] [] [] [(Attribute (Name self Load) _try_call Load) (Name attr Load)]) (Call (Name func Load) [(Name attr Load)] [])) ()) (Assign [(Name fpos32 Store)] (Lambda ([] [(x () ())] [] [] [] [(k () ())] []) (Call (Attribute (Name np Load) format_float_positional Load) [(Call (Attribute (Name np Load) float32 Load) [(Name x Load)] [])] [(() (Name k Load))])) ()) (Assign [(Name m Store)] (Lambda ([] [(self () ())] [(args () ())] [] [] [(kw () ())] []) (Call (Name func Load) [(Name self Load) (Starred (Name args Load) Load)] [(() (Name kw Load))])) ()) (Expr (Call (Attribute (Name stack Load) push Load) [(Lambda ([] [] [(exc () ())] [] [] [] []) (Subscript (Dict [] []) (ConstantInt 1 ()) Load))] [])) (Expr (Lambda ([] [] [(x () ())] [(y () ()) (z () ())] [(ConstantNone ()) (ConstantNone ())] [] []) (Name test Load))) (Expr (Lambda ([] [] [(x () ())] [(y () ()) (z () ())] [(ConstantNone ()) (ConstantNone ())] [(args () ())] []) (Name test Load))) (Expr (Lambda ([] [] [(x () ())] [] [] [(args () ())] []) (Name test Load))) (Expr (Lambda ([] [] [] [] [] [(args () ())] []) (Name test Load))) (Expr (Lambda ([] [(x () ()) (y () ())] [] [] [] [] []) (Name test Load))) (Expr (Lambda ([] [(x () ())] [(y () ())] [] [] [] []) (Name test Load))) (Expr (Lambda ([] [(x () ())] [(y () ())] [(z () ())] [(ConstantNone ())] [] []) (Name test Load))) (Expr (Lambda ([] [(x () ())] [(y () ())] [(z () ())] [(ConstantNone ())] [(args () ())] []) (Name test Load))) (Expr (Lambda ([] [(x () ())] [(y () ())] [] [] [(args () ())] []) (Name test Load))) (Expr (Lambda ([] [(x () ())] [] [] [] [(args () ())] []) (Name test Load))) (Expr (Lambda ([] [(x () ())] [(y () ())] [(z () ())] [(ConstantNone ())] [(args () ())] []) (Name test Load))) (Expr (Lambda ([(a () ())] [(b () ()) (c () ())] [] [] [] [] []) (Name test Load))) (Expr (Lambda ([(a () ())] [] [(b () ())] [] [] [] []) (Name test Load))) (Expr (Lambda ([(a () ())] [] [(b () ())] [(c () ()) (d () ())] [(ConstantNone ()) (ConstantNone ())] [] []) (Name test Load))) (Expr (Lambda ([(a () ())] [] [(b () ())] [(c () ())] [(ConstantNone ())] [(d () ())] []) (Name test Load))) (Expr (Lambda ([(a () ())] [] [] [] [] [(b () ())] []) (Name test Load))) (Expr (Lambda ([(a () ())] [] [(b () ())] [] [] [(c () ())] []) (Name test Load))) (Expr (Lambda ([(a () ())] [(b () ()) (c () ())] [(d () ())] [] [] [] []) (Name test Load))) (Expr (Lambda ([(a () ())] [(b () ()) (c () ())] [] [] [] [(d () ())] []) (Name test Load))) (Expr (Lambda ([(a () ())] [(b () ()) (c () ())] [(d () ())] [] [] [(e () ())] []) (Name test Load))) (Expr (Lambda ([(a () ())] [(b () ()) (c () ())] [(d () ())] [(e () ())] [(ConstantNone ())] [(f () ())] []) (Name test Load))) (Expr (Lambda ([] [] [] [(a () ())] [(ConstantNone ())] [] []) (Name test Load))) (Expr (Lambda ([] [] [] [(a () ())] [(ConstantNone ())] [(b () ())] []) (Name test Load))) (Expr (Lambda ([] [(a () ())] [] [(b () ())] [(ConstantNone ())] [] []) (Name test Load))) (Expr (Lambda ([] [(a () ())] [] [(b () ())] [(ConstantNone ())] [(c () ())] []) (Name test Load))) (Expr (Lambda ([(a () ())] [] [] [(b () ())] [(ConstantNone ())] [] []) (Name test Load))) (Expr (Lambda ([(a () ())] [(b () ())] [] [(c () ())] [(ConstantNone ())] [] []) (Name test Load))) (Expr (Lambda ([(a () ())] [] [] [(c () ())] [(ConstantNone ())] [(d () ())] []) (Name test Load))) (Expr (Lambda ([(a () ())] [(b () ())] [] [(c () ())] [(ConstantNone ())] [(d () ())] []) (Name test Load)))] []) diff --git a/tests/reference/ast_new-statements1-e081093.json b/tests/reference/ast_new-statements1-e081093.json index d1a38d331b..820eabc63f 100644 --- a/tests/reference/ast_new-statements1-e081093.json +++ b/tests/reference/ast_new-statements1-e081093.json @@ -2,11 +2,11 @@ "basename": "ast_new-statements1-e081093", "cmd": "lpython --show-ast --new-parser --no-color {infile} -o {outfile}", "infile": "tests/parser/statements1.py", - "infile_hash": "795f2671c2e282f01d1715deac8bdb342dbef6df5962ded5a3a045d1", + "infile_hash": "98dd16a7e41cfca5cce2fd716fa5888ad5b970cd368e6171f1e66306", "outfile": null, "outfile_hash": null, "stdout": "ast_new-statements1-e081093.stdout", - "stdout_hash": "8c0a1dd6e96f4b8ec7a5fd2996b0474d5d2e2f947b02e74658656067", + "stdout_hash": "ca1326a095da9613e6d61bf7c2f028d651f1dbf31b1878c266af9bf9", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/ast_new-statements1-e081093.stdout b/tests/reference/ast_new-statements1-e081093.stdout index 3ddcf6e777..dbe8943f15 100644 --- a/tests/reference/ast_new-statements1-e081093.stdout +++ b/tests/reference/ast_new-statements1-e081093.stdout @@ -1 +1 @@ -(Module [(Pass) (Break) (Continue) (Raise () ()) (Raise (Call (Name NameError Load) [(ConstantStr "String" ())] []) ()) (Raise (Name RuntimeError Load) (Name exc Load)) (Assert (Compare (Call (Name len Load) [(Name marks Load)] []) NotEq [(ConstantInt 0 ())]) (ConstantStr "List is empty." ())) (Assert (Compare (Name x Load) Eq [(ConstantStr "String" ())]) ()) (Assign [(Name x Store)] (ConstantInt 1 ()) ()) (Assign [(Tuple [(Name x Store) (Name y Store)] Store)] (Call (Name x Load) [] []) ()) (Assign [(Name x Store) (Name y Store)] (ConstantInt 1 ()) ()) (Assign [(Tuple [(Name x Store) (Name y Store)] Store)] (Tuple [(ConstantInt 1 ()) (ConstantInt 2 ())] Load) ()) (Assign [(Subscript (Name x Load) (Name i Load) Store)] (Tuple [(ConstantInt 1 ()) (ConstantInt 2 ())] Load) ()) (Assign [(Tuple [(Name x Store) (Name y Store) (Name z Store)] Store)] (Name t Load) ()) (Assign [(Tuple [(Name x Store) (Name y Store) (Name z Store)] Store)] (Name t Load) ()) (Assign [(Tuple [(Name x Store)] Store)] (Name t Load) ()) (Assign [(Tuple [(Name x Store)] Store)] (Name t Load) ()) (Assign [(Name obj Store)] (Tuple [(Name obj Load)] Load) ()) (AugAssign (Name x Store) Add (ConstantInt 1 ())) (AnnAssign (Name x Store) (Name i64 Load) () 1) (AnnAssign (Name y Store) (Name i32 Load) (ConstantInt 1 ()) 1) (Delete [(Name x Del)]) (Delete [(Tuple [] Del)]) (Delete [(Tuple [(Name x Del) (Name y Del)] Del)]) (Delete [(Tuple [(Name x Del) (Name y Del)] Del)]) (Delete [(Name x Del) (Name y Del)]) (Delete [(Name x Del) (Name y Del)]) (Return ()) (Return (BinOp (Name a Load) Add (Name b Load))) (Return (Call (Name x Load) [(Name a Load)] [])) (Return (Tuple [] Load)) (Return (Tuple [(Name x Load) (Name y Load)] Load)) (Return (Tuple [(Name x Load) (Name y Load)] Load)) (Return (Tuple [(Name x Load) (Name y Load)] Load)) (Return (Tuple [(Name x Load) (Name y Load)] Load)) (Global [a]) (Global [a b]) (Nonlocal [a]) (Nonlocal [a b]) (Expr (ConstantInt 123 ())) (Expr (UnaryOp USub (ConstantInt 123 ()))) (Expr (UnaryOp USub (ConstantInt 291 ()))) (Expr (ConstantInt 6844 ())) (Expr (UnaryOp USub (ConstantInt 83 ()))) (Expr (ConstantInt 87 ())) (Expr (UnaryOp USub (ConstantInt 13 ()))) (Expr (ConstantInt 13 ())) (Expr (ConstantInt 32768 ())) (Expr (ConstantInt 12 ())) (Expr (ConstantInt 23440334322333 ())) (Expr (ConstantFloat 123.000000 ())) (Expr (ConstantFloat 123.450000 ())) (Expr (ConstantFloat 123400000000.000000 ())) (Expr (BinOp (ConstantInt 12 ()) Add (ConstantComplex 0.000000 3.000000 ()))) (Expr (BinOp (ConstantFloat 0.120000 ()) Add (ConstantComplex 0.000000 0.001000 ()))) (Expr (ConstantStr "String" ())) (Expr (ConstantStr "String String" ())) (Expr (ConstantStr "String String" ())) (Expr (ConstantStr "String String" ())) (Expr (Subscript (ConstantStr "String String" ()) (Slice (ConstantInt 1 ()) () ()) Load)) (Assign [(Name x Store)] (ConstantStr "String String" ()) ()) (Assign [(Name x Store)] (BinOp (ConstantStr "String " ()) Add (ConstantStr "String" ())) ()) (Assign [(Name x Store)] (ConstantStr "String String" ()) ()) (Assign [(Name x Store)] (ConstantStr "String String" ()) ()) (Assign [(Name x Store)] (ConstantStr "String " ()) ()) (Expr (ConstantStr "String" ())) (Expr (ConstantBool .true. ())) (Expr (ConstantBool .false. ())) (Expr (BinOp (BinOp (Name x Load) Add (Name y Load)) Mult (Name z Load))) (Expr (BinOp (Name x Load) Sub (Name y Load))) (Expr (BinOp (Name x Load) Mult (Name y Load))) (Expr (BinOp (Name x Load) Div (Name y Load))) (Expr (BinOp (Name x Load) Mod (Name y Load))) (Expr (UnaryOp USub (Name y Load))) (Expr (UnaryOp UAdd (Name y Load))) (Expr (UnaryOp Invert (Name y Load))) (Expr (BinOp (Name x Load) Pow (Name y Load))) (Expr (BinOp (Name x Load) FloorDiv (Name y Load))) (Expr (BinOp (Name x Load) MatMult (Name y Load))) (Expr (BinOp (Name x Load) BitAnd (Name y Load))) (Expr (BinOp (Name x Load) BitOr (Name y Load))) (Expr (BinOp (Name x Load) BitXor (Name y Load))) (Expr (BinOp (Name x Load) LShift (Name y Load))) (Expr (BinOp (Name x Load) RShift (Name y Load))) (Expr (Compare (Name x Load) Eq [(Name y Load)])) (Expr (Compare (Name x Load) NotEq [(Name y Load)])) (Expr (Compare (Name x Load) Lt [(Name y Load)])) (Expr (Compare (Name x Load) LtE [(Name y Load)])) (Expr (Compare (Name x Load) Gt [(Name y Load)])) (Expr (Compare (Name x Load) GtE [(Name y Load)])) (Expr (Compare (ConstantStr "hello" ()) In [(Name x Load)])) (Expr (Compare (ConstantStr "a" ()) In [(Call (Attribute (Name a Load) func Load) [] [])])) (Expr (Compare (ConstantStr "lo" ()) In [(ConstantStr "hello" ())])) (Expr (Subscript (Attribute (Name a Load) b Load) (ConstantInt 1 ()) Load)) (Expr (Subscript (Attribute (Name a Load) b Load) (ConstantInt 1 ()) Load)) (Expr (Subscript (Attribute (Name a Load) b Load) (Slice (ConstantInt 1 ()) () ()) Load)) (Expr (Subscript (Attribute (Name a Load) b Load) (Slice () (UnaryOp USub (ConstantInt 1 ())) ()) Load)) (Expr (Subscript (Attribute (Name a Load) b Load) (Slice (ConstantInt 1 ()) (ConstantInt 2 ()) ()) Load)) (Expr (Subscript (Attribute (Name a Load) b Load) (Slice () () ()) Load)) (Expr (Subscript (Attribute (Name y Load) z Load) (Slice (ConstantInt 1 ()) (ConstantInt 2 ()) (ConstantInt 3 ())) Load)) (Expr (Subscript (Attribute (Name y Load) z Load) (Slice (ConstantInt 1 ()) () (ConstantInt 3 ())) Load)) (Expr (Subscript (Attribute (Name y Load) z Load) (Slice (ConstantInt 1 ()) () ()) Load)) (Assign [(Name x Store)] (NamedExpr (Name y Store) (ConstantInt 0 ())) ()) (If (NamedExpr (Name a Store) (Call (Name ord Load) [(ConstantStr "3" ())] [])) [(Assign [(Name x Store)] (ConstantInt 1 ()) ())] []) (Assign [(Name a Store)] (Set [(ConstantInt 1 ()) (ConstantInt 2 ()) (ConstantInt 3 ())]) ()) (Assign [(Name a Store)] (Set [(ConstantInt 1 ()) (ConstantInt 2 ()) (ConstantInt 3 ())]) ()) (AnnAssign (Name output Store) (Name bool Load) (Compare (Name x Load) Eq [(Name y Load)]) 1) (AnnAssign (Name output Store) (Name bool Load) () 1) (Assign [(Name output Store)] (Compare (Name x Load) Eq [(Name y Load)]) ()) (AnnAssign (Name output Store) (Name bool Load) (Compare (Name x Load) Gt [(Name y Load)]) 1) (AnnAssign (Name output Store) (Name bool Load) () 1) (Assign [(Name output Store)] (Compare (Name x Load) Gt [(Name y Load)]) ()) (AnnAssign (Name output Store) (Name bool Load) (Compare (List [(Name x Load)] Load) NotIn [(List [(Name y Load)] Load)]) 1) (AnnAssign (Name output Store) (Name bool Load) () 1) (Assign [(Name output Store)] (Compare (List [(Name x Load)] Load) NotIn [(List [(Name y Load)] Load)]) ()) (FunctionDef comparison_return ([] [(a () ()) (b () ())] [] [] [] [] []) [(Return (Compare (Name a Load) Gt [(Name b Load)]))] [] () ()) (FunctionDef comparison_return ([] [(a () ()) (b () ())] [] [] [] [] []) [(Return (Compare (List [(Name a Load)] Load) In [(List [(Name b Load)] Load)]))] [] () ()) (FunctionDef comparison_return ([] [(a () ()) (b () ())] [] [] [] [] []) [(AnnAssign (Name output Store) (Name bool Load) () 1) (Assign [(Name output Store)] (Compare (List [(Name a Load)] Load) NotIn [(List [(Name b Load)] Load)]) ()) (Return (Name output Load))] [] () ()) (FunctionDef comparison_return ([] [(a () ()) (b () ())] [] [] [] [] []) [(Assign [(Name output Store)] (Compare (List [(Name a Load)] Load) NotIn [(List [(Name b Load)] Load)]) ()) (Return (Name output Load))] [] () ())] []) +(Module [(Pass) (Break) (Continue) (Raise () ()) (Raise (Call (Name NameError Load) [(ConstantStr "String" ())] []) ()) (Raise (Name RuntimeError Load) (Name exc Load)) (Assert (Compare (Call (Name len Load) [(Name marks Load)] []) NotEq [(ConstantInt 0 ())]) (ConstantStr "List is empty." ())) (Assert (Compare (Name x Load) Eq [(ConstantStr "String" ())]) ()) (Assign [(Name x Store)] (ConstantInt 1 ()) ()) (Assign [(Tuple [(Name x Store) (Name y Store)] Store)] (Call (Name x Load) [] []) ()) (Assign [(Name x Store) (Name y Store)] (ConstantInt 1 ()) ()) (Assign [(Tuple [(Name x Store) (Name y Store)] Store)] (Tuple [(ConstantInt 1 ()) (ConstantInt 2 ())] Load) ()) (Assign [(Subscript (Name x Load) (Name i Load) Store)] (Tuple [(ConstantInt 1 ()) (ConstantInt 2 ())] Load) ()) (Assign [(Tuple [(Name x Store) (Name y Store) (Name z Store)] Store)] (Name t Load) ()) (Assign [(Tuple [(Name x Store) (Name y Store) (Name z Store)] Store)] (Name t Load) ()) (Assign [(Tuple [(Name x Store)] Store)] (Name t Load) ()) (Assign [(Tuple [(Name x Store)] Store)] (Name t Load) ()) (Assign [(Name obj Store)] (Tuple [(Name obj Load)] Load) ()) (AugAssign (Name x Store) Add (ConstantInt 1 ())) (AugAssign (Name x Store) Add (Tuple [(Name y Load) (Name z Load)] Load)) (AugAssign (Name x Store) Add (Tuple [(Tuple [(Name y Load) (Name z Load)] Load)] Load)) (AnnAssign (Name x Store) (Name i64 Load) () 1) (AnnAssign (Name y Store) (Name i32 Load) (ConstantInt 1 ()) 1) (Delete [(Name x Del)]) (Delete [(Tuple [] Del)]) (Delete [(Tuple [(Name x Del) (Name y Del)] Del)]) (Delete [(Tuple [(Name x Del) (Name y Del)] Del)]) (Delete [(Name x Del) (Name y Del)]) (Delete [(Name x Del) (Name y Del)]) (Return ()) (Return (BinOp (Name a Load) Add (Name b Load))) (Return (Call (Name x Load) [(Name a Load)] [])) (Return (Tuple [] Load)) (Return (Tuple [(Name x Load) (Name y Load)] Load)) (Return (Tuple [(Name x Load) (Name y Load)] Load)) (Return (Tuple [(Name x Load) (Name y Load)] Load)) (Return (Tuple [(Name x Load) (Name y Load)] Load)) (Global [a]) (Global [a b]) (Nonlocal [a]) (Nonlocal [a b]) (Expr (ConstantInt 123 ())) (Expr (UnaryOp USub (ConstantInt 123 ()))) (Expr (UnaryOp USub (ConstantInt 291 ()))) (Expr (ConstantInt 6844 ())) (Expr (UnaryOp USub (ConstantInt 83 ()))) (Expr (ConstantInt 87 ())) (Expr (UnaryOp USub (ConstantInt 13 ()))) (Expr (ConstantInt 13 ())) (Expr (ConstantInt 32768 ())) (Expr (ConstantInt 12 ())) (Expr (ConstantInt 23440334322333 ())) (Expr (ConstantFloat 123.000000 ())) (Expr (ConstantFloat 123.450000 ())) (Expr (ConstantFloat 123400000000.000000 ())) (Expr (BinOp (ConstantInt 12 ()) Add (ConstantComplex 0.000000 3.000000 ()))) (Expr (BinOp (ConstantFloat 0.120000 ()) Add (ConstantComplex 0.000000 0.001000 ()))) (Expr (ConstantStr "String" ())) (Expr (ConstantStr "String String" ())) (Expr (ConstantStr "String String" ())) (Expr (ConstantStr "String String" ())) (Expr (Subscript (ConstantStr "String String" ()) (Slice (ConstantInt 1 ()) () ()) Load)) (Assign [(Name x Store)] (ConstantStr "String String" ()) ()) (Assign [(Name x Store)] (BinOp (ConstantStr "String " ()) Add (ConstantStr "String" ())) ()) (Assign [(Name x Store)] (ConstantStr "String String" ()) ()) (Assign [(Name x Store)] (ConstantStr "String String" ()) ()) (Assign [(Name x Store)] (ConstantStr "String " ()) ()) (Expr (ConstantStr "String" ())) (Expr (ConstantBool .true. ())) (Expr (ConstantBool .false. ())) (Expr (BinOp (BinOp (Name x Load) Add (Name y Load)) Mult (Name z Load))) (Expr (BinOp (Name x Load) Sub (Name y Load))) (Expr (BinOp (Name x Load) Mult (Name y Load))) (Expr (BinOp (Name x Load) Div (Name y Load))) (Expr (BinOp (Name x Load) Mod (Name y Load))) (Expr (UnaryOp USub (Name y Load))) (Expr (UnaryOp UAdd (Name y Load))) (Expr (UnaryOp Invert (Name y Load))) (Expr (BinOp (Name x Load) Pow (Name y Load))) (Expr (BinOp (Name x Load) FloorDiv (Name y Load))) (Expr (BinOp (Name x Load) MatMult (Name y Load))) (Expr (BinOp (Name x Load) BitAnd (Name y Load))) (Expr (BinOp (Name x Load) BitOr (Name y Load))) (Expr (BinOp (Name x Load) BitXor (Name y Load))) (Expr (BinOp (Name x Load) LShift (Name y Load))) (Expr (BinOp (Name x Load) RShift (Name y Load))) (Expr (Compare (Name x Load) Eq [(Name y Load)])) (Expr (Compare (Name x Load) NotEq [(Name y Load)])) (Expr (Compare (Name x Load) Lt [(Name y Load)])) (Expr (Compare (Name x Load) LtE [(Name y Load)])) (Expr (Compare (Name x Load) Gt [(Name y Load)])) (Expr (Compare (Name x Load) GtE [(Name y Load)])) (Expr (Compare (ConstantStr "hello" ()) In [(Name x Load)])) (Expr (Compare (ConstantStr "a" ()) In [(Call (Attribute (Name a Load) func Load) [] [])])) (Expr (Compare (ConstantStr "lo" ()) In [(ConstantStr "hello" ())])) (Expr (Subscript (Attribute (Name a Load) b Load) (ConstantInt 1 ()) Load)) (Expr (Subscript (Attribute (Name a Load) b Load) (Tuple [(ConstantInt 1 ())] Load) Load)) (Expr (Subscript (Attribute (Name a Load) b Load) (Slice (ConstantInt 1 ()) () ()) Load)) (Expr (Subscript (Attribute (Name a Load) b Load) (Slice () (UnaryOp USub (ConstantInt 1 ())) ()) Load)) (Expr (Subscript (Attribute (Name a Load) b Load) (Slice (ConstantInt 1 ()) (ConstantInt 2 ()) ()) Load)) (Expr (Subscript (Attribute (Name a Load) b Load) (Slice () () ()) Load)) (Expr (Subscript (Attribute (Name y Load) z Load) (Slice (ConstantInt 1 ()) (ConstantInt 2 ()) (ConstantInt 3 ())) Load)) (Expr (Subscript (Attribute (Name y Load) z Load) (Slice (ConstantInt 1 ()) () (ConstantInt 3 ())) Load)) (Expr (Subscript (Attribute (Name y Load) z Load) (Slice (ConstantInt 1 ()) () ()) Load)) (Assign [(Name x Store)] (NamedExpr (Name y Store) (ConstantInt 0 ())) ()) (If (NamedExpr (Name a Store) (Call (Name ord Load) [(ConstantStr "3" ())] [])) [(Assign [(Name x Store)] (ConstantInt 1 ()) ())] []) (Assign [(Name a Store)] (Set [(ConstantInt 1 ()) (ConstantInt 2 ()) (ConstantInt 3 ())]) ()) (Assign [(Name a Store)] (Set [(ConstantInt 1 ()) (ConstantInt 2 ()) (ConstantInt 3 ())]) ()) (AnnAssign (Name output Store) (Name bool Load) (Compare (Name x Load) Eq [(Name y Load)]) 1) (AnnAssign (Name output Store) (Name bool Load) () 1) (Assign [(Name output Store)] (Compare (Name x Load) Eq [(Name y Load)]) ()) (AnnAssign (Name output Store) (Name bool Load) (Compare (Name x Load) Gt [(Name y Load)]) 1) (AnnAssign (Name output Store) (Name bool Load) () 1) (Assign [(Name output Store)] (Compare (Name x Load) Gt [(Name y Load)]) ()) (AnnAssign (Name output Store) (Name bool Load) (Compare (List [(Name x Load)] Load) NotIn [(List [(Name y Load)] Load)]) 1) (AnnAssign (Name output Store) (Name bool Load) () 1) (Assign [(Name output Store)] (Compare (List [(Name x Load)] Load) NotIn [(List [(Name y Load)] Load)]) ()) (FunctionDef comparison_return ([] [(a () ()) (b () ())] [] [] [] [] []) [(Return (Compare (Name a Load) Gt [(Name b Load)]))] [] () ()) (FunctionDef comparison_return ([] [(a () ()) (b () ())] [] [] [] [] []) [(Return (Compare (List [(Name a Load)] Load) In [(List [(Name b Load)] Load)]))] [] () ()) (FunctionDef comparison_return ([] [(a () ()) (b () ())] [] [] [] [] []) [(AnnAssign (Name output Store) (Name bool Load) () 1) (Assign [(Name output Store)] (Compare (List [(Name a Load)] Load) NotIn [(List [(Name b Load)] Load)]) ()) (Return (Name output Load))] [] () ()) (FunctionDef comparison_return ([] [(a () ()) (b () ())] [] [] [] [] []) [(Assign [(Name output Store)] (Compare (List [(Name a Load)] Load) NotIn [(List [(Name b Load)] Load)]) ()) (Return (Name output Load))] [] () ())] []) diff --git a/tests/reference/ast_new-type_comment1-710ea6c.json b/tests/reference/ast_new-type_comment1-710ea6c.json index 6c366a3268..d779580878 100644 --- a/tests/reference/ast_new-type_comment1-710ea6c.json +++ b/tests/reference/ast_new-type_comment1-710ea6c.json @@ -2,11 +2,11 @@ "basename": "ast_new-type_comment1-710ea6c", "cmd": "lpython --show-ast --new-parser --no-color {infile} -o {outfile}", "infile": "tests/parser/type_comment1.py", - "infile_hash": "c4c669232bd7137cb068b0d6aaa9f4a998a0d6244b4da03ce174ea10", + "infile_hash": "068e12017f2d2c484023dba5e6d127d0ef53e3e4148ce40452c1284b", "outfile": null, "outfile_hash": null, "stdout": "ast_new-type_comment1-710ea6c.stdout", - "stdout_hash": "9e22c0795da6142ec862c25e6b57dd3446f11cb35082caf318ba8f2c", + "stdout_hash": "272ac1a567b7b87ede290df9502f6a79817af997b41edb9fe05090b9", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/ast_new-type_comment1-710ea6c.stdout b/tests/reference/ast_new-type_comment1-710ea6c.stdout index b9f5813854..00ef6de115 100644 --- a/tests/reference/ast_new-type_comment1-710ea6c.stdout +++ b/tests/reference/ast_new-type_comment1-710ea6c.stdout @@ -1 +1 @@ -(Module [(Import [(pytest ())]) (FunctionDef ndarray_func ([] [(x () ())] [] [] [] [] []) [(Return (Name x Load))] [] () "(np.ndarray) -> np.ndarray") (FunctionDef test ([] [(x () ())] [] [] [] [] []) [(Return (Name x Load))] [(Name decorator1 Load) (Name decorator2 Load) (Name decorator3 Load)] () "(np.ndarray) -> np.ndarray") (FunctionDef test ([] [] [] [] [] [] []) [(Expr (ConstantEllipsis ()))] [] () ()) (FunctionDef main ([] [] [] [] [] [] []) [(Pass)] [] () ()) (Expr (Call (Name x Load) [(Name x Load) (Name y Load)] [])) (ImportFrom sympy.simplify [(collect ()) (powsimp ()) (separatevars ()) (simplify ())] 0)] [(TypeIgnore 0 "") (TypeIgnore 0 "") (TypeIgnore 0 "") (TypeIgnore 0 "") (TypeIgnore 0 "") (TypeIgnore 0 "") (TypeIgnore 0 "")]) +(Module [(Import [(pytest ())]) (FunctionDef ndarray_func ([] [(x () ())] [] [] [] [] []) [(Return (Name x Load))] [] () "(np.ndarray) -> np.ndarray") (FunctionDef test ([] [(x () ())] [] [] [] [] []) [(Return (Name x Load))] [(Name decorator1 Load) (Name decorator2 Load) (Name decorator3 Load)] () "(np.ndarray) -> np.ndarray") (FunctionDef test ([] [] [] [] [] [] []) [(Expr (ConstantEllipsis ()))] [] () ()) (FunctionDef main ([] [] [] [] [] [] []) [(Pass)] [] () ()) (Expr (Call (Name x Load) [(Name x Load) (Name y Load)] [])) (ImportFrom sympy.simplify [(collect ()) (powsimp ()) (separatevars ()) (simplify ())] 0) (Expr (Await (Call (Name test Load) [(Name x Load) (Name y Load) (Name z Load)] [])))] [(TypeIgnore 0 "") (TypeIgnore 0 "") (TypeIgnore 0 "") (TypeIgnore 0 "") (TypeIgnore 0 "") (TypeIgnore 0 "") (TypeIgnore 0 "") (TypeIgnore 0 "")])