]> matita.cs.unibo.it Git - helm.git/blob - helm/DEVEL/pxp/pxp/tools/ucs2_to_utf8/lexer.mll
- the mathql interpreter is not helm-dependent any more
[helm.git] / helm / DEVEL / pxp / pxp / tools / ucs2_to_utf8 / lexer.mll
1 {
2 (******************************************************)
3 (*    Claudio Sacerdoti Coen <sacerdot@cs.unibo.it>   *)
4 (*                   14/05/2000                       *)
5 (******************************************************)
6
7 open Parser
8
9 let comment_depth = ref 0;;
10
11 let charint_of_lexeme l =
12  String.set l 0 '0' ;
13  int_of_string l
14 ;;
15 }
16
17 let digit = ['0'-'9']|['A'-'F']
18
19 rule token =
20  parse
21     [' ' '\t' '\n']                           { token lexbuf }
22   | "let"                                     { LET }
23   | (['a'-'z']|'_')(['a'-'z']|['A'-'Z']|'_'|['0'-'9']|'\'')*
24                                               { IDENT (Lexing.lexeme lexbuf) }
25   | '='                                       { EQ }
26   | ";;"                                      { END_OF_LET }
27   | "|"                                       { PIPE }
28   | '['                                       { LBRACKET }
29   | ']'                                       { RBRACKET }
30   | '-'                                       { RANGE }
31   | "(*"                                      { incr comment_depth ;
32                                                 comment lexbuf
33                                               }
34   | "#x" digit digit digit digit              { CHAR (charint_of_lexeme (Lexing.lexeme lexbuf)) }
35   | eof                                       { EOF }
36
37 and comment =
38  parse
39     "(*" { incr comment_depth ; comment lexbuf }
40   | "*)" { decr comment_depth ;
41            if !comment_depth = 0 then token lexbuf else comment lexbuf
42          }
43   | _    { comment lexbuf }