fmt2
This commit is contained in:
parent
7683cada98
commit
726daf228d
1 changed files with 24 additions and 26 deletions
|
@ -185,10 +185,10 @@ pattern_list:
|
||||||
/********************************* DATA TYPE **********************************/
|
/********************************* DATA TYPE **********************************/
|
||||||
/* Pour résoudre un conflit, on a du split ty en 2 règles
|
/* 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 ]
|
* [ ty ] -> ty * [ ty ]
|
||||||
* ET
|
* ET
|
||||||
* ty -> ty STAR separated_nonempty_list(STAR,located(ty))
|
* ty -> ty STAR separated_nonempty_list(STAR, located(ty))
|
||||||
* ty -> ty * [ ty ]
|
* ty -> ty * [ ty ]
|
||||||
*/
|
*/
|
||||||
simple_ty:
|
simple_ty:
|
||||||
|
@ -244,7 +244,7 @@ simple_expression:
|
||||||
| l=located(literal) {
|
| l=located(literal) {
|
||||||
Literal l
|
Literal l
|
||||||
}
|
}
|
||||||
/* Variable */
|
/* Variable */
|
||||||
| i=located(identifier) {
|
| i=located(identifier) {
|
||||||
Variable(i, None)
|
Variable(i, None)
|
||||||
}
|
}
|
||||||
|
@ -255,7 +255,7 @@ simple_expression:
|
||||||
Variable(i, t_list)
|
Variable(i, t_list)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tuple n = 0 and n > 1 */
|
/* Tuple n = 0 and n > 1 */
|
||||||
| LPAREN RPAREN {
|
| LPAREN RPAREN {
|
||||||
Tuple([])
|
Tuple([])
|
||||||
}
|
}
|
||||||
|
@ -263,7 +263,7 @@ simple_expression:
|
||||||
Tuple(e::e_list)
|
Tuple(e::e_list)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tagged Value*/
|
/* Tagged Value*/
|
||||||
/* K */
|
/* K */
|
||||||
| const=located(constructor) {
|
| const=located(constructor) {
|
||||||
Tagged(const, None, [])
|
Tagged(const, None, [])
|
||||||
|
@ -280,7 +280,7 @@ simple_expression:
|
||||||
| const=located(constructor) INFERIOR t_list=option(separated_nonempty_list(COMMA, located(ty))) SUPERIOR {
|
| const=located(constructor) INFERIOR t_list=option(separated_nonempty_list(COMMA, located(ty))) SUPERIOR {
|
||||||
Tagged(const, t_list, [])
|
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 {
|
| 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)
|
Tagged(const, t_list, e_list)
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ expression:
|
||||||
Apply(e1, e2)
|
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) {| ...| ... | ...} */
|
/* Match (exp) {| ...| ... | ...} */
|
||||||
|
@ -351,13 +351,12 @@ expression:
|
||||||
Case(e, b)
|
Case(e, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO if ( exp ) then { expr } j'ai RIEN COMPRIS */
|
/* TODO if ( exp ) then { expr } j'ai RIEN COMPRIS */
|
||||||
/*
|
/* | IF LPAREN e=located(expression) RPAREN
|
||||||
| IF LPAREN e=located(expression) RPAREN
|
THEN LBRACE e2=located(expression) RBRACE {
|
||||||
THEN LBRACE e2=located(expression) RBRACE{
|
IfThenElse(e, e2, None)
|
||||||
IfThenElse(e,e2,None)
|
} */
|
||||||
}
|
|
||||||
*/
|
|
||||||
/* if ( expr ) then { expr } else { expr } */
|
/* if ( expr ) then { expr } else { expr } */
|
||||||
| IF LPAREN e=located(expression) RPAREN
|
| IF LPAREN e=located(expression) RPAREN
|
||||||
THEN LBRACE e2=located(expression) RBRACE
|
THEN LBRACE e2=located(expression) RBRACE
|
||||||
|
@ -365,15 +364,13 @@ expression:
|
||||||
IfThenElse(e, e2, e3)
|
IfThenElse(e, e2, e3)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reference ref expr */
|
/* Reference ref expr */
|
||||||
|
|
||||||
| REF e=located(expression) {
|
| REF e=located(expression) {
|
||||||
Ref(e)
|
Ref(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Affectation */
|
/* Affectation
|
||||||
/* expr := expr */
|
* expr := expr */
|
||||||
|
|
||||||
| e1=located(expression) ASSIGN e2=located(expression) {
|
| e1=located(expression) ASSIGN e2=located(expression) {
|
||||||
Assign(e1, e2)
|
Assign(e1, e2)
|
||||||
}
|
}
|
||||||
|
@ -385,24 +382,25 @@ expression:
|
||||||
While(e, e2)
|
While(e, e2)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do while TODO */
|
/* Do while
|
||||||
/* do { expr } until ( expr ) */
|
* do { expr } until ( expr ) */
|
||||||
|
/* TODO */
|
||||||
|
|
||||||
/* boucle for */
|
/* boucle for
|
||||||
/* for x in (e1 to e2) { expr } */
|
* for x in (e1 to e2) { expr } */
|
||||||
| FOR x=located(identifier)
|
| FOR x=located(identifier)
|
||||||
FROM LPAREN e1=located(expression) RPAREN TO LPAREN e2=located(expression) RPAREN
|
FROM LPAREN e1=located(expression) RPAREN TO LPAREN e2=located(expression) RPAREN
|
||||||
LBRACE e3=located(expression) RBRACE {
|
LBRACE e3=located(expression) RBRACE {
|
||||||
For(x, e1, e2, e3)
|
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 {
|
| LPAREN e=expression RPAREN {
|
||||||
e
|
e
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Annotation de type */
|
/* Annotation de type
|
||||||
/* (e : ty) */
|
* (e : ty) */
|
||||||
| LPAREN e=located(expression) COLON t=located(ty) RPAREN {
|
| LPAREN e=located(expression) COLON t=located(ty) RPAREN {
|
||||||
TypeAnnotation(e, t)
|
TypeAnnotation(e, t)
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue