From 714376413f68dad720d6253b1f36209d8d096443 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Tue, 18 Jan 2005 18:18:00 +0000 Subject: [PATCH] added pp_location (pretty printer of ast location) --- helm/ocaml/cic_transformations/cicAst.ml | 9 +++++++++ helm/ocaml/cic_transformations/cicAst.mli | 1 + 2 files changed, 10 insertions(+) diff --git a/helm/ocaml/cic_transformations/cicAst.ml b/helm/ocaml/cic_transformations/cicAst.ml index 399181372..9abd07a75 100644 --- a/helm/ocaml/cic_transformations/cicAst.ml +++ b/helm/ocaml/cic_transformations/cicAst.ml @@ -23,8 +23,17 @@ * http://helm.cs.unibo.it/ *) +open Printf + type location = Lexing.position * Lexing.position +let pp_location (loc_begin, loc_end) = + sprintf "(%d,%d)-(%d,%d)" + loc_begin.Lexing.pos_lnum + (loc_begin.Lexing.pos_cnum - loc_begin.Lexing.pos_bol) + loc_end.Lexing.pos_lnum + (loc_end.Lexing.pos_cnum - loc_end.Lexing.pos_bol) + let floc_of_loc (loc_begin, loc_end) = let floc_begin = { Lexing.pos_fname = ""; Lexing.pos_lnum = -1; Lexing.pos_bol = -1; diff --git a/helm/ocaml/cic_transformations/cicAst.mli b/helm/ocaml/cic_transformations/cicAst.mli index 8abd4f3c9..6bb67af22 100644 --- a/helm/ocaml/cic_transformations/cicAst.mli +++ b/helm/ocaml/cic_transformations/cicAst.mli @@ -26,6 +26,7 @@ (** {2 Parsing related types} *) type location = Lexing.position * Lexing.position +val pp_location: location -> string (** maps old style (i.e. <= 3.07) lexer location to new style location, * padding with dummy values where needed *) -- 2.39.2