feat: += mg

This commit is contained in:
Guillotin Damien 2021-12-12 15:43:20 +01:00
parent 5e17ce496a
commit 0931e4a1c8
6 changed files with 34 additions and 4 deletions

View file

@ -0,0 +1,5 @@
main{
int i = 1;
i += 2;
print i;
}

View file

@ -0,0 +1,8 @@
main{
int i = 3;
i += 4;
print i;
rat r = [4/5];
r += [1/8];
print r;
}

View file

@ -0,0 +1,6 @@
main{
int i = 1;
int j = 2;
j += i;
print j;
}

View file

@ -77,7 +77,8 @@ i :
| IF exp=e li1=bloc ELSE li2=bloc {Conditionnelle (exp,li1,li2)}
| WHILE exp=e li=bloc {TantQue (exp,li)}
| RETURN exp=e PV {Retour (exp)}
| aff=a EQUAL exp=e {Affectation (aff, exp)}
| aff=a EQUAL exp=e PV {Affectation (aff, exp)}
| aff=a PLUS EQUAL exp=e PV {Affectation (aff, Binaire (Plus, Affectable(aff), exp))}
dp :
| {[]}

View file

@ -109,8 +109,6 @@ let rec analyse_type_instruction opt i =
let _ = modifier_type_info t info in
AstType.Declaration(info, ne)
else
let _ = print_endline (string_of_type nt) in
let _ = print_endline (string_of_type t) in
raise (TypeInattendu(nt, t))
| AstTds.Affectation (aff, e) ->

View file

@ -111,4 +111,16 @@ let%expect_test "factrec" =
let%expect_test "pointeur1" =
runtam "../../fichiersRat/src-rat-tam-test/pointeur1.rat";
[%expect{| 3 |}]
[%expect{| 3 |}]
let%expect_test "assadd1" =
runtam "../../fichiersRat/src-rat-tam-test/assadd1.rat";
[%expect{| 3 |}]
let%expect_test "assadd2" =
runtam "../../fichiersRat/src-rat-tam-test/assadd2.rat";
[%expect{| 7[37/40] |}]
let%expect_test "assadd3" =
runtam "../../fichiersRat/src-rat-tam-test/assadd3.rat";
[%expect{| 3 |}]