This commit is contained in:
Mylloon 2023-10-20 19:10:39 +02:00
parent 7683cada98
commit 726daf228d
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -185,10 +185,10 @@ pattern_list:
/********************************* DATA TYPE **********************************/
/* Pour résoudre un conflit, on a du split ty en 2 règles
*
* separated_nonempty_list(STAR,located(ty)) -> ty STAR separated_nonempty_list(STAR,located(ty))
* separated_nonempty_list(STAR, located(ty)) -> ty STAR separated_nonempty_list(STAR, located(ty))
* [ ty ] -> ty * [ ty ]
* ET
* ty -> ty STAR separated_nonempty_list(STAR,located(ty))
* ty -> ty STAR separated_nonempty_list(STAR, located(ty))
* ty -> ty * [ ty ]
*/
simple_ty:
@ -244,7 +244,7 @@ simple_expression:
| l=located(literal) {
Literal l
}
/* Variable */
/* Variable */
| i=located(identifier) {
Variable(i, None)
}
@ -255,7 +255,7 @@ simple_expression:
Variable(i, t_list)
}
/* Tuple n = 0 and n > 1 */
/* Tuple n = 0 and n > 1 */
| LPAREN RPAREN {
Tuple([])
}
@ -263,7 +263,7 @@ simple_expression:
Tuple(e::e_list)
}
/* Tagged Value*/
/* Tagged Value*/
/* K */
| const=located(constructor) {
Tagged(const, None, [])
@ -280,7 +280,7 @@ simple_expression:
| const=located(constructor) INFERIOR t_list=option(separated_nonempty_list(COMMA, located(ty))) SUPERIOR {
Tagged(const, t_list, [])
}
/* K <ty_1, ..., ty_m> (e1,...,en) */
/* K <ty_1, ..., ty_m> (e1, ..., en) */
| const=located(constructor) INFERIOR t_list=option(separated_nonempty_list(COMMA, located(ty))) SUPERIOR LPAREN e_list=separated_nonempty_list(COMMA, located(expression)) RPAREN {
Tagged(const, t_list, e_list)
}
@ -343,7 +343,7 @@ expression:
Apply(e1, e2)
}
/* TODO operation binaire mais j'ai pas très bien compris encore */
/* TODO operation binaire mais j'ai pas très bien compris encore */
/* Match (exp) {| ...| ... | ...} */
@ -351,13 +351,12 @@ expression:
Case(e, b)
}
/* TODO if ( exp ) then { expr } j'ai RIEN COMPRIS */
/*
| IF LPAREN e=located(expression) RPAREN
THEN LBRACE e2=located(expression) RBRACE{
IfThenElse(e,e2,None)
}
*/
/* TODO if ( exp ) then { expr } j'ai RIEN COMPRIS */
/* | IF LPAREN e=located(expression) RPAREN
THEN LBRACE e2=located(expression) RBRACE {
IfThenElse(e, e2, None)
} */
/* if ( expr ) then { expr } else { expr } */
| IF LPAREN e=located(expression) RPAREN
THEN LBRACE e2=located(expression) RBRACE
@ -365,15 +364,13 @@ expression:
IfThenElse(e, e2, e3)
}
/* Reference ref expr */
/* Reference ref expr */
| REF e=located(expression) {
Ref(e)
}
/* Affectation */
/* expr := expr */
/* Affectation
* expr := expr */
| e1=located(expression) ASSIGN e2=located(expression) {
Assign(e1, e2)
}
@ -385,24 +382,25 @@ expression:
While(e, e2)
}
/* Do while TODO */
/* do { expr } until ( expr ) */
/* Do while
* do { expr } until ( expr ) */
/* TODO */
/* boucle for */
/* for x in (e1 to e2) { expr } */
/* boucle for
* for x in (e1 to e2) { expr } */
| FOR x=located(identifier)
FROM LPAREN e1=located(expression) RPAREN TO LPAREN e2=located(expression) RPAREN
LBRACE e3=located(expression) RBRACE {
For(x, e1, e2, e3)
}
/* Parenthésage pas sûr mais je vois pas sinon*/
/* Parenthésage pas sûr mais je vois pas sinon */
| LPAREN e=expression RPAREN {
e
}
/* Annotation de type */
/* (e : ty) */
/* Annotation de type
* (e : ty) */
| LPAREN e=located(expression) COLON t=located(ty) RPAREN {
TypeAnnotation(e, t)
}