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 :
|
||||
| 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)}
|
||||
|
||||
td :
|
||||
|
@ -76,8 +75,8 @@ fonc :
|
|||
bloc : AO li = is AF {li}
|
||||
|
||||
is :
|
||||
| {[]}
|
||||
| i1=i li=is {i1::li}
|
||||
| {[]}
|
||||
| i1=i li=is {i1::li}
|
||||
|
||||
i :
|
||||
| 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))}
|
||||
|
||||
dp :
|
||||
| {[]}
|
||||
| t=typ n=ID lp=dp {(t,n)::lp}
|
||||
| {[]}
|
||||
| t=typ n=ID lp=dp {(t,n)::lp}
|
||||
|
||||
typ :
|
||||
| BOOL {Bool}
|
||||
| INT {Int}
|
||||
| RAT {Rat}
|
||||
| t1=typ MULT {Pointeur (t1)}
|
||||
| t1=TID {TIdent (t1)}
|
||||
| BOOL {Bool}
|
||||
| INT {Int}
|
||||
| RAT {Rat}
|
||||
| t1=typ MULT {Pointeur (t1)}
|
||||
| t1=TID {TIdent (t1)}
|
||||
| STRUCT AO p=dp AF {Struct (p)}
|
||||
|
||||
e :
|
||||
|
|
|
@ -98,9 +98,13 @@ and analyse_code_instruction i taille_return taille_args taille_var =
|
|||
end
|
||||
|
||||
| Dref(a, t) ->
|
||||
(analyse_code_expression e) ^
|
||||
(analyse_code_affectable a) ^
|
||||
"STOREI (" ^ string_of_int (getTaille t) ^ ")\n"
|
||||
(analyse_code_expression e) ^
|
||||
(analyse_code_affectable a) ^
|
||||
"STOREI (" ^ string_of_int (getTaille t) ^ ")\n"
|
||||
|
||||
| Attribut(aff, info) ->
|
||||
(analyse_code_affectable a)
|
||||
(* TODO *)
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -134,4 +134,8 @@ let%expect_test "typedef1" =
|
|||
|
||||
let%expect_test "typedef2" =
|
||||
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