TP-automates/BE/descendant/Scanner.mll
2023-06-21 19:58:18 +02:00

56 lines
2.4 KiB
OCaml
Executable file

{
(* Partie recopiée dans le fichier CaML généré. *)
(* Ouverture de modules exploités dans les actions *)
(* Déclarations de types, de constantes, de fonctions, d'exceptions exploités dans les actions *)
open Tokens
exception Printf
}
(* Déclaration d'expressions régulières exploitées par la suite *)
let chiffre = ['0' - '9']
let entier = ['1' - '9']
let minuscule = ['a' - 'z']
let majuscule = ['A' - 'Z']
let alphabet = minuscule | majuscule
let alphanum = alphabet | chiffre | '_'
let commentaire =
(* Commentaire fin de ligne *)
"#" [^'\n']*
rule scanner = parse
| ['\n' '\t' ' ']+ { (scanner lexbuf) }
| commentaire { (scanner lexbuf) }
| "model" { UL_MODEL::(scanner lexbuf) }
| "system" { UL_SYSTEM::(scanner lexbuf) }
| "block" { UL_BLOCK::(scanner lexbuf) }
| "flow" { UL_FLOW::(scanner lexbuf) }
| "from" { UL_FROM::(scanner lexbuf) }
| "to" { UL_TO::(scanner lexbuf) }
| "in" { UL_IN::(scanner lexbuf) }
| "out" { UL_OUT::(scanner lexbuf) }
| "int" { UL_INT::(scanner lexbuf) }
| "float" { UL_FLOAT::(scanner lexbuf) }
| "boolean" { UL_BOOLEAN::(scanner lexbuf) }
| "{" { UL_ACCOUV::(scanner lexbuf) }
| "}" { UL_ACCFER::(scanner lexbuf) }
| "(" { UL_PAROUV::(scanner lexbuf) }
| ")" { UL_PARFER::(scanner lexbuf) }
| "[" { UL_CROOUV::(scanner lexbuf) }
| "]" { UL_CROFER::(scanner lexbuf) }
| ";" { UL_PTV::(scanner lexbuf) }
| "," { UL_VIRG::(scanner lexbuf) }
| ":" { UL_PT2::(scanner lexbuf) }
| "." { UL_PT::(scanner lexbuf) }
| majuscule alphabet* as texte { (UL_IDENT texte)::(scanner lexbuf) }
| minuscule alphabet* as texte { (UL_PORT texte)::(scanner lexbuf) }
| entier chiffre* as texte { (UL_ENTIER (int_of_string texte))::(scanner lexbuf) }
| eof { [UL_FIN] }
| _ as texte { (print_string "Erreur lexicale : ");(print_char texte);(print_newline ()); (UL_ERREUR::(scanner lexbuf)) }
{
}