ppx_compare Location

Reviewed By: cristianoc

Differential Revision: D4232376

fbshipit-source-id: 9162028
master
Josh Berdine 8 years ago committed by Facebook Github Bot
parent 27da735427
commit 6b3d7c4d25

@ -18,16 +18,10 @@ type t = {
line: int, /** The line number. -1 means "do not know" */
col: int, /** The column number. -1 means "do not know" */
file: DB.source_file /** The name of the source file */
};
}
[@@deriving compare];
let compare loc1 loc2 => {
let n = int_compare loc1.line loc2.line;
if (n != 0) {
n
} else {
DB.compare_source_file loc1.file loc2.file
}
};
let equal loc1 loc2 => compare loc1 loc2 == 0;
/** Dump a location */
@ -37,8 +31,6 @@ let d (loc: t) => L.add_print_action (L.PTloc, Obj.repr loc);
/** Dummy location */
let dummy = {line: (-1), col: (-1), file: DB.source_file_empty};
let equal loc1 loc2 => compare loc1 loc2 == 0;
/** Pretty print a location */
let pp f (loc: t) => F.fprintf f "[line %d]" loc.line;

@ -13,10 +13,11 @@ open! Utils;
type t = {
line: int, /** The line number. -1 means "do not know" */
col: int, /** The column number. -1 means "do not know" */
file: DB.source_file, /** The name of the source file */
};
file: DB.source_file /** The name of the source file */
}
[@@deriving compare];
let compare: t => t => int;
let equal: t => t => bool;
/** Dump a location. */
@ -26,8 +27,6 @@ let d: t => unit;
/** Dummy location */
let dummy: t;
let equal: t => t => bool;
/** Pretty print a location. */
let pp: Format.formatter => t => unit;

Loading…
Cancel
Save