/work/generate_visitors.sh

http://github.com/tybor/Liberty · Shell · 88 lines · 64 code · 10 blank · 14 comment · 7 complexity · 7dec8ee9ee85f623933817d6bfccaa6d MD5 · raw file

  1. #!/usr/bin/env bash
  2. # This file is part of Liberty Eiffel.
  3. #
  4. # Liberty Eiffel is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, version 3 of the License.
  7. #
  8. # Liberty Eiffel is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with Liberty Eiffel. If not, see <http://www.gnu.org/licenses/>.
  15. cd ${0%/*}
  16. p=$(pwd)
  17. p=${p%/*}
  18. cd $p/src/tools/semantics/code/visitors
  19. rm -f *.e *.bak
  20. for type in ASSERTION ENTITY EXPRESSION FEATURE INSTRUCTION; do
  21. what=$(echo $type | tr '[A-Z]' '[a-z]')
  22. dir=${what}s
  23. test $dir == "entitys" && dir=entities
  24. visitor=liberty_${what}_visitor.e
  25. echo Generating ${dir}
  26. cat > $visitor <<EOF
  27. -- This file is part of Liberty Eiffel.
  28. --
  29. -- Liberty Eiffel is free software: you can redistribute it and/or modify
  30. -- it under the terms of the GNU General Public License as published by
  31. -- the Free Software Foundation, version 3 of the License.
  32. --
  33. -- Liberty Eiffel is distributed in the hope that it will be useful,
  34. -- but WITHOUT ANY WARRANTY; without even the implied warranty of
  35. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  36. -- GNU General Public License for more details.
  37. --
  38. -- You should have received a copy of the GNU General Public License
  39. -- along with Liberty Eiffel. If not, see <http://www.gnu.org/licenses/>.
  40. --
  41. deferred class LIBERTY_${type}_VISITOR
  42. inherit
  43. EOF
  44. for f in ../${dir}/*.e; do
  45. if ! grep -q 'deferred class' $f; then
  46. f=${f##*/}; f=${f%.e}
  47. c=$(echo $f | tr '[a-z]' '[A-Z]')
  48. g=${f}_visitor
  49. v=$(echo $g | tr '[a-z]' '[A-Z]')
  50. cat > ${g}.e <<EOF
  51. -- This file is part of Liberty Eiffel.
  52. --
  53. -- Liberty Eiffel is free software: you can redistribute it and/or modify
  54. -- it under the terms of the GNU General Public License as published by
  55. -- the Free Software Foundation, version 3 of the License.
  56. --
  57. -- Liberty Eiffel is distributed in the hope that it will be useful,
  58. -- but WITHOUT ANY WARRANTY; without even the implied warranty of
  59. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  60. -- GNU General Public License for more details.
  61. --
  62. -- You should have received a copy of the GNU General Public License
  63. -- along with Liberty Eiffel. If not, see <http://www.gnu.org/licenses/>.
  64. --
  65. deferred class $v
  66. inherit VISITOR
  67. feature {$c}
  68. visit_$f (v: $c) is deferred end
  69. end
  70. EOF
  71. se pretty ${g}.e
  72. echo $v >> $visitor
  73. fi
  74. done
  75. echo end >> $visitor
  76. se pretty $visitor
  77. done
  78. rm -f *.bak