/src/tools/syntax/tree/liberty_ast_if.e

http://github.com/tybor/Liberty · Specman e · 68 lines · 40 code · 10 blank · 18 comment · 0 complexity · c2330987f566cfc708f48a1cab930ac7 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_IF
  16. --
  17. -- This class handles both "if" and "elseif" hence the redefines
  18. --
  19. inherit
  20. LIBERTY_AST_NON_TERMINAL_NODE
  21. redefine
  22. valid_name, make
  23. end
  24. create {LIBERTY_NODE_FACTORY}
  25. make
  26. feature {LIBERTY_AST_HANDLER}
  27. expression: LIBERTY_AST_EXPRESSION is
  28. do
  29. Result ::= nodes.item(1)
  30. end
  31. instructions: EIFFEL_LIST_NODE is
  32. do
  33. Result ::= nodes.item(3)
  34. end
  35. feature {ANY}
  36. count: INTEGER is 4
  37. name: STRING
  38. feature {}
  39. make (a_name: like eiffel_name; a_names: TRAVERSABLE[FIXED_STRING]) is
  40. do
  41. name := a_name.out
  42. Precursor(a_name, a_names)
  43. end
  44. possible_counts: SET[INTEGER] is
  45. once
  46. Result := {AVL_SET[INTEGER] << 4 >> }
  47. end
  48. valid_name (a_name: like eiffel_name): BOOLEAN is
  49. do
  50. inspect
  51. a_name
  52. when "If", "ElseIf" then
  53. Result := True
  54. else
  55. --Result := False
  56. end
  57. end
  58. end