X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fcic_notation%2FcicNotationLexer.ml;fp=helm%2Focaml%2Fcic_notation%2FcicNotationLexer.ml;h=b5cd026d6946cc45c2f5e5b811e5be727e847951;hb=34113d572c334c351ba66f4b05db503eed4d48f2;hp=92204cfb74221f9ae195c4ee2cd8b29f408a3f9c;hpb=7df7f06d2bc2a3fe1fe95aab957cef480d27eb86;p=helm.git diff --git a/helm/ocaml/cic_notation/cicNotationLexer.ml b/helm/ocaml/cic_notation/cicNotationLexer.ml index 92204cfb7..b5cd026d6 100644 --- a/helm/ocaml/cic_notation/cicNotationLexer.ml +++ b/helm/ocaml/cic_notation/cicNotationLexer.ml @@ -29,19 +29,24 @@ exception Error of int * int * string let regexp number = xml_digit+ + (* ZACK: breaks unicode's binder followed by an ascii letter without blank *) +(* let regexp ident_letter = xml_letter *) + +let regexp ident_letter = [ 'a' - 'z' 'A' - 'Z' ] + let regexp ident_decoration = '\'' | '!' | '?' | '`' -let regexp ident_cont = xml_letter | xml_digit | '_' -let regexp ident = xml_letter ident_cont* ident_decoration* +let regexp ident_cont = ident_letter | xml_digit | '_' +let regexp ident = ident_letter ident_cont* ident_decoration* let regexp tex_token = '\\' ident let regexp delim_begin = "\\[" let regexp delim_end = "\\]" -let regexp keyword = '"' ident '"' let regexp qkeyword = "'" ident "'" let regexp implicit = '?' +let regexp placeholder = '%' let regexp meta = implicit number let regexp csymbol = '\'' ident @@ -55,6 +60,11 @@ let regexp meta_ident = "$" ident let regexp meta_anonymous = "$_" let regexp qstring = '"' [^ '"']* '"' +let regexp begincomment = "(**" xml_blank +let regexp endcomment = "*)" +let regexp comment_char = [^'*'] | '*'[^')'] +let regexp note = "(*" ([^'*'] | "**") comment_char* "*)" + let level1_layouts = [ "sub"; "sup"; "below"; "above"; @@ -150,8 +160,6 @@ let expand_macro lexbuf = ("SYMBOL", Utf8Macro.expand macro) with Utf8Macro.Macro_not_found _ -> "SYMBOL", Ulexing.utf8_lexeme lexbuf -let keyword lexbuf = "KEYWORD", remove_quotes (Ulexing.utf8_lexeme lexbuf) - let remove_quotes s = String.sub s 1 (String.length s - 2) let remove_left_quote s = String.sub s 1 (String.length s - 1) @@ -196,7 +204,8 @@ let rec level2_meta_token = lexer let rec level2_ast_token = lexer | xml_blank+ -> level2_ast_token lexbuf | meta -> return lexbuf ("META", Ulexing.utf8_lexeme lexbuf) - | implicit -> return lexbuf ("IMPLICIT", Ulexing.utf8_lexeme lexbuf) + | implicit -> return lexbuf ("IMPLICIT", "") + | placeholder -> return lexbuf ("PLACEHOLDER", "") | ident -> let lexeme = Ulexing.utf8_lexeme lexbuf in if Hashtbl.mem level2_ast_keywords lexeme then @@ -204,7 +213,6 @@ let rec level2_ast_token = lexer else return lexbuf ("IDENT", lexeme) | number -> return lexbuf ("NUMBER", Ulexing.utf8_lexeme lexbuf) - | keyword -> return lexbuf (keyword lexbuf) | tex_token -> return lexbuf (expand_macro lexbuf) | uri -> return lexbuf ("URI", Ulexing.utf8_lexeme lexbuf) | qstring -> @@ -218,8 +226,15 @@ let rec level2_ast_token = lexer return lexbuf ("UNPARSED_META", remove_left_quote (Ulexing.utf8_lexeme lexbuf)) | meta_anonymous -> return lexbuf ("UNPARSED_META", "anonymous") - | _ -> return lexbuf ("SYMBOL", Ulexing.utf8_lexeme lexbuf) + | note -> + let comment = + Ulexing.utf8_sub_lexeme lexbuf 2 (Ulexing.lexeme_length lexbuf - 4) + in + return lexbuf ("NOTE", comment) + | begincomment -> return lexbuf ("BEGINCOMMENT","") + | endcomment -> return lexbuf ("ENDCOMMENT","") | eof -> return lexbuf ("EOI", "") + | _ -> return lexbuf ("SYMBOL", Ulexing.utf8_lexeme lexbuf) let rec level1_pattern_token = lexer | xml_blank+ -> level1_pattern_token lexbuf