/src/tools/syntax/tree/liberty_ast_e10.e

http://github.com/tybor/Liberty · Specman e · 131 lines · 96 code · 20 blank · 15 comment · 1 complexity · e8dd557a5649ecb041256cf7b19059f9 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_E10
  16. inherit
  17. LIBERTY_AST_NON_TERMINAL_NODE
  18. create {LIBERTY_NODE_FACTORY}
  19. make
  20. feature {LIBERTY_AST_HANDLER}
  21. is_call: BOOLEAN is
  22. do
  23. Result := count = 1 and then nodes.first.name.is_equal(once "Call")
  24. end
  25. call: LIBERTY_AST_CALL is
  26. require
  27. is_call
  28. do
  29. Result ::= nodes.item(0)
  30. end
  31. is_tuple: BOOLEAN is
  32. do
  33. Result := nodes.first.name.is_equal(once "KW [")
  34. check
  35. Result = nodes.last.name.is_equal(once "KW ]")
  36. end
  37. end
  38. tuple_actuals: EIFFEL_LIST_NODE is
  39. -- Void if empty tuple
  40. require
  41. is_tuple
  42. do
  43. if count = 3 then
  44. Result ::= nodes.item(1)
  45. end
  46. end
  47. is_open_argument: BOOLEAN is
  48. do
  49. Result := count = 1 and then nodes.first.name.is_equal(once "KW ?")
  50. end
  51. is_inline_agent: BOOLEAN is
  52. do
  53. Result := count = 4
  54. check
  55. Result = nodes.item(0).name.is_equal(once "Agent_Signature")
  56. end
  57. end
  58. inline_agent_signature: LIBERTY_AST_AGENT_SIGNATURE is
  59. require
  60. is_inline_agent
  61. do
  62. Result ::= nodes.item(0)
  63. end
  64. inline_agent_definition: LIBERTY_AST_ROUTINE_DEFINITION is
  65. require
  66. is_inline_agent
  67. do
  68. Result ::= nodes.item(2)
  69. end
  70. inline_agent_actuals: LIBERTY_AST_ACTUALS is
  71. require
  72. is_inline_agent
  73. do
  74. Result ::= nodes.item(3)
  75. end
  76. is_agent_creation: BOOLEAN is
  77. do
  78. Result := count = 2 and then nodes.item(0).name.is_equal(once "KW agent")
  79. end
  80. agent_creation_expression: LIBERTY_AST_EXPRESSION is
  81. require
  82. is_agent_creation
  83. do
  84. Result ::= nodes.item(1)
  85. end
  86. is_creation_expression: BOOLEAN is
  87. do
  88. Result := count = 1 and then nodes.item(0).name.is_equal(once "Creation_Expression")
  89. end
  90. creation_expression: LIBERTY_AST_CREATION_EXPRESSION is
  91. require
  92. is_creation_expression
  93. do
  94. Result ::= nodes.item(0)
  95. end
  96. is_void: BOOLEAN is
  97. do
  98. Result := count = 1 and then nodes.item(0).name.is_equal(once "KW Void")
  99. end
  100. feature {ANY}
  101. count: INTEGER is
  102. do
  103. Result := nodes.count
  104. end
  105. name: STRING is "e10"
  106. feature {}
  107. possible_counts: SET[INTEGER] is
  108. once
  109. Result := {AVL_SET[INTEGER] << 1, 2, 3, 4 >> }
  110. end
  111. end