adlint 2.6.14 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (401) hide show
  1. data/AUTHORS +1 -3
  2. data/ChangeLog +511 -0
  3. data/INSTALL +1 -1
  4. data/MANIFEST +57 -37
  5. data/NEWS +36 -7
  6. data/README +2 -2
  7. data/Rakefile +6 -6
  8. data/TODO +1 -1
  9. data/bin/adlint +25 -16
  10. data/bin/adlint_chk +22 -12
  11. data/bin/adlint_cma +17 -12
  12. data/bin/adlint_sma +22 -12
  13. data/bin/adlintize +98 -17
  14. data/etc/conf.d/fallback/cinit.erb +1 -1
  15. data/etc/conf.d/fallback/traits.erb +37 -37
  16. data/etc/conf.d/i686-cygwin/cinit-gcc_4.3.4.erb +1 -1
  17. data/etc/conf.d/i686-cygwin/traits-gcc_4.3.4.erb +41 -41
  18. data/etc/conf.d/i686-devkit/cinit-gcc_4.5.2.erb +1 -1
  19. data/etc/conf.d/i686-devkit/traits-gcc_4.5.2.erb +40 -40
  20. data/etc/conf.d/i686-linux/cinit-gcc_4.5.1.erb +1 -1
  21. data/etc/conf.d/i686-linux/traits-gcc_4.5.1.erb +40 -40
  22. data/etc/conf.d/i686-mingw/cinit-gcc_4.6.1.erb +1 -1
  23. data/etc/conf.d/i686-mingw/traits-gcc_4.6.1.erb +40 -40
  24. data/etc/conf.d/noarch/GNUmakefile.erb +1 -1
  25. data/etc/conf.d/noarch/adlint_all_bat.erb +1 -1
  26. data/etc/conf.d/noarch/adlint_all_sh.erb +1 -1
  27. data/etc/conf.d/noarch/pinit.erb +1 -1
  28. data/etc/conf.d/x86_64-ubuntu_12.04/cinit-gcc_4.6.3.erb +1 -1
  29. data/etc/conf.d/x86_64-ubuntu_12.04/traits-gcc_4.6.3.erb +42 -42
  30. data/etc/mesg.d/c_builtin/en_US/messages.yml +33 -33
  31. data/etc/mesg.d/c_builtin/ja_JP/messages.yml +5 -5
  32. data/etc/mesg.d/core/en_US/messages.yml +2 -2
  33. data/etc/mesg.d/core/ja_JP/messages.yml +2 -2
  34. data/features/code_check/W0018.feature +197 -0
  35. data/features/code_check/W0019.feature +79 -0
  36. data/features/code_check/W0021.feature +81 -0
  37. data/features/code_check/W0023.feature +203 -0
  38. data/features/code_check/W0024.feature +226 -0
  39. data/features/code_check/W0025.feature +5 -0
  40. data/features/code_check/W0088.feature +2 -2
  41. data/features/code_check/W0109.feature +2 -2
  42. data/features/code_check/W0477.feature +0 -3
  43. data/features/code_check/W0478.feature +0 -1
  44. data/features/code_check/W0582.feature +3 -3
  45. data/features/code_check/W0583.feature +4 -7
  46. data/features/code_check/W0646.feature +0 -1
  47. data/features/code_check/W0695.feature +0 -1
  48. data/features/code_check/W0705.feature +8 -0
  49. data/features/code_check/W0723.feature +0 -1
  50. data/features/code_check/W0745.feature +1 -0
  51. data/features/code_check/W0781.feature +1 -0
  52. data/features/code_check/W1057.feature +141 -0
  53. data/features/code_check/W1058.feature +93 -0
  54. data/features/code_check/W1059.feature +86 -0
  55. data/features/code_check/W1060.feature +77 -0
  56. data/features/code_check/W1061.feature +143 -0
  57. data/features/code_check/W1062.feature +162 -0
  58. data/features/code_check/W1063.feature +123 -0
  59. data/features/code_check/W1064.feature +83 -0
  60. data/features/code_check/W1065.feature +82 -0
  61. data/features/code_check/W9003.feature +2 -0
  62. data/features/step_definitions/code_check_steps.rb +1 -0
  63. data/features/support/env.rb +16 -13
  64. data/lib/adlint.rb +7 -4
  65. data/lib/adlint/analyzer.rb +131 -157
  66. data/lib/adlint/annot.rb +149 -0
  67. data/lib/adlint/cc1.rb +57 -0
  68. data/lib/adlint/{c → cc1}/branch.rb +74 -62
  69. data/lib/adlint/{c → cc1}/builtin.rb +21 -21
  70. data/lib/adlint/{c → cc1}/const.rb +119 -117
  71. data/lib/adlint/{c → cc1}/conv.rb +76 -78
  72. data/lib/adlint/{c → cc1}/ctrlexpr.rb +69 -86
  73. data/lib/adlint/cc1/domain.rb +8103 -0
  74. data/lib/adlint/{c → cc1}/enum.rb +3 -3
  75. data/lib/adlint/{c → cc1}/environ.rb +21 -21
  76. data/lib/adlint/{c → cc1}/expr.rb +232 -218
  77. data/lib/adlint/{c → cc1}/format.rb +305 -342
  78. data/lib/adlint/{c → cc1}/interp.rb +269 -220
  79. data/lib/adlint/cc1/lexer.rb +246 -0
  80. data/lib/adlint/{c → cc1}/mediator.rb +78 -84
  81. data/lib/adlint/{c → cc1}/object.rb +261 -264
  82. data/lib/adlint/{c → cc1}/operator.rb +7 -7
  83. data/lib/adlint/{c → cc1}/option.rb +4 -3
  84. data/lib/adlint/{c → cc1}/parser.rb +274 -506
  85. data/lib/adlint/{c → cc1}/parser.y +69 -301
  86. data/lib/adlint/cc1/phase.rb +138 -0
  87. data/lib/adlint/{c → cc1}/resolver.rb +66 -78
  88. data/lib/adlint/{c → cc1}/scanner.rb +57 -49
  89. data/lib/adlint/{c → cc1}/scope.rb +3 -3
  90. data/lib/adlint/{c → cc1}/seqp.rb +13 -5
  91. data/lib/adlint/{c → cc1}/syntax.rb +819 -1122
  92. data/lib/adlint/{c → cc1}/type.rb +1498 -1479
  93. data/lib/adlint/{c → cc1}/util.rb +20 -12
  94. data/lib/adlint/{c → cc1}/value.rb +699 -642
  95. data/lib/adlint/code.rb +163 -164
  96. data/lib/adlint/cpp.rb +2 -2
  97. data/lib/adlint/cpp/asm.rb +13 -14
  98. data/lib/adlint/cpp/constexpr.rb +42 -38
  99. data/lib/adlint/cpp/constexpr.y +44 -40
  100. data/lib/adlint/cpp/eval.rb +435 -435
  101. data/lib/adlint/cpp/lexer.rb +343 -340
  102. data/lib/adlint/cpp/macro.rb +188 -190
  103. data/lib/adlint/cpp/phase.rb +66 -45
  104. data/lib/adlint/cpp/scanner.rb +14 -17
  105. data/lib/adlint/cpp/source.rb +49 -55
  106. data/lib/adlint/cpp/subst.rb +65 -65
  107. data/lib/adlint/cpp/syntax.rb +155 -275
  108. data/lib/adlint/cpp/util.rb +22 -19
  109. data/lib/adlint/driver.rb +86 -93
  110. data/lib/adlint/error.rb +33 -52
  111. data/lib/adlint/exam.rb +158 -24
  112. data/lib/adlint/exam/c_builtin.rb +7 -7
  113. data/lib/adlint/exam/c_builtin/cc1_check.rb +20522 -0
  114. data/lib/adlint/exam/c_builtin/cc1_check_shima.rb +957 -0
  115. data/lib/adlint/exam/c_builtin/cc1_code.rb +459 -0
  116. data/lib/adlint/exam/c_builtin/cc1_metric.rb +794 -0
  117. data/lib/adlint/exam/c_builtin/cpp_check.rb +486 -441
  118. data/lib/adlint/exam/c_builtin/cpp_check_shima.rb +36 -39
  119. data/lib/adlint/exam/c_builtin/cpp_code.rb +63 -65
  120. data/lib/adlint/exam/c_builtin/ld_check.rb +136 -129
  121. data/lib/adlint/exam/c_builtin/ld_metric.rb +11 -11
  122. data/lib/adlint/lang.rb +25 -25
  123. data/lib/adlint/ld.rb +2 -2
  124. data/lib/adlint/ld/object.rb +220 -188
  125. data/lib/adlint/ld/phase.rb +94 -63
  126. data/lib/adlint/ld/typedef.rb +22 -11
  127. data/lib/adlint/ld/util.rb +43 -35
  128. data/lib/adlint/lexer.rb +59 -56
  129. data/lib/adlint/location.rb +140 -0
  130. data/lib/adlint/memo.rb +157 -0
  131. data/lib/adlint/message.rb +207 -156
  132. data/lib/adlint/metric.rb +139 -217
  133. data/lib/adlint/monitor.rb +45 -43
  134. data/lib/adlint/phase.rb +56 -29
  135. data/lib/adlint/prelude.rb +66 -54
  136. data/lib/adlint/report.rb +253 -332
  137. data/lib/adlint/source.rb +26 -27
  138. data/lib/adlint/supp.rb +131 -0
  139. data/lib/adlint/symbol.rb +14 -16
  140. data/lib/adlint/token.rb +19 -91
  141. data/lib/adlint/traits.rb +242 -226
  142. data/lib/adlint/util.rb +116 -205
  143. data/lib/adlint/version.rb +8 -8
  144. data/share/HEADER +2 -2
  145. data/share/doc/developers_guide_ja.html +148 -19
  146. data/share/doc/developers_guide_ja.texi +141 -11
  147. data/share/doc/samples/GNUmakefile +1 -1
  148. data/share/doc/samples/adlint_traits.yml +45 -36
  149. data/share/doc/users_guide_en.html +1321 -1252
  150. data/share/doc/users_guide_en.texi +475 -408
  151. data/share/doc/users_guide_ja.html +1932 -1878
  152. data/share/doc/users_guide_ja.texi +324 -273
  153. data/share/sample/bison-2.5/adlint/GNUmakefile +5 -1
  154. data/share/sample/bison-2.5/adlint/adlint_traits.yml +38 -38
  155. data/share/sample/bison-2.5/adlint/lib/GNUmakefile +1 -1
  156. data/share/sample/bison-2.5/adlint/lib/adlint_cinit.h +1 -1
  157. data/share/sample/bison-2.5/adlint/lib/adlint_pinit.h +1 -1
  158. data/share/sample/bison-2.5/adlint/lib/adlint_traits.yml +50 -42
  159. data/share/sample/bison-2.5/adlint/src/GNUmakefile +1 -1
  160. data/share/sample/bison-2.5/adlint/src/adlint_cinit.h +1 -1
  161. data/share/sample/bison-2.5/adlint/src/adlint_pinit.h +1 -1
  162. data/share/sample/bison-2.5/adlint/src/adlint_traits.yml +50 -42
  163. data/share/sample/ctags-5.8/adlint/GNUmakefile +1 -1
  164. data/share/sample/ctags-5.8/adlint/adlint_cinit.h +1 -1
  165. data/share/sample/ctags-5.8/adlint/adlint_pinit.h +1 -1
  166. data/share/sample/ctags-5.8/adlint/adlint_traits.yml +50 -42
  167. data/share/sample/flex-2.5.35/adlint/GNUmakefile +1 -1
  168. data/share/sample/flex-2.5.35/adlint/adlint_cinit.h +1 -1
  169. data/share/sample/flex-2.5.35/adlint/adlint_pinit.h +1 -1
  170. data/share/sample/flex-2.5.35/adlint/adlint_traits.yml +50 -42
  171. data/share/sample/ruby-1.9.3-p0/adlint/GNUmakefile +1 -1
  172. data/share/sample/ruby-1.9.3-p0/adlint/adlint_traits.yml +46 -38
  173. data/share/sample/ruby-1.9.3-p0/adlint/core/GNUmakefile +1 -1
  174. data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_cinit.h +1 -1
  175. data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_pinit.h +1 -1
  176. data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_traits.yml +50 -42
  177. data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/GNUmakefile +1 -1
  178. data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_cinit.h +1 -1
  179. data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_pinit.h +1 -1
  180. data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_traits.yml +50 -42
  181. data/share/sample/ruby-1.9.3-p0/adlint/enc/GNUmakefile +1 -1
  182. data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_cinit.h +1 -1
  183. data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_pinit.h +1 -1
  184. data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_traits.yml +50 -42
  185. data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/GNUmakefile +1 -1
  186. data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_cinit.h +1 -1
  187. data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_pinit.h +1 -1
  188. data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_traits.yml +50 -42
  189. data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/GNUmakefile +1 -1
  190. data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_cinit.h +1 -1
  191. data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_pinit.h +1 -1
  192. data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_traits.yml +50 -42
  193. data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/GNUmakefile +1 -1
  194. data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_cinit.h +1 -1
  195. data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_pinit.h +1 -1
  196. data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_traits.yml +50 -42
  197. data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/GNUmakefile +1 -1
  198. data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_cinit.h +1 -1
  199. data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_pinit.h +1 -1
  200. data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_traits.yml +50 -42
  201. data/share/sample/ruby-1.9.3-p0/adlint/ext-date/GNUmakefile +1 -1
  202. data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_cinit.h +1 -1
  203. data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_pinit.h +1 -1
  204. data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_traits.yml +50 -42
  205. data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/GNUmakefile +1 -1
  206. data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_cinit.h +1 -1
  207. data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_pinit.h +1 -1
  208. data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_traits.yml +50 -42
  209. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/GNUmakefile +1 -1
  210. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_cinit.h +1 -1
  211. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_pinit.h +1 -1
  212. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_traits.yml +50 -42
  213. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/GNUmakefile +1 -1
  214. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_cinit.h +1 -1
  215. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_pinit.h +1 -1
  216. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_traits.yml +50 -42
  217. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/GNUmakefile +1 -1
  218. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_cinit.h +1 -1
  219. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_pinit.h +1 -1
  220. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_traits.yml +50 -42
  221. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/GNUmakefile +1 -1
  222. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_cinit.h +1 -1
  223. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_pinit.h +1 -1
  224. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_traits.yml +50 -42
  225. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/GNUmakefile +1 -1
  226. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_cinit.h +1 -1
  227. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_pinit.h +1 -1
  228. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_traits.yml +50 -42
  229. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/GNUmakefile +1 -1
  230. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_cinit.h +1 -1
  231. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_pinit.h +1 -1
  232. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_traits.yml +50 -42
  233. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/GNUmakefile +1 -1
  234. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_cinit.h +1 -1
  235. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_pinit.h +1 -1
  236. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_traits.yml +50 -42
  237. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/GNUmakefile +1 -1
  238. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_cinit.h +1 -1
  239. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_pinit.h +1 -1
  240. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_traits.yml +50 -42
  241. data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/GNUmakefile +1 -1
  242. data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_cinit.h +1 -1
  243. data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_pinit.h +1 -1
  244. data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_traits.yml +50 -42
  245. data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/GNUmakefile +1 -1
  246. data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_cinit.h +1 -1
  247. data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_pinit.h +1 -1
  248. data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_traits.yml +50 -42
  249. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/GNUmakefile +1 -1
  250. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_cinit.h +1 -1
  251. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_pinit.h +1 -1
  252. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_traits.yml +50 -42
  253. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/GNUmakefile +1 -1
  254. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_cinit.h +1 -1
  255. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_pinit.h +1 -1
  256. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_traits.yml +50 -42
  257. data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/GNUmakefile +1 -1
  258. data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_cinit.h +1 -1
  259. data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_pinit.h +1 -1
  260. data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_traits.yml +50 -42
  261. data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/GNUmakefile +1 -1
  262. data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_cinit.h +1 -1
  263. data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_pinit.h +1 -1
  264. data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_traits.yml +50 -42
  265. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/GNUmakefile +1 -1
  266. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_cinit.h +1 -1
  267. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_pinit.h +1 -1
  268. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_traits.yml +50 -42
  269. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/GNUmakefile +1 -1
  270. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_cinit.h +1 -1
  271. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_pinit.h +1 -1
  272. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_traits.yml +50 -42
  273. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/GNUmakefile +1 -1
  274. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_cinit.h +1 -1
  275. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_pinit.h +1 -1
  276. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_traits.yml +50 -42
  277. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/GNUmakefile +1 -1
  278. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_cinit.h +1 -1
  279. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_pinit.h +1 -1
  280. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_traits.yml +50 -42
  281. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/GNUmakefile +1 -1
  282. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_cinit.h +1 -1
  283. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_pinit.h +1 -1
  284. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_traits.yml +50 -42
  285. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/GNUmakefile +1 -1
  286. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_cinit.h +1 -1
  287. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_pinit.h +1 -1
  288. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_traits.yml +50 -42
  289. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/GNUmakefile +1 -1
  290. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_cinit.h +1 -1
  291. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_pinit.h +1 -1
  292. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_traits.yml +50 -42
  293. data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/GNUmakefile +1 -1
  294. data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_cinit.h +1 -1
  295. data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_pinit.h +1 -1
  296. data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_traits.yml +50 -42
  297. data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/GNUmakefile +1 -1
  298. data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_cinit.h +1 -1
  299. data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_pinit.h +1 -1
  300. data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_traits.yml +50 -42
  301. data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/GNUmakefile +1 -1
  302. data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_cinit.h +1 -1
  303. data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_pinit.h +1 -1
  304. data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_traits.yml +50 -42
  305. data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/GNUmakefile +1 -1
  306. data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_cinit.h +1 -1
  307. data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_pinit.h +1 -1
  308. data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_traits.yml +50 -42
  309. data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/GNUmakefile +1 -1
  310. data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_cinit.h +1 -1
  311. data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_pinit.h +1 -1
  312. data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_traits.yml +50 -42
  313. data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/GNUmakefile +1 -1
  314. data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_cinit.h +1 -1
  315. data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_pinit.h +1 -1
  316. data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_traits.yml +50 -42
  317. data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/GNUmakefile +1 -1
  318. data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_cinit.h +1 -1
  319. data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_pinit.h +1 -1
  320. data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_traits.yml +50 -42
  321. data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/GNUmakefile +1 -1
  322. data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_cinit.h +1 -1
  323. data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_pinit.h +1 -1
  324. data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_traits.yml +50 -42
  325. data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/GNUmakefile +1 -1
  326. data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_cinit.h +1 -1
  327. data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_pinit.h +1 -1
  328. data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_traits.yml +50 -42
  329. data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/GNUmakefile +1 -1
  330. data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_cinit.h +1 -1
  331. data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_pinit.h +1 -1
  332. data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_traits.yml +50 -42
  333. data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/GNUmakefile +1 -1
  334. data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_cinit.h +1 -1
  335. data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_pinit.h +1 -1
  336. data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_traits.yml +50 -42
  337. data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/GNUmakefile +1 -1
  338. data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_cinit.h +1 -1
  339. data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_pinit.h +1 -1
  340. data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_traits.yml +50 -42
  341. data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/GNUmakefile +1 -1
  342. data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_cinit.h +1 -1
  343. data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_pinit.h +1 -1
  344. data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_traits.yml +50 -42
  345. data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/GNUmakefile +1 -1
  346. data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_cinit.h +1 -1
  347. data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_pinit.h +1 -1
  348. data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_traits.yml +50 -42
  349. data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/GNUmakefile +1 -1
  350. data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_cinit.h +1 -1
  351. data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_pinit.h +1 -1
  352. data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_traits.yml +50 -42
  353. data/share/sample/screen-4.0.3/adlint/GNUmakefile +1 -1
  354. data/share/sample/screen-4.0.3/adlint/adlint_cinit.h +1 -1
  355. data/share/sample/screen-4.0.3/adlint/adlint_pinit.h +1 -1
  356. data/share/sample/screen-4.0.3/adlint/adlint_traits.yml +50 -42
  357. data/share/sample/vim-7.3/adlint/vim/GNUmakefile +1 -1
  358. data/share/sample/vim-7.3/adlint/vim/adlint_cinit.h +1 -1
  359. data/share/sample/vim-7.3/adlint/vim/adlint_pinit.h +1 -1
  360. data/share/sample/vim-7.3/adlint/vim/adlint_traits.yml +50 -42
  361. data/share/sample/vim-7.3/adlint/xxd/GNUmakefile +1 -1
  362. data/share/sample/vim-7.3/adlint/xxd/adlint_cinit.h +1 -1
  363. data/share/sample/vim-7.3/adlint/xxd/adlint_pinit.h +1 -1
  364. data/share/sample/vim-7.3/adlint/xxd/adlint_traits.yml +49 -41
  365. data/share/sample/zsh-4.3.15/adlint/GNUmakefile +1 -1
  366. data/share/sample/zsh-4.3.15/adlint/adlint_traits.yml +46 -38
  367. data/share/sample/zsh-4.3.15/adlint/builtins/GNUmakefile +1 -1
  368. data/share/sample/zsh-4.3.15/adlint/builtins/adlint_cinit.h +1 -1
  369. data/share/sample/zsh-4.3.15/adlint/builtins/adlint_pinit.h +1 -1
  370. data/share/sample/zsh-4.3.15/adlint/builtins/adlint_traits.yml +50 -42
  371. data/share/sample/zsh-4.3.15/adlint/core/GNUmakefile +1 -1
  372. data/share/sample/zsh-4.3.15/adlint/core/adlint_cinit.h +1 -1
  373. data/share/sample/zsh-4.3.15/adlint/core/adlint_pinit.h +1 -1
  374. data/share/sample/zsh-4.3.15/adlint/core/adlint_traits.yml +50 -42
  375. data/share/sample/zsh-4.3.15/adlint/modules/GNUmakefile +1 -1
  376. data/share/sample/zsh-4.3.15/adlint/modules/adlint_cinit.h +1 -1
  377. data/share/sample/zsh-4.3.15/adlint/modules/adlint_pinit.h +1 -1
  378. data/share/sample/zsh-4.3.15/adlint/modules/adlint_traits.yml +50 -42
  379. data/share/sample/zsh-4.3.15/adlint/zle/GNUmakefile +1 -1
  380. data/share/sample/zsh-4.3.15/adlint/zle/adlint_cinit.h +1 -1
  381. data/share/sample/zsh-4.3.15/adlint/zle/adlint_pinit.h +1 -1
  382. data/share/sample/zsh-4.3.15/adlint/zle/adlint_traits.yml +50 -42
  383. data/spec/adlint/{c → cc1}/ctrlexpr_spec.rb +51 -49
  384. data/spec/adlint/{c → cc1}/domain_spec.rb +210 -179
  385. data/spec/adlint/{c → cc1}/operator_spec.rb +3 -3
  386. data/spec/adlint/{c → cc1}/syntax_spec.rb +10 -12
  387. data/spec/adlint/{c → cc1}/type_spec.rb +61 -68
  388. data/{lib/adlint/c.rb → spec/adlint/location_spec.rb} +24 -29
  389. data/spec/conf.d/default_traits.yml +38 -37
  390. data/spec/conf.d/empty_cinit.h +1 -1
  391. data/spec/conf.d/empty_pinit.h +1 -1
  392. data/spec/conf.d/project/foo.c +0 -0
  393. data/spec/spec_helper.rb +2 -2
  394. metadata +60 -40
  395. data/lib/adlint/c/domain.rb +0 -7931
  396. data/lib/adlint/c/lexer.rb +0 -252
  397. data/lib/adlint/c/phase.rb +0 -135
  398. data/lib/adlint/exam/c_builtin/c_check.rb +0 -20745
  399. data/lib/adlint/exam/c_builtin/c_check_shima.rb +0 -983
  400. data/lib/adlint/exam/c_builtin/c_code.rb +0 -477
  401. data/lib/adlint/exam/c_builtin/c_metric.rb +0 -818
