feat: wsh non en fait
This commit is contained in:
parent
951a1a441b
commit
cef62a7188
|
@ -0,0 +1,5 @@
|
||||||
|
main{
|
||||||
|
typedef Point = struct { int x int y };
|
||||||
|
Point p = {1 2}
|
||||||
|
print (p.x);
|
||||||
|
}
|
|
@ -63,7 +63,6 @@ main : lfi=prog EOF {lfi}
|
||||||
|
|
||||||
prog :
|
prog :
|
||||||
| ltd=td lf=fonc lfi=prog {let (Programme (_, lf1, li))=lfi in (Programme (ltd, lf::lf1,li))}
|
| ltd=td lf=fonc lfi=prog {let (Programme (_, lf1, li))=lfi in (Programme (ltd, lf::lf1,li))}
|
||||||
(* | lf=fonc lfi=prog {let (Programme ( lf1, li))=lfi in (Programme ( lf::lf1,li))} *)
|
|
||||||
| ID li=bloc {Programme ([], [], li)}
|
| ID li=bloc {Programme ([], [], li)}
|
||||||
|
|
||||||
td :
|
td :
|
||||||
|
@ -76,8 +75,8 @@ fonc :
|
||||||
bloc : AO li = is AF {li}
|
bloc : AO li = is AF {li}
|
||||||
|
|
||||||
is :
|
is :
|
||||||
| {[]}
|
| {[]}
|
||||||
| i1=i li=is {i1::li}
|
| i1=i li=is {i1::li}
|
||||||
|
|
||||||
i :
|
i :
|
||||||
| t=typ n=ID EQUAL exp=e PV {Declaration (t,n,exp)}
|
| t=typ n=ID EQUAL exp=e PV {Declaration (t,n,exp)}
|
||||||
|
@ -92,15 +91,15 @@ i :
|
||||||
| TYPEDEF tid=TID EQUAL type1=typ PV {LocalTypeDef (TypeDef(tid, type1))}
|
| TYPEDEF tid=TID EQUAL type1=typ PV {LocalTypeDef (TypeDef(tid, type1))}
|
||||||
|
|
||||||
dp :
|
dp :
|
||||||
| {[]}
|
| {[]}
|
||||||
| t=typ n=ID lp=dp {(t,n)::lp}
|
| t=typ n=ID lp=dp {(t,n)::lp}
|
||||||
|
|
||||||
typ :
|
typ :
|
||||||
| BOOL {Bool}
|
| BOOL {Bool}
|
||||||
| INT {Int}
|
| INT {Int}
|
||||||
| RAT {Rat}
|
| RAT {Rat}
|
||||||
| t1=typ MULT {Pointeur (t1)}
|
| t1=typ MULT {Pointeur (t1)}
|
||||||
| t1=TID {TIdent (t1)}
|
| t1=TID {TIdent (t1)}
|
||||||
| STRUCT AO p=dp AF {Struct (p)}
|
| STRUCT AO p=dp AF {Struct (p)}
|
||||||
|
|
||||||
e :
|
e :
|
||||||
|
|
|
@ -98,9 +98,13 @@ and analyse_code_instruction i taille_return taille_args taille_var =
|
||||||
end
|
end
|
||||||
|
|
||||||
| Dref(a, t) ->
|
| Dref(a, t) ->
|
||||||
(analyse_code_expression e) ^
|
(analyse_code_expression e) ^
|
||||||
(analyse_code_affectable a) ^
|
(analyse_code_affectable a) ^
|
||||||
"STOREI (" ^ string_of_int (getTaille t) ^ ")\n"
|
"STOREI (" ^ string_of_int (getTaille t) ^ ")\n"
|
||||||
|
|
||||||
|
| Attribut(aff, info) ->
|
||||||
|
(analyse_code_affectable a)
|
||||||
|
(* TODO *)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -135,3 +135,7 @@ let%expect_test "typedef1" =
|
||||||
let%expect_test "typedef2" =
|
let%expect_test "typedef2" =
|
||||||
runtam "../../fichiersRat/src-rat-tam-test/typedef2.rat";
|
runtam "../../fichiersRat/src-rat-tam-test/typedef2.rat";
|
||||||
[%expect{| 2 |}]
|
[%expect{| 2 |}]
|
||||||
|
|
||||||
|
let%expect_test "struct1" =
|
||||||
|
runtam "../../fichiersRat/src-rat-tam-test/struct1.rat";
|
||||||
|
[%expect{| 1 |}]
|
Loading…
Reference in a new issue