/src/tools/syntax/tree/liberty_ast_assignment_or_call.e

http://github.com/tybor/Liberty · Specman e · 107 lines · 78 code · 15 blank · 14 comment · 0 complexity · 76f3fd623f1f5115507b3e8baec833af 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_ASSIGNMENT_OR_CALL
  16. inherit
  17. LIBERTY_AST_NON_TERMINAL_NODE
  18. create {LIBERTY_NODE_FACTORY}
  19. make
  20. feature {LIBERTY_AST_HANDLER}
  21. writable: LIBERTY_AST_WRITABLE is
  22. require
  23. is_assignment
  24. do
  25. Result ::= nodes.item(0)
  26. end
  27. expression: LIBERTY_AST_EXPRESSION is
  28. require
  29. is_assignment
  30. do
  31. Result ::= nodes.item(2)
  32. end
  33. target: LIBERTY_AST_TARGET is
  34. require
  35. is_call
  36. do
  37. Result ::= nodes.item(0)
  38. end
  39. r10: LIBERTY_AST_R10 is
  40. require
  41. is_call
  42. do
  43. Result ::= nodes.item(1)
  44. end
  45. is_regular_assignment: BOOLEAN is
  46. require
  47. is_assignment
  48. do
  49. Result := nodes.item(1).name.is_equal(once "KW :=")
  50. ensure
  51. Result implies not is_assignment_attempt and then not is_forced_assignment
  52. end
  53. is_assignment_attempt: BOOLEAN is
  54. require
  55. is_assignment
  56. do
  57. Result := nodes.item(1).name.is_equal(once "KW ?=")
  58. ensure
  59. Result implies not is_regular_assignment and then not is_forced_assignment
  60. end
  61. is_forced_assignment: BOOLEAN is
  62. require
  63. is_assignment
  64. do
  65. Result := nodes.item(1).name.is_equal(once "KW ::=")
  66. ensure
  67. Result implies not is_assignment_attempt and then not is_regular_assignment
  68. end
  69. is_assignment: BOOLEAN is
  70. do
  71. Result := count = 3
  72. ensure
  73. Result = not is_call
  74. end
  75. is_call: BOOLEAN is
  76. do
  77. Result := count = 2
  78. ensure
  79. Result = not is_assignment
  80. end
  81. feature {ANY}
  82. count: INTEGER is
  83. do
  84. Result := nodes.count
  85. end
  86. name: STRING is "Assignment_Or_Call"
  87. feature {}
  88. possible_counts: SET[INTEGER] is
  89. once
  90. Result := {AVL_SET[INTEGER] << 2, 3 >> }
  91. end
  92. end