/src/tools/syntax/tree/liberty_ast_expression_root.e

http://github.com/tybor/Liberty · Specman e · 58 lines · 36 code · 8 blank · 14 comment · 0 complexity · 93b22fa8d83d22a88a2db3545ad4410e 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_ROOT[S_ -> LIBERTY_AST_NON_TERMINAL_NODE, B_ -> LIBERTY_AST_EXPRESSION_BINARY[S_]]
  16. inherit
  17. LIBERTY_AST_NON_TERMINAL_NODE
  18. feature {LIBERTY_AST_HANDLER}
  19. simple_expression: S_ is
  20. require
  21. is_simple_expression
  22. do
  23. Result ::= nodes.first
  24. ensure
  25. Result /= Void
  26. end
  27. binary_expression: B_ is
  28. require
  29. is_binary_expression
  30. do
  31. Result ::= nodes.first
  32. ensure
  33. Result /= Void
  34. end
  35. is_simple_expression: BOOLEAN is
  36. do
  37. Result := not is_binary_expression
  38. end
  39. is_binary_expression: BOOLEAN is
  40. do
  41. Result := nodes.first.name.has_suffix(once "-exp")
  42. end
  43. feature {ANY}
  44. count: INTEGER is 1
  45. feature {}
  46. possible_counts: SET[INTEGER] is
  47. once
  48. Result := {AVL_SET[INTEGER] << 1 >> }
  49. end
  50. end