Trying to fix Sequence
This commit is contained in:
parent
f8d9068012
commit
0c79e84739
1 changed files with 47 additions and 7 deletions
|
@ -44,6 +44,7 @@
|
||||||
%left PLUS MINUS
|
%left PLUS MINUS
|
||||||
%left SLASH STAR
|
%left SLASH STAR
|
||||||
|
|
||||||
|
%left ref1
|
||||||
%left fun1
|
%left fun1
|
||||||
%left app1
|
%left app1
|
||||||
|
|
||||||
|
@ -174,7 +175,6 @@ simple_pattern:
|
||||||
match l with | [alone] -> Position.value alone | _ -> PTuple(l)
|
match l with | [alone] -> Position.value alone | _ -> PTuple(l)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Annotation de type */
|
/* Annotation de type */
|
||||||
| p=located(simple_pattern) COLON ty=located(ty) {
|
| p=located(simple_pattern) COLON ty=located(ty) {
|
||||||
PTypeAnnotation(p, ty)
|
PTypeAnnotation(p, ty)
|
||||||
|
@ -288,10 +288,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)
|
||||||
}
|
}
|
||||||
|
| LPAREN e=located(expression) COLON t=located(ty) RPAREN {
|
||||||
|
TypeAnnotation(e, t)
|
||||||
|
}
|
||||||
/* 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)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/* Tuple n = 0 - Construction d'un 0-uplet */
|
/* Tuple n = 0 - Construction d'un 0-uplet */
|
||||||
| LPAREN RPAREN {
|
| LPAREN RPAREN {
|
||||||
Tuple([])
|
Tuple([])
|
||||||
|
@ -324,19 +330,49 @@ expr_list:
|
||||||
el
|
el
|
||||||
}
|
}
|
||||||
|
|
||||||
expression:
|
mid_expression:
|
||||||
|e=simple_expression{
|
|e=simple_expression{
|
||||||
e
|
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=mid_expression {
|
||||||
|
e
|
||||||
|
}
|
||||||
/* Field - Projection d’un champ */
|
/* Field - Projection d’un champ */
|
||||||
|
/*
|
||||||
| e=located(expression) DOT l=located(label_identifier) tl=option(type_list) {
|
| e=located(expression) DOT l=located(label_identifier) tl=option(type_list) {
|
||||||
Field(e, l, tl)
|
Field(e, l, tl)
|
||||||
}
|
}
|
||||||
/* Sequence - Séquencement *
|
/* Sequence - Séquencement *
|
||||||
* Pas sûr, voir s'il ne faut pas une troisième couche d'expression */
|
* 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)
|
Sequence(e :: e_list)
|
||||||
|
}*/
|
||||||
|
|
||||||
|
| e=located(expression) SEMICOLON e2=located(expression){
|
||||||
|
Sequence([e;e2])
|
||||||
}
|
}
|
||||||
/* | e1=located(expression) SEMICOLON e2=located(expression) {
|
/* | e1=located(expression) SEMICOLON e2=located(expression) {
|
||||||
Sequence([e1; e2])
|
Sequence([e1; e2])
|
||||||
|
@ -350,6 +386,7 @@ expression:
|
||||||
Fun(FunctionDefinition(p, e))
|
Fun(FunctionDefinition(p, e))
|
||||||
}
|
}
|
||||||
/* Application */
|
/* Application */
|
||||||
|
/*
|
||||||
| e1=located(expression) e2=located(expression) %prec app1 {
|
| e1=located(expression) e2=located(expression) %prec app1 {
|
||||||
Apply(e1, e2)
|
Apply(e1, e2)
|
||||||
}
|
}
|
||||||
|
@ -430,11 +467,14 @@ expression:
|
||||||
}
|
}
|
||||||
/* Parenthésage
|
/* Parenthésage
|
||||||
* Pas sûr mais je vois pas sinon */
|
* 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