- and aux_symbol s loc = function
- | _, None -> Ast.AttributedTerm (`Loc loc, Ast.Symbol (s, None))
- | uri, Some desc ->
- Ast.AttributedTerm (`Loc loc, Ast.Symbol (s, Some (uri,desc)))
+ and aux_symbol s env =
+ (* XXX: it's totally unclear why the env we receive here is in reverse
+ * order (a diff with the previous revision shows no obvious reason).
+ * This one-line patch is needed so that the default symbol chosen for
+ * storing the interpretation is the leftmost, rather than the rightmost *)
+ let env = List.rev env in
+ try
+ (let dv =
+ try List.find (function
+ | Env.DisambiguationValue(Some s',_,_,_) when s = s' -> true
+ | _ -> false) env
+ with Not_found ->
+ List.find (function
+ | Env.DisambiguationValue(None,_,_,_) -> true
+ | _ -> false) env
+ in
+ match dv with
+ | Env.DisambiguationValue(_,loc,uri,Some desc) ->
+ Ast.AttributedTerm (`Loc loc, Ast.Symbol (s, Some (uri,desc)))
+ | Env.DisambiguationValue(_,loc,_,_) ->
+ (* The important disambiguation info for symbols is the desc,
+ * if we don't have it, we won't use the uri either *)
+ Ast.AttributedTerm (`Loc loc, Ast.Symbol (s, None))
+ | _ -> assert false) (* vacuous *)
+ with Not_found ->
+ (* Ast.AttributedTerm (`Loc Stdpp.dummy_loc, Ast.Symbol (s, None))*)
+ Ast.Symbol (s, None)