/src/tools/syntax/tree/liberty_ast_type_definition.e

http://github.com/tybor/Liberty · Specman e · 116 lines · 85 code · 17 blank · 14 comment · 1 complexity · 777581ecd13f13113f301f867aa12ea3 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. --
  15. class LIBERTY_AST_TYPE_DEFINITION
  16. inherit
  17. LIBERTY_AST_NON_TERMINAL_NODE
  18. create {LIBERTY_NODE_FACTORY}
  19. make
  20. feature {LIBERTY_AST_HANDLER}
  21. is_class_type: BOOLEAN is
  22. do
  23. Result := nodes.last.name.is_equal(once "Effective_Type_Parameters")
  24. end
  25. is_separate: BOOLEAN is
  26. do
  27. Result := nodes.first.name.is_equal(once "KW separate")
  28. end
  29. type_name: LIBERTY_AST_CLASS_NAME is
  30. require
  31. is_class_type
  32. do
  33. if is_separate then
  34. Result ::= nodes.item(1)
  35. else
  36. Result ::= nodes.item(0)
  37. end
  38. end
  39. type_parameters: LIBERTY_AST_EFFECTIVE_TYPE_PARAMETERS is
  40. require
  41. is_class_type
  42. do
  43. Result ::= nodes.last
  44. end
  45. is_anchor: BOOLEAN is
  46. do
  47. Result := nodes.first.name.is_equal(once "KW like")
  48. end
  49. is_like_result: BOOLEAN is
  50. do
  51. Result := is_anchor and then nodes.item(1).name.is_equal(once "KW Result")
  52. ensure
  53. Result implies is_anchor
  54. end
  55. is_like_current: BOOLEAN is
  56. do
  57. Result := is_anchor and then nodes.item(1).name.is_equal(once "KW Current")
  58. ensure
  59. Result implies is_anchor
  60. end
  61. is_like_entity: BOOLEAN is
  62. do
  63. Result := is_anchor and then nodes.item(1).name.is_equal(once "KW entity name")
  64. ensure
  65. Result implies is_anchor
  66. end
  67. entity_anchor: LIBERTY_AST_ENTITY_NAME is
  68. require
  69. is_like_entity
  70. do
  71. Result ::= nodes.item(1)
  72. end
  73. anchor_remainder: LIBERTY_AST_R10 is
  74. require
  75. is_anchor
  76. do
  77. Result ::= nodes.item(2)
  78. end
  79. anchor_index: INTEGER is
  80. require
  81. is_anchor
  82. local
  83. anchor: EIFFEL_TERMINAL_NODE
  84. do
  85. anchor ::= nodes.first
  86. Result := anchor.image.index
  87. end
  88. feature {ANY}
  89. count: INTEGER is
  90. do
  91. Result := nodes.count
  92. end
  93. name: STRING is "Type_Definition"
  94. feature {}
  95. possible_counts: SET[INTEGER] is
  96. once
  97. Result := {AVL_SET[INTEGER] << 2, 3 >> }
  98. end
  99. end