create_grammar_images.sh 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. #!/bin/sh
  2. # This script assembles aggregated railway graph images from logically
  3. # (basic) related railway graph images.
  4. #
  5. # 1. Railway graph images *.png should exist.
  6. # 2. The script crops all these images, puts a white border around them, and writes
  7. # them into a working directory as PPM files. That is, the user does not have to
  8. # provide properly cropped images, but just rough cuts of individual productions
  9. # from an Xtext syntax graph.
  10. # 3. The script creates images of groups of related railway graph images by calling
  11. # the (internally defined) "create_grammar_image" command. For example, running
  12. # the command
  13. #
  14. # create_grammar_image reaction-effect \
  15. # reactioneffect \
  16. # eventraisingexpression
  17. #
  18. # expects the files "docu_grammar_020_reactioneffect.ppm" and
  19. # "docu_grammar_020_eventraisingexpression.ppm" to exist in the working directory.
  20. # These images are concatenated top to bottom in the given order, i.e. "reactioneffect"
  21. # on top, "eventraisingexpression" below, and the result will be written to the
  22. # file "${docuAgi}reaction-effect.png".
  23. # Working directory containing PPM versions of grammar image files:
  24. wd="work"
  25. # Prefix of statechart language non-terminal symbols image files:
  26. docuNtiPrefix="docu_grammar_020_"
  27. # Prefix of statechart language aggregated symbols image files:
  28. docuAgiPrefix="docu_grammar_030_"
  29. # Path + prefix of statechart language non-terminal symbols image files (PNG):
  30. docuNti="../src/user-guide/images/${docuNtiPrefix}"
  31. # Path + prefix of statechart language aggregated image files (PNG):
  32. docuAgi="../src/user-guide/images/${docuAgiPrefix}"
  33. # Prefix of statechart language non-terminal symbols image files:
  34. sctunitNtiPrefix="sctunit_grammar_020_"
  35. # Prefix of statechart language aggregated symbols image files:
  36. sctunitAgiPrefix="sctunit_grammar_030_"
  37. # Path + prefix of statechart language non-terminal symbols image files (PNG):
  38. sctunitNti="../src/user-guide/images/${sctunitNtiPrefix}"
  39. # Path + prefix of statechart language aggregated image files (PNG):
  40. sctunitAgi="../src/user-guide/images/${sctunitAgiPrefix}"
  41. setup_workdir()
  42. {
  43. if [ \! -e ${wd} ]
  44. then
  45. echo "Creating working directory ${wd}."
  46. mkdir -p ${wd}
  47. echo "Populating working directory with PPM images."
  48. for i in ${docuNti}*.png ${sctunitNti}*.png
  49. do
  50. ppmWorkFile="${wd}/`basename $i .png`.ppm"
  51. pngWorkFile="${wd}/`basename $i`"
  52. pngtopnm ${i} | pnmcrop | pnmmargin -white 10 >"${ppmWorkFile}"
  53. pnmtopng -compression 9 "${ppmWorkFile}" >"${pngWorkFile}"
  54. done
  55. fi
  56. }
  57. create_grammar_image()
  58. {
  59. local targetName="$1"
  60. shift
  61. n=""
  62. for i in $*
  63. do
  64. n="${n} ${wd}/${ntiPrefix}${i}.ppm"
  65. done
  66. local outputFile="${agi}${targetName}.png"
  67. echo "Creating grammar image file ${outputFile}"
  68. pnmcat -topbottom -jleft ${n} | \
  69. pnmtopng -compression 9 >"${outputFile}"
  70. }
  71. setup_workdir
  72. ntiPrefix="${docuNtiPrefix}"
  73. agiPrefix="${docuAgiPrefix}"
  74. agi="${docuAgi}"
  75. # Transition: overview
  76. create_grammar_image transition-overview \
  77. transitionreaction \
  78. stexttrigger \
  79. reactiontrigger \
  80. defaulttrigger \
  81. # Transition: event trigger + guard
  82. create_grammar_image transition-eventtrigger \
  83. transitionreaction \
  84. stexttrigger \
  85. reactiontrigger \
  86. defaulttrigger
  87. # Transition: reaction effect
  88. create_grammar_image reaction-effect \
  89. reactioneffect \
  90. eventraisingexpression
  91. # Transition: detailed
  92. create_grammar_image transition-detailed \
  93. transitionspecification \
  94. transitionreaction \
  95. stexttrigger \
  96. reactiontrigger \
  97. eventspec \
  98. regulareventspec \
  99. simplefeaturecall \
  100. simpleelementreferenceexpression \
  101. timeeventspec \
  102. timeeventtype \
  103. conditionalexpression \
  104. timeunit \
  105. builtineventspec \
  106. entryevent \
  107. exitevent \
  108. alwaysevent \
  109. defaulttrigger \
  110. reactioneffect \
  111. eventraisingexpression \
  112. featurecall \
  113. transitionproperty \
  114. entrypointspec \
  115. exitpointspec
  116. # State: overview
  117. create_grammar_image state-overview \
  118. statescope \
  119. localreaction \
  120. # Local reaction
  121. create_grammar_image state-localreaction \
  122. localreaction \
  123. reactiontrigger \
  124. reactioneffect
  125. # Event specification overview
  126. create_grammar_image event-specification-overview \
  127. reactiontrigger \
  128. eventspec \
  129. regulareventspec \
  130. timeeventspec \
  131. timeeventtype \
  132. timeunit \
  133. builtineventspec \
  134. entryevent \
  135. exitevent \
  136. alwaysevent
  137. # Guard condition overview
  138. create_grammar_image guard-condition-overview \
  139. reactiontrigger \
  140. guard
  141. #
  142. # SCTUnit grammar
  143. #
  144. ntiPrefix="${sctunitNtiPrefix}"
  145. agiPrefix="${sctunitAgiPrefix}"
  146. agi="${sctunitAgi}"
  147. # Test package
  148. create_grammar_image test_unit \
  149. testpackage \
  150. packageimport \
  151. namedsctunitelement \
  152. sctunitelement
  153. # Operation
  154. create_grammar_image operation \
  155. sctunitoperation \
  156. statementblock \
  157. teststatement
  158. # Assertion
  159. create_grammar_image assertion \
  160. assertionstatement \
  161. positiveverifystatement \
  162. negativeverifystatement
  163. # Process
  164. create_grammar_image proceed \
  165. proceedexpression \
  166. proceedunit