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

/src/lib/parse/eiffel/eiffel_non_terminal_node_impl.e

http://github.com/tybor/Liberty
Specman e | 137 lines | 95 code | 19 blank | 23 comment | 0 complexity | 20b8a3cf10bb2ba120cbeef7589a0c9c MD5 | raw file
  1-- This file is part of a Liberty Eiffel library.
  2-- See the full copyright at the end.
  3--
  4class EIFFEL_NON_TERMINAL_NODE_IMPL
  5
  6inherit
  7   EIFFEL_NON_TERMINAL_NODE
  8
  9creation {EIFFEL_NODE_FACTORY}
 10   make
 11
 12feature {ANY}
 13   name: FIXED_STRING
 14
 15   accept (visitor: VISITOR) is
 16      local
 17         v: EIFFEL_NON_TERMINAL_NODE_IMPL_VISITOR
 18      do
 19         v ::= visitor
 20         v.visit_eiffel_non_terminal_node_impl(Current)
 21      end
 22
 23   name_at (index: INTEGER): FIXED_STRING is
 24      do
 25         Result := names.item(index - lower + names.lower)
 26      end
 27
 28   node_at (index: INTEGER): EIFFEL_NODE is
 29      do
 30         Result := nodes.item(index)
 31      end
 32
 33   valid_index (index: INTEGER): BOOLEAN is
 34      do
 35         Result := nodes.valid_index(index)
 36      end
 37
 38   lower: INTEGER is
 39      do
 40         Result := nodes.lower
 41      end
 42
 43   upper: INTEGER is
 44      do
 45         Result := nodes.upper
 46      end
 47
 48   count: INTEGER is
 49      do
 50         Result := nodes.count
 51      end
 52
 53   is_empty: BOOLEAN is
 54      do
 55         Result := nodes.is_empty
 56      end
 57
 58feature {EIFFEL_GRAMMAR}
 59   set (index: INTEGER; node: EIFFEL_NODE) is
 60      do
 61         nodes.put(node, index)
 62         node.set_parent(Current)
 63      end
 64
 65feature {EIFFEL_NODE_HANDLER}
 66   display (output: OUTPUT_STREAM; indent: INTEGER; p: STRING) is
 67      local
 68         i: INTEGER
 69      do
 70         do_indent(output, indent, p)
 71         output.put_character('"')
 72         output.put_string(name)
 73         output.put_line(once "%":")
 74         from
 75            i := lower
 76         until
 77            i > upper
 78         loop
 79            node_at(i).display(output, indent + 1, " * ")
 80            i := i + 1
 81         end
 82      end
 83
 84   generate (o: OUTPUT_STREAM) is
 85      local
 86         i: INTEGER
 87      do
 88         from
 89            i := lower
 90         until
 91            i > upper
 92         loop
 93            node_at(i).generate(o)
 94            i := i + 1
 95         end
 96         generate_forgotten(o)
 97      end
 98
 99feature {}
100   make (a_name: like name; a_names: like names) is
101      do
102         name := a_name
103         names := a_names
104         create nodes.make(a_names.count)
105      ensure
106         name = a_name
107         names = a_names
108      end
109
110   names: TRAVERSABLE[FIXED_STRING]
111
112   nodes: FAST_ARRAY[EIFFEL_NODE]
113
114invariant
115   names.count = nodes.count
116
117end -- class EIFFEL_NON_TERMINAL_NODE_IMPL
118--
119-- Copyright (c) 2009 by all the people cited in the AUTHORS file.
120--
121-- Permission is hereby granted, free of charge, to any person obtaining a copy
122-- of this software and associated documentation files (the "Software"), to deal
123-- in the Software without restriction, including without limitation the rights
124-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
125-- copies of the Software, and to permit persons to whom the Software is
126-- furnished to do so, subject to the following conditions:
127--
128-- The above copyright notice and this permission notice shall be included in
129-- all copies or substantial portions of the Software.
130--
131-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
132-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
133-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
134-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
135-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
136-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
137-- THE SOFTWARE.