/src/tools/syntax/tree/liberty_ast_expression_binary.e

http://github.com/tybor/Liberty · Specman e · 88 lines · 62 code · 12 blank · 14 comment · 0 complexity · 9f52c8d20786483bb3ae711f34d38d22 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. deferred class LIBERTY_AST_EXPRESSION_BINARY[E_ -> LIBERTY_AST_NON_TERMINAL_NODE]
  16. inherit
  17. LIBERTY_AST_NON_TERMINAL_NODE
  18. feature {LIBERTY_AST_HANDLER}
  19. left_expression: E_ is
  20. require
  21. not is_empty
  22. not is_binary
  23. do
  24. Result ::= nodes.first
  25. end
  26. left_binary: like Current is
  27. require
  28. not is_empty
  29. is_binary
  30. do
  31. Result ::= nodes.first
  32. end
  33. right_expression: E_ is
  34. require
  35. not is_empty
  36. do
  37. Result ::= nodes.last
  38. end
  39. is_binary: BOOLEAN is
  40. require
  41. not is_empty
  42. do
  43. Result := nodes.first.name = eiffel_name
  44. end
  45. is_double_operator: BOOLEAN is
  46. do
  47. Result := count = 4
  48. end
  49. operator1: EIFFEL_IMAGE is
  50. local
  51. op1: LIBERTY_AST_TERMINAL_NODE
  52. do
  53. op1 ::= nodes.item(1)
  54. Result := op1.image
  55. end
  56. operator2: EIFFEL_IMAGE is
  57. require
  58. is_double_operator
  59. local
  60. op2: LIBERTY_AST_TERMINAL_NODE
  61. do
  62. op2 ::= nodes.item(2)
  63. Result := op2.image
  64. end
  65. feature {ANY}
  66. count: INTEGER is
  67. do
  68. Result := nodes.count
  69. end
  70. feature {}
  71. possible_counts: SET[INTEGER] is
  72. once
  73. Result := {AVL_SET[INTEGER] << 3, 4 >> } -- depends on the operator
  74. end
  75. errors: LIBERTY_ERRORS
  76. end