124 conflitcs

This commit is contained in:
Nicolas PENELOUX 2023-10-23 17:05:28 +02:00
parent 94fdab56fc
commit bfbcc60c5d
2 changed files with 30 additions and 4 deletions

View file

@ -17,8 +17,31 @@
| None -> "" | None -> ""
in in
error msg (lex_join lexbuf.lex_start_p lexbuf.lex_curr_p) error msg (lex_join lexbuf.lex_start_p lexbuf.lex_curr_p)
(*Fonction qui va convertir une string de caractère ascii en vrai caractère.
On en a besoin pour certains test *)
(*)
let recup_char charac lexbuf =
let taille = String.length charac in
match charac with
| "\\n" -> '\n'
| "\\r" -> '\r'
| "\\t" -> '\t'
| "\\\'" -> '\''
| "\\\\" -> '\\'
| _ ->
(let s2 = String.get charac 1 in
if s2 = '0' || s2 = '1' || s2 = '2' then
(let s=String.sub charac 1 (taille - 1) in
let i = int_of_string s in
Char.chr i)
else error lexbuf )
*)
} }
let newline = ('\010' | '\013' | "\013\010") let newline = ('\010' | '\013' | "\013\010")
let blank = [' ' '\009' '\012'] let blank = [' ' '\009' '\012']
@ -130,10 +153,11 @@ rule token = parse
(* Characters *) (* Characters *)
| "'" (letter as c) "'" { CHAR c } | "'" (letter as c) "'" { CHAR c }
(* | "'" (atom as c) "'" { (* On retire le \ du début (*| "'" (atom as c) "'" {CHAR (recup_char c lexbuf )} (* On retire le \ du début
* TODO: fix *) * TODO: fix *)
(*)
let code = int_of_string (String.sub c 1 ((String.length c) - 2)) let code = int_of_string (String.sub c 1 ((String.length c) - 2))
in CHAR (Char.chr (code)) } *) in CHAR (Char.chr (code)) } *) *)
(** Lexing error *) (** Lexing error *)
(* erreur qui advient pour le test 22-char-literal, le code renvoie bizarrement que "Error (during lexing) "*) (* erreur qui advient pour le test 22-char-literal, le code renvoie bizarrement que "Error (during lexing) "*)

View file

@ -22,13 +22,15 @@
/* TODO: Résoudre tout les shift/reduce conflits */ /* TODO: Résoudre tout les shift/reduce conflits */
%left FUN
%left STRING
%left INT
%right WHILE REF DO %right WHILE REF DO
%left FUN MATCH IF FOR %left LET MATCH IF FOR
%right ARROW %right ARROW
%right SEMICOLON %right SEMICOLON
%left ASSIGN %left ASSIGN
%left LPAREN %left LPAREN
%left LET