Merge branch 'anri' of gaufre.informatique.univ-paris-diderot.fr:Anri/compilation-m1-2023 into anri

This commit is contained in:
Mylloon 2023-10-24 21:44:31 +02:00
commit 885f2e0790
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -44,6 +44,7 @@
%left PLUS MINUS
%left SLASH STAR
%left ref1
%left fun1
%left app1
@ -173,7 +174,6 @@ simple_pattern:
match l with | [alone] -> Position.value alone | _ -> PTuple(l)
}
/* Annotation de type */
| p=located(simple_pattern) COLON ty=located(ty) {
PTypeAnnotation(p, ty)
@ -287,10 +287,16 @@ simple_expression:
| i=located(var_identifier) tl=option(type_list) {
Variable(i, tl)
}
| LPAREN e=located(expression) COLON t=located(ty) RPAREN {
TypeAnnotation(e, t)
}
/* Tagged Value - Construction d'une donnée */
/*
| const=located(constructor) tl=option(type_list) el=optionlist(expr_list) {
Tagged(const, tl, el)
}
*/
/* Tuple n = 0 - Construction d'un 0-uplet */
| LPAREN RPAREN {
Tuple([])
@ -309,7 +315,7 @@ simple_expression:
}
/* Lecture de variable
* !expr */
| EXCLA e=located(simple_expression) {
| EXCLA e=located(simple_expression){
Read(e)
}
@ -323,20 +329,50 @@ expr_list:
el
}
mid_expression:
|e=simple_expression{
e
}
/* Parenthésage */
| LPAREN e=expression RPAREN {
e
}
/* Field record */
| e=located(mid_expression) DOT l=located(label_identifier) tl=option(type_list) {
Field(e, l, tl)
}
/* Application */
| e1=located(mid_expression) e2=located(mid_expression) %prec app1 {
Apply(e1, e2)
}
| const=located(constructor) tl=option(type_list) el=optionlist(expr_list) {
Tagged(const, tl, el)
}
expression:
| e=simple_expression {
| e=mid_expression {
e
}
/* Field - Projection dun champ */
/*
| e=located(expression) DOT l=located(label_identifier) tl=option(type_list) {
Field(e, l, tl)
}
/* Sequence - Séquencement *
* Pas sûr, voir s'il ne faut pas une troisième couche d'expression */
| e=located(simple_expression)
SEMICOLON e_list=separated_nonempty_list(SEMICOLON, located(simple_expression)) {
/*
| e=located(mid_expression)
SEMICOLON e_list=separated_nonempty_list(SEMICOLON, located(mid_expression)) {
Sequence(e :: e_list)
}
}*/
| e=located(expression) SEMICOLON e2=located(expression){
Sequence([e;e2])
}
/* | e1=located(expression) SEMICOLON e2=located(expression) {
Sequence([e1; e2])
} */
@ -349,6 +385,7 @@ expression:
Fun(FunctionDefinition(p, e))
}
/* Application */
/*
| e1=located(expression) e2=located(expression) %prec app1 {
Apply(e1, e2)
}
@ -429,11 +466,14 @@ expression:
}
/* Parenthésage
* Pas sûr mais je vois pas sinon */
/*
| LPAREN e=expression RPAREN {
e
}
}*/
/* Annotation de type
* (e : ty) */
/*
| LPAREN e=located(expression) COLON t=located(ty) RPAREN {
TypeAnnotation(e, t)
}