136 -> 30 conflicts

This commit is contained in:
Nicolas PENELOUX 2023-10-24 13:29:57 +02:00
parent cd04e3c0fc
commit 5f48faa278

View file

@ -1,6 +1,7 @@
%{ (* -*- tuareg -*- *)
open HopixAST
(* open Position *)
%}
@ -15,30 +16,40 @@
%token<char> CHAR
%start<HopixAST.t> program
/* TODO: Résoudre tout les shift/reduce conflits */
%left FUN
%left STRING
%left INT
%right WHILE REF DO
%left LET MATCH IF FOR
%right ARROW
%right SEMICOLON
%left ASSIGN
%left LPAREN
%left let1
%left FUN
%left STRING
%left INT CID CHAR WHILE
%left ID
%right REF DO
%left LET MATCH IF FOR
%right ARROW
%right SEMICOLON
%left DOT
%left ASSIGN
%left LBRACE
%left BACKSLASH
%left EXCLA COLON
/* Priorités binop */
%left EXCLA COLON
/* priorités binop */
%left D_OR
%left D_AND
%left EQUAL_OP INF_EQUAL_OP INF_OP SUP_EQUAL_OP SUP_OP
%left PLUS MINUS
%left SLASH STAR
%left let1
%left fun1
@ -116,14 +127,14 @@ label_with_type:
vdefinition:
/* Valeur simple */
| LET i=located(identifier) ts=option(vdef_type_scheme)
EQUAL e=located(expression) %prec let1 {
SimpleValue(i, ts, e)
EQUAL e=located(expression) %prec let1{
SimpleValue(i, ts, e)
}
/* Fonction(s)
* Exemple :
* - fun : int f a = 1
* - fun f a = 1 and : int g a = 2 */
| FUN fl=separated_nonempty_list(AND_KW, fundef) {
| FUN fl=separated_nonempty_list(AND_KW, fundef) {
RecFunctions(fl)
}
@ -331,13 +342,16 @@ expression:
}
/* Sequence - Séquencement *
* 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)
}
/* | e1=located(expression) SEMICOLON e2=located(expression) {
Sequence([e1; e2])
} */
/*
|e1=located(expression) SEMICOLON e2=located(expression){
Sequence([e1;e2])
}*/
/* Definition locale */
| vd=vdefinition SEMICOLON e=located(expression) {
Define(vd, e)