PageRenderTime 15ms CodeModel.GetById 9ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/src/lib/parse/eiffel/eiffel_list_node_impl.e

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