ascii table
This commit is contained in:
parent
24860a540f
commit
0fcd634f81
1 changed files with 7 additions and 6 deletions
|
@ -21,7 +21,7 @@
|
|||
|
||||
(* Fonction qui convertie une chaîne de caractère ascii en vrai caractère.
|
||||
* Notamment les escapes : "\n" ou "\000" *)
|
||||
let recup_char data lexbuf =
|
||||
let recup_char data =
|
||||
match data with
|
||||
| "\\n" -> Some '\n'
|
||||
| "\\b" -> Some '\b'
|
||||
|
@ -54,7 +54,7 @@ let octa = "0o" ['0'-'7']+
|
|||
|
||||
(* Définition d'un atom
|
||||
* aka un string qui représente un char, par exemple "\065" = 'A' *)
|
||||
let ascii_table = ['\000'-'\255']
|
||||
let ascii_table = "\\" ['0'-'2'] ['0'-'9'] ['0'-'9'] (* TODO: on déborde de 255 à 299 :( *)
|
||||
let ascii_hex = "\\0x" hex_dig hex_dig
|
||||
let printable = ['\032'-'\038' '\040'-'\127']
|
||||
let escapes = "\\n" | "\\b" | "\\r" | "\\t" | "\\'" | "\\\"" | "\\\\"
|
||||
|
@ -73,13 +73,14 @@ let type_variable = '`' ident
|
|||
(* Littéraux entiers *)
|
||||
|
||||
let int ='-'? digit+
|
||||
| hexa
|
||||
| bina
|
||||
| octa
|
||||
| hexa
|
||||
| bina
|
||||
| octa
|
||||
|
||||
(* Littéraux caractères *)
|
||||
let letter = (digit | ['A'-'Z'] | ['a'-'z'])
|
||||
|
||||
(* tmp *)
|
||||
let ascii_trop_grand = '\\' ['3'-'9']['0'-'9'](['0'-'9'])+
|
||||
|
||||
rule token = parse
|
||||
|
@ -157,7 +158,7 @@ rule token = parse
|
|||
|
||||
(* Characters *)
|
||||
| "'" (letter as c) "'" { CHAR c }
|
||||
| "'" (atom as a) "'" { match recup_char a lexbuf with
|
||||
| "'" (atom as a) "'" { match recup_char a with
|
||||
| Some c -> CHAR c
|
||||
| None -> error lexbuf None "" }
|
||||
|
||||
|
|
Reference in a new issue