X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fcic_notation%2FcicNotationLexer.ml;h=33fb8fd78494085a819c9d65fb11e2020a654c42;hb=97c2d258a5c524eb5c4b85208899d80751a2c82f;hp=17d77f9028e46dcde96f2287902d24dbc959d692;hpb=921ba3b356400323b440a073a7030c5386d3b421;p=helm.git diff --git a/helm/ocaml/cic_notation/cicNotationLexer.ml b/helm/ocaml/cic_notation/cicNotationLexer.ml index 17d77f902..33fb8fd78 100644 --- a/helm/ocaml/cic_notation/cicNotationLexer.ml +++ b/helm/ocaml/cic_notation/cicNotationLexer.ml @@ -107,7 +107,7 @@ 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" ] + "with"; "in"; "and"; "to"; "as"; "on"; "return" ] let add_level2_ast_keyword k = Hashtbl.add level2_ast_keywords k () let remove_level2_ast_keyword k = Hashtbl.remove level2_ast_keywords k @@ -123,9 +123,12 @@ let _ = ("<>", <:unicode>); (":=", <:unicode>); ] +let regexp uri_step = [ 'a' - 'z' 'A' - 'Z' '0' - '9' '_' '-' ]+ + let regexp uri = ("cic:/" | "theory:/") (* schema *) - ident ('/' ident)* (* path *) +(* ident ('/' ident)* |+ path +| *) + uri_step ('/' uri_step)* (* path *) ('.' ident)+ (* ext *) ("#xpointer(" number ('/' number)+ ")")? (* xpointer *) @@ -255,14 +258,12 @@ let rec comment_token acc depth = let acc = acc ^ Ulexing.utf8_lexeme lexbuf in comment_token acc depth lexbuf -let lookup_ligatures lexeme = List.rev (Hashtbl.find_all ligatures lexeme) - (** @param k continuation to be invoked when no ligature has been found *) let rec ligatures_token k = lexer | ligature -> let lexeme = Ulexing.utf8_lexeme lexbuf in - (match lookup_ligatures lexeme with + (match List.rev (Hashtbl.find_all ligatures lexeme) with | [] -> (* ligature not found, rollback and try default lexer *) Ulexing.rollback lexbuf; k lexbuf @@ -341,3 +342,10 @@ let level1_pattern_lexer = mk_lexer level1_pattern_token let level2_ast_lexer = mk_lexer level2_ast_token let level2_meta_lexer = mk_lexer level2_meta_token +let lookup_ligatures lexeme = + try + if lexeme.[0] = '\\' + then [ Utf8Macro.expand (String.sub lexeme 1 (String.length lexeme - 1)) ] + else List.rev (Hashtbl.find_all ligatures lexeme) + with Invalid_argument _ | Utf8Macro.Macro_not_found _ as exn -> [] +