refactor doing nothing
This commit is contained in:
parent
88efc86649
commit
485c2cd15c
1 changed files with 41 additions and 48 deletions
|
@ -24,7 +24,6 @@
|
||||||
%left ID
|
%left ID
|
||||||
%right ARROW
|
%right ARROW
|
||||||
%right SEMICOLON
|
%right SEMICOLON
|
||||||
%left DOT
|
|
||||||
%left ASSIGN
|
%left ASSIGN
|
||||||
%left LBRACE
|
%left LBRACE
|
||||||
|
|
||||||
|
@ -275,7 +274,6 @@ colon_type_scheme:
|
||||||
|
|
||||||
|
|
||||||
/********************************* EXPRESSION *********************************/
|
/********************************* EXPRESSION *********************************/
|
||||||
|
|
||||||
simple_expression:
|
simple_expression:
|
||||||
/* Simple litteral */
|
/* Simple litteral */
|
||||||
| l=located(literal) {
|
| l=located(literal) {
|
||||||
|
@ -285,53 +283,16 @@ simple_expression:
|
||||||
| i=located(var_identifier) tl=option(type_list) {
|
| i=located(var_identifier) tl=option(type_list) {
|
||||||
Variable(i, tl)
|
Variable(i, tl)
|
||||||
}
|
}
|
||||||
/* Annotation de type
|
|
||||||
* ( expr : type ) */
|
|
||||||
| LPAREN e=located(expression) COLON t=located(ty) RPAREN {
|
|
||||||
TypeAnnotation(e, t)
|
|
||||||
}
|
|
||||||
/* Tuple n = 0 - Construction d'un 0-uplet */
|
|
||||||
| LPAREN RPAREN {
|
|
||||||
Tuple([])
|
|
||||||
}
|
|
||||||
/* Tuple n > 1 - Construction d'un n-uplet (n > 1) */
|
/* Tuple n > 1 - Construction d'un n-uplet (n > 1) */
|
||||||
| el=expr_list {
|
| el=expr_list {
|
||||||
(* S'il y a qu'1 élément, alors c'est juste une expression *)
|
(* S'il y a qu'1 élément, alors c'est juste une expression *)
|
||||||
match el with | [alone] -> Position.value alone | _ -> Tuple(el)
|
match el with | [alone] -> Position.value alone | _ -> Tuple(el)
|
||||||
}
|
}
|
||||||
/* Record - Construction d'un enregistrement */
|
|
||||||
| LBRACE l=separated_nonempty_list(
|
|
||||||
COMMA,
|
|
||||||
separated_pair(located(label_identifier), EQUAL, located(expression))
|
|
||||||
) RBRACE tl=option(type_list) {
|
|
||||||
Record(l, tl)
|
|
||||||
}
|
|
||||||
/* Lecture de variable
|
|
||||||
* !expr */
|
|
||||||
| EXCLA e=located(simple_expression) {
|
|
||||||
Read(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
type_list:
|
|
||||||
| INFERIOR tl=separated_list(COMMA, located(ty)) SUPERIOR {
|
|
||||||
tl
|
|
||||||
}
|
|
||||||
|
|
||||||
expr_list:
|
|
||||||
| LPAREN el=separated_nonempty_list(COMMA, located(expression)) RPAREN {
|
|
||||||
el
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
mid_expression:
|
mid_expression:
|
||||||
| e=simple_expression {
|
| e=simple_expression {
|
||||||
e
|
e
|
||||||
}
|
}
|
||||||
/* Field record */
|
|
||||||
| e=located(mid_expression) DOT l=located(label_identifier) tl=option(type_list) {
|
|
||||||
Field(e, l, tl)
|
|
||||||
}
|
|
||||||
/* Tagged Value - Construction d'une donnée */
|
/* Tagged Value - Construction d'une donnée */
|
||||||
| const=located(constructor) tl=option(type_list) el=optionlist(expr_list) {
|
| const=located(constructor) tl=option(type_list) el=optionlist(expr_list) {
|
||||||
Tagged(const, tl, el)
|
Tagged(const, tl, el)
|
||||||
|
@ -340,13 +301,32 @@ mid_expression:
|
||||||
| e1=located(mid_expression) e2=located(mid_expression) %prec app1 {
|
| e1=located(mid_expression) e2=located(mid_expression) %prec app1 {
|
||||||
Apply(e1, e2)
|
Apply(e1, e2)
|
||||||
}
|
}
|
||||||
|
/* Lecture de variable
|
||||||
|
* !expr */
|
||||||
|
| EXCLA e=located(simple_expression) {
|
||||||
|
Read(e)
|
||||||
|
}
|
||||||
|
/* Record - Construction d'un enregistrement */
|
||||||
|
| LBRACE l=separated_nonempty_list(
|
||||||
|
COMMA,
|
||||||
|
separated_pair(located(label_identifier), EQUAL, located(expression))
|
||||||
|
) RBRACE tl=option(type_list) {
|
||||||
|
Record(l, tl)
|
||||||
|
}
|
||||||
|
|
||||||
expression:
|
expression:
|
||||||
| e=mid_expression {
|
| e=mid_expression {
|
||||||
e
|
e
|
||||||
}
|
}
|
||||||
|
/* Annotation de type
|
||||||
|
* ( expr : type ) */
|
||||||
|
| LPAREN e=located(expression) COLON t=located(ty) RPAREN {
|
||||||
|
TypeAnnotation(e, t)
|
||||||
|
}
|
||||||
|
/* Tuple n = 0 - Construction d'un 0-uplet */
|
||||||
|
| LPAREN RPAREN {
|
||||||
|
Tuple([])
|
||||||
|
}
|
||||||
/* Sequence - Séquencement */
|
/* Sequence - Séquencement */
|
||||||
| e=located(expression) SEMICOLON e2=located(expression) {
|
| e=located(expression) SEMICOLON e2=located(expression) {
|
||||||
Sequence([e; e2])
|
Sequence([e; e2])
|
||||||
|
@ -423,7 +403,20 @@ expression:
|
||||||
| REF e=located(mid_expression) {
|
| REF e=located(mid_expression) {
|
||||||
Ref(e)
|
Ref(e)
|
||||||
}
|
}
|
||||||
|
/* Field record */
|
||||||
|
| e=located(mid_expression) DOT l=located(label_identifier) tl=option(type_list) {
|
||||||
|
Field(e, l, tl)
|
||||||
|
}
|
||||||
|
|
||||||
|
type_list:
|
||||||
|
| INFERIOR tl=separated_list(COMMA, located(ty)) SUPERIOR {
|
||||||
|
tl
|
||||||
|
}
|
||||||
|
|
||||||
|
expr_list:
|
||||||
|
| LPAREN el=separated_nonempty_list(COMMA, located(expression)) RPAREN {
|
||||||
|
el
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************** BASIC TYPES *********************************/
|
/******************************** BASIC TYPES *********************************/
|
||||||
|
|
Reference in a new issue