/src/tools/syntax/tree/liberty_ast_manifest_or_type_test.e

http://github.com/tybor/Liberty · Specman e · 186 lines · 143 code · 29 blank · 14 comment · 1 complexity · af1b4bf8c4ff653b74a7228d46511370 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_MANIFEST_OR_TYPE_TEST
  16. inherit
  17. LIBERTY_AST_NON_TERMINAL_NODE
  18. create {LIBERTY_NODE_FACTORY}
  19. make
  20. feature {LIBERTY_AST_HANDLER}
  21. is_number: BOOLEAN is
  22. do
  23. Result := count = 1 and then nodes.item(0).name.is_equal(once "KW number")
  24. end
  25. number: LIBERTY_AST_NUMBER is
  26. require
  27. is_number
  28. do
  29. Result ::= nodes.item(0)
  30. end
  31. is_true: BOOLEAN is
  32. do
  33. Result := count = 1 and then nodes.item(0).name.is_equal(once "KW True")
  34. end
  35. is_false: BOOLEAN is
  36. do
  37. Result := count = 1 and then nodes.item(0).name.is_equal(once "KW False")
  38. end
  39. is_character: BOOLEAN is
  40. do
  41. Result := count = 1 and then nodes.item(0).name.is_equal(once "KW character")
  42. end
  43. character: LIBERTY_AST_CHARACTER is
  44. require
  45. is_character
  46. do
  47. Result ::= nodes.item(0)
  48. end
  49. is_string: BOOLEAN is
  50. do
  51. Result := (count = 1 or else count = 2) and then nodes.last.name.is_equal(once "KW string")
  52. end
  53. is_once_string: BOOLEAN is
  54. do
  55. Result := nodes.item(0).name.is_equal(once "KW once")
  56. ensure
  57. Result implies is_string
  58. end
  59. string: LIBERTY_AST_STRING is
  60. require
  61. is_string
  62. do
  63. Result ::= nodes.last
  64. end
  65. is_typed_open_argument: BOOLEAN is
  66. do
  67. Result := count = 3
  68. check
  69. Result implies nodes.item(1).name.is_equal(once "Type_Definition")
  70. end
  71. end
  72. open_argument_type: LIBERTY_AST_TYPE_DEFINITION is
  73. require
  74. is_typed_open_argument
  75. do
  76. Result ::= nodes.item(1)
  77. end
  78. is_assignment_test: BOOLEAN is
  79. do
  80. Result := count = 5 and then nodes.item(3).name.is_equal(once "KW ?:=")
  81. end
  82. assignment_test_type: LIBERTY_AST_TYPE_DEFINITION is
  83. require
  84. is_assignment_test
  85. do
  86. Result ::= nodes.item(1)
  87. end
  88. assignment_test_expression: LIBERTY_AST_EXPRESSION is
  89. require
  90. is_assignment_test
  91. do
  92. Result ::= nodes.item(4)
  93. end
  94. is_typed_manifest: BOOLEAN is
  95. do
  96. Result := count > 3 and then not is_assignment_test and then nodes.item(1).name.is_equal(once "Type_Definition")
  97. end
  98. is_number_typed_manifest: BOOLEAN is
  99. do
  100. Result := count = 4 and then nodes.item(2).name.is_equal(once "KW number")
  101. ensure
  102. Result implies is_typed_manifest
  103. end
  104. is_string_typed_manifest: BOOLEAN is
  105. do
  106. Result := count = 4 and then nodes.item(2).name.is_equal(once "KW string")
  107. ensure
  108. Result implies is_typed_manifest
  109. end
  110. is_array_typed_manifest: BOOLEAN is
  111. do
  112. Result := count = 5 and then nodes.item(3).name.is_equal(once "Array")
  113. ensure
  114. Result implies is_typed_manifest
  115. end
  116. typed_manifest_type: LIBERTY_AST_TYPE_DEFINITION is
  117. require
  118. is_typed_manifest
  119. do
  120. Result ::= nodes.item(1)
  121. end
  122. typed_manifest_number: LIBERTY_AST_NUMBER is
  123. require
  124. is_number_typed_manifest
  125. do
  126. Result ::= nodes.item(2)
  127. end
  128. typed_manifest_string: LIBERTY_AST_STRING is
  129. require
  130. is_string_typed_manifest
  131. do
  132. Result ::= nodes.item(2)
  133. end
  134. typed_manifest_array_parameters: EIFFEL_LIST_NODE is
  135. require
  136. is_array_typed_manifest
  137. do
  138. Result ::= nodes.item(2)
  139. end
  140. typed_manifest_array: LIBERTY_AST_ARRAY is
  141. require
  142. is_array_typed_manifest
  143. do
  144. Result ::= nodes.item(3)
  145. end
  146. feature {ANY}
  147. count: INTEGER is
  148. do
  149. Result := nodes.count
  150. end
  151. name: STRING is "Manifest_Or_Type_Test"
  152. feature {}
  153. possible_counts: SET[INTEGER] is
  154. once
  155. Result := {AVL_SET[INTEGER] << 1, 2, 3, 4, 5 >> }
  156. end
  157. end