From 9444102aeab3c611ec5d55fef0a629f2edfc13a8 Mon Sep 17 00:00:00 2001 From: Nicolas PENELOUX Date: Tue, 24 Oct 2023 15:20:11 +0200 Subject: [PATCH 1/2] =?UTF-8?q?Lexer=20g=C3=A8re=20mieux=20les=20nombres?= =?UTF-8?q?=20d=C3=A9sormais?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flap/src/hopix/hopixLexer.mll | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/flap/src/hopix/hopixLexer.mll b/flap/src/hopix/hopixLexer.mll index 3ecb07c..d1e8f92 100644 --- a/flap/src/hopix/hopixLexer.mll +++ b/flap/src/hopix/hopixLexer.mll @@ -45,9 +45,9 @@ let blank = [' ' '\009' '\012'] let hex_dig = ['0'-'9' 'a'-'f' 'A'-'F'] let digit = ['0'-'9'] -let hexa = "0x" hex_dig -let bina = "0b" ['0'-'1'] -let octa = "0o" ['0'-'7'] +let hexa = "0x" hex_dig+ +let bina = "0b" ['0'-'1']+ +let octa = "0o" ['0'-'7']+ (* Définition d'un atom @@ -69,7 +69,11 @@ let constr_id = ['A'-'Z']['A'-'Z' 'a'-'z' '0'-'9' '_']* (* Identificateur de variables de type *) let type_variable = '`' ident (* Littéraux entiers *) -let int = '-'? (digit+ | hexa+ | bina+ | octa+) +(*let int = '-'? (digit+ | hexa | bina | octa)*) +let int = '-'? ['0'-'9']+ +| "0x" ['0'-'9' 'a'-'f' 'A'-'F']+ +| "0b" ['0'-'1']+ +| "0o" ['0'-'7']+ (* Littéraux caractères *) let letter = (digit | ['A'-'Z'] | ['a'-'z']) From 862a4b78356e19b7d34a7a6cae5bc300bc18001a Mon Sep 17 00:00:00 2001 From: Nicolas PENELOUX Date: Tue, 24 Oct 2023 15:25:55 +0200 Subject: [PATCH 2/2] int plus propre --- flap/src/hopix/hopixLexer.mll | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/flap/src/hopix/hopixLexer.mll b/flap/src/hopix/hopixLexer.mll index d1e8f92..630f966 100644 --- a/flap/src/hopix/hopixLexer.mll +++ b/flap/src/hopix/hopixLexer.mll @@ -69,11 +69,12 @@ let constr_id = ['A'-'Z']['A'-'Z' 'a'-'z' '0'-'9' '_']* (* Identificateur de variables de type *) let type_variable = '`' ident (* Littéraux entiers *) -(*let int = '-'? (digit+ | hexa | bina | octa)*) -let int = '-'? ['0'-'9']+ -| "0x" ['0'-'9' 'a'-'f' 'A'-'F']+ -| "0b" ['0'-'1']+ -| "0o" ['0'-'7']+ + +let int ='-'? digit+ +| hexa +| bina +| octa + (* Littéraux caractères *) let letter = (digit | ['A'-'Z'] | ['a'-'z'])