PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/lib/parse/eiffel/eiffel_position.e

http://github.com/tybor/Liberty
Specman e | 74 lines | 43 code | 7 blank | 24 comment | 1 complexity | f7286a788e7aa5e183293a3d66056e5f MD5 | raw file
 1-- This file is part of a Liberty Eiffel library.
 2-- See the full copyright at the end.
 3--
 4expanded class EIFFEL_POSITION
 5
 6insert
 7   ANY
 8      redefine
 9         default_create, is_equal
10      end
11
12creation {EIFFEL_GRAMMAR}
13   default_create
14
15feature {EIFFEL_GRAMMAR}
16   next (buffer: MINI_PARSER_BUFFER): like Current is
17      do
18         buffer.next
19         index := buffer.current_index
20         if not buffer.end_reached then
21            inspect
22               buffer.current_character
23            when '%N' then
24               line := line + 1
25               column := 1
26            when '%R' then
27               -- ignored
28            else
29               column := column + 1
30            end
31         end
32         Result := Current
33      end
34
35feature {EIFFEL_GRAMMAR, EIFFEL_IMAGE, EIFFEL_POSITION}
36   line: INTEGER
37   column: INTEGER
38   index: INTEGER
39
40feature {ANY}
41   is_equal (other: like Current): BOOLEAN is
42      do
43         Result := index = other.index
44      end
45
46feature {}
47   default_create is
48      do
49         index := 1
50         line := 1
51         column := 1
52      end
53
54end -- class EIFFEL_POSITION
55--
56-- Copyright (c) 2009 by all the people cited in the AUTHORS file.
57--
58-- Permission is hereby granted, free of charge, to any person obtaining a copy
59-- of this software and associated documentation files (the "Software"), to deal
60-- in the Software without restriction, including without limitation the rights
61-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
62-- copies of the Software, and to permit persons to whom the Software is
63-- furnished to do so, subject to the following conditions:
64--
65-- The above copyright notice and this permission notice shall be included in
66-- all copies or substantial portions of the Software.
67--
68-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
69-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
70-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
71-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
72-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
73-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
74-- THE SOFTWARE.