@@ -1,7 +1,7 @@
1
1
  # C runtime scope.
2
2
  #
3
3
  # Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
4
- # Copyright:: Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
4
+ # Copyright:: Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
5
5
  # License:: GPLv3+: GNU General Public License version 3 or later
6
6
  #
7
7
  # Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
@@ -11,7 +11,7 @@
11
11
  # / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
12
12
  # / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
13
13
  # / __ |/ /_/ / /___/ / /| / / /
14
- # /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
14
+ # /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
15
15
  #
16
16
  # This file is part of AdLint.
17
17
  #
@@ -30,7 +30,7 @@
30
30
  #++
31
31
 
32
32
  module AdLint #:nodoc:
33
- module C #:nodoc:
33
+ module Cc1 #:nodoc:
34
34
 
35
35
  class Scope
36
36
  def initialize(depth)
@@ -1,7 +1,7 @@
1
1
  # Sequence points of C language evaluation.
2
2
  #
3
3
  # Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
4
- # Copyright:: Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
4
+ # Copyright:: Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
5
5
  # License:: GPLv3+: GNU General Public License version 3 or later
6
6
  #
7
7
  # Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
@@ -11,7 +11,7 @@
11
11
  # / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
12
12
  # / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
13
13
  # / __ |/ /_/ / /___/ / /| / / /
14
- # /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
14
+ # /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
15
15
  #
16
16
  # This file is part of AdLint.
17
17
  #
@@ -29,8 +29,10 @@
29
29
  #
30
30
  #++
31
31
 
32
+ require "adlint/location"
33
+
32
34
  module AdLint #:nodoc:
33
- module C #:nodoc:
35
+ module Cc1 #:nodoc:
34
36
 
35
37
  # NOTE: The ISO C99 standard says;
36
38
  #
@@ -56,13 +58,19 @@ module C #:nodoc:
56
58
  # movement of the objects passed as arguments to that call (7.20.5).
57
59
 
58
60
  class SequencePoint
59
- def initialize(last_node, obvious = true)
60
- @last_node = last_node
61
+ include LocationHolder
62
+
63
+ def initialize(lst_node, obvious = true)
64
+ @last_node = lst_node
61
65
  @obvious = obvious
62
66
  end
63
67
 
64
68
  attr_reader :last_node
65
69
 
70
+ def location
71
+ @last_node.location
72
+ end
73
+
66
74
  def obvious?
67
75
  @obvious
68
76
  end
@@ -1,7 +1,7 @@
1
1
  # AST of C language.
2
2
  #
3
3
  # Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
4
- # Copyright:: Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
4
+ # Copyright:: Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
5
5
  # License:: GPLv3+: GNU General Public License version 3 or later
6
6
  #
7
7
  # Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
@@ -11,7 +11,7 @@
11
11
  # / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
12
12
  # / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
13
13
  # / __ |/ /_/ / /___/ / /| / / /
14
- # /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
14
+ # /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
15
15
  #
16
16
  # This file is part of AdLint.
17
17
  #
@@ -30,134 +30,137 @@
30
30
  #++
31
31
 
32
32
  require "adlint/symbol"
33
+ require "adlint/location"
34
+ require "adlint/exam"
33
35
  require "adlint/util"
34
- require "adlint/c/seqp"
35
- require "adlint/c/operator"
36
+ require "adlint/cc1/seqp"
37
+ require "adlint/cc1/operator"
36
38
 
37
39
  module AdLint #:nodoc:
38
- module C #:nodoc:
40
+ module Cc1 #:nodoc:
39
41
 
40
42
  # == DESCRIPTION
41
43
  # === SyntaxNode class hierarchy
42
44
  # SyntaxNode
43
- # <--- Expression
44
- # <--- ErrorExpression
45
- # <--- PrimaryExpression
46
- # <--- ObjectSpecifier
47
- # <--- ConstantSpecifier
48
- # <--- StringLiteralSpecifier
49
- # <--- NullConstantSpecifier
50
- # <--- GroupedExpression
51
- # <--- PostfixExpression
52
- # <--- ArraySubscriptExpression
53
- # <--- FunctionCallExpression
54
- # <--- MemberAccessByValueExpression
55
- # <--- MemberAccessByPointerExpression
56
- # <--- BitAccessByValueExpression
57
- # <--- BitAccessByPointerExpression
58
- # <--- PostfixIncrementExpression
59
- # <--- PostfixDecrementExpression
60
- # <--- CompoundLiteralExpression
61
- # <--- UnaryExpression
62
- # <--- PrefixIncrementExpression
63
- # <--- PrefixDecrementExpression
64
- # <--- AddressExpression
65
- # <--- IndirectionExpression
66
- # <--- UnaryArithmeticExpression
67
- # <--- SizeofExpression
68
- # <--- SizeofTypeExpression
69
- # <--- AlignofExpression
70
- # <--- AlignofTypeExpression
71
- # <--- CastExpression
72
- # <--- BinaryExpression
73
- # <--- MultiplicativeExpression
74
- # <--- AdditiveExpression
75
- # <--- ShiftExpression
76
- # <--- RelationalExpression
77
- # <--- EqualityExpression
78
- # <--- AndExpression
79
- # <--- ExclusiveOrExpression
80
- # <--- InclusiveOrExpression
81
- # <--- LogicalAndExpression
82
- # <--- LogicalOrExpression
83
- # <--- ConditionalExpression
84
- # <--- SimpleAssignmentExpression
85
- # <--- CompoundAssignmentExpression
86
- # <--- CommaSeparatedExpression
87
- # <--- Declaration
88
- # <--- FunctionDeclaration -------------------- SymbolicElement <<module>>
89
- # <--- VariableDeclaration ----------------------+ | | | |
90
- # <--- Definition | | | |
91
- # <--- VariableDefinition -------------------+ | | |
92
- # <--- PseudoVariableDefinition | | |
93
- # <--- FunctionDefinition ----------------------+ | |
94
- # <--- KandRFunctionDefinition | |
95
- # <--- AnsiFunctionDefinition | |
96
- # <--- ParameterDefinition | |
97
- # <--- TypeDeclaration -----------------------------------+ |
98
- # <--- TypedefDeclaration |
99
- # <--- StructTypeDeclaration |
100
- # <--- PseudoStructTypeDeclaration |
101
- # <--- UnionTypeDeclaration |
102
- # <--- PseudoUnionTypeDeclaration |
103
- # <--- EnumTypeDeclaration |
104
- # <--- PseudoEnumTypeDeclaration |
105
- # <--- DeclarationSpecifiers |
106
- # <--- InitDeclarator |
107
- # <--- TypeSpecifier |
108
- # <--- StandardTypeSpecifier |
109
- # <--- TypedefTypeSpecifier |
110
- # <--- StructSpecifier |
111
- # <--- UnionSpecifier |
112
- # <--- TypeofTypeSpecifier |
113
- # <--- StructDeclaration |
114
- # <--- MemberDeclaration |
115
- # <--- SpecifierQualifierList |
116
- # <--- StructDeclarator |
117
- # <--- EnumSpecifier |
118
- # <--- Enumerator -------------------------------------------+
119
- # <--- Declarator
120
- # <--- IdentifierDeclarator
121
- # <--- GroupedDeclarator
122
- # <--- ArrayDeclarator
123
- # <--- FunctionDeclarator
124
- # <--- AnsiFunctionDeclarator
125
- # <--- KandRFunctionDeclarator
126
- # <--- AbbreviatedFunctionDeclarator
127
- # <--- AbstractDeclarator
128
- # <--- PointerAbstractDeclarator
129
- # <--- GroupedAbstractDeclarator
130
- # <--- ArrayAbstractDeclarator
131
- # <--- FunctionAbstractDeclarator
132
- # <--- ParameterTypeList
133
- # <--- ParameterDeclaration
134
- # <--- Statement
135
- # <--- ErrorStatement
136
- # <--- LabeledStatement
137
- # <--- GenericLabeledStatement
138
- # <--- CaseLabeledStatement
139
- # <--- DefaultLabeledStatement
140
- # <--- CompoundStatement
141
- # <--- ExpressionStatement
142
- # <--- SelectionStatement
143
- # <--- IfStatement
144
- # <--- IfElseStatement
145
- # <--- SwitchStatement
146
- # <--- IterationStatement
147
- # <--- WhileStatement
148
- # <--- DoStatement
149
- # <--- ForStatement
150
- # <--- C99ForStatement
151
- # <--- JumpStatement
152
- # <--- GotoStatement
153
- # <--- ContinueStatement
154
- # <--- BreakStatement
155
- # <--- ReturnStatement
156
- # <--- TranslationUnit
157
- # <--- TypeName
158
- # <--- Initializer
45
+ # <-- Expression
46
+ # <-- ErrorExpression
47
+ # <-- PrimaryExpression
48
+ # <-- ObjectSpecifier
49
+ # <-- ConstantSpecifier
50
+ # <-- StringLiteralSpecifier
51
+ # <-- NullConstantSpecifier
52
+ # <-- GroupedExpression
53
+ # <-- PostfixExpression
54
+ # <-- ArraySubscriptExpression
55
+ # <-- FunctionCallExpression
56
+ # <-- MemberAccessByValueExpression
57
+ # <-- MemberAccessByPointerExpression
58
+ # <-- BitAccessByValueExpression
59
+ # <-- BitAccessByPointerExpression
60
+ # <-- PostfixIncrementExpression
61
+ # <-- PostfixDecrementExpression
62
+ # <-- CompoundLiteralExpression
63
+ # <-- UnaryExpression
64
+ # <-- PrefixIncrementExpression
65
+ # <-- PrefixDecrementExpression
66
+ # <-- AddressExpression
67
+ # <-- IndirectionExpression
68
+ # <-- UnaryArithmeticExpression
69
+ # <-- SizeofExpression
70
+ # <-- SizeofTypeExpression
71
+ # <-- AlignofExpression
72
+ # <-- AlignofTypeExpression
73
+ # <-- CastExpression
74
+ # <-- BinaryExpression
75
+ # <-- MultiplicativeExpression
76
+ # <-- AdditiveExpression
77
+ # <-- ShiftExpression
78
+ # <-- RelationalExpression
79
+ # <-- EqualityExpression
80
+ # <-- AndExpression
81
+ # <-- ExclusiveOrExpression
82
+ # <-- InclusiveOrExpression
83
+ # <-- LogicalAndExpression
84
+ # <-- LogicalOrExpression
85
+ # <-- ConditionalExpression
86
+ # <-- SimpleAssignmentExpression
87
+ # <-- CompoundAssignmentExpression
88
+ # <-- CommaSeparatedExpression
89
+ # <-- Declaration
90
+ # <-- FunctionDeclaration -------------------- SymbolicElement <<module>>
91
+ # <-- VariableDeclaration ----------------------+ | | | |
92
+ # <-- Definition | | | |
93
+ # <-- VariableDefinition --------------------+ | | |
94
+ # <-- PseudoVariableDefinition | | |
95
+ # <-- FunctionDefinition -----------------------+ | |
96
+ # <-- KandRFunctionDefinition | |
97
+ # <-- AnsiFunctionDefinition | |
98
+ # <-- ParameterDefinition | |
99
+ # <-- TypeDeclaration -----------------------------------+ |
100
+ # <-- TypedefDeclaration |
101
+ # <-- StructTypeDeclaration |
102
+ # <-- PseudoStructTypeDeclaration |
103
+ # <-- UnionTypeDeclaration |
104
+ # <-- PseudoUnionTypeDeclaration |
105
+ # <-- EnumTypeDeclaration |
106
+ # <-- PseudoEnumTypeDeclaration |
107
+ # <-- DeclarationSpecifiers |
108
+ # <-- InitDeclarator |
109
+ # <-- TypeSpecifier |
110
+ # <-- StandardTypeSpecifier |
111
+ # <-- TypedefTypeSpecifier |
112
+ # <-- StructSpecifier |
113
+ # <-- UnionSpecifier |
114
+ # <-- TypeofTypeSpecifier |
115
+ # <-- StructDeclaration |
116
+ # <-- MemberDeclaration |
117
+ # <-- SpecifierQualifierList |
118
+ # <-- StructDeclarator |
119
+ # <-- EnumSpecifier |
120
+ # <-- Enumerator -------------------------------------------+
121
+ # <-- Declarator
122
+ # <-- IdentifierDeclarator
123
+ # <-- GroupedDeclarator
124
+ # <-- ArrayDeclarator
125
+ # <-- FunctionDeclarator
126
+ # <-- AnsiFunctionDeclarator
127
+ # <-- KandRFunctionDeclarator
128
+ # <-- AbbreviatedFunctionDeclarator
129
+ # <-- AbstractDeclarator
130
+ # <-- PointerAbstractDeclarator
131
+ # <-- GroupedAbstractDeclarator
132
+ # <-- ArrayAbstractDeclarator
133
+ # <-- FunctionAbstractDeclarator
134
+ # <-- ParameterTypeList
135
+ # <-- ParameterDeclaration
136
+ # <-- Statement
137
+ # <-- ErrorStatement
138
+ # <-- LabeledStatement
139
+ # <-- GenericLabeledStatement
140
+ # <-- CaseLabeledStatement
141
+ # <-- DefaultLabeledStatement
142
+ # <-- CompoundStatement
143
+ # <-- ExpressionStatement
144
+ # <-- SelectionStatement
145
+ # <-- IfStatement
146
+ # <-- IfElseStatement
147
+ # <-- SwitchStatement
148
+ # <-- IterationStatement
149
+ # <-- WhileStatement
150
+ # <-- DoStatement
151
+ # <-- ForStatement
152
+ # <-- C99ForStatement
153
+ # <-- JumpStatement
154
+ # <-- GotoStatement
155
+ # <-- ContinueStatement
156
+ # <-- BreakStatement
157
+ # <-- ReturnStatement
158
+ # <-- TranslationUnit
159
+ # <-- TypeName
160
+ # <-- Initializer
159
161
  class SyntaxNode
160
162
  include Visitable
163
+ include LocationHolder
161
164
 
162
165
  def initialize
163
166
  @head_token = nil
@@ -206,8 +209,8 @@ module C #:nodoc:
206
209
  module SyntaxNodeCollector
207
210
  def collect_object_specifiers(node)
208
211
  if node
