Source

lambda-translator / lexer.mll

{
  type token = Lambda | Dot | Ident of string | Open | Close
| Int of int | EOL
  exception Eof
}

let digit = ['0'-'9']
let alpha = ['A'-'Z' 'a'-'z' '_']

rule token = parse
  [' ' '\t']     { token lexbuf }     (* skip blanks *)
| ['\n' ]        { EOL }
| "lambda"       { Lambda }
| '\\'           { Lambda }
| '.'            { Dot }
| '('            { Open }
| ')'            { Close }
| alpha (digit|alpha)*
    { Ident (Lexing.lexeme lexbuf) }
| ['0'-'9']+     { Int (int_of_string(Lexing.lexeme lexbuf)) }
| eof            { raise Eof }