2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #ifndef incl_HPHP_PARSER_LOCATION_H_
18 #define incl_HPHP_PARSER_LOCATION_H_
24 ///////////////////////////////////////////////////////////////////////////////
28 Location(int l0
, int c0
, int l1
, int c1
)
29 : r(l0
, c0
, l1
, c1
) {}
33 Range(int l0
, int c0
, int l1
, int c1
)
34 : line0(l0
), char0(c0
), line1(l1
), char1(c1
) {}
40 int compare(const Range
& other
) const {
41 if (line0
< other
.line0
) return -1;
42 if (line0
> other
.line0
) return 1;
43 if (char0
< other
.char0
) return -1;
44 if (char0
> other
.char0
) return 1;
45 if (line1
< other
.line1
) return -1;
46 if (line1
> other
.line1
) return 1;
47 if (char1
< other
.char1
) return -1;
48 if (char1
> other
.char1
) return 1;
57 void first(int line
, char pos
) {
58 r
.line0
= line
; r
.char0
= pos
;
60 void first(Location
&loc
) {
61 r
.line0
= loc
.r
.line0
; r
.char0
= loc
.r
.char0
;
63 void last(int line
, char pos
) {
64 r
.line1
= line
; r
.char1
= pos
;
66 void last(Location
&loc
) {
67 r
.line1
= loc
.r
.line1
; r
.char1
= loc
.r
.char1
;
71 * This only guarantees consistent result between two locations, whether or
72 * not it makes sense, because we're comparing those integers first for
75 int compare(const Location
*loc
) const {
76 if (auto d
= r
.compare(loc
->r
)) return d
;
77 return strcmp(file
, loc
->file
);
81 ///////////////////////////////////////////////////////////////////////////////
84 #endif // incl_HPHP_PARSER_LOCATION_H_