/tutorial/backtracking/expand_expression/abstract/expression_item.e

http://github.com/tybor/Liberty · Specman e · 93 lines · 59 code · 13 blank · 21 comment · 0 complexity · 27c1c410088803874b495ab808c4975c MD5 · raw file

  1. -- See the Copyright notice at the end of this file.
  2. --
  3. class EXPRESSION_ITEM
  4. -- very raw class to make the expresion tree
  5. -- not any safety check is done, be careful
  6. -- no comment
  7. inherit
  8. EXPRESSION_ITEM_GLOBALS
  9. redefine out
  10. end
  11. creation {ANY}
  12. make_or, make_and, make_value, make_failure, make_success, make_empty
  13. feature {ANY}
  14. first, second: like Current
  15. type: INTEGER
  16. value: STRING
  17. make_failure is
  18. do
  19. type := Failure_item
  20. end
  21. make_success is
  22. do
  23. type := Success_item
  24. end
  25. make_empty is
  26. do
  27. type := Empty_item
  28. end
  29. make_value (val: STRING) is
  30. do
  31. type := Value_item
  32. value := val
  33. end
  34. make_or (f, s: like Current) is
  35. do
  36. type := Or_item
  37. first := f
  38. second := s
  39. end
  40. make_and (f, s: like Current) is
  41. do
  42. type := And_item
  43. first := f
  44. second := s
  45. end
  46. out: STRING is
  47. do
  48. inspect
  49. type
  50. when Empty_item then
  51. Result := to_pointer.out + ": empty"
  52. when Failure_item then
  53. Result := to_pointer.out + ": failure"
  54. when Success_item then
  55. Result := to_pointer.out + ": success"
  56. when Value_item then
  57. Result := to_pointer.out + ": value=" + value
  58. when And_item then
  59. Result := to_pointer.out + ": " + first.to_pointer.out + " and " + second.to_pointer.out
  60. when Or_item then
  61. Result := to_pointer.out + ": " + first.to_pointer.out + " or " + second.to_pointer.out
  62. end
  63. end
  64. end -- class EXPRESSION_ITEM
  65. --
  66. -- ------------------------------------------------------------------------------------------------------------------------------
  67. -- Copyright notice below. Please read.
  68. --
  69. -- This file is free software, which comes along with SmartEiffel. This software is distributed in the hope that it will be
  70. -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  71. -- You can modify it as you want, provided this footer is kept unaltered, and a notification of the changes is added.
  72. -- You are allowed to redistribute it and sell it, alone or as a part of another product.
  73. --
  74. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  75. -- Copyright(C) 2003-2005: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  76. --
  77. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  78. --
  79. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  80. -- ------------------------------------------------------------------------------------------------------------------------------