]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/components/content_pres/cicNotationLexer.ml
notation with mstyle attributes, like colors and size
[helm.git] / helm / software / components / content_pres / cicNotationLexer.ml
index bd071c5b9a6da869dc1384ac7264a5c83ce20bcb..4221417a0183dbf19a2e54cf140a802fdaad9ba4 100644 (file)
@@ -30,7 +30,12 @@ open Printf
 exception Error of int * int * string
 
 let regexp number = xml_digit+
-let regexp utf8_blank = " " | "\n" | "\t" | [160] (* this is a nbsp *)
+let regexp utf8_blank = " " | "\r\n" | "\n" | "\t" | [160] (* this is a nbsp *)
+let regexp floatwithunit = 
+  [ '0' - '9' ] + ["."] [ '0' - '9' ] + ([ 'a' - 'z' ] + | "" )
+let regexp color = "#" [ '0' - '9' 'a' - 'f' 'A' - 'F' ] [ '0' - '9' 'a' - 'f'
+'A' - 'F' ] [ '0' - '9' 'a' - 'f' 'A' - 'F' ] [ '0' - '9' 'a' - 'f' 'A' - 'F' ]
+[ '0' - '9' 'a' - 'f' 'A' - 'F' ] [ '0' - '9' 'a' - 'f' 'A' - 'F' ]
 
   (* ZACK: breaks unicode's binder followed by an ascii letter without blank *)
 (* let regexp ident_letter = xml_letter *)
@@ -50,6 +55,10 @@ let is_ligature_char =
       true
     with Not_found -> false))
 
+let regexp we_proved = "we" utf8_blank+ "proved"
+let regexp we_have = "we" utf8_blank+ "have"
+let regexp let_rec = "let" utf8_blank+ "rec" 
+let regexp let_corec = "let" utf8_blank+  "corec"
 let regexp ident_decoration = '\'' | '?' | '`'
 let regexp ident_cont = ident_letter | xml_digit | '_'
 let regexp ident = ident_letter ident_cont* ident_decoration*
@@ -94,7 +103,7 @@ let level1_keywords =
     "break";
     "list0"; "list1"; "sep";
     "opt";
-    "term"; "ident"; "number"
+    "term"; "ident"; "number"; "mstyle"
   ] @ level1_layouts
 
 let level2_meta_keywords =
@@ -109,8 +118,8 @@ let level2_meta_keywords =
 let level2_ast_keywords = Hashtbl.create 23
 let _ =
   List.iter (fun k -> Hashtbl.add level2_ast_keywords k ())
-  [ "CProp"; "Prop"; "Type"; "Set"; "let"; "rec"; "corec"; "match";
-    "with"; "in"; "and"; "to"; "as"; "on"; "return" ]
+  [ "CProp"; "Prop"; "Type"; "Set"; "let"; "match";
+  "with"; "in"; "and"; "to"; "as"; "on"; "return"; "done" ]
 
 let add_level2_ast_keyword k = Hashtbl.add level2_ast_keywords k ()
 let remove_level2_ast_keyword k = Hashtbl.remove level2_ast_keywords k
@@ -274,6 +283,10 @@ let rec ligatures_token k =
 
 and level2_ast_token =
   lexer
+  | let_rec -> return lexbuf ("LETREC","")
+  | let_corec -> return lexbuf ("LETCOREC","")
+  | we_proved -> return lexbuf ("WEPROVED","")
+  | we_have -> return lexbuf ("WEHAVE","")
   | utf8_blank+ -> ligatures_token level2_ast_token lexbuf
   | meta ->
      let s = Ulexing.utf8_lexeme lexbuf in
@@ -325,6 +338,9 @@ and level1_pattern_token =
          else
            return lexbuf ("IDENT", s)
        end
+  | color -> return lexbuf ("COLOR", Ulexing.utf8_lexeme lexbuf)
+  | floatwithunit -> 
+      return lexbuf ("FLOATWITHUNIT", Ulexing.utf8_lexeme lexbuf)
   | tex_token -> return lexbuf (expand_macro lexbuf)
   | qkeyword ->
       return lexbuf ("QKEYWORD", remove_quotes (Ulexing.utf8_lexeme lexbuf))