Source

lambda-translator / lexer.mll

Full commit
  
{
(*  open Term        (* The type token is defined in parser.mli *)*)
  type t = 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 }