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