]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/DEVEL/pxp/pxp/tools/ucs2_to_utf8/lexer.mll
Initial revision
[helm.git] / helm / DEVEL / pxp / pxp / tools / ucs2_to_utf8 / lexer.mll
diff --git a/helm/DEVEL/pxp/pxp/tools/ucs2_to_utf8/lexer.mll b/helm/DEVEL/pxp/pxp/tools/ucs2_to_utf8/lexer.mll
new file mode 100644 (file)
index 0000000..dfbeb5a
--- /dev/null
@@ -0,0 +1,43 @@
+{
+(******************************************************)
+(*    Claudio Sacerdoti Coen <sacerdot@cs.unibo.it>   *)
+(*                   14/05/2000                       *)
+(******************************************************)
+
+open Parser
+
+let comment_depth = ref 0;;
+
+let charint_of_lexeme l =
+ String.set l 0 '0' ;
+ int_of_string l
+;;
+}
+
+let digit = ['0'-'9']|['A'-'F']
+
+rule token =
+ parse
+    [' ' '\t' '\n']                           { token lexbuf }
+  | "let"                                     { LET }
+  | (['a'-'z']|'_')(['a'-'z']|['A'-'Z']|'_'|['0'-'9']|'\'')*
+                                              { IDENT (Lexing.lexeme lexbuf) }
+  | '='                                       { EQ }
+  | ";;"                                      { END_OF_LET }
+  | "|"                                       { PIPE }
+  | '['                                       { LBRACKET }
+  | ']'                                       { RBRACKET }
+  | '-'                                       { RANGE }
+  | "(*"                                      { incr comment_depth ;
+                                                comment lexbuf
+                                              }
+  | "#x" digit digit digit digit              { CHAR (charint_of_lexeme (Lexing.lexeme lexbuf)) }
+  | eof                                       { EOF }
+
+and comment =
+ parse
+    "(*" { incr comment_depth ; comment lexbuf }
+  | "*)" { decr comment_depth ;
+           if !comment_depth = 0 then token lexbuf else comment lexbuf
+         }
+  | _    { comment lexbuf }