let regexp paren = [ '(' '[' '{' ')' ']' '}' ]
let regexp implicit = '?'
let regexp symbol_char =
- [^ 'a' - 'z' 'A' - 'Z' '0' - '9' ' ' '\t' '\n' '\\' '(' '[' '{' ')' ']' '}' ]
-
+ [^ 'a' - 'z' 'A' - 'Z' '0' - '9'
+ ' ' '\t' '\n'
+ '\\' '(' '[' '{' ')' ']' '}' '?'
+ ]
let regexp blanks = blank+
let regexp num = digit+
let regexp tex_token = '\\' alpha+
let regexp meta = implicit num
let regexp qstring = '"' [^ '"']* '"'
let regexp uri =
- (* schema *) (* path *) (* ext *) (* xpointer *)
- ("cic:/" | "theory:/") ident ('/' ident)* ('.' ident)+ ('#' num ('/' num)*)?
+ ("cic:/" | "theory:/") (* schema *)
+ ident ('/' ident)* (* path *)
+ ('.' ident)+ (* ext *)
+ ("#xpointer(" num ('/' num)+ ")")? (* xpointer *)
(* let regexp catchall = .* *)
let keywords = Hashtbl.create 17
Cic.LetIn (Cic.Name var, Cic.CoFix (!counter, funs), cic))
in
List.fold_right (build_term inductiveFuns) inductiveFuns cic_body
- | CicAst.Ident (name, subst) ->
+ | CicAst.Ident (name, subst)
+ | CicAst.Uri (name, subst) as ast ->
+ let is_uri = function CicAst.Uri _ -> true | _ -> false in
(try
+ if is_uri ast then raise Not_found;(* don't search the env for URIs *)
let index = find_in_environment name context in
if subst <> None then
CicTextualParser2.fail loc
"Explicit substitutions not allowed here";
Cic.Rel index
with Not_found ->
- let cic = resolve env (Id name) () in
+ let cic =
+ if is_uri ast then (* we have the URI, build the term out of it *)
+ try
+ CicUtil.term_of_uri name
+ with UriManager.IllFormedUri _ ->
+ CicTextualParser2.fail loc "Ill formed URI"
+ else
+ resolve env (Id name) ()
+ in
let mk_subst uris =
let ids_to_uris =
List.map (fun uri -> UriManager.name_of_uri uri, uri) uris
let dom' = aux loc context term in
dom' @ dom)
[Id name] subst))
+ | CicAst.Uri _ -> []
| CicAst.Implicit -> []
| CicAst.Num (num, i) -> [ Num i ]
| CicAst.Meta (index, local_context) ->
let size1 = countvar c var in
countterm size1 s) current_size l in
countterm size1 t
- | A.Ident(s,None) -> current_size + (String.length s)
- | A.Ident(s,Some l) ->
+ | A.Ident (s,None)
+ | A.Uri (s, None) -> current_size + (String.length s)
+ | A.Ident (s,Some l)
+ | A.Uri (s,Some l) ->
List.fold_left
(fun c (v,t) -> countterm (c + (String.length v)) t)
(current_size + (String.length s)) l
make_defs "let rec" vars in
Box.V(make_attributes [Some "helm","xref"] [xref],
definitions@[ast2box ~tail body])
- | A.Ident (s, subst) ->
+ | A.Ident (s, subst)
+ | A.Uri (s, subst) ->
let subst =
let rec make_substs start_txt =
function
| A.Symbol (name,_) ->
let attr = make_std_attributes xref in
P.Mi (attr,name)
- | A.Ident (name,subst) ->
+ | A.Ident (name,subst)
+ | A.Uri (name,subst) ->
let attr = make_std_attributes xref in
let rec make_subst =
(function
sprintf "%s = %s" (pp_capture_variable var) (pp_term body))
definitions))
(pp_term term)
- | CicAst.Ident (name, Some [])
- | CicAst.Ident (name, None) ->
+ | CicAst.Ident (name, Some []) | CicAst.Ident (name, None)
+ | CicAst.Uri (name, Some []) | CicAst.Uri (name, None) ->
name
- | CicAst.Ident (name, Some substs) -> sprintf "%s \\subst [%s]" name (pp_substs substs)
+ | CicAst.Ident (name, Some substs)
+ | CicAst.Uri (name, Some substs) ->
+ sprintf "%s \\subst [%s]" name (pp_substs substs)
| CicAst.Implicit -> "?"
| CicAst.Meta (index, substs) ->
sprintf "%d[%s]" index