This repository has been archived on 2024-01-18. You can view files and clone it, but cannot push or open issues or pull requests.
compilation/tp/tp-menhir/code/lexer.mll

18 lines
427 B
OCaml
Raw Permalink Normal View History

2023-10-02 09:39:12 +02:00
{ (* Emacs, open this file with -*- tuareg -*- *)
open Parser
}
let layout = ' ' | '\t' | '\n'
let number = ['0'-'9']+
let identifier = ['a'-'z']['A'-'Z' '0'-'9' 'a'-'z' '_']*
rule token = parse
| eof { EOF }
| layout { token lexbuf }
| number as i { INT (int_of_string i) }
| identifier as s { ID s }
| "+" { PLUS }
| _ as c {
failwith (Printf.sprintf "Invalid character: %c\n" c)
}