home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / Caml Light 0.7 / examples / calc / lexer.mll < prev    next >
Encoding:
Text File  |  1995-06-01  |  465 b   |  17 lines  |  [TEXT/MPS ]

  1. {
  2. #open "parser";;        (* The type token is defined in parser.mli *)
  3. exception Eof;;
  4. }
  5. rule Token = parse
  6.     [` ` `\t`]     { Token lexbuf }     (* skip blanks *)
  7.   | [`\n` ]        { EOL }
  8.   | [`0`-`9`]+     { INT(int_of_string (get_lexeme lexbuf)) }
  9.   | `+`            { PLUS }
  10.   | `-`            { MINUS }
  11.   | `*`            { TIMES }
  12.   | `/`            { DIV }
  13.   | `(`            { LPAREN }
  14.   | `)`            { RPAREN }
  15.   | eof            { raise Eof }
  16. ;;
  17.