Skip to content

Commit fb97b8d

Browse files
Merge pull request #1052 from akshanshbhatt/pr_1025
2 parents 221b2b5 + be31848 commit fb97b8d

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

src/lpython/parser/parser.yy

+1
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ augassign_op
469469
| ">>=" { $$ = OPERATOR(RShift, @$); }
470470
| "**=" { $$ = OPERATOR(Pow, @$); }
471471
| "//=" { $$ = OPERATOR(FloorDiv, @$); }
472+
| "@=" { $$ = OPERATOR(MatMult, @$); }
472473
;
473474

474475
ann_assignment_statement

tests/parser/statements2.py

+5
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,8 @@
2828
if x not\
2929
in\
3030
z: ...
31+
32+
def imatmul(a, b):
33+
"Same as a @= b."
34+
a @= b
35+
return a

tests/reference/ast_new-statements2-c4cdc5f.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"basename": "ast_new-statements2-c4cdc5f",
33
"cmd": "lpython --show-ast --new-parser --no-color {infile} -o {outfile}",
44
"infile": "tests/parser/statements2.py",
5-
"infile_hash": "3f62769b76800a0cce6aacdbb90a41a01c7282854b7e7d3a140f9d90",
5+
"infile_hash": "3be5c5c199bae9d20d51a30cb785a08faa69aa7cb13f18aae44ffe01",
66
"outfile": null,
77
"outfile_hash": null,
88
"stdout": "ast_new-statements2-c4cdc5f.stdout",
9-
"stdout_hash": "3ee936a39b6a42bde485fe9aae08abb897163c25c6f911e16ffd173e",
9+
"stdout_hash": "b740926cb114f97c24252d42bc2a0a1b374c3c3d6f286c9d869f1512",
1010
"stderr": null,
1111
"stderr_hash": null,
1212
"returncode": 0
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
(Module [(Expr (Call (Call (Call (Name getattr Load) [(Name x Load) (Name y Load)] []) [(Name a Load) (Name b Load)] []) [(ConstantInt 5 ())] [(a (Name a Load)) (b (ConstantInt 0 ()))])) (Expr (Call (Call (Name func Load) [(Name a Load) (Name _op Load)] []) [(Name s Load)] [])) (Expr (Call (Call (Name test Load) [] []) [] [])) (Assign [(Name a Store)] (Subscript (List [(ConstantInt 1 ()) (ConstantInt 2 ())] Load) (ConstantInt 0 ()) Load) ()) (Assign [(Tuple [(Name a Store) (Name b Store)] Store)] (Subscript (BinOp (List [(ConstantInt 1 ()) (ConstantInt 2 ())] Load) Add (List [(ConstantInt 0 ()) (ConstantInt 0 ())] Load)) (Slice () (ConstantInt 2 ()) ()) Load) ()) (Assign [(Tuple [(Name a Store) (Name b Store)] Store)] (Subscript (BinOp (Call (Attribute (Name c Load) d Load) [] []) Add (List [(ConstantInt 1 ()) (ConstantInt 0 ())] Load)) (Slice () () ()) Load) ()) (Expr (Subscript (Dict [(ConstantStr "a" ()) (ConstantStr "b" ())] [(Name a Load) (Name b Load)]) (Name val Load) Load)) (If (Compare (Subscript (Subscript (Name args Load) (Name i Load) Load) (Slice () (ConstantInt 1 ()) ()) Load) In [(List [(ConstantStr "" ()) (ConstantStr "." ())] Load)]) [(Pass)] []) (Assign [(Name x Store)] (List [(Subscript (ListComp (BinOp (UnaryOp USub (Name c Load)) Mod (Name self Load)) [((Name c Store) (Call (Name reversed Load) [(Attribute (Attribute (Name T Load) rep Load) rep Load)] []) [] 0)]) (Slice () (UnaryOp USub (ConstantInt 1 ())) ()) Load)] Load) ()) (Expr (Subscript (ListComp (Name x Load) [((Name x Store) (Name G Load) [(Call (Attribute (Attribute (Name self Load) ring Load) is_unit Load) [(Subscript (Name x Load) (ConstantInt 0 ()) Load)] [])] 0)]) (ConstantInt 0 ()) Load)) (If (Compare (Name x Load) NotIn [(Name z Load)]) [(Expr (ConstantEllipsis ()))] []) (If (Compare (Name x Load) NotIn [(Name z Load)]) [(Expr (ConstantEllipsis ()))] []) (If (Compare (Name x Load) NotIn [(Name z Load)]) [(Expr (ConstantEllipsis ()))] [])] [])
1+
(Module [(Expr (Call (Call (Call (Name getattr Load) [(Name x Load) (Name y Load)] []) [(Name a Load) (Name b Load)] []) [(ConstantInt 5 ())] [(a (Name a Load)) (b (ConstantInt 0 ()))])) (Expr (Call (Call (Name func Load) [(Name a Load) (Name _op Load)] []) [(Name s Load)] [])) (Expr (Call (Call (Name test Load) [] []) [] [])) (Assign [(Name a Store)] (Subscript (List [(ConstantInt 1 ()) (ConstantInt 2 ())] Load) (ConstantInt 0 ()) Load) ()) (Assign [(Tuple [(Name a Store) (Name b Store)] Store)] (Subscript (BinOp (List [(ConstantInt 1 ()) (ConstantInt 2 ())] Load) Add (List [(ConstantInt 0 ()) (ConstantInt 0 ())] Load)) (Slice () (ConstantInt 2 ()) ()) Load) ()) (Assign [(Tuple [(Name a Store) (Name b Store)] Store)] (Subscript (BinOp (Call (Attribute (Name c Load) d Load) [] []) Add (List [(ConstantInt 1 ()) (ConstantInt 0 ())] Load)) (Slice () () ()) Load) ()) (Expr (Subscript (Dict [(ConstantStr "a" ()) (ConstantStr "b" ())] [(Name a Load) (Name b Load)]) (Name val Load) Load)) (If (Compare (Subscript (Subscript (Name args Load) (Name i Load) Load) (Slice () (ConstantInt 1 ()) ()) Load) In [(List [(ConstantStr "" ()) (ConstantStr "." ())] Load)]) [(Pass)] []) (Assign [(Name x Store)] (List [(Subscript (ListComp (BinOp (UnaryOp USub (Name c Load)) Mod (Name self Load)) [((Name c Store) (Call (Name reversed Load) [(Attribute (Attribute (Name T Load) rep Load) rep Load)] []) [] 0)]) (Slice () (UnaryOp USub (ConstantInt 1 ())) ()) Load)] Load) ()) (Expr (Subscript (ListComp (Name x Load) [((Name x Store) (Name G Load) [(Call (Attribute (Attribute (Name self Load) ring Load) is_unit Load) [(Subscript (Name x Load) (ConstantInt 0 ()) Load)] [])] 0)]) (ConstantInt 0 ()) Load)) (If (Compare (Name x Load) NotIn [(Name z Load)]) [(Expr (ConstantEllipsis ()))] []) (If (Compare (Name x Load) NotIn [(Name z Load)]) [(Expr (ConstantEllipsis ()))] []) (If (Compare (Name x Load) NotIn [(Name z Load)]) [(Expr (ConstantEllipsis ()))] []) (FunctionDef imatmul ([] [(a () ()) (b () ())] [] [] [] [] []) [(Expr (ConstantStr "Same as a @= b." ())) (AugAssign (Name a Store) MatMult (Name b Load)) (Return (Name a Load))] [] () ())] [])

0 commit comments

Comments
 (0)