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

/src/tools/errors/liberty_semantics_position.e

http://github.com/tybor/Liberty
Specman e | 89 lines | 62 code | 13 blank | 14 comment | 2 complexity | 0cb28f96f56a59e53dc79a96df6e4c68 MD5 | raw file
 1-- This file is part of Liberty Eiffel.
 2--
 3-- Liberty Eiffel is free software: you can redistribute it and/or modify
 4-- it under the terms of the GNU General Public License as published by
 5-- the Free Software Foundation, version 3 of the License.
 6--
 7-- Liberty Eiffel is distributed in the hope that it will be useful,
 8-- but WITHOUT ANY WARRANTY; without even the implied warranty of
 9-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10-- GNU General Public License for more details.
11--
12-- You should have received a copy of the GNU General Public License
13-- along with Liberty Eiffel.  If not, see <http://www.gnu.org/licenses/>.
14--
15class LIBERTY_SEMANTICS_POSITION
16
17inherit
18   LIBERTY_POSITION
19      redefine
20         show
21      end
22
23insert
24   EIFFEL_NODE_HANDLER
25
26create {LIBERTY_ERRORS}
27   make
28
29feature {ANY}
30   is_unknown: BOOLEAN is False
31
32   show (stream: OUTPUT_STREAM) is
33      do
34         generate_source
35         if index <= source.upper then
36            Precursor(stream)
37         else
38            debug
39               stream.put_string(once "Invalid position ")
40               stream.put_integer(index)
41               stream.put_new_line
42            end
43         end
44      end
45
46feature {}
47   ast: LIBERTY_AST_NON_TERMINAL_NODE
48
49feature {}
50   make (a_index: like index; a_ast: like ast; a_file: like file) is
51      require
52         a_ast /= Void
53         a_index > 0
54         a_file /= Void
55      do
56         index := a_index
57         ast := a_ast
58         file := a_file
59      ensure
60         index = a_index
61         ast = a_ast
62         file = a_file
63      end
64
65   generate_source is
66      do
67         if last_ast_in_code_buffer.item /= ast then
68            code_buffer.clear
69            ast.generate(code_buffer)
70            last_ast_in_code_buffer.set_item(ast)
71         end
72      end
73
74   last_ast_in_code_buffer: REFERENCE[EIFFEL_NODE] is
75      once
76         create Result
77      end
78
79   code_buffer: STRING_OUTPUT_STREAM is
80      once
81         create Result.connect_to(source)
82      end
83
84   source: STRING is ""
85
86invariant
87   ast /= Void
88
89end