diff --git a/flap/src/hopix/hopixParser.mly b/flap/src/hopix/hopixParser.mly index f2e55cc..61ba393 100644 --- a/flap/src/hopix/hopixParser.mly +++ b/flap/src/hopix/hopixParser.mly @@ -256,18 +256,18 @@ simple_expression: | i=located(identifier) tl=option(type_list) { Variable(i, tl) } - -/* Tuple n = 0 and n > 1 - Construction d'un 0-uplet */ +/* Tagged Value - Construction d'une donnée */ +| const=located(constructor) tl=option(type_list) el=optionlist(expr_list) { + Tagged(const, tl, el) + } +/* Tuple n = 0 - Construction d'un 0-uplet */ | LPAREN RPAREN { Tuple([]) } /* Tuple n > 1 - Construction d'un n-uplet (n > 1) */ | el=expr_list { - Tuple(el) - } -/* Tagged Value - Construction d'une donnée */ -| const=located(constructor) tl=option(type_list) el=optionlist(expr_list) { - Tagged(const, tl, el) + (* S'il y a qu'1 élément, alors c'est juste une expression *) + match el with | [alone] -> Position.value alone | _ -> Tuple(el) } /* Record - Construction d'un enregistrement */ | LBRACE l=separated_nonempty_list( @@ -283,7 +283,7 @@ simple_expression: } type_list: -| INFERIOR tl=optionlist(separated_nonempty_list(COMMA, located(ty))) SUPERIOR { +| INFERIOR tl=separated_list(COMMA, located(ty)) SUPERIOR { tl } @@ -292,7 +292,6 @@ expr_list: el } - expression: | e=simple_expression { e @@ -302,7 +301,7 @@ expression: Field(e, l, tl) } /* Sequence - Séquencement * - * Pas sûr, voir s'il ne fuat 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)) { Sequence(e :: e_list) @@ -405,8 +404,6 @@ expression: } - - /******************************** BASIC TYPES *********************************/ type_variable: | tid=TID {