1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2009 Jean-Sebastien Gelinas <calestar@gmail.com>
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
21 redef type OTHER: Location
23 readable var _file
: String
24 readable var _line_start
: Int
25 readable var _line_end
: Int
26 readable var _column_start
: Int
27 readable var _column_end
: Int
29 init(f
: String, line_s
: Int, line_e
: Int, column_s
: Int, column_e
: Int) do
33 _column_start
= column_s
34 _column_end
= column_e
37 init with_file
(f
: String) do init(f
,0,0,0,0)
39 redef fun to_s
: String do
40 if line_start
== line_end
then
41 if column_start
== column_end
then
42 return "{file}:{line_start},{column_start}"
44 return "{file}:{line_start},{column_start}--{column_end}"
47 return "{file}:{line_start},{column_start}--{line_end}:{column_end}"
51 redef fun <(other
: OTHER): Bool do
52 if line_start
!= other
.line_start
then return line_start
< other
.line_start
53 if column_start
!= other
.column_start
then return column_start
< other
.column_start
54 if line_end
!= other
.line_end
then return line_end
< other
.line_end
56 return column_end
< other
.column_end