From bfbcc60c5d4b1244bec72437dca2a2ba3ff9ba7d Mon Sep 17 00:00:00 2001 From: Nicolas PENELOUX Date: Mon, 23 Oct 2023 17:05:28 +0200 Subject: [PATCH] 124 conflitcs --- flap/src/hopix/hopixLexer.mll | 28 ++++++++++++++++++++++++++-- flap/src/hopix/hopixParser.mly | 6 ++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/flap/src/hopix/hopixLexer.mll b/flap/src/hopix/hopixLexer.mll index 0310fe5..ce3a926 100644 --- a/flap/src/hopix/hopixLexer.mll +++ b/flap/src/hopix/hopixLexer.mll @@ -17,8 +17,31 @@ | None -> "" in 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 blank = [' ' '\009' '\012'] @@ -130,10 +153,11 @@ rule token = parse (* Characters *) | "'" (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 *) + (*) 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 *) (* erreur qui advient pour le test 22-char-literal, le code renvoie bizarrement que "Error (during lexing) "*) diff --git a/flap/src/hopix/hopixParser.mly b/flap/src/hopix/hopixParser.mly index bb03730..0898f95 100644 --- a/flap/src/hopix/hopixParser.mly +++ b/flap/src/hopix/hopixParser.mly @@ -22,13 +22,15 @@ /* TODO: Résoudre tout les shift/reduce conflits */ +%left FUN +%left STRING +%left INT %right WHILE REF DO -%left FUN MATCH IF FOR +%left LET MATCH IF FOR %right ARROW %right SEMICOLON %left ASSIGN %left LPAREN -%left LET