pieuvre/lexer.mll
2024-04-09 11:09:33 +02:00

30 lines
703 B
OCaml

{
open Parser
exception Eof
}
let lowercase = ['a'-'z']
let uppercase = ['A'-'Z']
let digit = ['0'-'9']
let word = (lowercase | uppercase)*
let var_id = lowercase lowercase* digit*
let ty_id = uppercase word digit*
rule token = parse
| [' ' '\t'] { token lexbuf }
| '\n' { EOL }
| '+' { PLUS }
| '*' { TIMES }
| '1' { TOP }
| '0' { BOTTOM }
| '(' { LPAREN }
| ')' { RPAREN }
| "FUN" { FUN }
| ':' { COLON }
| "=>" { ARR }
| "exf" { EXFALSO }
| var_id as s { VARID(s) }
| ty_id as s { TYID(s) }
| eof { raise Eof }