type conflict
This commit is contained in:
parent
3dc4a1068c
commit
0e81edc636
1 changed files with 31 additions and 14 deletions
|
@ -6,9 +6,9 @@
|
|||
%}
|
||||
|
||||
/* Opérateurs à ajouter au fur et a mesure (pour réduire les warnings temporairement) :
|
||||
* BINOP DO ELSE FOR FROM IF INFERIOR MATCH PIPE REF SUPERIOR THEN TO UNTIL WHILE */
|
||||
* BINOP DO ELSE FOR FROM IF MATCH PIPE REF THEN TO UNTIL WHILE */
|
||||
%token EOF LET TYPE WILDCARD STAR ARROW DPOINT EXTERN FUN COMMA AND EQUAL LPAREN
|
||||
%token RPAREN LBRACK RBRACK LBRACE RBRACE
|
||||
%token RPAREN LBRACK RBRACK LBRACE RBRACE INFERIOR SUPERIOR
|
||||
|
||||
%token<Mint.t> INT
|
||||
%token<string> ID TID CID
|
||||
|
@ -84,25 +84,42 @@ pattern:
|
|||
}
|
||||
|
||||
|
||||
/* Ici on a un conflit entre :
|
||||
* 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 * [ ty ]
|
||||
*
|
||||
* En gros il sait pas si il doit interpréter le premier type en tant que type
|
||||
* ou en tant que list de type de 1 élément */
|
||||
ty:
|
||||
/* Temporaire None - compile pas */
|
||||
/* | tc=type_constructor {
|
||||
TyCon(tc, None)
|
||||
} */
|
||||
|
||||
/* Todo version avec l'optionnel */
|
||||
/* Application d'un constructeur de type */
|
||||
| tc=type_constructor l=list_ty {
|
||||
TyCon(tc, l)
|
||||
}
|
||||
/* Fonctions */
|
||||
| ty1=located(ty) ARROW ty2=located(ty) {
|
||||
TyArrow(ty1, ty2)
|
||||
}
|
||||
| ty1=located(ty) STAR ty2=located(ty) {
|
||||
TyTuple([ty1; ty2])
|
||||
/* N-uplets (N > 1) */
|
||||
| th=located(ty) STAR tt=separated_nonempty_list(STAR, located(ty)) {
|
||||
TyTuple(th :: tt)
|
||||
}
|
||||
| ty1=located(ty) STAR ty2=located(ty) STAR liste_ty=separated_list(STAR, located(ty)) {
|
||||
TyTuple(ty1::ty2::liste_ty)
|
||||
}
|
||||
| LPAREN type_var=type_variable RPAREN {
|
||||
/* Variables de type */
|
||||
| type_var=type_variable {
|
||||
TyVar type_var
|
||||
}
|
||||
/* Type entre parenthèses */
|
||||
| LPAREN ty1=ty RPAREN {
|
||||
ty1
|
||||
}
|
||||
|
||||
/* Auxilliaire pour TyCon dans ty */
|
||||
list_ty:
|
||||
| INFERIOR tl=separated_list(COMMA, located(ty)) SUPERIOR {
|
||||
tl
|
||||
}
|
||||
|
||||
|
||||
type_scheme:
|
||||
|
|
Reference in a new issue