2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-2013 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_
20 #include "hphp/util/base.h"
23 ///////////////////////////////////////////////////////////////////////////////
25 DECLARE_BOOST_TYPES(Location
);
28 Location() : file(""), line0(1), char0(1), line1(1), char1(1), cursor(0) {}
37 void first(int line
, char pos
) {
38 line0
= line
; char0
= pos
;
40 void first(Location
&loc
) {
41 line0
= loc
.line0
; char0
= loc
.char0
;
43 void last(int line
, char pos
) {
44 line1
= line
; char1
= pos
;
46 void last(Location
&loc
) {
47 line1
= loc
.line1
; char1
= loc
.char1
;
51 * This only guarantees consistent result between two locations, whether or
52 * not it makes sense, because we're comparing those integers first for
55 int compare(Location
*loc
) {
56 if (line0
< loc
->line0
) return -1; if (line0
> loc
->line0
) return 1;
57 if (char0
< loc
->char0
) return -1; if (char0
> loc
->char0
) return 1;
58 if (line1
< loc
->line1
) return -1; if (line1
> loc
->line1
) return 1;
59 if (char1
< loc
->char1
) return -1; if (char1
> loc
->char1
) return 1;
60 return strcmp(file
, loc
->file
);
64 ///////////////////////////////////////////////////////////////////////////////
67 #endif // incl_HPHP_PARSER_LOCATION_H_