209
- ObjectSpecifierCollector.new.tap { |collector|
210
- node.accept(collector)
212
+ ObjectSpecifierCollector.new.tap { |col|
213
+ node.accept(col)
211
214
  }.object_specifiers
212
215
  else
213
216
  []
@@ -217,8 +220,8 @@ module C #:nodoc:
217
220
 
218
221
  def collect_identifier_declarators(node)
219
222
  if node
220
- IdentifierDeclaratorCollector.new.tap { |collector|
221
- node.accept(collector)
223
+ IdentifierDeclaratorCollector.new.tap { |col|
224
+ node.accept(col)
222
225
  }.identifier_declarators
223
226
  else
224
227
  []
@@ -228,8 +231,8 @@ module C #:nodoc:
228
231
 
229
232
  def collect_typedef_type_specifiers(node)
230
233
  if node
231
- TypedefTypeSpecifierCollector.new.tap { |collector|
232
- node.accept(collector)
234
+ TypedefTypeSpecifierCollector.new.tap { |col|
235
+ node.accept(col)
233
236
  }.typedef_type_specifiers
234
237
  else
235
238
  []
@@ -239,8 +242,8 @@ module C #:nodoc:
239
242
 
240
243
  def collect_function_declarators(node)
241
244
  if node
242
- FunctionDeclaratorCollector.new.tap { |collector|
243
- node.accept(collector)
245
+ FunctionDeclaratorCollector.new.tap { |col|
246
+ node.accept(col)
244
247
  }.function_declarators
245
248
  else
246
249
  []
@@ -250,8 +253,8 @@ module C #:nodoc:
250
253
 
251
254
  def collect_simple_assignment_expressions(node)
252
255
  if node
253
- SimpleAssignmentExpressionCollector.new.tap { |collector|
254
- node.accept(collector)
256
+ SimpleAssignmentExpressionCollector.new.tap { |col|
257
+ node.accept(col)
255
258
  }.simple_assignment_expressions
256
259
  else
257
260
  []
@@ -261,8 +264,8 @@ module C #:nodoc:
261
264
 
262
265
  def collect_compound_assignment_expressions(node)
263
266
  if node
264
- CompoundAssignmentExpressionCollector.new.tap { |collector|
265
- node.accept(collector)
267
+ CompoundAssignmentExpressionCollector.new.tap { |col|
268
+ node.accept(col)
266
269
  }.compound_assignment_expressions
267
270
  else
268
271
  []
@@ -272,8 +275,8 @@ module C #:nodoc:
272
275
 
273
276
  def collect_prefix_increment_expressions(node)
274
277
  if node
275
- PrefixIncrementExpressionCollector.new.tap { |collector|
276
- node.accept(collector)
278
+ PrefixIncrementExpressionCollector.new.tap { |col|
279
+ node.accept(col)
277
280
  }.prefix_increment_expressions
278
281
  else
279
282
  []
@@ -283,8 +286,8 @@ module C #:nodoc:
283
286
 
284
287
  def collect_prefix_decrement_expressions(node)
285
288
  if node
286
- PrefixDecrementExpressionCollector.new.tap { |collector|
287
- node.accept(collector)
289
+ PrefixDecrementExpressionCollector.new.tap { |col|
290
+ node.accept(col)
288
291
  }.prefix_decrement_expressions
289
292
  else
290
293
  []
@@ -294,8 +297,8 @@ module C #:nodoc:
294
297
 
295
298
  def collect_postfix_increment_expressions(node)
296
299
  if node
297
- PostfixIncrementExpressionCollector.new.tap { |collector|
298
- node.accept(collector)
300
+ PostfixIncrementExpressionCollector.new.tap { |col|
301
+ node.accept(col)
299
302
  }.postfix_increment_expressions
300
303
  else
301
304
  []
@@ -305,8 +308,8 @@ module C #:nodoc:
305
308
 
306
309
  def collect_postfix_decrement_expressions(node)
307
310
  if node
308
- PostfixDecrementExpressionCollector.new.tap { |collector|
309
- node.accept(collector)
311
+ PostfixDecrementExpressionCollector.new.tap { |col|
312
+ node.accept(col)
310
313
  }.postfix_decrement_expressions
311
314
  else
312
315
  []
@@ -316,8 +319,8 @@ module C #:nodoc:
316
319
 
317
320
  def collect_additive_expressions(node)
318
321
  if node
319
- AdditiveExpressionCollector.new.tap { |collector|
320
- node.accept(collector)
322
+ AdditiveExpressionCollector.new.tap { |col|
323
+ node.accept(col)
321
324
  }.additive_expressions
322
325
  else
323
326
  []
@@ -327,8 +330,8 @@ module C #:nodoc:
327
330
 
328
331
  def collect_relational_expressions(node)
329
332
  if node
330
- RelationalExpressionCollector.new.tap { |collector|
331
- node.accept(collector)
333
+ RelationalExpressionCollector.new.tap { |col|
334
+ node.accept(col)
332
335
  }.relational_expressions
333
336
  else
334
337
  []
@@ -338,8 +341,8 @@ module C #:nodoc:
338
341
 
339
342
  def collect_equality_expressions(node)
340
343
  if node
341
- EqualityExpressionCollector.new.tap { |collector|
342
- node.accept(collector)
344
+ EqualityExpressionCollector.new.tap { |col|
345
+ node.accept(col)
343
346
  }.equality_expressions
344
347
  else
345
348
  []
@@ -349,8 +352,8 @@ module C #:nodoc:
349
352
 
350
353
  def collect_logical_and_expressions(node)
351
354
  if node
352
- LogicalAndExpressionCollector.new.tap { |collector|
353
- node.accept(collector)
355
+ LogicalAndExpressionCollector.new.tap { |col|
356
+ node.accept(col)
354
357
  }.logical_and_expressions
355
358
  else
356
359
  []
@@ -360,8 +363,8 @@ module C #:nodoc:
360
363
 
361
364
  def collect_logical_or_expressions(node)
362
365
  if node
363
- LogicalOrExpressionCollector.new.tap { |collector|
364
- node.accept(collector)
366
+ LogicalOrExpressionCollector.new.tap { |col|
367
+ node.accept(col)
365
368
  }.logical_or_expressions
366
369
  else
367
370
  []
@@ -371,8 +374,8 @@ module C #:nodoc:
371
374
 
372
375
  def collect_generic_labeled_statements(node)
373
376
  if node
374
- GenericLabeledStatementCollector.new.tap { |collector|
375
- node.accept(collector)
377
+ GenericLabeledStatementCollector.new.tap { |col|
378
+ node.accept(col)
376
379
  }.generic_labeled_statements
377
380
  else
378
381
  []
@@ -382,8 +385,8 @@ module C #:nodoc:
382
385
 
383
386
  def collect_if_statements(node)
384
387
  if node
385
- IfStatementCollector.new.tap { |collector|
386
- node.accept(collector)
388
+ IfStatementCollector.new.tap { |col|
389
+ node.accept(col)
387
390
  }.if_statements
388
391
  else
389
392
  []
@@ -393,8 +396,8 @@ module C #:nodoc:
393
396
 
394
397
  def collect_if_else_statements(node)
395
398
  if node
396
- IfElseStatementCollector.new.tap { |collector|
397
- node.accept(collector)
399
+ IfElseStatementCollector.new.tap { |col|
400
+ node.accept(col)
398
401
  }.if_else_statements
399
402
  else
400
403
  []
@@ -404,8 +407,8 @@ module C #:nodoc:
404
407
 
405
408
  def collect_goto_statements(node)
406
409
  if node
407
- GotoStatementCollector.new.tap { |collector|
408
- node.accept(collector)
410
+ GotoStatementCollector.new.tap { |col|
411
+ node.accept(col)
409
412
  }.goto_statements
410
413
  else
411
414
  []
@@ -415,8 +418,8 @@ module C #:nodoc:
415
418
 
416
419
  def collect_array_declarators(node)
417
420
  if node
418
- ArrayDeclaratorCollector.new.tap { |collector|
419
- node.accept(collector)
421
+ ArrayDeclaratorCollector.new.tap { |col|
422
+ node.accept(col)
420
423
  }.array_declarators
421
424
  else
422
425
  []
@@ -426,8 +429,8 @@ module C #:nodoc:
426
429
 
427
430
  def collect_constant_specifiers(node)
428
431
  if node
429
- ConstantSpecifierCollector.new.tap { |collector|
430
- node.accept(collector)
432
+ ConstantSpecifierCollector.new.tap { |col|
433
+ node.accept(col)
431
434
  }.constant_specifiers
432
435
  else
433
436
  []
@@ -442,8 +445,8 @@ module C #:nodoc:
442
445
  @full = false
443
446
  end
444
447
 
445
- def full=(full_expression)
446
- @full = full_expression
448
+ def full=(expr_is_full)
449
+ @full = expr_is_full
447
450
 
448
451
  # NOTE: The ISO C99 standard says;
449
452
  #
@@ -456,7 +459,7 @@ module C #:nodoc:
456
459
  # expression of a while or do statement (6.8.5); each of the
457
460
  # expressions of a for statement (6.8.5.3); the expression in a
458
461
  # return statement (6.8.6.4).
459
- if full_expression
462
+ if expr_is_full
460
463
  append_sequence_point!
461
464
  else
462
465
  delete_sequence_point!
@@ -467,10 +470,8 @@ module C #:nodoc:
467
470
  subclass_responsibility
468
471
  end
469
472
 
470
- def constant?(enumerator_table)
471
- object_specifiers.all? do |object_specifier|
472
- enumerator_table.lookup(object_specifier.identifier.value)
473
- end
473
+ def constant?(enum_tbl)
474
+ object_specifiers.all? { |os| enum_tbl.lookup(os.identifier.value) }
474
475
  end
475
476
 
476
477
  def logical?
@@ -486,12 +487,12 @@ module C #:nodoc:
486
487
  end
487
488
 
488
489
  def object_specifiers
489
- ObjectSpecifierCollector.new.tap { |collector|
490
- self.accept(collector)
490
+ ObjectSpecifierCollector.new.tap { |col|
491
+ self.accept(col)
491
492
  }.object_specifiers
492
493
  end
493
494
 
494
- def to_normalized_logical(parent_expression = nil)
495
+ def to_normalized_logical(parent_expr = nil)
495
496
  subclass_responsibility
496
497
  end
497
498
 
@@ -505,17 +506,17 @@ module C #:nodoc:
505
506
  end
506
507
 
507
508
  private
508
- def create_normalized_logical_of(expression)
509
- EqualityExpression.new(Token.new("!=", "!=", expression.location),
510
- GroupedExpression.new(expression),
511
- ConstantSpecifier.of_zero(expression.location))
509
+ def create_normalized_logical_of(expr)
510
+ EqualityExpression.new(Token.new("!=", "!=", expr.location),
511
+ GroupedExpression.new(expr),
512
+ ConstantSpecifier.of_zero(expr.location))
512
513
  end
513
514
  end
514
515
 
515
516
  class ErrorExpression < Expression
516
- def initialize(error_token)
517
+ def initialize(err_tok)
517
518
  super()
518
- @error_token = error_token
519
+ @error_token = err_tok
519
520
  end
520
521
 
521
522
  def location
@@ -538,7 +539,7 @@ module C #:nodoc:
538
539
  false
539
540
  end
540
541
 
541
- def to_normalized_logical(parent_expression = nil)
542
+ def to_normalized_logical(parent_expr = nil)
542
543
  self
543
544
  end
544
545
 
@@ -559,9 +560,9 @@ module C #:nodoc:
559
560
  class PrimaryExpression < Expression; end
560
561
 
561
562
  class ObjectSpecifier < PrimaryExpression
562
- def initialize(identifier)
563
+ def initialize(id)
563
564
  super()
564
- @identifier = identifier
565
+ @identifier = id
565
566
  end
566
567
 
567
568
  attr_reader :identifier
@@ -586,8 +587,8 @@ module C #:nodoc:
586
587
  false
587
588
  end
588
589
 
589
- def to_normalized_logical(parent_expression = nil)
590
- case parent_expression
590
+ def to_normalized_logical(parent_expr = nil)
591
+ case parent_expr
591
592
  when nil, LogicalAndExpression, LogicalOrExpression
592
593
  create_normalized_logical_of(self)
593
594
  else
@@ -610,13 +611,13 @@ module C #:nodoc:
610
611
  end
611
612
 
612
613
  class ConstantSpecifier < PrimaryExpression
613
- def self.of_zero(location = nil)
614
- self.new(Token.new(:CONSTANT, "0", location || Location.new))
614
+ def self.of_zero(loc = nil)
615
+ self.new(Token.new(:CONSTANT, "0", loc || Location.new))
615
616
  end
616
617
 
617
- def initialize(constant)
618
+ def initialize(const)
618
619
  super()
619
- @constant = constant
620
+ @constant = const
620
621
  end
621
622
 
622
623
  attr_reader :constant
@@ -626,7 +627,7 @@ module C #:nodoc:
626
627
  end
627
628
 
628
629
  def prefix
629
- @constant.value.scan(/\A(?:0x|0b|L)/i).first
630
+ @constant.value.scan(/\A(?:0x|0b|0(?=[0-9])|L)/i).first
630
631
  end
631
632
 
632
633
  def suffix
@@ -653,8 +654,8 @@ module C #:nodoc:
653
654
  false
654
655
  end
655
656
 
656
- def to_normalized_logical(parent_expression = nil)
657
- case parent_expression
657
+ def to_normalized_logical(parent_expr = nil)
658
+ case parent_expr
658
659
  when nil, LogicalAndExpression, LogicalOrExpression
659
660
  create_normalized_logical_of(self)
660
661
  else
@@ -677,9 +678,9 @@ module C #:nodoc:
677
678
  end
678
679
 
679
680
  class StringLiteralSpecifier < PrimaryExpression
680
- def initialize(literal)
681
+ def initialize(lit)
681
682
  super()
682
- @literal = literal
683
+ @literal = lit
683
684
  end
684
685
 
685
686
  attr_reader :literal
@@ -708,8 +709,8 @@ module C #:nodoc:
708
709
  false
709
710
  end
710
711
 
711
- def to_normalized_logical(parent_expression = nil)
712
- case parent_expression
712
+ def to_normalized_logical(parent_expr = nil)
713
+ case parent_expr
713
714
  when nil, LogicalAndExpression, LogicalOrExpression
714
715
  create_normalized_logical_of(self)
715
716
  else
@@ -732,9 +733,9 @@ module C #:nodoc:
732
733
  end
733
734
 
734
735
  class NullConstantSpecifier < PrimaryExpression
735
- def initialize(token)
736
+ def initialize(tok)
736
737
  super()
737
- @token = token
738
+ @token = tok
738
739
  end
739
740
 
740
741
  attr_reader :token
@@ -759,8 +760,8 @@ module C #:nodoc:
759
760
  false
760
761
  end
761
762
 
762
- def to_normalized_logical(parent_expression = nil)
763
- case parent_expression
763
+ def to_normalized_logical(parent_expr = nil)
764
+ case parent_expr
764
765
  when nil, LogicalAndExpression, LogicalOrExpression
765
766
  create_normalized_logical_of(self)
766
767
  else
@@ -783,11 +784,11 @@ module C #:nodoc:
783
784
  end
784
785
 
785
786
  class GroupedExpression < PrimaryExpression
786
- def initialize(expression)
787
+ def initialize(expr)
787
788
  super()
788
- @expression = expression
789
- self.head_token = expression.head_token
790
- self.tail_token = expression.tail_token
789
+ @expression = expr
790
+ self.head_token = expr.head_token
791
+ self.tail_token = expr.tail_token
791
792
  end
792
793
 
793
794
  attr_reader :expression
@@ -812,11 +813,10 @@ module C #:nodoc:
812
813
  @expression.bitwise?
813
814
  end
814
815
 
815
- def to_normalized_logical(parent_expression = nil)
816
- case parent_expression
816
+ def to_normalized_logical(parent_expr = nil)
817
+ case parent_expr
817
818
  when nil, LogicalAndExpression, LogicalOrExpression
818
- GroupedExpression.new(
819
- @expression.to_normalized_logical(parent_expression))
819
+ GroupedExpression.new(@expression.to_normalized_logical(parent_expr))
820
820
  else
821
821
  self
822
822
  end
@@ -837,8 +837,8 @@ module C #:nodoc:
837
837
  end
838
838
 
839
839
  class PostfixExpression < Expression
840
- def initialize(operator)
841
- @operator = operator
840
+ def initialize(op)
841
+ @operator = op
842
842
  end
843
843
 
844
844
  attr_reader :operator
@@ -849,10 +849,10 @@ module C #:nodoc:
849
849
  end
850
850
 
851
851
  class ArraySubscriptExpression < PostfixExpression
852
- def initialize(expression, array_subscript, left_bracket)
852
+ def initialize(expr, ary_subs, left_bracket)
853
853
  super(left_bracket)
854
- @expression = expression
855
- @array_subscript = array_subscript
854
+ @expression = expr
855
+ @array_subscript = ary_subs
856
856
  end
857
857
 
858
858
  attr_reader :expression
@@ -874,8 +874,8 @@ module C #:nodoc:
874
874
  false
875
875
  end
876
876
 
877
- def to_normalized_logical(parent_expression = nil)
878
- case parent_expression
877
+ def to_normalized_logical(parent_expr = nil)
878
+ case parent_expr
879
879
  when nil, LogicalAndExpression, LogicalOrExpression
880
880
  create_normalized_logical_of(self)
881
881
  else
@@ -899,10 +899,10 @@ module C #:nodoc:
899
899
  end
900
900
 
901
901
  class FunctionCallExpression < PostfixExpression
902
- def initialize(expression, argument_expressions, left_paren)
902
+ def initialize(expr, arg_exprs, left_paren)
903
903
  super(left_paren)
904
- @expression = expression
905
- @argument_expressions = argument_expressions
904
+ @expression = expr
905
+ @argument_expressions = arg_exprs
906
906
  end
907
907
 
908
908
  attr_reader :expression
@@ -924,8 +924,8 @@ module C #:nodoc:
924
924
  false
925
925
  end
926
926
 
927
- def to_normalized_logical(parent_expression = nil)
928
- case parent_expression
927
+ def to_normalized_logical(parent_expr = nil)
928
+ case parent_expr
929
929
  when nil, LogicalAndExpression, LogicalOrExpression
930
930
  create_normalized_logical_of(self)
931
931
  else
@@ -950,10 +950,10 @@ module C #:nodoc:
950
950
  end
951
951
 
952
952
  class MemberAccessByValueExpression < PostfixExpression
953
- def initialize(expression, identifier, dot)
953
+ def initialize(expr, id, dot)
954
954
  super(dot)
955
- @expression = expression
956
- @identifier = identifier
955
+ @expression = expr
956
+ @identifier = id
957
957
  end
958
958
 
959
959
  attr_reader :expression
@@ -975,8 +975,8 @@ module C #:nodoc:
975
975
  false
976
976
  end
977
977
 
978
- def to_normalized_logical(parent_expression = nil)
979
- case parent_expression
978
+ def to_normalized_logical(parent_expr = nil)
979
+ case parent_expr
980
980
  when nil, LogicalAndExpression, LogicalOrExpression
981
981
  create_normalized_logical_of(self)
982
982
  else
@@ -999,10 +999,10 @@ module C #:nodoc:
999
999
  end
1000
1000
 
1001
1001
  class MemberAccessByPointerExpression < PostfixExpression
1002
- def initialize(expression, identifier, arrow)
1002
+ def initialize(expr, id, arrow)
1003
1003
  super(arrow)
1004
- @expression = expression
1005
- @identifier = identifier
1004
+ @expression = expr
1005
+ @identifier = id
1006
1006
  end
1007
1007
 
1008
1008
  attr_reader :expression
@@ -1024,8 +1024,8 @@ module C #:nodoc:
1024
1024
  false
1025
1025
  end
1026
1026
 
1027
- def to_normalized_logical(parent_expression = nil)
1028
- case parent_expression
1027
+ def to_normalized_logical(parent_expr = nil)
1028
+ case parent_expr
1029
1029
  when nil, LogicalAndExpression, LogicalOrExpression
1030
1030
  create_normalized_logical_of(self)
1031
1031
  else
@@ -1048,10 +1048,10 @@ module C #:nodoc:
1048
1048
  end
1049
1049
 
1050
1050
  class BitAccessByValueExpression < PostfixExpression
1051
- def initialize(expression, constant, dot)
1051
+ def initialize(expr, const, dot)
1052
1052
  super(dot)
1053
- @expression = expression
1054
- @constant = constant
1053
+ @expression = expr
1054
+ @constant = const
1055
1055
  end
1056
1056
 
1057
1057
  attr_reader :expression
@@ -1073,8 +1073,8 @@ module C #:nodoc:
1073
1073
  false
1074
1074
  end
1075
1075
 
1076
- def to_normalized_logical(parent_expression = nil)
1077
- case parent_expression
1076
+ def to_normalized_logical(parent_expr = nil)
1077
+ case parent_expr
1078
1078
  when nil, LogicalAndExpression, LogicalOrExpression
1079
1079
  create_normalized_logical_of(self)
1080
1080
  else
@@ -1097,10 +1097,10 @@ module C #:nodoc:
1097
1097
  end
1098
1098
 
1099
1099
  class BitAccessByPointerExpression < PostfixExpression
1100
- def initialize(expression, constant, arrow)
1100
+ def initialize(expr, const, arrow)
1101
1101
  super(arrow)
1102
- @expression = expression
1103
- @constant = constant
1102
+ @expression = expr
1103
+ @constant = const
1104
1104
  end
1105
1105
 
1106
1106
  attr_reader :expression
@@ -1122,8 +1122,8 @@ module C #:nodoc:
1122
1122
  false
1123
1123
  end
1124
1124
 
1125
- def to_normalized_logical(parent_expression = nil)
1126
- case parent_expression
1125
+ def to_normalized_logical(parent_expr = nil)
1126
+ case parent_expr
1127
1127
  when nil, LogicalAndExpression, LogicalOrExpression
1128
1128
  create_normalized_logical_of(self)
1129
1129
  else
@@ -1146,9 +1146,9 @@ module C #:nodoc:
1146
1146
  end
1147
1147
 
1148
1148
  class PostfixIncrementExpression < PostfixExpression
1149
- def initialize(operator, operand)
1150
- super(operator)
1151
- @operand = operand
1149
+ def initialize(op, ope)
1150
+ super(op)
1151
+ @operand = ope
1152
1152
  end
1153
1153
 
1154
1154
  attr_reader :operand
@@ -1169,8 +1169,8 @@ module C #:nodoc:
1169
1169
  false
1170
1170
  end
1171
1171
 
1172
- def to_normalized_logical(parent_expression = nil)
1173
- case parent_expression
1172
+ def to_normalized_logical(parent_expr = nil)
1173
+ case parent_expr
1174
1174
  when nil, LogicalAndExpression, LogicalOrExpression
1175
1175
  create_normalized_logical_of(self)
1176
1176
  else
@@ -1193,9 +1193,9 @@ module C #:nodoc:
1193
1193
  end
1194
1194
 
1195
1195
  class PostfixDecrementExpression < PostfixExpression
1196
- def initialize(operator, operand)
1197
- super(operator)
1198
- @operand = operand
1196
+ def initialize(op, ope)
1197
+ super(op)
1198
+ @operand = ope
1199
1199
  end
1200
1200
 
1201
1201
  attr_reader :operand
@@ -1216,8 +1216,8 @@ module C #:nodoc:
1216
1216
  false
1217
1217
  end
1218
1218
 
1219
- def to_normalized_logical(parent_expression = nil)
1220
- case parent_expression
1219
+ def to_normalized_logical(parent_expr = nil)
1220
+ case parent_expr
1221
1221
  when nil, LogicalAndExpression, LogicalOrExpression
1222
1222
  create_normalized_logical_of(self)
1223
1223
  else
@@ -1240,10 +1240,10 @@ module C #:nodoc:
1240
1240
  end
1241
1241
 
1242
1242
  class CompoundLiteralExpression < PostfixExpression
1243
- def initialize(type_name, initializers, left_paren)
1243
+ def initialize(type_name, inits, left_paren)
1244
1244
  super(left_paren)
1245
1245
  @type_name = type_name
1246
- @initializers = initializers
1246
+ @initializers = inits
1247
1247
  end
1248
1248
 
1249
1249
  attr_reader :type_name
@@ -1265,8 +1265,8 @@ module C #:nodoc:
1265
1265
  false
1266
1266
  end
1267
1267
 
1268
- def to_normalized_logical(parent_expression = nil)
1269
- case parent_expression
1268
+ def to_normalized_logical(parent_expr = nil)
1269
+ case parent_expr
1270
1270
  when nil, LogicalAndExpression, LogicalOrExpression
1271
1271
  create_normalized_logical_of(self)
1272
1272
  else
@@ -1290,10 +1290,10 @@ module C #:nodoc:
1290
1290
  end
1291
1291
 
1292
1292
  class UnaryExpression < Expression
1293
- def initialize(operator, operand)
1293
+ def initialize(op, ope)
1294
1294
  super()
1295
- @operator = operator
1296
- @operand = operand
1295
+ @operator = op
1296
+ @operand = ope
1297
1297
  end
1298
1298
 
1299
1299
  attr_reader :operator
@@ -1330,8 +1330,8 @@ module C #:nodoc:
1330
1330
  false
1331
1331
  end
1332
1332
 
1333
- def to_normalized_logical(parent_expression = nil)
1334
- case parent_expression
1333
+ def to_normalized_logical(parent_expr = nil)
1334
+ case parent_expr
1335
1335
  when nil, LogicalAndExpression, LogicalOrExpression
1336
1336
  create_normalized_logical_of(self)
1337
1337
  else
@@ -1361,8 +1361,8 @@ module C #:nodoc:
1361
1361
  false
1362
1362
  end
1363
1363
 
1364
- def to_normalized_logical(parent_expression = nil)
1365
- case parent_expression
1364
+ def to_normalized_logical(parent_expr = nil)
1365
+ case parent_expr
1366
1366
  when nil, LogicalAndExpression, LogicalOrExpression
1367
1367
  create_normalized_logical_of(self)
1368
1368
  else
@@ -1392,8 +1392,8 @@ module C #:nodoc:
1392
1392
  false
1393
1393
  end
1394
1394
 
1395
- def to_normalized_logical(parent_expression = nil)
1396
- case parent_expression
1395
+ def to_normalized_logical(parent_expr = nil)
1396
+ case parent_expr
1397
1397
  when nil, LogicalAndExpression, LogicalOrExpression
1398
1398
  create_normalized_logical_of(self)
1399
1399
  else
@@ -1423,8 +1423,8 @@ module C #:nodoc:
1423
1423
  false
1424
1424
  end
1425
1425
 
1426
- def to_normalized_logical(parent_expression = nil)
1427
- case parent_expression
1426
+ def to_normalized_logical(parent_expr = nil)
1427
+ case parent_expr
1428
1428
  when nil, LogicalAndExpression, LogicalOrExpression
1429
1429
  create_normalized_logical_of(self)
1430
1430
  else
@@ -1454,12 +1454,12 @@ module C #:nodoc:
1454
1454
  operator.type == "~"
1455
1455
  end
1456
1456
 
1457
- def to_normalized_logical(parent_expression = nil)
1457
+ def to_normalized_logical(parent_expr = nil)
1458
1458
  if operator.type == "!"
1459
1459
  normalized_operand = @operand.to_normalized_logical
1460
1460
  GroupedExpression.new(normalized_operand.to_complemental_logical)
1461
1461
  else
1462
- case parent_expression
1462
+ case parent_expr
1463
1463
  when nil, LogicalAndExpression, LogicalOrExpression
1464
1464
  create_normalized_logical_of(self)
1465
1465
  else
@@ -1496,8 +1496,8 @@ module C #:nodoc:
1496
1496
  false
1497
1497
  end
1498
1498
 
1499
- def to_normalized_logical(parent_expression = nil)
1500
- case parent_expression
1499
+ def to_normalized_logical(parent_expr = nil)
1500
+ case parent_expr
1501
1501
  when nil, LogicalAndExpression, LogicalOrExpression
1502
1502
  create_normalized_logical_of(self)
1503
1503
  else
@@ -1531,8 +1531,8 @@ module C #:nodoc:
1531
1531
  false
1532
1532
  end
1533
1533
 
1534
- def to_normalized_logical(parent_expression = nil)
1535
- case parent_expression
1534
+ def to_normalized_logical(parent_expr = nil)
1535
+ case parent_expr
1536
1536
  when nil, LogicalAndExpression, LogicalOrExpression
1537
1537
  create_normalized_logical_of(self)
1538
1538
  else
@@ -1566,8 +1566,8 @@ module C #:nodoc:
1566
1566
  false
1567
1567
  end
1568
1568
 
1569
- def to_normalized_logical(parent_expression = nil)
1570
- case parent_expression
1569
+ def to_normalized_logical(parent_expr = nil)
1570
+ case parent_expr
1571
1571
  when nil, LogicalAndExpression, LogicalOrExpression
1572
1572
  create_normalized_logical_of(self)
1573
1573
  else
@@ -1601,8 +1601,8 @@ module C #:nodoc:
1601
1601
  false
1602
1602
  end
1603
1603
 
1604
- def to_normalized_logical(parent_expression = nil)
1605
- case parent_expression
1604
+ def to_normalized_logical(parent_expr = nil)
1605
+ case parent_expr
1606
1606
  when nil, LogicalAndExpression, LogicalOrExpression
1607
1607
  create_normalized_logical_of(self)
1608
1608
  else
@@ -1620,10 +1620,10 @@ module C #:nodoc:
1620
1620
  end
1621
1621
 
1622
1622
  class CastExpression < Expression
1623
- def initialize(type_name, operand)
1623
+ def initialize(type_name, ope)
1624
1624
  super()
1625
1625
  @type_name = type_name
1626
- @operand = operand
1626
+ @operand = ope
1627
1627
  end
1628
1628
 
1629
1629
  attr_reader :type_name
@@ -1649,8 +1649,8 @@ module C #:nodoc:
1649
1649
  @operand.bitwise?
1650
1650
  end
1651
1651
 
1652
- def to_normalized_logical(parent_expression = nil)
1653
- case parent_expression
1652
+ def to_normalized_logical(parent_expr = nil)
1653
+ case parent_expr
1654
1654
  when nil, LogicalAndExpression, LogicalOrExpression
1655
1655
  create_normalized_logical_of(self)
1656
1656
  else
@@ -1673,9 +1673,9 @@ module C #:nodoc:
1673
1673
  end
1674
1674
 
1675
1675
  class BinaryExpression < Expression
1676
- def initialize(operator, lhs_operand, rhs_operand)
1676
+ def initialize(op, lhs_operand, rhs_operand)
1677
1677
  super()
1678
- @operator = operator
1678
+ @operator = op
1679
1679
  @lhs_operand = lhs_operand
1680
1680
  @rhs_operand = rhs_operand
1681
1681
  end
@@ -1715,8 +1715,8 @@ module C #:nodoc:
1715
1715
  false
1716
1716
  end
1717
1717
 
1718
- def to_normalized_logical(parent_expression = nil)
1719
- case parent_expression
1718
+ def to_normalized_logical(parent_expr = nil)
1719
+ case parent_expr
1720
1720
  when nil, LogicalAndExpression, LogicalOrExpression
1721
1721
  create_normalized_logical_of(self)
1722
1722
  else
@@ -1746,8 +1746,8 @@ module C #:nodoc:
1746
1746
  false
1747
1747
  end
1748
1748
 
1749
- def to_normalized_logical(parent_expression = nil)
1750
- case parent_expression
1749
+ def to_normalized_logical(parent_expr = nil)
1750
+ case parent_expr
1751
1751
  when nil, LogicalAndExpression, LogicalOrExpression
1752
1752
  create_normalized_logical_of(self)
1753
1753
  else
@@ -1777,8 +1777,8 @@ module C #:nodoc:
1777
1777
  true
1778
1778
  end
1779
1779
 
1780
- def to_normalized_logical(parent_expression = nil)
1781
- case parent_expression
1780
+ def to_normalized_logical(parent_expr = nil)
1781
+ case parent_expr
1782
1782
  when nil, LogicalAndExpression, LogicalOrExpression
1783
1783
  create_normalized_logical_of(self)
1784
1784
  else
@@ -1808,14 +1808,14 @@ module C #:nodoc:
1808
1808
  false
1809
1809
  end
1810
1810
 
1811
- def to_normalized_logical(parent_expression = nil)
1811
+ def to_normalized_logical(parent_expr = nil)
1812
1812
  self
1813
1813
  end
1814
1814
 
1815
1815
  def to_complemental_logical
1816
- operator = ComparisonOperator.new(@operator).for_complement.to_s
1817
- operator_token = Token.new(operator, operator, @operator.location)
1818
- RelationalExpression.new(operator_token, @lhs_operand, @rhs_operand)
1816
+ op = ComparisonOperator.new(@operator).for_complement.to_s
1817
+ op_tok = Token.new(op, op, @operator.location)
1818
+ RelationalExpression.new(op_tok, @lhs_operand, @rhs_operand)
1819
1819
  end
1820
1820
  end
1821
1821
 
@@ -1836,14 +1836,14 @@ module C #:nodoc:
1836
1836
  false
1837
1837
  end
1838
1838
 
1839
- def to_normalized_logical(parent_expression = nil)
1839
+ def to_normalized_logical(parent_expr = nil)
1840
1840
  self
1841
1841
  end
1842
1842
 
1843
1843
  def to_complemental_logical
1844
- operator = ComparisonOperator.new(@operator).for_complement.to_s
1845
- operator_token = Token.new(operator, operator, @operator.location)
1846
- EqualityExpression.new(operator_token, @lhs_operand, @rhs_operand)
1844
+ op = ComparisonOperator.new(@operator).for_complement.to_s
1845
+ op_tok = Token.new(op, op, @operator.location)
1846
+ EqualityExpression.new(op_tok, @lhs_operand, @rhs_operand)
1847
1847
  end
1848
1848
  end
1849
1849
 
@@ -1864,8 +1864,8 @@ module C #:nodoc:
1864
1864
  true
1865
1865
  end
1866
1866
 
1867
- def to_normalized_logical(parent_expression = nil)
1868
- case parent_expression
1867
+ def to_normalized_logical(parent_expr = nil)
1868
+ case parent_expr
1869
1869
  when nil, LogicalAndExpression, LogicalOrExpression
1870
1870
  create_normalized_logical_of(self)
1871
1871
  else
@@ -1895,8 +1895,8 @@ module C #:nodoc:
1895
1895
  true
1896
1896
  end
1897
1897
 
1898
- def to_normalized_logical(parent_expression = nil)
1899
- case parent_expression
1898
+ def to_normalized_logical(parent_expr = nil)
1899
+ case parent_expr
1900
1900
  when nil, LogicalAndExpression, LogicalOrExpression
1901
1901
  create_normalized_logical_of(self)
1902
1902
  else
@@ -1926,8 +1926,8 @@ module C #:nodoc:
1926
1926
  true
1927
1927
  end
1928
1928
 
1929
- def to_normalized_logical(parent_expression = nil)
1930
- case parent_expression
1929
+ def to_normalized_logical(parent_expr = nil)
1930
+ case parent_expr
1931
1931
  when nil, LogicalAndExpression, LogicalOrExpression
1932
1932
  create_normalized_logical_of(self)
1933
1933
  else
@@ -1941,7 +1941,7 @@ module C #:nodoc:
1941
1941
  end
1942
1942
 
1943
1943
  class LogicalAndExpression < BinaryExpression
1944
- def initialize(operator, lhs_operand, rhs_operand)
1944
+ def initialize(op, lhs_operand, rhs_operand)
1945
1945
  super
1946
1946
 
1947
1947
  # NOTE: The ISO C99 standard says;
@@ -1976,7 +1976,7 @@ module C #:nodoc:
1976
1976
  false
1977
1977
  end
1978
1978
 
1979
- def to_normalized_logical(parent_expression = nil)
1979
+ def to_normalized_logical(parent_expr = nil)
1980
1980
  LogicalAndExpression.new(@operator,
1981
1981
  @lhs_operand.to_normalized_logical(self),
1982
1982
  @rhs_operand.to_normalized_logical(self))
@@ -1990,7 +1990,7 @@ module C #:nodoc:
1990
1990
  end
1991
1991
 
1992
1992
  class LogicalOrExpression < BinaryExpression
1993
- def initialize(operator, lhs_operand, rhs_operand)
1993
+ def initialize(op, lhs_operand, rhs_operand)
1994
1994
  super
1995
1995
 
1996
1996
  # NOTE: The ISO C99 standard says;
@@ -2025,7 +2025,7 @@ module C #:nodoc:
2025
2025
  false
2026
2026
  end
2027
2027
 
2028
- def to_normalized_logical(parent_expression = nil)
2028
+ def to_normalized_logical(parent_expr = nil)
2029
2029
  LogicalOrExpression.new(@operator,
2030
2030
  @lhs_operand.to_normalized_logical(self),
2031
2031
  @rhs_operand.to_normalized_logical(self))
@@ -2039,11 +2039,11 @@ module C #:nodoc:
2039
2039
  end
2040
2040
 
2041
2041
  class ConditionalExpression < Expression
2042
- def initialize(condition, then_expression, else_expression, question_mark)
2042
+ def initialize(cond, then_expr, else_expr, question_mark)
2043
2043
  super()
2044
- @condition = condition
2045
- @then_expression = then_expression
2046
- @else_expression = else_expression
2044
+ @condition = cond
2045
+ @then_expression = then_expr
2046
+ @else_expression = else_expr
2047
2047
  @question_mark = question_mark
2048
2048
 
2049
2049
  # NOTE: The ISO C99 standard says;
@@ -2095,8 +2095,8 @@ module C #:nodoc:
2095
2095
  @then_expression.bitwise? || @else_expression.bitwise?
2096
2096
  end
2097
2097
 
2098
- def to_normalized_logical(parent_expression = nil)
2099
- case parent_expression
2098
+ def to_normalized_logical(parent_expr = nil)
2099
+ case parent_expr
2100
2100
  when nil, LogicalAndExpression, LogicalOrExpression
2101
2101
  create_normalized_logical_of(self)
2102
2102
  else
@@ -2138,8 +2138,8 @@ module C #:nodoc:
2138
2138
  rhs_operand.bitwise?
2139
2139
  end
2140
2140
 
2141
- def to_normalized_logical(parent_expression = nil)
2142
- case parent_expression
2141
+ def to_normalized_logical(parent_expr = nil)
2142
+ case parent_expr
2143
2143
  when nil, LogicalAndExpression, LogicalOrExpression
2144
2144
  create_normalized_logical_of(self)
2145
2145
  else
@@ -2169,8 +2169,8 @@ module C #:nodoc:
2169
2169
  ["<<=", ">>=", "&=", "^=", "|="].include?(operator.type)
2170
2170
  end
2171
2171
 
2172
- def to_normalized_logical(parent_expression = nil)
2173
- case parent_expression
2172
+ def to_normalized_logical(parent_expr = nil)
2173
+ case parent_expr
2174
2174
  when nil, LogicalAndExpression, LogicalOrExpression
2175
2175
  create_normalized_logical_of(self)
2176
2176
  else
@@ -2184,10 +2184,10 @@ module C #:nodoc:
2184
2184
  end
2185
2185
 
2186
2186
  class CommaSeparatedExpression < Expression
2187
- def initialize(first_expression)
2187
+ def initialize(fst_expr)
2188
2188
  super()
2189
2189
  @expressions = []
2190
- push(first_expression)
2190
+ push(fst_expr)
2191
2191
  end
2192
2192
 
2193
2193
  attr_reader :expressions
@@ -2212,8 +2212,8 @@ module C #:nodoc:
2212
2212
  @expressions.last.bitwise?
2213
2213
  end
2214
2214
 
2215
- def to_normalized_logical(parent_expression = nil)
2216
- case parent_expression
2215
+ def to_normalized_logical(parent_expr = nil)
2216
+ case parent_expr
2217
2217
  when nil, LogicalAndExpression, LogicalOrExpression
2218
2218
  create_normalized_logical_of(@expressions.last)
2219
2219
  else
@@ -2229,8 +2229,10 @@ module C #:nodoc:
2229
2229
  @expressions.map { |expr| expr.to_s }.join(",")
2230
2230
  end
2231
2231
 
2232
- def push(expression)
2233
- @expressions.push(expression)
2232
+ def push(expr)
2233
+ self.head_token = expr.head_token if @expressions.empty?
2234
+ @expressions.push(expr)
2235
+ self.tail_token = expr.tail_token
2234
2236
 
2235
2237
  # NOTE: The ISO C99 standard says;
2236
2238
  #
@@ -2285,12 +2287,11 @@ module C #:nodoc:
2285
2287
  class Declaration < SyntaxNode
2286
2288
  include DeclarationSpecifiersHolder
2287
2289
 
2288
- def initialize(declaration_specifiers, init_declarators, symbol_table)
2290
+ def initialize(dcl_specs, init_dcrs, sym_tbl)
2289
2291
  super()
2290
- @declaration_specifiers = declaration_specifiers
2291
- @init_declarators = init_declarators
2292
- @items = build_items(declaration_specifiers, init_declarators,
2293
- symbol_table)
2292
+ @declaration_specifiers = dcl_specs
2293
+ @init_declarators = init_dcrs
2294
+ @items = build_items(dcl_specs, init_dcrs, sym_tbl)
2294
2295
  end
2295
2296
 
2296
2297
  attr_reader :declaration_specifiers
@@ -2307,95 +2308,77 @@ module C #:nodoc:
2307
2308
  end
2308
2309
 
2309
2310
  private
2310
- def build_items(declaration_specifiers, init_declarators, symbol_table)
2311
- build_type_declaration(
2312
- declaration_specifiers, init_declarators, symbol_table) +
2313
- build_function_declaration(
2314
- declaration_specifiers, init_declarators, symbol_table) +
2315
- build_variable_declaration(
2316
- declaration_specifiers, init_declarators, symbol_table) +
2317
- build_variable_definition(
2318
- declaration_specifiers, init_declarators, symbol_table)
2319
- end
2320
-
2321
- def build_type_declaration(declaration_specifiers, init_declarators,
2322
- symbol_table)
2323
- return [] unless declaration_specifiers
2324
-
2325
- result = []
2326
-
2327
- declaration_specifiers.type_specifiers.each do |type_specifier|
2328
- visitor = TypeDeclarationBuilder.new(symbol_table)
2329
- type_specifier.accept(visitor)
2330
- result.concat(visitor.type_declarations)
2311
+ def build_items(dcl_specs, init_dcrs, sym_tbl)
2312
+ build_type_declaration(dcl_specs, init_dcrs, sym_tbl) +
2313
+ build_function_declaration(dcl_specs, init_dcrs, sym_tbl) +
2314
+ build_variable_declaration(dcl_specs, init_dcrs, sym_tbl) +
2315
+ build_variable_definition(dcl_specs, init_dcrs, sym_tbl)
2316
+ end
2317
+
2318
+ def build_type_declaration(dcl_specs, init_dcrs, sym_tbl)
2319
+ return [] unless dcl_specs
2320
+
2321
+ type_dcls = []
2322
+
2323
+ dcl_specs.type_specifiers.each do |type_spec|
2324
+ visitor = TypeDeclarationBuilder.new(sym_tbl)
2325
+ type_spec.accept(visitor)
2326
+ type_dcls.concat(visitor.type_declarations)
2331
2327
  end
2332
2328
 
2333
- if declaration_specifiers.storage_class_specifier &&
2334
- declaration_specifiers.storage_class_specifier.type == :TYPEDEF
2335
- init_declarators.each do |init_declarator|
2336
- symbol = symbol_table.create_new_symbol(
2337
- TypedefName, init_declarator.declarator.identifier)
2338
- result.push(TypedefDeclaration.new(declaration_specifiers,
2339
- init_declarator, symbol))
2329
+ if sc = dcl_specs.storage_class_specifier and sc.type == :TYPEDEF
2330
+ init_dcrs.each do |init_dcr|
2331
+ id = init_dcr.declarator.identifier
2332
+ sym = sym_tbl.create_new_symbol(TypedefName, id)
2333
+ type_dcls.push(TypedefDeclaration.new(dcl_specs, init_dcr, sym))
2340
2334
  end
2341
2335
  end
2342
2336
 
2343
- result
2337
+ type_dcls
2344
2338
  end
2345
2339
 
2346
- def build_function_declaration(declaration_specifiers, init_declarators,
2347
- symbol_table)
2348
- if declaration_specifiers &&
2349
- declaration_specifiers.storage_class_specifier &&
2350
- declaration_specifiers.storage_class_specifier.type == :TYPEDEF
2340
+ def build_function_declaration(dcl_specs, init_dcrs, sym_tbl)
2341
+ if dcl_specs && sc_spec = dcl_specs.storage_class_specifier and
2342
+ sc_spec.type == :TYPEDEF
2351
2343
  return []
2352
2344
  end
2353
2345
 
2354
- init_declarators.each_with_object([]) do |init_declarator, result|
2355
- if init_declarator.declarator.function?
2356
- symbol = symbol_table.create_new_symbol(
2357
- ObjectName, init_declarator.declarator.identifier)
2358
- result.push(FunctionDeclaration.new(declaration_specifiers,
2359
- init_declarator, symbol))
2346
+ init_dcrs.each_with_object([]) do |init_dcr, fun_dcls|
2347
+ if init_dcr.declarator.function?
2348
+ id = init_dcr.declarator.identifier
2349
+ sym = sym_tbl.create_new_symbol(ObjectName, id)
2350
+ fun_dcls.push(FunctionDeclaration.new(dcl_specs, init_dcr, sym))
2360
2351
  end
2361
2352
  end
2362
2353
  end
2363
2354
 
2364
- def build_variable_declaration(declaration_specifiers, init_declarators,
2365
- symbol_table)
2366
- return [] unless declaration_specifiers
2355
+ def build_variable_declaration(dcl_specs, init_dcrs, sym_tbl)
2356
+ return [] unless dcl_specs
2367
2357
 
2368
- unless declaration_specifiers.storage_class_specifier &&
2369
- declaration_specifiers.storage_class_specifier.type == :EXTERN
2358
+ unless sc = dcl_specs.storage_class_specifier and sc.type == :EXTERN
2370
2359
  return []
2371
2360
  end
2372
2361
 
2373
- init_declarators.each_with_object([]) do |init_declarator, result|
2374
- if init_declarator.declarator.variable?
2375
- declarator = init_declarator.declarator
2376
- symbol =
2377
- symbol_table.create_new_symbol(ObjectName, declarator.identifier)
2378
- result.push(VariableDeclaration.new(declaration_specifiers,
2379
- declarator, symbol))
2362
+ init_dcrs.each_with_object([]) do |init_dcr, var_dcls|
2363
+ if init_dcr.declarator.variable?
2364
+ dcr = init_dcr.declarator
2365
+ sym = sym_tbl.create_new_symbol(ObjectName, dcr.identifier)
2366
+ var_dcls.push(VariableDeclaration.new(dcl_specs, dcr, sym))
2380
2367
  end
2381
2368
  end
2382
2369
  end
2383
2370
 
2384
- def build_variable_definition(declaration_specifiers, init_declarators,
2385
- symbol_table)
2386
- if declaration_specifiers &&
2387
- declaration_specifiers.storage_class_specifier &&
2388
- (declaration_specifiers.storage_class_specifier.type == :EXTERN ||
2389
- declaration_specifiers.storage_class_specifier.type == :TYPEDEF)
2371
+ def build_variable_definition(dcl_specs, init_dcrs, sym_tbl)
2372
+ if dcl_specs && sc = dcl_specs.storage_class_specifier and
2373
+ sc.type == :EXTERN || sc.type == :TYPEDEF
2390
2374
  return []
2391
2375
  end
2392
2376
 
2393
- init_declarators.each_with_object([]) do |init_declarator, result|
2394
- if init_declarator.declarator.variable?
2395
- symbol = symbol_table.create_new_symbol(
2396
- ObjectName, init_declarator.declarator.identifier)
2397
- result.push(VariableDefinition.new(declaration_specifiers,
2398
- init_declarator, symbol))
2377
+ init_dcrs.each_with_object([]) do |init_dcr, var_defs|
2378
+ if init_dcr.declarator.variable?
2379
+ id = init_dcr.declarator.identifier
2380
+ sym = sym_tbl.create_new_symbol(ObjectName, id)
2381
+ var_defs.push(VariableDefinition.new(dcl_specs, init_dcr, sym))
2399
2382
  end
2400
2383
  end
2401
2384
  end
@@ -2406,11 +2389,11 @@ module C #:nodoc:
2406
2389
  include DeclarationSpecifiersHolder
2407
2390
  include SyntaxNodeCollector
2408
2391
 
2409
- def initialize(declaration_specifiers, init_declarator, symbol)
2392
+ def initialize(dcl_specs, init_dcr, sym)
2410
2393
  super()
2411
- @declaration_specifiers = declaration_specifiers
2412
- @init_declarator = init_declarator
2413
- @symbol = symbol
2394
+ @declaration_specifiers = dcl_specs
2395
+ @init_declarator = init_dcr
2396
+ @symbol = sym
2414
2397
  @type = nil
2415
2398
  end
2416
2399
 
@@ -2445,11 +2428,11 @@ module C #:nodoc:
2445
2428
  include SymbolicElement
2446
2429
  include DeclarationSpecifiersHolder
2447
2430
 
2448
- def initialize(declaration_specifiers, declarator, symbol)
2431
+ def initialize(dcl_specs, dcr, sym)
2449
2432
  super()
2450
- @declaration_specifiers = declaration_specifiers
2451
- @declarator = declarator
2452
- @symbol = symbol
2433
+ @declaration_specifiers = dcl_specs
2434
+ @declarator = dcr
2435
+ @symbol = sym
2453
2436
  @type = nil
2454
2437
  end
2455
2438
 
@@ -2475,8 +2458,8 @@ module C #:nodoc:
2475
2458
  class Definition < SyntaxNode
2476
2459
  include DeclarationSpecifiersHolder
2477
2460
 
2478
- def initialize(declaration_specifiers)
2479
- @declaration_specifiers = declaration_specifiers
2461
+ def initialize(dcl_specs)
2462
+ @declaration_specifiers = dcl_specs
2480
2463
  @type = nil
2481
2464
  end
2482
2465
 
@@ -2487,11 +2470,11 @@ module C #:nodoc:
2487
2470
  class VariableDefinition < Definition
2488
2471
  include SymbolicElement
2489
2472
 
2490
- def initialize(declaration_specifiers, init_declarator, symbol)
2491
- super(declaration_specifiers)
2473
+ def initialize(dcl_specs, init_dcr, sym)
2474
+ super(dcl_specs)
2492
2475
 
2493
- @init_declarator = init_declarator
2494
- @symbol = symbol
2476
+ @init_declarator = init_dcr
2477
+ @symbol = sym
2495
2478
  end
2496
2479
 
2497
2480
  attr_reader :init_declarator
@@ -2518,9 +2501,9 @@ module C #:nodoc:
2518
2501
  class TypeDeclaration < SyntaxNode
2519
2502
  include SymbolicElement
2520
2503
 
2521
- def initialize(symbol)
2504
+ def initialize(sym)
2522
2505
  super()
2523
- @symbol = symbol
2506
+ @symbol = sym
2524
2507
  end
2525
2508
 
2526
2509
  attr_reader :symbol
@@ -2529,10 +2512,10 @@ module C #:nodoc:
2529
2512
  class TypedefDeclaration < TypeDeclaration
2530
2513
  include DeclarationSpecifiersHolder
2531
2514
 
2532
- def initialize(declaration_specifiers, init_declarator, symbol)
2533
- super(symbol)
2534
- @declaration_specifiers = declaration_specifiers
2535
- @init_declarator = init_declarator
2515
+ def initialize(dcl_specs, init_dcr, sym)
2516
+ super(sym)
2517
+ @declaration_specifiers = dcl_specs
2518
+ @init_declarator = init_dcr
2536
2519
  @type = nil
2537
2520
  end
2538
2521
 
@@ -2559,10 +2542,10 @@ module C #:nodoc:
2559
2542
  end
2560
2543
 
2561
2544
  class StructTypeDeclaration < TypeDeclaration
2562
- def initialize(struct_specifier, symbol)
2563
- super(symbol)
2564
- @struct_specifier = struct_specifier
2565
- @struct_declarations = struct_specifier.struct_declarations
2545
+ def initialize(struct_spec, sym)
2546
+ super(sym)
2547
+ @struct_specifier = struct_spec
2548
+ @struct_declarations = struct_spec.struct_declarations
2566
2549
  @type = nil
2567
2550
  end
2568
2551
 
@@ -2586,18 +2569,18 @@ module C #:nodoc:
2586
2569
  end
2587
2570
 
2588
2571
  class PseudoStructTypeDeclaration < StructTypeDeclaration
2589
- def initialize(struct_specifier)
2590
- super(struct_specifier, nil)
2572
+ def initialize(struct_spec)
2573
+ super(struct_spec, nil)
2591
2574
  end
2592
2575
 
2593
- def mark_as_referred_by(token) end
2576
+ def mark_as_referred_by(tok) end
2594
2577
  end
2595
2578
 
2596
2579
  class UnionTypeDeclaration < TypeDeclaration
2597
- def initialize(union_specifier, symbol)
2598
- super(symbol)
2599
- @union_specifier = union_specifier
2600
- @struct_declarations = union_specifier.struct_declarations
2580
+ def initialize(union_spec, sym)
2581
+ super(sym)
2582
+ @union_specifier = union_spec
2583
+ @struct_declarations = union_spec.struct_declarations
2601
2584
  @type = nil
2602
2585
  end
2603
2586
 
@@ -2621,17 +2604,17 @@ module C #:nodoc:
2621
2604
  end
2622
2605
 
2623
2606
  class PseudoUnionTypeDeclaration < UnionTypeDeclaration
2624
- def initialize(union_specifier)
2625
- super(union_specifier, nil)
2607
+ def initialize(union_spec)
2608
+ super(union_spec, nil)
2626
2609
  end
2627
2610
 
2628
- def mark_as_referred_by(token) end
2611
+ def mark_as_referred_by(tok) end
2629
2612
  end
2630
2613
 
2631
2614
  class EnumTypeDeclaration < TypeDeclaration
2632
- def initialize(enum_specifier, symbol)
2633
- super(symbol)
2634
- @enum_specifier = enum_specifier
2615
+ def initialize(enum_spec, sym)
2616
+ super(sym)
2617
+ @enum_specifier = enum_spec
2635
2618
  @type = nil
2636
2619
  end
2637
2620
 
@@ -2657,11 +2640,11 @@ module C #:nodoc:
2657
2640
  end
2658
2641
 
2659
2642
  class PseudoEnumTypeDeclaration < EnumTypeDeclaration
2660
- def initialize(enum_specifier)
2661
- super(enum_specifier, nil)
2643
+ def initialize(enum_spec)
2644
+ super(enum_spec, nil)
2662
2645
  end
2663
2646
 
2664
- def mark_as_referred_by(token) end
2647
+ def mark_as_referred_by(tok) end
2665
2648
  end
2666
2649
 
2667
2650
  class DeclarationSpecifiers < SyntaxNode
@@ -2696,10 +2679,10 @@ module C #:nodoc:
2696
2679
  end
2697
2680
 
2698
2681
  class InitDeclarator < SyntaxNode
2699
- def initialize(declarator, initializer)
2682
+ def initialize(dcr, init)
2700
2683
  super()
2701
- @declarator = declarator
2702
- @initializer = initializer
2684
+ @declarator = dcr
2685
+ @initializer = init
2703
2686
  end
2704
2687
 
2705
2688
  attr_reader :declarator
@@ -2721,9 +2704,9 @@ module C #:nodoc:
2721
2704
  end
2722
2705
 
2723
2706
  class StandardTypeSpecifier < TypeSpecifier
2724
- def initialize(token)
2707
+ def initialize(tok)
2725
2708
  super()
2726
- @token = token
2709
+ @token = tok
2727
2710
  end
2728
2711
 
2729
2712
  attr_reader :token
@@ -2742,9 +2725,9 @@ module C #:nodoc:
2742
2725
  end
2743
2726
 
2744
2727
  class TypedefTypeSpecifier < TypeSpecifier
2745
- def initialize(token)
2728
+ def initialize(tok)
2746
2729
  super()
2747
- @token = token
2730
+ @token = tok
2748
2731
  end
2749
2732
 
2750
2733
  attr_reader :token
@@ -2768,10 +2751,10 @@ module C #:nodoc:
2768
2751
  end
2769
2752
 
2770
2753
  class StructSpecifier < TypeSpecifier
2771
- def initialize(identifier, struct_declarations)
2754
+ def initialize(id, struct_dcls)
2772
2755
  super()
2773
- @identifier = identifier
2774
- @struct_declarations = struct_declarations
2756
+ @identifier = id
2757
+ @struct_declarations = struct_dcls
2775
2758
  end
2776
2759
 
2777
2760
  attr_reader :identifier
@@ -2800,10 +2783,10 @@ module C #:nodoc:
2800
2783
  end
2801
2784
 
2802
2785
  class UnionSpecifier < TypeSpecifier
2803
- def initialize(identifier, struct_declarations)
2786
+ def initialize(id, struct_dcls)
2804
2787
  super()
2805
- @identifier = identifier
2806
- @struct_declarations = struct_declarations
2788
+ @identifier = id
2789
+ @struct_declarations = struct_dcls
2807
2790
  end
2808
2791
 
2809
2792
  attr_reader :identifier
@@ -2833,11 +2816,11 @@ module C #:nodoc:
2833
2816
  end
2834
2817
 
2835
2818
  class StructDeclaration < SyntaxNode
2836
- def initialize(specifier_qualifier_list, struct_declarators)
2819
+ def initialize(spec_qual_list, struct_dcrs)
2837
2820
  super()
2838
- @specifier_qualifier_list = specifier_qualifier_list
2839
- @struct_declarators = struct_declarators
2840
- @items = build_items(specifier_qualifier_list, struct_declarators)
2821
+ @specifier_qualifier_list = spec_qual_list
2822
+ @struct_declarators = struct_dcrs
2823
+ @items = build_items(spec_qual_list, struct_dcrs)
2841
2824
  end
2842
2825
 
2843
2826
  attr_reader :specifier_qualifier_list
@@ -2858,21 +2841,20 @@ module C #:nodoc:
2858
2841
  end
2859
2842
 
2860
2843
  private
2861
- def build_items(specifier_qualifier_list, struct_declarators)
2862
- struct_declarators.each_with_object([]) do |struct_declarator, items|
2844
+ def build_items(spec_qual_list, struct_dcrs)
2845
+ struct_dcrs.each_with_object([]) do |struct_dcr, items|
2863
2846
  # FIXME: Must support unnamed bit padding.
2864
- next unless struct_declarator.declarator
2865
- items.push(MemberDeclaration.new(specifier_qualifier_list,
2866
- struct_declarator))
2847
+ next unless struct_dcr.declarator
2848
+ items.push(MemberDeclaration.new(spec_qual_list, struct_dcr))
2867
2849
  end
2868
2850
  end
2869
2851
  end
2870
2852
 
2871
2853
  class MemberDeclaration < SyntaxNode
2872
- def initialize(specifier_qualifier_list, struct_declarator)
2854
+ def initialize(spec_qual_list, struct_dcl)
2873
2855
  super()
2874
- @specifier_qualifier_list = specifier_qualifier_list
2875
- @struct_declarator = struct_declarator
2856
+ @specifier_qualifier_list = spec_qual_list
2857
+ @struct_declarator = struct_dcl
2876
2858
  @type = nil
2877
2859
  end
2878
2860
 
@@ -2918,10 +2900,10 @@ module C #:nodoc:
2918
2900
  end
2919
2901
 
2920
2902
  class StructDeclarator < SyntaxNode
2921
- def initialize(declarator, expression)
2903
+ def initialize(dcr, expr)
2922
2904
  super()
2923
- @declarator = declarator
2924
- @expression = expression
2905
+ @declarator = dcr
2906
+ @expression = expr
2925
2907
  end
2926
2908
 
2927
2909
  attr_reader :declarator
@@ -2941,10 +2923,10 @@ module C #:nodoc:
2941
2923
  end
2942
2924
 
2943
2925
  class EnumSpecifier < TypeSpecifier
2944
- def initialize(identifier, enumerators, trailing_comma = nil)
2926
+ def initialize(id, enums, trailing_comma = nil)
2945
2927
  super()
2946
- @identifier = identifier
2947
- @enumerators = enumerators
2928
+ @identifier = id
2929
+ @enumerators = enums
2948
2930
  @trailing_comma = trailing_comma
2949
2931
  end
2950
2932
 
@@ -2977,11 +2959,11 @@ module C #:nodoc:
2977
2959
  class Enumerator < SyntaxNode
2978
2960
  include SymbolicElement
2979
2961
 
2980
- def initialize(identifier, expression, symbol)
2962
+ def initialize(id, expr, sym)
2981
2963
  super()
2982
- @identifier = identifier
2983
- @expression = expression
2984
- @symbol = symbol
2964
+ @identifier = id
2965
+ @expression = expr
2966
+ @symbol = sym
2985
2967
  end
2986
2968
 
2987
2969
  attr_reader :identifier
@@ -3008,9 +2990,9 @@ module C #:nodoc:
3008
2990
  end
3009
2991
 
3010
2992
  class TypeofTypeSpecifier < TypeSpecifier
3011
- def initialize(expression, type_name)
2993
+ def initialize(expr, type_name)
3012
2994
  super()
3013
- @expression = expression
2995
+ @expression = expr
3014
2996
  @type_name = type_name
3015
2997
  end
3016
2998
 
@@ -3051,8 +3033,8 @@ module C #:nodoc:
3051
3033
  false
3052
3034
  end
3053
3035
 
3054
- def full=(full_declarator)
3055
- @full = full_declarator
3036
+ def full=(dcr_is_full)
3037
+ @full = dcr_is_full
3056
3038
 
3057
3039
  # NOTE: The ISO C99 standard says;
3058
3040
  #
@@ -3067,7 +3049,7 @@ module C #:nodoc:
3067
3049
  # specified by the full declarator is said to be variably modified.
3068
3050
  # Furthermore, any type derived by declarator type derivation from a
3069
3051
  # variably modified type is itself variably modified.
3070
- if full_declarator
3052
+ if dcr_is_full
3071
3053
  append_sequence_point!
3072
3054
  else
3073
3055
  delete_sequence_point!
@@ -3104,9 +3086,9 @@ module C #:nodoc:
3104
3086
  end
3105
3087
 
3106
3088
  class IdentifierDeclarator < Declarator
3107
- def initialize(identifier)
3089
+ def initialize(id)
3108
3090
  super()
3109
- @identifier = identifier
3091
+ @identifier = id
3110
3092
  end
3111
3093
 
3112
3094
  attr_reader :identifier
@@ -3142,15 +3124,15 @@ module C #:nodoc:
3142
3124
  end
3143
3125
 
3144
3126
  class GroupedDeclarator < Declarator
3145
- def initialize(declarator)
3127
+ def initialize(base_dcr)
3146
3128
  super()
3147
- @base = declarator
3129
+ @base = base_dcr
3148
3130
  end
3149
3131
 
3150
3132
  attr_reader :base
3151
3133
 
3152
3134
  def location
3153
- @base.location
3135
+ @base ? @base.location || head_location : head_location
3154
3136
  end
3155
3137
 
3156
3138
  def identifier
@@ -3181,17 +3163,17 @@ module C #:nodoc:
3181
3163
  end
3182
3164
 
3183
3165
  class ArrayDeclarator < Declarator
3184
- def initialize(declarator, size_expression)
3166
+ def initialize(base_dcr, size_expr)
3185
3167
  super()
3186
- @base = declarator
3187
- @size_expression = size_expression
3168
+ @base = base_dcr
3169
+ @size_expression = size_expr
3188
3170
  end
3189
3171
 
3190
3172
  attr_reader :base
3191
3173
  attr_reader :size_expression
3192
3174
 
3193
3175
  def location
3194
- @base.location
3176
+ @base ? @base.location || head_location : head_location
3195
3177
  end
3196
3178
 
3197
3179
  def identifier
@@ -3223,15 +3205,15 @@ module C #:nodoc:
3223
3205
  end
3224
3206
 
3225
3207
  class FunctionDeclarator < Declarator
3226
- def initialize(declarator)
3208
+ def initialize(base_dcr)
3227
3209
  super()
3228
- @base = declarator
3210
+ @base = base_dcr
3229
3211
  end
3230
3212
 
3231
3213
  attr_reader :base
3232
3214
 
3233
3215
  def location
3234
- @base.location
3216
+ @base ? @base.location || head_location : head_location
3235
3217
  end
3236
3218
 
3237
3219
  def identifier
@@ -3251,9 +3233,9 @@ module C #:nodoc:
3251
3233
  end
3252
3234
 
3253
3235
  class AnsiFunctionDeclarator < FunctionDeclarator
3254
- def initialize(declarator, parameter_type_list)
3255
- super(declarator)
3256
- @parameter_type_list = parameter_type_list
3236
+ def initialize(base_dcr, param_type_list)
3237
+ super(base_dcr)
3238
+ @parameter_type_list = param_type_list
3257
3239
  end
3258
3240
 
3259
3241
  attr_accessor :parameter_type_list
@@ -3268,9 +3250,9 @@ module C #:nodoc:
3268
3250
  end
3269
3251
 
3270
3252
  class KandRFunctionDeclarator < FunctionDeclarator
3271
- def initialize(declarator, identifier_list)
3272
- super(declarator)
3273
- @identifier_list = identifier_list
3253
+ def initialize(base_dcr, id_list)
3254
+ super(base_dcr)
3255
+ @identifier_list = id_list
3274
3256
  end
3275
3257
 
3276
3258
  attr_reader :identifier_list
@@ -3299,9 +3281,9 @@ module C #:nodoc:
3299
3281
  end
3300
3282
 
3301
3283
  class ParameterTypeList < SyntaxNode
3302
- def initialize(parameters, have_va_list)
3284
+ def initialize(params, have_va_list)
3303
3285
  super()
3304
- @parameters = parameters
3286
+ @parameters = params
3305
3287
  @have_va_list = have_va_list
3306
3288
  end
3307
3289
 
@@ -3323,10 +3305,10 @@ module C #:nodoc:
3323
3305
  class ParameterDeclaration < SyntaxNode
3324
3306
  include DeclarationSpecifiersHolder
3325
3307
 
3326
- def initialize(declaration_specifiers, declarator)
3308
+ def initialize(dcl_specs, dcr)
3327
3309
  super()
3328
- @declaration_specifiers = declaration_specifiers
3329
- @declarator = declarator
3310
+ @declaration_specifiers = dcl_specs
3311
+ @declarator = dcr
3330
3312
  @type = nil
3331
3313
  end
3332
3314
 
@@ -3357,9 +3339,9 @@ module C #:nodoc:
3357
3339
  end
3358
3340
 
3359
3341
  class ErrorStatement < Statement
3360
- def initialize(error_token)
3342
+ def initialize(err_tok)
3361
3343
  super()
3362
- @error_token = error_token
3344
+ @error_token = err_tok
3363
3345
  end
3364
3346
 
3365
3347
  def location
@@ -3374,10 +3356,10 @@ module C #:nodoc:
3374
3356
  class LabeledStatement < Statement; end
3375
3357
 
3376
3358
  class GenericLabeledStatement < LabeledStatement
3377
- def initialize(label, statement)
3359
+ def initialize(label, stmt)
3378
3360
  super()
3379
3361
  @label = label
3380
- @statement = statement
3362
+ @statement = stmt
3381
3363
  @referrers = []
3382
3364
  end
3383
3365
 
@@ -3396,10 +3378,10 @@ module C #:nodoc:
3396
3378
  end
3397
3379
 
3398
3380
  class CaseLabeledStatement < LabeledStatement
3399
- def initialize(expression, statement)
3381
+ def initialize(expr, stmt)
3400
3382
  super()
3401
- @expression = expression
3402
- @statement = statement
3383
+ @expression = expr
3384
+ @statement = stmt
3403
3385
  end
3404
3386
 
3405
3387
  attr_reader :expression
@@ -3417,9 +3399,9 @@ module C #:nodoc:
3417
3399
  end
3418
3400
 
3419
3401
  class DefaultLabeledStatement < LabeledStatement
3420
- def initialize(statement)
3402
+ def initialize(stmt)
3421
3403
  super()
3422
- @statement = statement
3404
+ @statement = stmt
3423
3405
  end
3424
3406
 
3425
3407
  attr_reader :statement
@@ -3453,9 +3435,9 @@ module C #:nodoc:
3453
3435
  end
3454
3436
 
3455
3437
  class ExpressionStatement < Statement
3456
- def initialize(expression)
3438
+ def initialize(expr)
3457
3439
  super()
3458
- @expression = expression
3440
+ @expression = expr
3459
3441
  end
3460
3442
 
3461
3443
  attr_reader :expression
@@ -3473,11 +3455,11 @@ module C #:nodoc:
3473
3455
  class SelectionStatement < Statement; end
3474
3456
 
3475
3457
  class IfStatement < SelectionStatement
3476
- def initialize(expression, statement, header_terminator)
3458
+ def initialize(expr, stmt, header_term)
3477
3459
  super()
3478
- @expression = expression
3479
- @statement = statement
3480
- @header_terminator = header_terminator
3460
+ @expression = expr
3461
+ @statement = stmt
3462
+ @header_terminator = header_term
3481
3463
  end
3482
3464
 
3483
3465
  attr_reader :expression
@@ -3495,14 +3477,13 @@ module C #:nodoc:
3495
3477
  end
3496
3478
 
3497
3479
  class IfElseStatement < SelectionStatement
3498
- def initialize(expression, then_statement, else_statement,
3499
- then_header_terminator, else_header_terminator)
3480
+ def initialize(expr, then_stmt, else_stmt, then_term, else_term)
3500
3481
  super()
3501
- @expression = expression
3502
- @then_statement = then_statement
3503
- @else_statement = else_statement
3504
- @then_header_terminator = then_header_terminator
3505
- @else_header_terminator = else_header_terminator
3482
+ @expression = expr
3483
+ @then_statement = then_stmt
3484
+ @else_statement = else_stmt
3485
+ @then_header_terminator = then_term
3486
+ @else_header_terminator = else_term
3506
3487
  end
3507
3488
 
3508
3489
  attr_reader :expression
@@ -3524,10 +3505,10 @@ module C #:nodoc:
3524
3505
  end
3525
3506
 
3526
3507
  class SwitchStatement < SelectionStatement
3527
- def initialize(expression, statement)
3508
+ def initialize(expr, stmt)
3528
3509
  super()
3529
- @expression = expression
3530
- @statement = statement
3510
+ @expression = expr
3511
+ @statement = stmt
3531
3512
  derive_clause_conditions
3532
3513
  end
3533
3514
 
@@ -3545,71 +3526,70 @@ module C #:nodoc:
3545
3526
 
3546
3527
  private
3547
3528
  def derive_clause_conditions
3548
- case_expressions = []
3549
- default_labeled_statement = nil
3550
-
3551
- @statement.block_items.each do |block_item|
3552
- while block_item.kind_of?(GenericLabeledStatement)
3553
- block_item = block_item.statement
3554
- end
3529
+ case_exprs = []
3530
+ default_stmt = nil
3555
3531
 
3556
- case block_item
3532
+ @statement.block_items.each do |item|
3533
+ case item
3534
+ when GenericLabeledStatement
3535
+ item = item.statement
3536
+ redo
3557
3537
  when CaseLabeledStatement
3558
- block_item.normalized_expression = equal_to_expression(
3559
- @expression, block_item.expression, block_item.location)
3560
- case_expressions.push(block_item.normalized_expression)
3538
+ item.normalized_expression =
3539
+ equal_to_expression(@expression, item.expression, item.location)
3540
+ case_exprs.push(item.normalized_expression)
3541
+ item = item.statement
3542
+ redo
3561
3543
  when DefaultLabeledStatement
3562
- default_labeled_statement = block_item
3544
+ default_stmt = item
3545
+ item = item.statement
3546
+ redo
3563
3547
  end
3564
3548
  end
3565
3549
 
3566
- if default_labeled_statement
3567
- default_labeled_statement.normalized_expression =
3568
- derive_default_clause_condition(case_expressions,
3569
- default_labeled_statement.location)
3550
+ if default_stmt
3551
+ default_stmt.normalized_expression =
3552
+ derive_default_clause_condition(case_exprs, default_stmt.location)
3570
3553
  end
3571
3554
  end
3572
3555
 
3573
- def derive_default_clause_condition(case_expressions, location)
3574
- if case_expressions.empty?
3575
- equal_to_expression(@expression, @expression, location)
3556
+ def derive_default_clause_condition(case_exprs, loc)
3557
+ if case_exprs.empty?
3558
+ equal_to_expression(@expression, @expression, loc)
3576
3559
  else
3577
- case_expressions.map { |expr|
3578
- not_equal_to_expression(expr.lhs_operand, expr.rhs_operand, location)
3579
- }.reduce do |result, expr|
3580
- logical_and_expression(result, expr, location)
3581
- end
3560
+ case_exprs.map { |expr|
3561
+ not_equal_to_expression(expr.lhs_operand, expr.rhs_operand, loc)
3562
+ }.reduce { |cond, expr| logical_and_expression(cond, expr, loc) }
3582
3563
  end
3583
3564
  end
3584
3565
 
3585
- def equal_to_expression(lhs, rhs, location)
3586
- EqualityExpression.new(equal_to_operator(location), lhs, rhs)
3566
+ def equal_to_expression(lhs, rhs, loc)
3567
+ EqualityExpression.new(equal_to_operator(loc), lhs, rhs)
3587
3568
  end
3588
3569
 
3589
- def not_equal_to_expression(lhs, rhs, location)
3590
- EqualityExpression.new(not_equal_to_operator(location), lhs, rhs)
3570
+ def not_equal_to_expression(lhs, rhs, loc)
3571
+ EqualityExpression.new(not_equal_to_operator(loc), lhs, rhs)
3591
3572
  end
3592
3573
 
3593
- def logical_and_expression(lhs, rhs, location)
3594
- LogicalAndExpression.new(logical_and_operator(location), lhs, rhs)
3574
+ def logical_and_expression(lhs, rhs, loc)
3575
+ LogicalAndExpression.new(logical_and_operator(loc), lhs, rhs)
3595
3576
  end
3596
3577
 
3597
- def equal_to_operator(location)
3598
- Token.new("==", "==", location)
3578
+ def equal_to_operator(loc)
3579
+ Token.new("==", "==", loc)
3599
3580
  end
3600
3581
 
3601
- def not_equal_to_operator(location)
3602
- Token.new("!=", "!=", location)
3582
+ def not_equal_to_operator(loc)
3583
+ Token.new("!=", "!=", loc)
3603
3584
  end
3604
3585
 
3605
- def logical_and_operator(location)
3606
- Token.new("&&", "&&", location)
3586
+ def logical_and_operator(loc)
3587
+ Token.new("&&", "&&", loc)
3607
3588
  end
3608
3589
  end
3609
3590
 
3610
3591
  class IterationStatement < Statement
3611
3592
  include SyntaxNodeCollector
3612
- extend Memoizable
3613
3593
 
3614
3594
  def deduct_controlling_expression
3615
3595
  subclass_responsibility
@@ -3625,9 +3605,9 @@ module C #:nodoc:
3625
3605
  end
3626
3606
 
3627
3607
  private
3628
- def deduct_controlling_expression_candidates(rough_candidates)
3608
+ def deduct_controlling_expression_candidates(rough_cands)
3629
3609
  varying_var_names = varying_variable_names
3630
- rough_candidates.select do |expr_pair|
3610
+ rough_cands.select do |expr_pair|
3631
3611
  collect_object_specifiers(expr_pair.first).any? do |os|
3632
3612
  varying_var_names.include?(os.identifier.value)
3633
3613
  end
@@ -3655,8 +3635,10 @@ module C #:nodoc:
3655
3635
  def contain_loop_breaking?(node)
3656
3636
  items = node.kind_of?(CompoundStatement) ? node.block_items : [node]
3657
3637
  items.any? do |item|
3658
- item = item.statement while item.kind_of?(GenericLabeledStatement)
3659
3638
  case item
3639
+ when GenericLabeledStatement
3640
+ item = item.statement
3641
+ redo
3660
3642
  when GotoStatement
3661
3643
  # FIXME: Must check whether the goto-statement goes outside of the
3662
3644
  # loop or not.
@@ -3714,11 +3696,11 @@ module C #:nodoc:
3714
3696
  end
3715
3697
 
3716
3698
  class WhileStatement < IterationStatement
3717
- def initialize(expression, statement, header_terminator)
3699
+ def initialize(expr, stmt, header_term)
3718
3700
  super()
3719
- @expression = expression
3720
- @statement = statement
3721
- @header_terminator = header_terminator
3701
+ @expression = expr
3702
+ @statement = stmt
3703
+ @header_terminator = header_term
3722
3704
  end
3723
3705
 
3724
3706
  attr_reader :expression
@@ -3730,10 +3712,8 @@ module C #:nodoc:
3730
3712
  end
3731
3713
 
3732
3714
  def deduct_controlling_expression
3733
- selections = collect_loop_breaking_selection_statements(@statement)
3734
- rough_candidates = [
3735
- [@expression, @expression]
3736
- ] + selections.map { |stmt|
3715
+ sels = collect_loop_breaking_selection_statements(@statement)
3716
+ rough_cands = [[@expression, @expression]] + sels.map { |stmt|
3737
3717
  [stmt.expression,
3738
3718
  stmt.expression.to_normalized_logical.to_complemental_logical]
3739
3719
  }
@@ -3743,7 +3723,7 @@ module C #:nodoc:
3743
3723
  # FIXME: When the loop breaking selection-statement is a
3744
3724
  # if-else-statement and the loop breaking is in the else branch,
3745
3725
  # the controlling expression should be inverted.
3746
- deduct_controlling_expression_candidates(rough_candidates).first
3726
+ deduct_controlling_expression_candidates(rough_cands).first
3747
3727
  end
3748
3728
 
3749
3729
  def inspect(indent = 0)
@@ -3753,12 +3733,12 @@ module C #:nodoc:
3753
3733
  end
3754
3734
 
3755
3735
  class DoStatement < IterationStatement
3756
- def initialize(statement, expression, header_terminator, footer_initiator)
3736
+ def initialize(stmt, expr, header_term, footer_init)
3757
3737
  super()
3758
- @statement = statement
3759
- @expression = expression
3760
- @header_terminator = header_terminator
3761
- @footer_initiator = footer_initiator
3738
+ @statement = stmt
3739
+ @expression = expr
3740
+ @header_terminator = header_term
3741
+ @footer_initiator = footer_init
3762
3742
  end
3763
3743
 
3764
3744
  attr_reader :statement
@@ -3771,10 +3751,8 @@ module C #:nodoc:
3771
3751
  end
3772
3752
 
3773
3753
  def deduct_controlling_expression
3774
- selections = collect_loop_breaking_selection_statements(@statement)
3775
- rough_candidates = [
3776
- [@expression, @expression]
3777
- ] + selections.map { |stmt|
3754
+ sels = collect_loop_breaking_selection_statements(@statement)
3755
+ rough_cands = [[@expression, @expression]] + sels.map { |stmt|
3778
3756
  [stmt.expression,
3779
3757
  stmt.expression.to_normalized_logical.to_complemental_logical]
3780
3758
  }
@@ -3784,7 +3762,7 @@ module C #:nodoc:
3784
3762
  # FIXME: When the loop breaking selection-statement is a
3785
3763
  # if-else-statement and the loop breaking is in the else branch,
3786
3764
  # the controlling expression should be inverted.
3787
- deduct_controlling_expression_candidates(rough_candidates).first
3765
+ deduct_controlling_expression_candidates(rough_cands).first
3788
3766
  end
3789
3767
 
3790
3768
  def inspect(indent = 0)
@@ -3794,14 +3772,13 @@ module C #:nodoc:
3794
3772
  end
3795
3773
 
3796
3774
  class ForStatement < IterationStatement
3797
- def initialize(initial_statement, condition_statement, expression,
3798
- body_statement, header_terminator)
3775
+ def initialize(init_stmt, cond_stmt, expr, body_stmt, header_term)
3799
3776
  super()
3800
- @initial_statement = initial_statement
3801
- @condition_statement = condition_statement
3802
- @expression = expression
3803
- @body_statement = body_statement
3804
- @header_terminator = header_terminator
3777
+ @initial_statement = init_stmt
3778
+ @condition_statement = cond_stmt
3779
+ @expression = expr
3780
+ @body_statement = body_stmt
3781
+ @header_terminator = header_term
3805
3782
  end
3806
3783
 
3807
3784
  attr_reader :initial_statement
@@ -3815,10 +3792,10 @@ module C #:nodoc:
3815
3792
  end
3816
3793
 
3817
3794
  def deduct_controlling_expression
3818
- selections = collect_loop_breaking_selection_statements(@body_statement)
3819
- rough_candidates = [
3795
+ sels = collect_loop_breaking_selection_statements(@body_statement)
3796
+ rough_cands = [
3820
3797
  [@condition_statement.expression, @condition_statement.expression]
3821
- ] + selections.map { |stmt|
3798
+ ] + sels.map { |stmt|
3822
3799
  [stmt.expression,
3823
3800
  stmt.expression.to_normalized_logical.to_complemental_logical]
3824
3801
  }
@@ -3828,7 +3805,7 @@ module C #:nodoc:
3828
3805
  # FIXME: When the loop breaking selection-statement is a
3829
3806
  # if-else-statement and the loop breaking is in the else branch,
3830
3807
  # the controlling expression should be inverted.
3831
- deduct_controlling_expression_candidates(rough_candidates).first
3808
+ deduct_controlling_expression_candidates(rough_cands).first
3832
3809
  end
3833
3810
 
3834
3811
  def inspect(indent = 0)
@@ -3841,14 +3818,13 @@ module C #:nodoc:
3841
3818
  end
3842
3819
 
3843
3820
  class C99ForStatement < IterationStatement
3844
- def initialize(declaration, condition_statement, expression,
3845
- body_statement, header_terminator)
3821
+ def initialize(dcl, cond_stmt, expr, body_stmt, header_term)
3846
3822
  super()
3847
- @declaration = declaration
3848
- @condition_statement = condition_statement
3849
- @expression = expression
3850
- @body_statement = body_statement
3851
- @header_terminator = header_terminator
3823
+ @declaration = dcl
3824
+ @condition_statement = cond_stmt
3825
+ @expression = expr
3826
+ @body_statement = body_stmt
3827
+ @header_terminator = header_term
3852
3828
  end
3853
3829
 
3854
3830
  attr_reader :declaration
@@ -3862,10 +3838,10 @@ module C #:nodoc:
3862
3838
  end
3863
3839
 
3864
3840
  def deduct_controlling_expression
3865
- selections = collect_loop_breaking_selection_statements(@body_statement)
3866
- rough_candidates = [
3841
+ sels = collect_loop_breaking_selection_statements(@body_statement)
3842
+ rough_cands = [
3867
3843
  [@condition_statement.expression, @condition_statement.expression]
3868
- ] + selections.map { |stmt|
3844
+ ] + sels.map { |stmt|
3869
3845
  [stmt.expression,
3870
3846
  stmt.expression.to_normalized_logical.to_complemental_logical]
3871
3847
  }
@@ -3875,7 +3851,7 @@ module C #:nodoc:
3875
3851
  # FIXME: When the loop breaking selection-statement is a
3876
3852
  # if-else-statement and the loop breaking is in the else branch,
3877
3853
  # the controlling expression should be inverted.
3878
- deduct_controlling_expression_candidates(rough_candidates).first
3854
+ deduct_controlling_expression_candidates(rough_cands).first
3879
3855
  end
3880
3856
 
3881
3857
  def inspect(indent = 0)
@@ -3894,9 +3870,9 @@ module C #:nodoc:
3894
3870
  end
3895
3871
 
3896
3872
  class GotoStatement < JumpStatement
3897
- def initialize(identifier)
3873
+ def initialize(id)
3898
3874
  super()
3899
- @identifier = identifier
3875
+ @identifier = id
3900
3876
  end
3901
3877
 
3902
3878
  attr_reader :identifier
@@ -3919,9 +3895,9 @@ module C #:nodoc:
3919
3895
  end
3920
3896
 
3921
3897
  class ReturnStatement < JumpStatement
3922
- def initialize(expression)
3898
+ def initialize(expr)
3923
3899
  super()
3924
- @expression = expression
3900
+ @expression = expr
3925
3901
  end
3926
3902
 
3927
3903
  attr_reader :expression
@@ -3934,14 +3910,18 @@ module C #:nodoc:
3934
3910
 
3935
3911
  class TranslationUnit < SyntaxNode
3936
3912
  def initialize
3937
- super()
3913
+ super
3938
3914
  @external_declarations = []
3939
3915
  end
3940
3916
 
3941
3917
  attr_reader :external_declarations
3942
3918
 
3943
- def push(external_declaration)
3944
- @external_declarations.push(external_declaration)
3919
+ def push(external_dcl)
3920
+ if @external_declarations.empty?
3921
+ self.head_token = external_dcl.head_token
3922
+ end
3923
+ @external_declarations.push(external_dcl)
3924
+ self.tail_token = external_dcl.tail_token
3945
3925
  self
3946
3926
  end
3947
3927
 
@@ -3959,17 +3939,15 @@ module C #:nodoc:
3959
3939
  include SymbolicElement
3960
3940
  include SyntaxNodeCollector
3961
3941
 
3962
- def initialize(declaration_specifiers, declarator, parameter_definitions,
3963
- compound_statement, symbol_table)
3964
- super(declaration_specifiers)
3942
+ def initialize(dcl_specs, dcr, param_defs, compound_stmt, sym_tbl)
3943
+ super(dcl_specs)
3965
3944
 
3966
- @declarator = declarator
3967
- @parameter_definitions = parameter_definitions
3968
- @function_body = compound_statement
3969
- @symbol = symbol_table.create_new_symbol(ObjectName, identifier)
3970
- @type_declaration = build_type_declaration(declaration_specifiers,
3971
- symbol_table)
3972
- build_label_references(compound_statement)
3945
+ @declarator = dcr
3946
+ @parameter_definitions = param_defs
3947
+ @function_body = compound_stmt
3948
+ @symbol = sym_tbl.create_new_symbol(ObjectName, identifier)
3949
+ @type_declaration = build_type_declaration(dcl_specs, sym_tbl)
3950
+ build_label_references(compound_stmt)
3973
3951
  end
3974
3952
 
3975
3953
  attr_reader :declarator
@@ -4010,11 +3988,11 @@ module C #:nodoc:
4010
3988
  end
4011
3989
 
4012
3990
  private
4013
- def build_type_declaration(declaration_specifiers, symbol_table)
4014
- return nil unless declaration_specifiers
4015
- declaration_specifiers.type_specifiers.each do |type_specifier|
4016
- visitor = TypeDeclarationBuilder.new(symbol_table)
4017
- type_specifier.accept(visitor)
3991
+ def build_type_declaration(dcl_specs, sym_tbl)
3992
+ return nil unless dcl_specs
3993
+ dcl_specs.type_specifiers.each do |type_spec|
3994
+ visitor = TypeDeclarationBuilder.new(sym_tbl)
3995
+ type_spec.accept(visitor)
4018
3996
  unless visitor.type_declarations.empty?
4019
3997
  return visitor.type_declarations.first
4020
3998
  end
@@ -4022,29 +4000,26 @@ module C #:nodoc:
4022
4000
  nil
4023
4001
  end
4024
4002
 
4025
- def build_label_references(compound_statement)
4026
- labels = collect_generic_labeled_statements(compound_statement)
4003
+ def build_label_references(compound_stmt)
4004
+ labels = collect_generic_labeled_statements(compound_stmt)
4027
4005
 
4028
- gotos = collect_goto_statements(compound_statement)
4006
+ gotos = collect_goto_statements(compound_stmt)
4029
4007
 
4030
- labels.each do |generic_labeled_statement|
4031
- label_name = generic_labeled_statement.label.value
4032
- gotos.select { |goto_statement|
4033
- goto_statement.identifier.value == label_name
4034
- }.each do |goto_statement|
4035
- generic_labeled_statement.referrers.push(goto_statement)
4008
+ labels.each do |generic_labeled_stmt|
4009
+ label_name = generic_labeled_stmt.label.value
4010
+ gotos.select { |goto_stmt|
4011
+ goto_stmt.identifier.value == label_name
4012
+ }.each do |goto_stmt|
4013
+ generic_labeled_stmt.referrers.push(goto_stmt)
4036
4014
  end
4037
4015
  end
4038
4016
  end
4039
4017
  end
4040
4018
 
4041
4019
  class KandRFunctionDefinition < FunctionDefinition
4042
- def initialize(declaration_specifiers, declarator, declarations,
4043
- compound_statement, symbol_table)
4044
- parameter_definitions = create_parameters(declarator.identifier_list,
4045
- declarations, symbol_table)
4046
- super(declaration_specifiers, declarator, parameter_definitions,
4047
- compound_statement, symbol_table)
4020
+ def initialize(dcl_specs, dcr, dcls, compound_stmt, sym_tbl)
4021
+ param_defs = create_parameters(dcr.identifier_list, dcls, sym_tbl)
4022
+ super(dcl_specs, dcr, param_defs, compound_stmt, sym_tbl)
4048
4023
  end
4049
4024
 
4050
4025
  def identifier_list
@@ -4052,62 +4027,59 @@ module C #:nodoc:
4052
4027
  end
4053
4028
 
4054
4029
  private
4055
- def create_parameters(parameter_names, declarations, symbol_table)
4056
- return [] unless parameter_names
4057
-
4058
- parameter_names.each_with_object([]) do |name, result|
4059
- variable_definition =
4060
- find_variable_definition(declarations, name, symbol_table)
4061
- result.push(
4062
- variable_definition_to_parameter_definition(variable_definition))
4030
+ def create_parameters(param_names, dcls, sym_tbl)
4031
+ return [] unless param_names
4032
+
4033
+ param_names.each_with_object([]) do |name, param_defs|
4034
+ var_def = find_variable_definition(dcls, name, sym_tbl)
4035
+ param_defs.push(variable_definition_to_parameter_definition(var_def))
4063
4036
  end
4064
4037
  end
4065
4038
 
4066
- def find_variable_definition(declarations, name, symbol_table)
4067
- declarations.each do |declaration|
4068
- declaration.items.select { |item|
4039
+ def find_variable_definition(dcls, name, sym_tbl)
4040
+ dcls.each do |dcl|
4041
+ dcl.items.select { |item|
4069
4042
  item.kind_of?(VariableDefinition)
4070
- }.each do |definition|
4071
- return definition if definition.identifier.value == name.value
4043
+ }.each do |var_def|
4044
+ if var_def.identifier.value == name.value
4045
+ return var_def
4046
+ end
4072
4047
  end
4073
4048
  end
4074
4049
 
4075
- declaration = implicit_parameter_definition(name, symbol_table)
4076
- declarations.push(declaration)
4077
- declaration.items.first
4050
+ dcls.push(dcl = implicit_parameter_definition(name, sym_tbl))
4051
+ dcl.items.first
4078
4052
  end
4079
4053
 
4080
- def variable_definition_to_parameter_definition(variable_definition)
4081
- declaration_specifiers = variable_definition.declaration_specifiers
4082
- declarator = variable_definition.init_declarator.declarator
4083
- pdef = ParameterDefinition.new(declaration_specifiers, declarator)
4054
+ def variable_definition_to_parameter_definition(var_def)
4055
+ dcl_specs = var_def.declaration_specifiers
4056
+ dcr = var_def.init_declarator.declarator
4057
+ param_def = ParameterDefinition.new(dcl_specs, dcr)
4084
4058
 
4085
- unless declaration_specifiers
4086
- pdef.head_token = declarator.head_token
4087
- pdef.tail_token = declarator.tail_token
4059
+ unless dcl_specs
4060
+ param_def.head_token = dcr.head_token
4061
+ param_def.tail_token = dcr.tail_token
4088
4062
  end
4089
4063
 
4090
- unless declarator
4091
- pdef.head_token = declaration_specifiers.head_token
4092
- pdef.tail_token = declaration_specifiers.tail_token
4064
+ unless dcr
4065
+ param_def.head_token = dcl_specs.head_token
4066
+ param_def.tail_token = dcl_specs.tail_token
4093
4067
  end
4094
4068
 
4095
- pdef
4069
+ param_def
4096
4070
  end
4097
4071
 
4098
- def implicit_parameter_definition(identifier, symbol_table)
4099
- init_declarator =
4100
- InitDeclarator.new(IdentifierDeclarator.new(identifier), nil)
4101
- Declaration.new(nil, [init_declarator], symbol_table)
4072
+ def implicit_parameter_definition(id, sym_tbl)
4073
+ init_dcr = InitDeclarator.new(IdentifierDeclarator.new(id), nil)
4074
+ Declaration.new(nil, [init_dcr], sym_tbl)
4102
4075
  end
4103
4076
  end
4104
4077
 
4105
4078
  class AnsiFunctionDefinition < FunctionDefinition
4106
- def initialize(declaration_specifiers, declarator,
4107
- compound_statement, symbol_table)
4108
- super(declaration_specifiers, declarator,
4109
- create_parameters(declarator.innermost_parameter_type_list),
4110
- compound_statement, symbol_table)
4079
+ def initialize(dcl_specs, dcr, compound_stmt, sym_tbl)
4080
+ super(dcl_specs, dcr,
4081
+ create_parameters(dcr.innermost_parameter_type_list),
4082
+ compound_stmt, sym_tbl)
4111
4083
  end
4112
4084
 
4113
4085
  def parameter_type_list
@@ -4115,33 +4087,32 @@ module C #:nodoc:
4115
4087
  end
4116
4088
 
4117
4089
  private
4118
- def create_parameters(parameter_type_list)
4119
- return [] unless parameter_type_list
4120
- parameter_type_list.parameters.map do |parameter_declaration|
4121
- declaration_specifiers = parameter_declaration.declaration_specifiers
4122
- declarator = parameter_declaration.declarator
4123
- pdef = ParameterDefinition.new(declaration_specifiers, declarator)
4124
-
4125
- unless declaration_specifiers
4126
- pdef.head_token = declarator.head_token
4127
- pdef.tail_token = declarator.tail_token
4090
+ def create_parameters(param_type_list)
4091
+ return [] unless param_type_list
4092
+ param_type_list.parameters.map do |param_dcl|
4093
+ dcl_specs = param_dcl.declaration_specifiers
4094
+ dcr = param_dcl.declarator
4095
+ param_def = ParameterDefinition.new(dcl_specs, dcr)
4096
+
4097
+ unless dcl_specs
4098
+ param_def.head_token = dcr.head_token
4099
+ param_def.tail_token = dcr.tail_token
4128
4100
  end
4129
4101
 
4130
- unless declarator
4131
- pdef.head_token = declaration_specifiers.head_token
4132
- pdef.tail_token = declaration_specifiers.tail_token
4102
+ unless dcr
4103
+ param_def.head_token = dcl_specs.head_token
4104
+ param_def.tail_token = dcl_specs.tail_token
4133
4105
  end
4134
4106
 
4135
- pdef
4107
+ param_def
4136
4108
  end
4137
4109
  end
4138
4110
  end
4139
4111
 
4140
4112
  class ParameterDefinition < Definition
4141
- def initialize(declaration_specifiers, declarator)
4142
- super(declaration_specifiers)
4143
-
4144
- @declarator = declarator
4113
+ def initialize(dcl_specs, dcr)
4114
+ super(dcl_specs)
4115
+ @declarator = dcr
4145
4116
  end
4146
4117
 
4147
4118
  attr_reader :declarator
@@ -4159,7 +4130,14 @@ module C #:nodoc:
4159
4130
  end
4160
4131
 
4161
4132
  def location
4162
- identifier ? identifier.location : nil
4133
+ case
4134
+ when identifier
4135
+ identifier.location
4136
+ when declaration_specifiers
4137
+ declaration_specifiers.location
4138
+ else
4139
+ Location.new
4140
+ end
4163
4141
  end
4164
4142
 
4165
4143
  def to_variable_definition
@@ -4176,9 +4154,8 @@ module C #:nodoc:
4176
4154
  end
4177
4155
 
4178
4156
  class PseudoVariableDefinition < VariableDefinition
4179
- def initialize(declaration_specifiers, init_declarator, type)
4180
- super(declaration_specifiers, init_declarator, nil)
4181
-
4157
+ def initialize(dcl_specs, init_dcr, type)
4158
+ super(dcl_specs, init_dcr, nil)
4182
4159
  self.type = type
4183
4160
  end
4184
4161
 
@@ -4186,13 +4163,12 @@ module C #:nodoc:
4186
4163
  end
4187
4164
 
4188
4165
  class TypeName < SyntaxNode
4189
- def initialize(specifier_qualifier_list, abstract_declarator, symbol_table)
4166
+ def initialize(spec_qual_list, abstract_dcr, sym_tbl)
4190
4167
  super()
4191
- @specifier_qualifier_list = specifier_qualifier_list
4192
- @abstract_declarator = abstract_declarator
4168
+ @specifier_qualifier_list = spec_qual_list
4169
+ @abstract_declarator = abstract_dcr
4193
4170
  @type = nil
4194
- @type_declaration = build_type_declaration(specifier_qualifier_list,
4195
- symbol_table)
4171
+ @type_declaration = build_type_declaration(spec_qual_list, sym_tbl)
4196
4172
  end
4197
4173
 
4198
4174
  attr_reader :specifier_qualifier_list
@@ -4213,10 +4189,10 @@ module C #:nodoc:
4213
4189
  end
4214
4190
 
4215
4191
  private
4216
- def build_type_declaration(specifier_qualifier_list, symbol_table)
4217
- specifier_qualifier_list.type_specifiers.each do |type_specifier|
4218
- visitor = TypeDeclarationBuilder.new(symbol_table)
4219
- type_specifier.accept(visitor)
4192
+ def build_type_declaration(spec_qual_list, sym_tbl)
4193
+ spec_qual_list.type_specifiers.each do |type_spec|
4194
+ visitor = TypeDeclarationBuilder.new(sym_tbl)
4195
+ type_spec.accept(visitor)
4220
4196
  unless visitor.type_declarations.empty?
4221
4197
  return visitor.type_declarations.first
4222
4198
  end
@@ -4236,16 +4212,16 @@ module C #:nodoc:
4236
4212
  end
4237
4213
 
4238
4214
  class PointerAbstractDeclarator < AbstractDeclarator
4239
- def initialize(abstract_declarator, pointer)
4215
+ def initialize(abstract_dcr, ptr)
4240
4216
  super()
4241
- @base = abstract_declarator
4242
- @pointer = pointer
4217
+ @base = abstract_dcr
4218
+ @pointer = ptr
4243
4219
  end
4244
4220
 
4245
4221
  attr_reader :base
4246
4222
 
4247
4223
  def location
4248
- head_location
4224
+ @base ? @base.location || head_location : head_location
4249
4225
  end
4250
4226
 
4251
4227
  def function?(stack = [])
@@ -4272,15 +4248,15 @@ module C #:nodoc:
4272
4248
  end
4273
4249
 
4274
4250
  class GroupedAbstractDeclarator < AbstractDeclarator
4275
- def initialize(abstract_declarator)
4251
+ def initialize(abstract_dcr)
4276
4252
  super()
4277
- @base = abstract_declarator
4253
+ @base = abstract_dcr
4278
4254
  end
4279
4255
 
4280
4256
  attr_reader :base
4281
4257
 
4282
4258
  def location
4283
- @base.location
4259
+ @base ? @base.location || head_location : head_location
4284
4260
  end
4285
4261
 
4286
4262
  def function?
@@ -4305,19 +4281,17 @@ module C #:nodoc:
4305
4281
  end
4306
4282
 
4307
4283
  class ArrayAbstractDeclarator < AbstractDeclarator
4308
- def initialize(abstract_declarator, size_expression)
4284
+ def initialize(abstract_dcr, size_expr)
4309
4285
  super()
4310
- @base = abstract_declarator
4311
- @size_expression = size_expression
4286
+ @base = abstract_dcr
4287
+ @size_expression = size_expr
4312
4288
  end
4313
4289
 
4314
4290
  attr_reader :base
4315
4291
  attr_reader :size_expression
4316
4292
 
4317
4293
  def location
4318
- return @base.location if @base
4319
- return @size_expression.location if @size_expression
4320
- nil
4294
+ @base ? @base.location || head_location : head_location
4321
4295
  end
4322
4296
 
4323
4297
  def function?(stack = [])
@@ -4344,19 +4318,17 @@ module C #:nodoc:
4344
4318
  end
4345
4319
 
4346
4320
  class FunctionAbstractDeclarator < AbstractDeclarator
4347
- def initialize(abstract_declarator, parameter_type_list)
4321
+ def initialize(abstract_dcr, param_type_list)
4348
4322
  super()
4349
- @base = abstract_declarator
4350
- @parameter_type_list = parameter_type_list
4323
+ @base = abstract_dcr
4324
+ @parameter_type_list = param_type_list
4351
4325
  end
4352
4326
 
4353
4327
  attr_reader :base
4354
4328
  attr_reader :parameter_type_list
4355
4329
 
4356
4330
  def location
4357
- return @base.location if @base
4358
- return @parameter_type_list.location if @parameter_type_list
4359
- nil
4331
+ @base ? @base.location || head_location : head_location
4360
4332
  end
4361
4333
 
4362
4334
  def function?(stack = [])
@@ -4375,10 +4347,10 @@ module C #:nodoc:
4375
4347
  end
4376
4348
 
4377
4349
  class Initializer < SyntaxNode
4378
- def initialize(expression, initializers)
4350
+ def initialize(expr, inits)
4379
4351
  super()
4380
- @expression = expression
4381
- @initializers = initializers
4352
+ @expression = expr
4353
+ @initializers = inits
4382
4354
  end
4383
4355
 
4384
4356
  attr_reader :expression
@@ -4431,8 +4403,8 @@ module C #:nodoc:
4431
4403
  end
4432
4404
 
4433
4405
  class TypeDeclarationBuilder
4434
- def initialize(symbol_table)
4435
- @symbol_table = symbol_table
4406
+ def initialize(sym_tbl)
4407
+ @symbol_table = sym_tbl
4436
4408
  @type_declarations = []
4437
4409
  end
4438
4410
 
@@ -4447,23 +4419,23 @@ module C #:nodoc:
4447
4419
  def visit_struct_specifier(node)
4448
4420
  if node.struct_declarations
4449
4421
  node.struct_declarations.each { |child| child.accept(self) }
4450
- symbol = @symbol_table.create_new_symbol(StructTag, node.identifier)
4451
- @type_declarations.push(StructTypeDeclaration.new(node, symbol))
4422
+ sym = @symbol_table.create_new_symbol(StructTag, node.identifier)
4423
+ @type_declarations.push(StructTypeDeclaration.new(node, sym))
4452
4424
  end
4453
4425
  end
4454
4426
 
4455
4427
  def visit_union_specifier(node)
4456
4428
  if node.struct_declarations
4457
4429
  node.struct_declarations.each { |child| child.accept(self) }
4458
- symbol = @symbol_table.create_new_symbol(UnionTag, node.identifier)
4459
- @type_declarations.push(UnionTypeDeclaration.new(node, symbol))
4430
+ sym = @symbol_table.create_new_symbol(UnionTag, node.identifier)
4431
+ @type_declarations.push(UnionTypeDeclaration.new(node, sym))
4460
4432
  end
4461
4433
  end
4462
4434
 
4463
4435
  def visit_enum_specifier(node)
4464
4436
  if node.enumerators
4465
- symbol = @symbol_table.create_new_symbol(EnumTag, node.identifier)
4466
- @type_declarations.push(EnumTypeDeclaration.new(node, symbol))
4437
+ sym = @symbol_table.create_new_symbol(EnumTag, node.identifier)
4438
+ @type_declarations.push(EnumTypeDeclaration.new(node, sym))
4467
4439
  end
4468
4440
  end
4469
4441
 
@@ -4535,7 +4507,7 @@ module C #:nodoc:
4535
4507
 
4536
4508
  def visit_compound_literal_expression(node)
4537
4509
  node.type_name.accept(self) if node.type_name
4538
- node.initializers.each { |ini| ini.accept(self) }
4510
+ node.initializers.each { |init| init.accept(self) }
4539
4511
  end
4540
4512
 
4541
4513
  def visit_prefix_increment_expression(node)
@@ -4651,7 +4623,7 @@ module C #:nodoc:
4651
4623
 
4652
4624
  def visit_declaration(node)
4653
4625
  node.declaration_specifiers.accept(self) if node.declaration_specifiers
4654
- node.init_declarators.each { |decl| decl.accept(self) }
4626
+ node.init_declarators.each { |dcr| dcr.accept(self) }
4655
4627
  node.items.each { |item| item.accept(self) }
4656
4628
  end
4657
4629
 
@@ -4677,7 +4649,7 @@ module C #:nodoc:
4677
4649
  end
4678
4650
 
4679
4651
  def visit_declaration_specifiers(node)
4680
- node.type_specifiers.each { |ts| ts.accept(self) }
4652
+ node.type_specifiers.each { |type_spec| type_spec.accept(self) }
4681
4653
  end
4682
4654
 
4683
4655
  def visit_init_declarator(node)
@@ -4693,19 +4665,19 @@ module C #:nodoc:
4693
4665
 
4694
4666
  def visit_struct_specifier(node)
4695
4667
  if node.struct_declarations
4696
- node.struct_declarations.each { |decl| decl.accept(self) }
4668
+ node.struct_declarations.each { |dcl| dcl.accept(self) }
4697
4669
  end
4698
4670
  end
4699
4671
 
4700
4672
  def visit_union_specifier(node)
4701
4673
  if node.struct_declarations
4702
- node.struct_declarations.each { |decl| decl.accept(self) }
4674
+ node.struct_declarations.each { |dcl| dcl.accept(self) }
4703
4675
  end
4704
4676
  end
4705
4677
 
4706
4678
  def visit_struct_declaration(node)
4707
4679
  node.specifier_qualifier_list.accept(self)
4708
- node.struct_declarators.each { |decl| decl.accept(self) }
4680
+ node.struct_declarators.each { |dcr| dcr.accept(self) }
4709
4681
  node.items.each { |item| item.accept(self) }
4710
4682
  end
4711
4683
 
@@ -4713,7 +4685,7 @@ module C #:nodoc:
4713
4685
  end
4714
4686
 
4715
4687
  def visit_specifier_qualifier_list(node)
4716
- node.type_specifiers.each { |ts| ts.accept(self) }
4688
+ node.type_specifiers.each { |type_spec| type_spec.accept(self) }
4717
4689
  end
4718
4690
 
4719
4691
  def visit_struct_declarator(node)
@@ -4848,13 +4820,13 @@ module C #:nodoc:
4848
4820
  end
4849
4821
 
4850
4822
  def visit_translation_unit(node)
4851
- node.external_declarations.each { |decl| decl.accept(self) }
4823
+ node.external_declarations.each { |dcl| dcl.accept(self) }
4852
4824
  end
4853
4825
 
4854
4826
  def visit_kandr_function_definition(node)
4855
4827
  node.declaration_specifiers.accept(self) if node.declaration_specifiers
4856
4828
  node.declarator.accept(self)
4857
- node.parameter_definitions.each { |pdef| pdef.accept(self) }
4829
+ node.parameter_definitions.each { |param_def| param_def.accept(self) }
4858
4830
  node.function_body.accept(self)
4859
4831
  node.type_declaration.accept(self) if node.type_declaration
4860
4832
  end
@@ -4862,7 +4834,7 @@ module C #:nodoc:
4862
4834
  def visit_ansi_function_definition(node)
4863
4835
  node.declaration_specifiers.accept(self) if node.declaration_specifiers
4864
4836
  node.declarator.accept(self)
4865
- node.parameter_definitions.each { |pdef| pdef.accept(self) }
4837
+ node.parameter_definitions.each { |param_def| param_def.accept(self) }
4866
4838
  node.function_body.accept(self)
4867
4839
  node.type_declaration.accept(self) if node.type_declaration
4868
4840
  end
@@ -4899,7 +4871,7 @@ module C #:nodoc:
4899
4871
  when node.expression
4900
4872
  node.expression.accept(self)
4901
4873
  when node.initializers
4902
- node.initializers.each { |ini| ini.accept(self) }
4874
+ node.initializers.each { |init| init.accept(self) }
4903
4875
  end
4904
4876
  end
4905
4877
  end
@@ -5098,385 +5070,110 @@ module C #:nodoc:
5098
5070
  def_plugin :enter_initializer
5099
5071
  def_plugin :leave_initializer
5100
5072
 
5101
- def visit_error_expression(node)
5102
- visit_with_notifying(__method__, node) { super }
5103
- end
5104
-
5105
- def visit_object_specifier(node)
5106
- visit_with_notifying(__method__, node) { super }
5107
- end
5108
-
5109
- def visit_constant_specifier(node)
5110
- visit_with_notifying(__method__, node) { super }
5111
- end
5112
-
5113
- def visit_string_literal_specifier(node)
5114
- visit_with_notifying(__method__, node) { super }
5115
- end
5116
-
5117
- def visit_null_constant_specifier(node)
5118
- visit_with_notifying(__method__, node) { super }
5119
- end
5120
-
5121
- def visit_grouped_expression(node)
5122
- visit_with_notifying(__method__, node) { super }
5123
- end
5124
-
5125
- def visit_array_subscript_expression(node)
5126
- visit_with_notifying(__method__, node) { super }
5127
- end
5128
-
5129
- def visit_function_call_expression(node)
5130
- visit_with_notifying(__method__, node) { super }
5131
- end
5132
-
5133
- def visit_member_access_by_value_expression(node)
5134
- visit_with_notifying(__method__, node) { super }
5135
- end
5136
-
5137
- def visit_member_access_by_pointer_expression(node)
5138
- visit_with_notifying(__method__, node) { super }
5139
- end
5140
-
5141
- def visit_bit_access_by_value_expression(node)
5142
- visit_with_notifying(__method__, node) { super }
5143
- end
5144
-
5145
- def visit_bit_access_by_pointer_expression(node)
5146
- visit_with_notifying(__method__, node) { super }
5147
- end
5148
-
5149
- def visit_postfix_increment_expression(node)
5150
- visit_with_notifying(__method__, node) { super }
5151
- end
5152
-
5153
- def visit_postfix_decrement_expression(node)
5154
- visit_with_notifying(__method__, node) { super }
5155
- end
5156
-
5157
- def visit_compound_literal_expression(node)
5158
- visit_with_notifying(__method__, node) { super }
5159
- end
5160
-
5161
- def visit_prefix_increment_expression(node)
5162
- visit_with_notifying(__method__, node) { super }
5163
- end
5164
-
5165
- def visit_prefix_decrement_expression(node)
5166
- visit_with_notifying(__method__, node) { super }
5167
- end
5168
-
5169
- def visit_address_expression(node)
5170
- visit_with_notifying(__method__, node) { super }
5171
- end
5172
-
5173
- def visit_indirection_expression(node)
5174
- visit_with_notifying(__method__, node) { super }
5175
- end
5176
-
5177
- def visit_unary_arithmetic_expression(node)
5178
- visit_with_notifying(__method__, node) { super }
5179
- end
5180
-
5181
- def visit_sizeof_expression(node)
5182
- visit_with_notifying(__method__, node) { super }
5183
- end
5184
-
5185
- def visit_sizeof_type_expression(node)
5186
- visit_with_notifying(__method__, node) { super }
5187
- end
5188
-
5189
- def visit_alignof_expression(node)
5190
- visit_with_notifying(__method__, node) { super }
5191
- end
5192
-
5193
- def visit_alignof_type_expression(node)
5194
- visit_with_notifying(__method__, node) { super }
5195
- end
5196
-
5197
- def visit_cast_expression(node)
5198
- visit_with_notifying(__method__, node) { super }
5199
- end
5200
-
5201
- def visit_multiplicative_expression(node)
5202
- visit_with_notifying(__method__, node) { super }
5203
- end
5204
-
5205
- def visit_additive_expression(node)
5206
- visit_with_notifying(__method__, node) { super }
5207
- end
5208
-
5209
- def visit_shift_expression(node)
5210
- visit_with_notifying(__method__, node) { super }
5211
- end
5212
-
5213
- def visit_relational_expression(node)
5214
- visit_with_notifying(__method__, node) { super }
5215
- end
5216
-
5217
- def visit_equality_expression(node)
5218
- visit_with_notifying(__method__, node) { super }
5219
- end
5220
-
5221
- def visit_and_expression(node)
5222
- visit_with_notifying(__method__, node) { super }
5223
- end
5224
-
5225
- def visit_exclusive_or_expression(node)
5226
- visit_with_notifying(__method__, node) { super }
5227
- end
5228
-
5229
- def visit_inclusive_or_expression(node)
5230
- visit_with_notifying(__method__, node) { super }
5231
- end
5232
-
5233
- def visit_logical_and_expression(node)
5234
- visit_with_notifying(__method__, node) { super }
5235
- end
5236
-
5237
- def visit_logical_or_expression(node)
5238
- visit_with_notifying(__method__, node) { super }
5239
- end
5240
-
5241
- def visit_conditional_expression(node)
5242
- visit_with_notifying(__method__, node) { super }
5243
- end
5244
-
5245
- def visit_simple_assignment_expression(node)
5246
- visit_with_notifying(__method__, node) { super }
5247
- end
5248
-
5249
- def visit_compound_assignment_expression(node)
5250
- visit_with_notifying(__method__, node) { super }
5251
- end
5252
-
5253
- def visit_comma_separated_expression(node)
5254
- visit_with_notifying(__method__, node) { super }
5255
- end
5256
-
5257
- def visit_declaration(node)
5258
- visit_with_notifying(__method__, node) { super }
5259
- end
5260
-
5261
- def visit_function_declaration(node)
5262
- visit_with_notifying(__method__, node) { super }
5263
- end
5264
-
5265
- def visit_variable_declaration(node)
5266
- visit_with_notifying(__method__, node) { super }
5267
- end
5268
-
5269
- def visit_variable_definition(node)
5270
- visit_with_notifying(__method__, node) { super }
5271
- end
5272
-
5273
- def visit_typedef_declaration(node)
5274
- visit_with_notifying(__method__, node) { super }
5275
- end
5276
-
5277
- def visit_struct_type_declaration(node)
5278
- visit_with_notifying(__method__, node) { super }
5279
- end
5280
-
5281
- def visit_union_type_declaration(node)
5282
- visit_with_notifying(__method__, node) { super }
5283
- end
5284
-
5285
- def visit_enum_type_declaration(node)
5286
- visit_with_notifying(__method__, node) { super }
5287
- end
5288
-
5289
- def visit_declaration_specifiers(node)
5290
- visit_with_notifying(__method__, node) { super }
5291
- end
5292
-
5293
- def visit_init_declarator(node)
5294
- visit_with_notifying(__method__, node) { super }
5295
- end
5296
-
5297
- def visit_standard_type_specifier(node)
5298
- visit_with_notifying(__method__, node) { super }
5299
- end
5300
-
5301
- def visit_typedef_type_specifier(node)
5302
- visit_with_notifying(__method__, node) { super }
5303
- end
5304
-
5305
- def visit_struct_specifier(node)
5306
- visit_with_notifying(__method__, node) { super }
5307
- end
5308
-
5309
- def visit_union_specifier(node)
5310
- visit_with_notifying(__method__, node) { super }
5311
- end
5312
-
5313
- def visit_struct_declaration(node)
5314
- visit_with_notifying(__method__, node) { super }
5315
- end
5316
-
5317
- def visit_member_declaration(node)
5318
- visit_with_notifying(__method__, node) { super }
5319
- end
5320
-
5321
- def visit_specifier_qualifier_list(node)
5322
- visit_with_notifying(__method__, node) { super }
5323
- end
5324
-
5325
- def visit_struct_declarator(node)
5326
- visit_with_notifying(__method__, node) { super }
5327
- end
5328
-
5329
- def visit_enum_specifier(node)
5330
- visit_with_notifying(__method__, node) { super }
5331
- end
5332
-
5333
- def visit_enumerator(node)
5334
- visit_with_notifying(__method__, node) { super }
5335
- end
5336
-
5337
- def visit_typeof_type_specifier(node)
5338
- visit_with_notifying(__method__, node) { super }
5339
- end
5340
-
5341
- def visit_identifier_declarator(node)
5342
- visit_with_notifying(__method__, node) { super }
5343
- end
5344
-
5345
- def visit_grouped_declarator(node)
5346
- visit_with_notifying(__method__, node) { super }
5347
- end
5348
-
5349
- def visit_array_declarator(node)
5350
- visit_with_notifying(__method__, node) { super }
5351
- end
5352
-
5353
- def visit_ansi_function_declarator(node)
5354
- visit_with_notifying(__method__, node) { super }
5355
- end
5356
-
5357
- def visit_kandr_function_declarator(node)
5358
- visit_with_notifying(__method__, node) { super }
5359
- end
5360
-
5361
- def visit_abbreviated_function_declarator(node)
5362
- visit_with_notifying(__method__, node) { super }
5363
- end
5364
-
5365
- def visit_parameter_type_list(node)
5366
- visit_with_notifying(__method__, node) { super }
5367
- end
5368
-
5369
- def visit_parameter_declaration(node)
5370
- visit_with_notifying(__method__, node) { super }
5371
- end
5372
-
5373
- def visit_error_statement(node)
5374
- visit_with_notifying(__method__, node) { super }
5375
- end
5376
-
5377
- def visit_generic_labeled_statement(node)
5378
- visit_with_notifying(__method__, node) { super }
5379
- end
5380
-
5381
- def visit_case_labeled_statement(node)
5382
- visit_with_notifying(__method__, node) { super }
5383
- end
5384
-
5385
- def visit_default_labeled_statement(node)
5386
- visit_with_notifying(__method__, node) { super }
5387
- end
5388
-
5389
- def visit_compound_statement(node)
5390
- visit_with_notifying(__method__, node) { super }
5391
- end
5392
-
5393
- def visit_expression_statement(node)
5394
- visit_with_notifying(__method__, node) { super }
5395
- end
5396
-
5397
- def visit_if_statement(node)
5398
- visit_with_notifying(__method__, node) { super }
5399
- end
5400
-
5401
- def visit_if_else_statement(node)
5402
- visit_with_notifying(__method__, node) { super }
5403
- end
5404
-
5405
- def visit_switch_statement(node)
5406
- visit_with_notifying(__method__, node) { super }
5407
- end
5408
-
5409
- def visit_while_statement(node)
5410
- visit_with_notifying(__method__, node) { super }
5411
- end
5412
-
5413
- def visit_do_statement(node)
5414
- visit_with_notifying(__method__, node) { super }
5415
- end
5416
-
5417
- def visit_for_statement(node)
5418
- visit_with_notifying(__method__, node) { super }
5419
- end
5420
-
5421
- def visit_c99_for_statement(node)
5422
- visit_with_notifying(__method__, node) { super }
5423
- end
5424
-
5425
- def visit_goto_statement(node)
5426
- visit_with_notifying(__method__, node) { super }
5427
- end
5428
-
5429
- def visit_continue_statement(node)
5430
- visit_with_notifying(__method__, node) { super }
5431
- end
5432
-
5433
- def visit_break_statement(node)
5434
- visit_with_notifying(__method__, node) { super }
5435
- end
5436
-
5437
- def visit_return_statement(node)
5438
- visit_with_notifying(__method__, node) { super }
5439
- end
5440
-
5441
- def visit_translation_unit(node)
5442
- visit_with_notifying(__method__, node) { super }
5443
- end
5444
-
5445
- def visit_kandr_function_definition(node)
5446
- visit_with_notifying(__method__, node) { super }
5447
- end
5448
-
5449
- def visit_ansi_function_definition(node)
5450
- visit_with_notifying(__method__, node) { super }
5451
- end
5452
-
5453
- def visit_parameter_definition(node)
5454
- visit_with_notifying(__method__, node) { super }
5455
- end
5456
-
5457
- def visit_type_name(node)
5458
- visit_with_notifying(__method__, node) { super }
5459
- end
5460
-
5461
- def visit_pointer_abstract_declarator(node)
5462
- visit_with_notifying(__method__, node) { super }
5463
- end
5464
-
5465
- def visit_grouped_abstract_declarator(node)
5466
- visit_with_notifying(__method__, node) { super }
5467
- end
5468
-
5469
- def visit_array_abstract_declarator(node)
5470
- visit_with_notifying(__method__, node) { super }
5471
- end
5472
-
5473
- def visit_function_abstract_declarator(node)
5474
- visit_with_notifying(__method__, node) { super }
5475
- end
5476
-
5477
- def visit_initializer(node)
5478
- visit_with_notifying(__method__, node) { super }
5479
- end
5073
+ def self.def_visitor_method(node_name)
5074
+ class_eval <<-EOS
5075
+ define_method("visit_#{node_name}") do |*args|
5076
+ visit_with_notifying(__method__, args.first) { super(args.first) }
5077
+ end
5078
+ EOS
5079
+ end
5080
+ private_class_method :def_visitor_method
5081
+
5082
+ def_visitor_method :error_expression
5083
+ def_visitor_method :object_specifier
5084
+ def_visitor_method :constant_specifier
5085
+ def_visitor_method :string_literal_specifier
5086
+ def_visitor_method :null_constant_specifier
5087
+ def_visitor_method :grouped_expression
5088
+ def_visitor_method :array_subscript_expression
5089
+ def_visitor_method :function_call_expression
5090
+ def_visitor_method :member_access_by_value_expression
5091
+ def_visitor_method :member_access_by_pointer_expression
5092
+ def_visitor_method :bit_access_by_value_expression
5093
+ def_visitor_method :bit_access_by_pointer_expression
5094
+ def_visitor_method :postfix_increment_expression
5095
+ def_visitor_method :postfix_decrement_expression
5096
+ def_visitor_method :compound_literal_expression
5097
+ def_visitor_method :prefix_increment_expression
5098
+ def_visitor_method :prefix_decrement_expression
5099
+ def_visitor_method :address_expression
5100
+ def_visitor_method :indirection_expression
5101
+ def_visitor_method :unary_arithmetic_expression
5102
+ def_visitor_method :sizeof_expression
5103
+ def_visitor_method :sizeof_type_expression
5104
+ def_visitor_method :alignof_expression
5105
+ def_visitor_method :alignof_type_expression
5106
+ def_visitor_method :cast_expression
5107
+ def_visitor_method :multiplicative_expression
5108
+ def_visitor_method :additive_expression
5109
+ def_visitor_method :shift_expression
5110
+ def_visitor_method :relational_expression
5111
+ def_visitor_method :equality_expression
5112
+ def_visitor_method :and_expression
5113
+ def_visitor_method :exclusive_or_expression
5114
+ def_visitor_method :inclusive_or_expression
5115
+ def_visitor_method :logical_and_expression
5116
+ def_visitor_method :logical_or_expression
5117
+ def_visitor_method :conditional_expression
5118
+ def_visitor_method :simple_assignment_expression
5119
+ def_visitor_method :compound_assignment_expression
5120
+ def_visitor_method :comma_separated_expression
5121
+ def_visitor_method :declaration
5122
+ def_visitor_method :function_declaration
5123
+ def_visitor_method :variable_declaration
5124
+ def_visitor_method :variable_definition
5125
+ def_visitor_method :typedef_declaration
5126
+ def_visitor_method :struct_type_declaration
5127
+ def_visitor_method :union_type_declaration
5128
+ def_visitor_method :enum_type_declaration
5129
+ def_visitor_method :declaration_specifiers
5130
+ def_visitor_method :init_declarator
5131
+ def_visitor_method :standard_type_specifier
5132
+ def_visitor_method :typedef_type_specifier
5133
+ def_visitor_method :struct_specifier
5134
+ def_visitor_method :union_specifier
5135
+ def_visitor_method :struct_declaration
5136
+ def_visitor_method :member_declaration
5137
+ def_visitor_method :specifier_qualifier_list
5138
+ def_visitor_method :struct_declarator
5139
+ def_visitor_method :enum_specifier
5140
+ def_visitor_method :enumerator
5141
+ def_visitor_method :typeof_type_specifier
5142
+ def_visitor_method :identifier_declarator
5143
+ def_visitor_method :grouped_declarator
5144
+ def_visitor_method :array_declarator
5145
+ def_visitor_method :ansi_function_declarator
5146
+ def_visitor_method :kandr_function_declarator
5147
+ def_visitor_method :abbreviated_function_declarator
5148
+ def_visitor_method :parameter_type_list
5149
+ def_visitor_method :parameter_declaration
5150
+ def_visitor_method :error_statement
5151
+ def_visitor_method :generic_labeled_statement
5152
+ def_visitor_method :case_labeled_statement
5153
+ def_visitor_method :default_labeled_statement
5154
+ def_visitor_method :compound_statement
5155
+ def_visitor_method :expression_statement
5156
+ def_visitor_method :if_statement
5157
+ def_visitor_method :if_else_statement
5158
+ def_visitor_method :switch_statement
5159
+ def_visitor_method :while_statement
5160
+ def_visitor_method :do_statement
5161
+ def_visitor_method :for_statement
5162
+ def_visitor_method :c99_for_statement
5163
+ def_visitor_method :goto_statement
5164
+ def_visitor_method :continue_statement
5165
+ def_visitor_method :break_statement
5166
+ def_visitor_method :return_statement
5167
+ def_visitor_method :translation_unit
5168
+ def_visitor_method :kandr_function_definition
5169
+ def_visitor_method :ansi_function_definition
5170
+ def_visitor_method :parameter_definition
5171
+ def_visitor_method :type_name
5172
+ def_visitor_method :pointer_abstract_declarator
5173
+ def_visitor_method :grouped_abstract_declarator
5174
+ def_visitor_method :array_abstract_declarator
5175
+ def_visitor_method :function_abstract_declarator
5176
+ def_visitor_method :initializer
5480
5177
 
5481
5178
  private
5482
5179
  def visit_with_notifying(caller_method, node, &block)