From 9b29e8fb8c8e7e31d46b67630d055db5caf33962 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Tue, 17 Oct 2023 17:48:00 +0200 Subject: [PATCH] tokens --- flap/src/hopix/hopixParser.mly | 39 +++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/flap/src/hopix/hopixParser.mly b/flap/src/hopix/hopixParser.mly index cc671a1..1975ea5 100644 --- a/flap/src/hopix/hopixParser.mly +++ b/flap/src/hopix/hopixParser.mly @@ -5,10 +5,9 @@ %} -/* Opérateurs à ajouter au fur et a mesure (pour réduire les warnings temporairement) : - * 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 INFERIOR SUPERIOR +%token RPAREN LBRACK RBRACK LBRACE RBRACE INFERIOR SUPERIOR BINOP DO ELSE FOR +%token FROM IF MATCH PIPE REF THEN TO UNTIL WHILE %token INT %token ID TID CID @@ -84,36 +83,42 @@ pattern: } -/* Ici on a un conflit entre : +/* 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)) * [ 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: + */ +simple_ty: /* Application d'un constructeur de type */ | tc=type_constructor l=list_ty { TyCon(tc, l) } +/* Variables de type */ +| type_var=type_variable { + TyVar(type_var) + } +/* Type entre parenthèses */ +| LPAREN ty1=ty RPAREN { + ty1 + } + + +ty: +/* Un type peut être un simple_type */ +| t=simple_ty { + t + } /* Fonctions */ | ty1=located(ty) ARROW ty2=located(ty) { TyArrow(ty1, ty2) } /* N-uplets (N > 1) */ -| th=located(ty) STAR tt=separated_nonempty_list(STAR, located(ty)) { +| th=located(simple_ty) STAR tt=separated_nonempty_list(STAR, located(simple_ty)) { TyTuple(th :: tt) } -/* 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: