adlint 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (465) hide show
  1. data/AUTHORS +27 -0
  2. data/COPYING +674 -0
  3. data/ChangeLog +820 -0
  4. data/INSTALL +78 -0
  5. data/MANIFEST +464 -0
  6. data/NEWS +38 -0
  7. data/README +74 -0
  8. data/Rakefile +167 -0
  9. data/TODO +29 -0
  10. data/bin/adlint +141 -0
  11. data/bin/adlint_chk +129 -0
  12. data/bin/adlint_cma +122 -0
  13. data/bin/adlint_sma +129 -0
  14. data/bin/adlintize +286 -0
  15. data/etc/conf.d/fallback/cinit.erb +11 -0
  16. data/etc/conf.d/fallback/traits.erb +216 -0
  17. data/etc/conf.d/i686-cygwin/cinit-gcc_4.3.4.erb +149 -0
  18. data/etc/conf.d/i686-cygwin/traits-gcc_4.3.4.erb +227 -0
  19. data/etc/conf.d/i686-devkit/cinit-gcc_4.5.2.erb +224 -0
  20. data/etc/conf.d/i686-devkit/traits-gcc_4.5.2.erb +226 -0
  21. data/etc/conf.d/i686-linux/cinit-gcc_4.5.1.erb +219 -0
  22. data/etc/conf.d/i686-linux/traits-gcc_4.5.1.erb +224 -0
  23. data/etc/conf.d/i686-mingw/cinit-gcc_4.6.1.erb +234 -0
  24. data/etc/conf.d/i686-mingw/traits-gcc_4.6.1.erb +226 -0
  25. data/etc/conf.d/noarch/GNUmakefile.erb +119 -0
  26. data/etc/conf.d/noarch/adlint_all_bat.erb +9 -0
  27. data/etc/conf.d/noarch/adlint_all_sh.erb +10 -0
  28. data/etc/conf.d/noarch/pinit.erb +11 -0
  29. data/etc/mesg.d/en_US/messages.yml +784 -0
  30. data/etc/mesg.d/ja_JP/messages.yml +784 -0
  31. data/lib/adlint/analyzer.rb +294 -0
  32. data/lib/adlint/c/branch.rb +251 -0
  33. data/lib/adlint/c/builtin.rb +92 -0
  34. data/lib/adlint/c/code.rb +490 -0
  35. data/lib/adlint/c/const.rb +465 -0
  36. data/lib/adlint/c/conv.rb +212 -0
  37. data/lib/adlint/c/ctrlexpr.rb +949 -0
  38. data/lib/adlint/c/domain.rb +7499 -0
  39. data/lib/adlint/c/environ.rb +133 -0
  40. data/lib/adlint/c/expr.rb +1725 -0
  41. data/lib/adlint/c/format.rb +3209 -0
  42. data/lib/adlint/c/interp.rb +1740 -0
  43. data/lib/adlint/c/lexer.rb +241 -0
  44. data/lib/adlint/c/mediator.rb +313 -0
  45. data/lib/adlint/c/message.rb +13597 -0
  46. data/lib/adlint/c/metric.rb +765 -0
  47. data/lib/adlint/c/object.rb +1018 -0
  48. data/lib/adlint/c/parser.rb +3800 -0
  49. data/lib/adlint/c/parser.y +2054 -0
  50. data/lib/adlint/c/phase.rb +712 -0
  51. data/lib/adlint/c/resolver.rb +270 -0
  52. data/lib/adlint/c/scanner.rb +248 -0
  53. data/lib/adlint/c/scope.rb +74 -0
  54. data/lib/adlint/c/syntax.rb +4279 -0
  55. data/lib/adlint/c/type.rb +7506 -0
  56. data/lib/adlint/c/util.rb +91 -0
  57. data/lib/adlint/c/value.rb +2310 -0
  58. data/lib/adlint/c.rb +56 -0
  59. data/lib/adlint/code.rb +500 -0
  60. data/lib/adlint/cpp/code.rb +189 -0
  61. data/lib/adlint/cpp/constexpr.rb +721 -0
  62. data/lib/adlint/cpp/constexpr.y +389 -0
  63. data/lib/adlint/cpp/eval.rb +1012 -0
  64. data/lib/adlint/cpp/lexer.rb +860 -0
  65. data/lib/adlint/cpp/macro.rb +637 -0
  66. data/lib/adlint/cpp/message.rb +992 -0
  67. data/lib/adlint/cpp/phase.rb +176 -0
  68. data/lib/adlint/cpp/scanner.rb +93 -0
  69. data/lib/adlint/cpp/source.rb +169 -0
  70. data/lib/adlint/cpp/subst.rb +300 -0
  71. data/lib/adlint/cpp/syntax.rb +1412 -0
  72. data/lib/adlint/cpp/util.rb +97 -0
  73. data/lib/adlint/cpp.rb +43 -0
  74. data/lib/adlint/driver.rb +147 -0
  75. data/lib/adlint/error.rb +179 -0
  76. data/lib/adlint/lang.rb +97 -0
  77. data/lib/adlint/ld/message.rb +259 -0
  78. data/lib/adlint/ld/metric.rb +57 -0
  79. data/lib/adlint/ld/object.rb +542 -0
  80. data/lib/adlint/ld/phase.rb +193 -0
  81. data/lib/adlint/ld/typedef.rb +109 -0
  82. data/lib/adlint/ld/util.rb +88 -0
  83. data/lib/adlint/ld.rb +37 -0
  84. data/lib/adlint/lexer.rb +293 -0
  85. data/lib/adlint/message.rb +368 -0
  86. data/lib/adlint/metric.rb +805 -0
  87. data/lib/adlint/monitor.rb +144 -0
  88. data/lib/adlint/phase.rb +90 -0
  89. data/lib/adlint/prelude.rb +314 -0
  90. data/lib/adlint/report.rb +617 -0
  91. data/lib/adlint/source.rb +155 -0
  92. data/lib/adlint/symbol.rb +127 -0
  93. data/lib/adlint/token.rb +215 -0
  94. data/lib/adlint/traits.rb +643 -0
  95. data/lib/adlint/util.rb +524 -0
  96. data/lib/adlint/version.rb +71 -0
  97. data/lib/adlint.rb +66 -0
  98. data/share/HEADER +45 -0
  99. data/share/demo/Makefile +110 -0
  100. data/share/demo/ambig_operator/ambig_operator.c +289 -0
  101. data/share/demo/arg_points_unset/arg_points_unset.c +37 -0
  102. data/share/demo/array_range/array_range.c +62 -0
  103. data/share/demo/bad_bitfields/bad_bitfields.c +74 -0
  104. data/share/demo/bad_brace/bad_brace.c +19 -0
  105. data/share/demo/bad_charset/abcde$.h +0 -0
  106. data/share/demo/bad_charset/bad_charset.c +22 -0
  107. data/share/demo/bad_comment/bad_comment.c +3 -0
  108. data/share/demo/bad_const/bad_const.c +19 -0
  109. data/share/demo/bad_conv/bad_conv.c +48 -0
  110. data/share/demo/bad_indent/bad_indent.c +50 -0
  111. data/share/demo/bad_init/bad_init.c +49 -0
  112. data/share/demo/bad_macro/bad_macro.c +97 -0
  113. data/share/demo/bitwise_expr/bitwise_expr.c +19 -0
  114. data/share/demo/call_by_value/call_by_value.c +26 -0
  115. data/share/demo/cross_ref/cross_ref.c +21 -0
  116. data/share/demo/dangling_else/dangling_else.c +20 -0
  117. data/share/demo/dead_code/dead_code.c +237 -0
  118. data/share/demo/deep_nest/deep_nest.c +57 -0
  119. data/share/demo/dense_switch/dense_switch.c +62 -0
  120. data/share/demo/direct_recur/direct_recur.c +15 -0
  121. data/share/demo/div_by_zero/div_by_zero.c +35 -0
  122. data/share/demo/dos_source/dos_source.c +7 -0
  123. data/share/demo/funptr_cast/funptr_cast.c +26 -0
  124. data/share/demo/goto_stmt/goto_stmt.c +19 -0
  125. data/share/demo/id_hiding/id_hiding.c +19 -0
  126. data/share/demo/ill_defined/ill_defined.c +13 -0
  127. data/share/demo/implicit_conv/implicit_conv.c +60 -0
  128. data/share/demo/implicit_int/implicit_int.c +14 -0
  129. data/share/demo/incomplete_type/incomplete_type.c +49 -0
  130. data/share/demo/indirect_recur/indirect_recur_1.c +14 -0
  131. data/share/demo/indirect_recur/indirect_recur_1.h +7 -0
  132. data/share/demo/indirect_recur/indirect_recur_2.c +12 -0
  133. data/share/demo/indirect_recur/indirect_recur_2.h +6 -0
  134. data/share/demo/indirect_recur/indirect_recur_3.c +6 -0
  135. data/share/demo/indirect_recur/indirect_recur_3.h +6 -0
  136. data/share/demo/indirect_recur/indirect_recur_4.c +25 -0
  137. data/share/demo/intro_demo/intro_demo.c +76 -0
  138. data/share/demo/intro_demo/intro_demo.h +12 -0
  139. data/share/demo/intro_demo/useless_header.h +5 -0
  140. data/share/demo/invalid_call/invalid_call.c +32 -0
  141. data/share/demo/kandr_fundef/kandr_fundef.c +10 -0
  142. data/share/demo/line_comment/line_comment.c +12 -0
  143. data/share/demo/local_decl/local_decl.c +9 -0
  144. data/share/demo/logical_trick/logical_trick.c +36 -0
  145. data/share/demo/long_sym/long_sym.c +5 -0
  146. data/share/demo/loop_var/loop_var.c +92 -0
  147. data/share/demo/malloc_or_die/malloc_or_die.c +43 -0
  148. data/share/demo/may_be_null/may_be_null.c +52 -0
  149. data/share/demo/may_be_null_arith/may_be_null_arith.c +15 -0
  150. data/share/demo/may_be_unset/may_be_unset.c +34 -0
  151. data/share/demo/mmapped_io/mmapped_io.c +23 -0
  152. data/share/demo/multi_break/multi_break.c +33 -0
  153. data/share/demo/multi_decl/multi_decl_1.c +17 -0
  154. data/share/demo/multi_decl/multi_decl_1.h +6 -0
  155. data/share/demo/multi_decl/multi_decl_2.c +13 -0
  156. data/share/demo/multi_decl/multi_decl_2.h +6 -0
  157. data/share/demo/multi_decl/multi_decl_3.c +22 -0
  158. data/share/demo/multi_def/multi_def_1.c +36 -0
  159. data/share/demo/multi_def/multi_def_1.h +6 -0
  160. data/share/demo/multi_def/multi_def_2.c +22 -0
  161. data/share/demo/multi_def/multi_def_2.h +6 -0
  162. data/share/demo/multi_def/multi_def_3.c +6 -0
  163. data/share/demo/multi_typedef/multi_typedef.c +11 -0
  164. data/share/demo/multi_typedef/multi_typedef_1.h +1 -0
  165. data/share/demo/multi_typedef/multi_typedef_2.h +1 -0
  166. data/share/demo/must_be_false/must_be_false.c +53 -0
  167. data/share/demo/must_be_null/must_be_null.c +13 -0
  168. data/share/demo/must_be_null_arith/must_be_null_arith.c +14 -0
  169. data/share/demo/must_be_true/must_be_true.c +21 -0
  170. data/share/demo/no_eof_nl/no_eof_nl.c +4 -0
  171. data/share/demo/no_void_arg/no_void_arg.c +14 -0
  172. data/share/demo/null_stmt/null_stmt.c +19 -0
  173. data/share/demo/octal_const/octal_const.c +20 -0
  174. data/share/demo/output_by_param/output_by_param.c +17 -0
  175. data/share/demo/overflow/overflow.c +74 -0
  176. data/share/demo/press_release/press_release.c +40 -0
  177. data/share/demo/retn_lvar_addr/retn_lvar_addr.c +47 -0
  178. data/share/demo/shift_expr/shift_expr.c +14 -0
  179. data/share/demo/should_be_typedef/should_be_typedef.c +51 -0
  180. data/share/demo/static_paths/static_paths.c +153 -0
  181. data/share/demo/static_vars/static_vars.c +39 -0
  182. data/share/demo/tag_hiding/tag_hiding.c +18 -0
  183. data/share/demo/tricky_incdec/tricky_incdec.c +12 -0
  184. data/share/demo/undefined_macro/undefined_macro.c +17 -0
  185. data/share/demo/uninit_vars/uninit_vars.c +28 -0
  186. data/share/demo/union_type/union_type.c +23 -0
  187. data/share/demo/unmatch_decl/unmatch_decl_1.c +12 -0
  188. data/share/demo/unmatch_decl/unmatch_decl_1.h +8 -0
  189. data/share/demo/unmatch_decl/unmatch_decl_2.c +10 -0
  190. data/share/demo/unmatch_decl/unmatch_decl_2.h +8 -0
  191. data/share/demo/unmatch_decl/unmatch_decl_3.c +7 -0
  192. data/share/demo/unmatch_paren_macro/unmatch_paren_macro.c +15 -0
  193. data/share/demo/unreachable/unreachable.c +34 -0
  194. data/share/demo/useless_exp_funs/useless_exp_funs_1.c +14 -0
  195. data/share/demo/useless_exp_funs/useless_exp_funs_1.h +1 -0
  196. data/share/demo/useless_exp_funs/useless_exp_funs_2.c +6 -0
  197. data/share/demo/useless_exp_vars/useless_export_1.c +8 -0
  198. data/share/demo/useless_exp_vars/useless_export_1.h +1 -0
  199. data/share/demo/useless_exp_vars/useless_export_2.c +7 -0
  200. data/share/demo/useless_expr/useless_expr.c +17 -0
  201. data/share/demo/useless_funs/useless_funs_1.c +21 -0
  202. data/share/demo/useless_funs/useless_funs_1.h +8 -0
  203. data/share/demo/useless_funs/useless_funs_2.c +6 -0
  204. data/share/demo/useless_header/useless_header.c +9 -0
  205. data/share/demo/useless_header/useless_header_1.h +12 -0
  206. data/share/demo/useless_header/useless_header_2.h +6 -0
  207. data/share/demo/useless_header/useless_header_3.h +9 -0
  208. data/share/demo/useless_header/useless_header_4.h +3 -0
  209. data/share/demo/useless_vars/useless_vars.c +17 -0
  210. data/share/demo/va_funcall/va_funcall.c +25 -0
  211. data/share/demo/various_fundef/various_fundef.c +36 -0
  212. data/share/demo/wchar_wstring/wchar_wstring.c +7 -0
  213. data/share/demo/wrap_around/wrap_around.c +38 -0
  214. data/share/doc/Makefile +16 -0
  215. data/share/doc/adlint_on_adqua.png +0 -0
  216. data/share/doc/adlint_on_eclipse_en.png +0 -0
  217. data/share/doc/adlint_on_eclipse_ja.png +0 -0
  218. data/share/doc/adlint_on_vim_en.png +0 -0
  219. data/share/doc/adlint_on_vim_ja.png +0 -0
  220. data/share/doc/developers_guide_ja.html +171 -0
  221. data/share/doc/developers_guide_ja.texi +87 -0
  222. data/share/doc/gen_mesg_sections.rb +39 -0
  223. data/share/doc/samples/GNUmakefile +162 -0
  224. data/share/doc/samples/adlint_traits.yml +238 -0
  225. data/share/doc/texinfo.css +22 -0
  226. data/share/doc/users_guide_en.html +39975 -0
  227. data/share/doc/users_guide_en.texi +32640 -0
  228. data/share/doc/users_guide_ja.html +40505 -0
  229. data/share/doc/users_guide_ja.texi +33189 -0
  230. data/share/logo/adlint-110.png +0 -0
  231. data/share/logo/adlint-524.png +0 -0
  232. data/share/logo/adlint.svg +4637 -0
  233. data/share/sample/README +6 -0
  234. data/share/sample/bison-2.5/adlint/GNUmakefile +170 -0
  235. data/share/sample/bison-2.5/adlint/adlint_traits.yml +225 -0
  236. data/share/sample/bison-2.5/adlint/lib/GNUmakefile +198 -0
  237. data/share/sample/bison-2.5/adlint/lib/adlint_cinit.h +228 -0
  238. data/share/sample/bison-2.5/adlint/lib/adlint_pinit.h +21 -0
  239. data/share/sample/bison-2.5/adlint/lib/adlint_traits.yml +238 -0
  240. data/share/sample/bison-2.5/adlint/src/GNUmakefile +166 -0
  241. data/share/sample/bison-2.5/adlint/src/adlint_cinit.h +228 -0
  242. data/share/sample/bison-2.5/adlint/src/adlint_pinit.h +21 -0
  243. data/share/sample/bison-2.5/adlint/src/adlint_traits.yml +239 -0
  244. data/share/sample/ctags-5.8/adlint/GNUmakefile +169 -0
  245. data/share/sample/ctags-5.8/adlint/adlint_cinit.h +219 -0
  246. data/share/sample/ctags-5.8/adlint/adlint_pinit.h +13 -0
  247. data/share/sample/ctags-5.8/adlint/adlint_traits.yml +225 -0
  248. data/share/sample/flex-2.5.35/adlint/GNUmakefile +140 -0
  249. data/share/sample/flex-2.5.35/adlint/adlint_cinit.h +219 -0
  250. data/share/sample/flex-2.5.35/adlint/adlint_pinit.h +14 -0
  251. data/share/sample/flex-2.5.35/adlint/adlint_traits.yml +225 -0
  252. data/share/sample/ruby-1.9.3-p0/adlint/GNUmakefile +314 -0
  253. data/share/sample/ruby-1.9.3-p0/adlint/adlint_traits.yml +225 -0
  254. data/share/sample/ruby-1.9.3-p0/adlint/core/GNUmakefile +204 -0
  255. data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_cinit.h +228 -0
  256. data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_pinit.h +28 -0
  257. data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_traits.yml +240 -0
  258. data/share/sample/ruby-1.9.3-p0/adlint/enc/GNUmakefile +163 -0
  259. data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_cinit.h +228 -0
  260. data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_pinit.h +24 -0
  261. data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_traits.yml +240 -0
  262. data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/GNUmakefile +149 -0
  263. data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_cinit.h +228 -0
  264. data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_pinit.h +24 -0
  265. data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_traits.yml +240 -0
  266. data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/GNUmakefile +131 -0
  267. data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_cinit.h +228 -0
  268. data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_pinit.h +24 -0
  269. data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_traits.yml +241 -0
  270. data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/GNUmakefile +131 -0
  271. data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_cinit.h +228 -0
  272. data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_pinit.h +24 -0
  273. data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_traits.yml +241 -0
  274. data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/GNUmakefile +131 -0
  275. data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_cinit.h +228 -0
  276. data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_pinit.h +24 -0
  277. data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_traits.yml +241 -0
  278. data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/GNUmakefile +131 -0
  279. data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_cinit.h +228 -0
  280. data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_pinit.h +24 -0
  281. data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_traits.yml +241 -0
  282. data/share/sample/ruby-1.9.3-p0/adlint/ext-date/GNUmakefile +134 -0
  283. data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_cinit.h +228 -0
  284. data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_pinit.h +24 -0
  285. data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_traits.yml +241 -0
  286. data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/GNUmakefile +131 -0
  287. data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_cinit.h +228 -0
  288. data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_pinit.h +24 -0
  289. data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_traits.yml +241 -0
  290. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/GNUmakefile +131 -0
  291. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_cinit.h +228 -0
  292. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_pinit.h +24 -0
  293. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_traits.yml +241 -0
  294. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/GNUmakefile +131 -0
  295. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_cinit.h +228 -0
  296. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_pinit.h +24 -0
  297. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_traits.yml +242 -0
  298. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/GNUmakefile +132 -0
  299. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_cinit.h +228 -0
  300. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_pinit.h +24 -0
  301. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_traits.yml +242 -0
  302. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/GNUmakefile +132 -0
  303. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_cinit.h +228 -0
  304. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_pinit.h +24 -0
  305. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_traits.yml +242 -0
  306. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/GNUmakefile +132 -0
  307. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_cinit.h +228 -0
  308. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_pinit.h +24 -0
  309. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_traits.yml +242 -0
  310. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/GNUmakefile +132 -0
  311. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_cinit.h +228 -0
  312. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_pinit.h +24 -0
  313. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_traits.yml +242 -0
  314. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/GNUmakefile +134 -0
  315. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_cinit.h +228 -0
  316. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_pinit.h +24 -0
  317. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_traits.yml +241 -0
  318. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/GNUmakefile +140 -0
  319. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_cinit.h +228 -0
  320. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_pinit.h +24 -0
  321. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_traits.yml +242 -0
  322. data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/GNUmakefile +131 -0
  323. data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_cinit.h +228 -0
  324. data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_pinit.h +24 -0
  325. data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_traits.yml +241 -0
  326. data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/GNUmakefile +131 -0
  327. data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_cinit.h +228 -0
  328. data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_pinit.h +24 -0
  329. data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_traits.yml +241 -0
  330. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/GNUmakefile +131 -0
  331. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_cinit.h +228 -0
  332. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_pinit.h +24 -0
  333. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_traits.yml +241 -0
  334. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/GNUmakefile +134 -0
  335. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_cinit.h +228 -0
  336. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_pinit.h +24 -0
  337. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_traits.yml +242 -0
  338. data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/GNUmakefile +131 -0
  339. data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_cinit.h +228 -0
  340. data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_pinit.h +24 -0
  341. data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_traits.yml +241 -0
  342. data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/GNUmakefile +131 -0
  343. data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_cinit.h +228 -0
  344. data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_pinit.h +24 -0
  345. data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_traits.yml +241 -0
  346. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/GNUmakefile +131 -0
  347. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_cinit.h +228 -0
  348. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_pinit.h +24 -0
  349. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_traits.yml +241 -0
  350. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/GNUmakefile +131 -0
  351. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_cinit.h +228 -0
  352. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_pinit.h +24 -0
  353. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_traits.yml +241 -0
  354. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/GNUmakefile +131 -0
  355. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_cinit.h +228 -0
  356. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_pinit.h +24 -0
  357. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_traits.yml +241 -0
  358. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/GNUmakefile +131 -0
  359. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_cinit.h +228 -0
  360. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_pinit.h +24 -0
  361. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_traits.yml +241 -0
  362. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/GNUmakefile +131 -0
  363. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_cinit.h +228 -0
  364. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_pinit.h +24 -0
  365. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_traits.yml +241 -0
  366. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/GNUmakefile +131 -0
  367. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_cinit.h +228 -0
  368. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_pinit.h +24 -0
  369. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_traits.yml +241 -0
  370. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/GNUmakefile +131 -0
  371. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_cinit.h +228 -0
  372. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_pinit.h +24 -0
  373. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_traits.yml +241 -0
  374. data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/GNUmakefile +131 -0
  375. data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_cinit.h +228 -0
  376. data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_pinit.h +24 -0
  377. data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_traits.yml +241 -0
  378. data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/GNUmakefile +162 -0
  379. data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_cinit.h +228 -0
  380. data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_pinit.h +24 -0
  381. data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_traits.yml +241 -0
  382. data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/GNUmakefile +131 -0
  383. data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_cinit.h +228 -0
  384. data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_pinit.h +24 -0
  385. data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_traits.yml +241 -0
  386. data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/GNUmakefile +135 -0
  387. data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_cinit.h +228 -0
  388. data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_pinit.h +24 -0
  389. data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_traits.yml +241 -0
  390. data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/GNUmakefile +131 -0
  391. data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_cinit.h +228 -0
  392. data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_pinit.h +24 -0
  393. data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_traits.yml +241 -0
  394. data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/GNUmakefile +131 -0
  395. data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_cinit.h +228 -0
  396. data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_pinit.h +24 -0
  397. data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_traits.yml +241 -0
  398. data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/GNUmakefile +131 -0
  399. data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_cinit.h +228 -0
  400. data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_pinit.h +24 -0
  401. data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_traits.yml +241 -0
  402. data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/GNUmakefile +131 -0
  403. data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_cinit.h +228 -0
  404. data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_pinit.h +24 -0
  405. data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_traits.yml +241 -0
  406. data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/GNUmakefile +132 -0
  407. data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_cinit.h +228 -0
  408. data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_pinit.h +24 -0
  409. data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_traits.yml +241 -0
  410. data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/GNUmakefile +144 -0
  411. data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_cinit.h +228 -0
  412. data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_pinit.h +24 -0
  413. data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_traits.yml +241 -0
  414. data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/GNUmakefile +131 -0
  415. data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_cinit.h +228 -0
  416. data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_pinit.h +24 -0
  417. data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_traits.yml +241 -0
  418. data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/GNUmakefile +131 -0
  419. data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_cinit.h +228 -0
  420. data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_pinit.h +24 -0
  421. data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_traits.yml +241 -0
  422. data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/GNUmakefile +140 -0
  423. data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_cinit.h +228 -0
  424. data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_pinit.h +24 -0
  425. data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_traits.yml +241 -0
  426. data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/GNUmakefile +131 -0
  427. data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_cinit.h +228 -0
  428. data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_pinit.h +24 -0
  429. data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_traits.yml +241 -0
  430. data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/GNUmakefile +131 -0
  431. data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_cinit.h +228 -0
  432. data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_pinit.h +24 -0
  433. data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_traits.yml +241 -0
  434. data/share/sample/screen-4.0.3/adlint/GNUmakefile +162 -0
  435. data/share/sample/screen-4.0.3/adlint/adlint_cinit.h +228 -0
  436. data/share/sample/screen-4.0.3/adlint/adlint_pinit.h +21 -0
  437. data/share/sample/screen-4.0.3/adlint/adlint_traits.yml +238 -0
  438. data/share/sample/vim-7.3/adlint/vim/GNUmakefile +185 -0
  439. data/share/sample/vim-7.3/adlint/vim/adlint_cinit.h +228 -0
  440. data/share/sample/vim-7.3/adlint/vim/adlint_pinit.h +25 -0
  441. data/share/sample/vim-7.3/adlint/vim/adlint_traits.yml +250 -0
  442. data/share/sample/vim-7.3/adlint/xxd/GNUmakefile +131 -0
  443. data/share/sample/vim-7.3/adlint/xxd/adlint_cinit.h +228 -0
  444. data/share/sample/vim-7.3/adlint/xxd/adlint_pinit.h +24 -0
  445. data/share/sample/vim-7.3/adlint/xxd/adlint_traits.yml +237 -0
  446. data/share/sample/zsh-4.3.15/adlint/GNUmakefile +146 -0
  447. data/share/sample/zsh-4.3.15/adlint/adlint_traits.yml +225 -0
  448. data/share/sample/zsh-4.3.15/adlint/builtins/GNUmakefile +132 -0
  449. data/share/sample/zsh-4.3.15/adlint/builtins/adlint_cinit.h +228 -0
  450. data/share/sample/zsh-4.3.15/adlint/builtins/adlint_pinit.h +24 -0
  451. data/share/sample/zsh-4.3.15/adlint/builtins/adlint_traits.yml +240 -0
  452. data/share/sample/zsh-4.3.15/adlint/core/GNUmakefile +153 -0
  453. data/share/sample/zsh-4.3.15/adlint/core/adlint_cinit.h +228 -0
  454. data/share/sample/zsh-4.3.15/adlint/core/adlint_pinit.h +23 -0
  455. data/share/sample/zsh-4.3.15/adlint/core/adlint_traits.yml +239 -0
  456. data/share/sample/zsh-4.3.15/adlint/modules/GNUmakefile +147 -0
  457. data/share/sample/zsh-4.3.15/adlint/modules/adlint_cinit.h +228 -0
  458. data/share/sample/zsh-4.3.15/adlint/modules/adlint_pinit.h +24 -0
  459. data/share/sample/zsh-4.3.15/adlint/modules/adlint_traits.yml +240 -0
  460. data/share/sample/zsh-4.3.15/adlint/zle/GNUmakefile +144 -0
  461. data/share/sample/zsh-4.3.15/adlint/zle/adlint_cinit.h +228 -0
  462. data/share/sample/zsh-4.3.15/adlint/zle/adlint_pinit.h +24 -0
  463. data/share/sample/zsh-4.3.15/adlint/zle/adlint_traits.yml +239 -0
  464. data/spec/MUST_WRITE_SPECS_WITH_RSPEC +0 -0
  465. metadata +532 -0
@@ -0,0 +1,1412 @@
1
+ # AST of C preprocessor language.
2
+ #
3
+ # Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
4
+ # Copyright:: Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
5
+ # License:: GPLv3+: GNU General Public License version 3 or later
6
+ #
7
+ # Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
8
+
9
+ #--
10
+ # ___ ____ __ ___ _________
11
+ # / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
12
+ # / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
13
+ # / __ |/ /_/ / /___/ / /| / / /
14
+ # /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
15
+ #
16
+ # This file is part of AdLint.
17
+ #
18
+ # AdLint is free software: you can redistribute it and/or modify it under the
19
+ # terms of the GNU General Public License as published by the Free Software
20
+ # Foundation, either version 3 of the License, or (at your option) any later
21
+ # version.
22
+ #
23
+ # AdLint is distributed in the hope that it will be useful, but WITHOUT ANY
24
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
25
+ # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
26
+ #
27
+ # You should have received a copy of the GNU General Public License along with
28
+ # AdLint. If not, see <http://www.gnu.org/licenses/>.
29
+ #
30
+ #++
31
+
32
+ require "adlint/symbol"
33
+ require "adlint/util"
34
+
35
+ module AdLint #:nodoc:
36
+ module Cpp #:nodoc:
37
+
38
+ class SyntaxNode
39
+ include Visitable
40
+
41
+ def location
42
+ subclass_responsibility
43
+ end
44
+
45
+ def inspect(indent = 0)
46
+ subclass_responsibility
47
+ end
48
+
49
+ def short_class_name
50
+ self.class.name.sub(/\A.*::/, "")
51
+ end
52
+ end
53
+
54
+ class IdentifierList < SyntaxNode
55
+ def initialize(identifiers = [])
56
+ @identifiers = identifiers
57
+ end
58
+
59
+ attr_reader :identifiers
60
+
61
+ def push(identifier)
62
+ @identifiers.push(identifier)
63
+ self
64
+ end
65
+
66
+ def location
67
+ @identifiers.first.location
68
+ end
69
+
70
+ def inspect(indent = 0)
71
+ ([" " * indent + short_class_name] +
72
+ @identifiers.map { |child| child.inspect }).join("\n")
73
+ end
74
+ end
75
+
76
+ class PreprocessingFile < SyntaxNode
77
+ def initialize(fpath, group = nil)
78
+ @fpath = fpath
79
+ @group = group
80
+ end
81
+
82
+ attr_reader :fpath
83
+ attr_reader :group
84
+
85
+ def location
86
+ @group.location
87
+ end
88
+
89
+ def concat(preprocessing_file)
90
+ @group.group_parts.concat(preprocessing_file.group.group_parts)
91
+ end
92
+
93
+ def inspect(indent = 0)
94
+ " " * indent + "#{short_class_name}\n" +
95
+ (@group ? @group.inspect(indent + 1) : "")
96
+ end
97
+ end
98
+
99
+ class Group < SyntaxNode
100
+ def initialize
101
+ super
102
+ @group_parts = []
103
+ end
104
+
105
+ attr_reader :group_parts
106
+
107
+ def push(group_part)
108
+ @group_parts.push(group_part)
109
+ self
110
+ end
111
+
112
+ def location
113
+ @group_parts.first.location
114
+ end
115
+
116
+ def inspect(indent = 0)
117
+ ([" " * indent + short_class_name] +
118
+ @group_parts.map { |child| child.inspect(indent + 1) }).join("\n")
119
+ end
120
+ end
121
+
122
+ class GroupPart < SyntaxNode; end
123
+
124
+ class IfSection < GroupPart
125
+ def initialize(if_group, elif_groups, else_group, endif_line)
126
+ @if_group = if_group
127
+ @elif_groups = elif_groups
128
+ @else_group = else_group
129
+ @endif_line = endif_line
130
+ end
131
+
132
+ attr_reader :if_group
133
+ attr_reader :elif_groups
134
+ attr_reader :else_group
135
+ attr_reader :endif_line
136
+
137
+ def location
138
+ @if_group.location
139
+ end
140
+
141
+ def inspect(indent = 0)
142
+ [" " * indent + short_class_name,
143
+ @if_group ? @if_group.inspect(indent + 1) : nil,
144
+ @elif_groups ? @elif_groups.inspect(indent + 1) : nil,
145
+ @else_group ? @else_group.inspect(indent + 1) : nil,
146
+ @endif_line ? @endif_line.inspect(indent + 1) : nil
147
+ ].compact.join("\n")
148
+ end
149
+ end
150
+
151
+ class IfGroup < SyntaxNode
152
+ def initialize(keyword)
153
+ @keyword = keyword
154
+ end
155
+
156
+ attr_reader :keyword
157
+
158
+ def location
159
+ @keyword.location
160
+ end
161
+ end
162
+
163
+ class IfStatement < IfGroup
164
+ def initialize(keyword, expression, group)
165
+ super(keyword)
166
+ @expression = expression
167
+ @group = group
168
+ end
169
+
170
+ attr_accessor :expression
171
+ attr_reader :group
172
+
173
+ def inspect(indent = 0)
174
+ [" " * indent + "#{short_class_name}",
175
+ @expression.inspect(indent + 1),
176
+ @group ? @group.inspect(indent + 1) : nil].compact.join("\n")
177
+ end
178
+ end
179
+
180
+ class IfdefStatement < IfGroup
181
+ def initialize(keyword, identifier, group)
182
+ super(keyword)
183
+ @identifier = identifier
184
+ @group = group
185
+ end
186
+
187
+ attr_reader :identifier
188
+ attr_reader :group
189
+
190
+ def inspect(indent = 0)
191
+ [" " * indent + "#{short_class_name} #{@identifier.inspect}",
192
+ @group ? @group.inspect(indent + 1) : nil].join("\n")
193
+ end
194
+ end
195
+
196
+ class IfndefStatement < IfGroup
197
+ def initialize(keyword, identifier, group)
198
+ super(keyword)
199
+ @identifier = identifier
200
+ @group = group
201
+ end
202
+
203
+ attr_reader :identifier
204
+ attr_reader :group
205
+
206
+ def inspect(indent = 0)
207
+ [" " * indent + "#{short_class_name} #{@identifier.inspect}",
208
+ @group ? @group.inspect(indent + 1) : nil].join("\n")
209
+ end
210
+ end
211
+
212
+ class ElifGroups < SyntaxNode
213
+ def initialize
214
+ super
215
+ @elif_statements = []
216
+ end
217
+
218
+ attr_reader :elif_statements
219
+
220
+ def push(elif_statement)
221
+ @elif_statements.push(elif_statement)
222
+ self
223
+ end
224
+
225
+ def inspect(indent = 0)
226
+ ([" " * indent + short_class_name] +
227
+ @elif_statements.map { |child| child.inspect(indent + 1) }).join("\n")
228
+ end
229
+ end
230
+
231
+ class ElifGroup < SyntaxNode
232
+ def initialize(keyword)
233
+ @keyword = keyword
234
+ end
235
+
236
+ attr_reader :keyword
237
+
238
+ def location
239
+ @keyword.location
240
+ end
241
+ end
242
+
243
+ class ElifStatement < ElifGroup
244
+ def initialize(keyword, expression, group)
245
+ super(keyword)
246
+ @expression = expression
247
+ @group = group
248
+ end
249
+
250
+ attr_accessor :expression
251
+ attr_reader :group
252
+
253
+ def inspect(indent = 0)
254
+ [" " * indent + "#{short_class_name} #{@expression.inspect}",
255
+ @group ? @group.inspect(indent + 1) : nil].compact.join("\n")
256
+ end
257
+ end
258
+
259
+ class ElseGroup < SyntaxNode
260
+ def initialize(keyword)
261
+ @keyword = keyword
262
+ end
263
+
264
+ attr_reader :keyword
265
+
266
+ def location
267
+ @keyword.location
268
+ end
269
+ end
270
+
271
+ class ElseStatement < ElseGroup
272
+ def initialize(keyword, group)
273
+ super(keyword)
274
+ @group = group
275
+ end
276
+
277
+ attr_reader :group
278
+
279
+ def inspect(indent = 0)
280
+ [" " * indent + short_class_name,
281
+ @group ? @group.inspect(indent + 1) : nil].compact.join("\n")
282
+ end
283
+ end
284
+
285
+ class EndifLine < SyntaxNode
286
+ def initialize(keyword)
287
+ @keyword = keyword
288
+ end
289
+
290
+ attr_reader :keyword
291
+
292
+ def location
293
+ @keyword.location
294
+ end
295
+
296
+ def inspect(indent = 0)
297
+ " " * indent + "#{short_class_name} (#{@keyword.inspect})"
298
+ end
299
+ end
300
+
301
+ class ControlLine < GroupPart
302
+ def initialize(keyword)
303
+ @keyword = keyword
304
+ end
305
+
306
+ attr_reader :keyword
307
+
308
+ def location
309
+ @keyword.location
310
+ end
311
+ end
312
+
313
+ class IncludeLine < ControlLine
314
+ def initialize(keyword, header_name, include_depth)
315
+ super(keyword)
316
+ @header_name = header_name
317
+ @include_depth = include_depth
318
+ end
319
+
320
+ attr_reader :include_depth
321
+ attr_reader :header_name
322
+ attr_accessor :fpath
323
+ end
324
+
325
+ class UserIncludeLine < IncludeLine
326
+ def initialize(keyword, user_header_name, include_depth)
327
+ super(keyword, user_header_name, include_depth)
328
+ end
329
+
330
+ def inspect(indent = 0)
331
+ " " * indent + "#{short_class_name} (#{header_name.inspect})"
332
+ end
333
+ end
334
+
335
+ class UserIncludeNextLine < UserIncludeLine; end
336
+
337
+ class SystemIncludeLine < IncludeLine
338
+ def initialize(keyword, system_header_name, include_depth)
339
+ super(keyword, system_header_name, include_depth)
340
+ end
341
+
342
+ def inspect(indent = 0)
343
+ " " * indent + "#{short_class_name} (#{header_name.inspect})"
344
+ end
345
+ end
346
+
347
+ class SystemIncludeNextLine < SystemIncludeLine; end
348
+
349
+ class DefineLine < ControlLine
350
+ include SymbolicElement
351
+
352
+ def initialize(keyword, identifier, replacement_list, symbol)
353
+ super(keyword)
354
+ @identifier = identifier
355
+ @replacement_list = replacement_list
356
+ @symbol = symbol
357
+ end
358
+
359
+ attr_reader :identifier
360
+ attr_reader :replacement_list
361
+ attr_reader :symbol
362
+ end
363
+
364
+ class ObjectLikeDefineLine < DefineLine
365
+ def inspect(indent = 0)
366
+ " " * indent + "#{short_class_name} (#{identifier.inspect})"
367
+ end
368
+ end
369
+
370
+ class PseudoObjectLikeDefineLine < DefineLine
371
+ def initialize(name_str)
372
+ super(nil, Token.new(:PP_TOKEN, name_str, Location.new), nil, nil)
373
+ end
374
+
375
+ def mark_as_referred_by(token) end
376
+ end
377
+
378
+ class FunctionLikeDefineLine < DefineLine
379
+ def initialize(keyword, identifier, identifier_list, replacement_list,
380
+ symbol)
381
+ super(keyword, identifier, replacement_list, symbol)
382
+ @identifier_list = identifier_list
383
+ end
384
+
385
+ attr_reader :identifier_list
386
+
387
+ def have_va_list?
388
+ false
389
+ end
390
+
391
+ def inspect(indent = 0)
392
+ " " * indent + "#{short_class_name} (#{identifier.inspect})"
393
+ end
394
+ end
395
+
396
+ class PseudoFunctionLikeDefineLine < FunctionLikeDefineLine
397
+ def initialize(name_str, param_names)
398
+ identifier_list = IdentifierList.new(
399
+ param_names.map { |str| Token.new(:PP_TOKEN, str, Location.new) })
400
+
401
+ super(nil, Token.new(:PP_TOKEN, name_str, Location.new), identifier_list,
402
+ nil, nil)
403
+ end
404
+
405
+ def mark_as_referred_by(token) end
406
+ end
407
+
408
+ class VaFunctionLikeDefineLine < FunctionLikeDefineLine
409
+ def have_va_list?
410
+ true
411
+ end
412
+ end
413
+
414
+ class UndefLine < ControlLine
415
+ def initialize(keyword, identifier)
416
+ super(keyword)
417
+ @identifier = identifier
418
+ end
419
+
420
+ attr_reader :identifier
421
+
422
+ def inspect(indent = 0)
423
+ " " * indent + "#{short_class_name} (#{@identifier.inspect})"
424
+ end
425
+ end
426
+
427
+ class LineLine < ControlLine
428
+ def initialize(keyword, pp_tokens)
429
+ super(keyword)
430
+ @pp_tokens = pp_tokens
431
+ end
432
+
433
+ attr_reader :pp_tokens
434
+
435
+ def inspect(indent = 0)
436
+ " " * indent + "#{short_class_name} (#{@pp_tokens.inspect})"
437
+ end
438
+ end
439
+
440
+ class ErrorLine < ControlLine
441
+ def initialize(keyword, pp_tokens)
442
+ super(keyword)
443
+ @pp_tokens = pp_tokens
444
+ end
445
+
446
+ attr_reader :pp_tokens
447
+
448
+ def inspect(indent = 0)
449
+ " " * indent +
450
+ "#{short_class_name} (#{@pp_tokens ? @pp_tokens.inspect : ""})"
451
+ end
452
+ end
453
+
454
+ class PragmaLine < ControlLine
455
+ def initialize(keyword, pp_tokens)
456
+ super(keyword)
457
+ @pp_tokens = pp_tokens
458
+ end
459
+
460
+ attr_reader :pp_tokens
461
+
462
+ def inspect(indent = 0)
463
+ " " * indent +
464
+ "#{short_class_name} (#{@pp_tokens ? @pp_tokens.inspect : ""})"
465
+ end
466
+ end
467
+
468
+ class TextLine < GroupPart
469
+ def initialize(token)
470
+ @token = token
471
+ end
472
+
473
+ attr_reader :token
474
+
475
+ def location
476
+ @token.location
477
+ end
478
+
479
+ def inspect(indent = 0)
480
+ " " * indent + "#{short_class_name} (#{@token.inspect})"
481
+ end
482
+ end
483
+
484
+ class NullDirective < GroupPart
485
+ def initialize(token)
486
+ @token = token
487
+ end
488
+
489
+ attr_reader :token
490
+
491
+ def location
492
+ @token.location
493
+ end
494
+
495
+ def inspect(indent = 0)
496
+ " " * indent + "#{short_class_name} (#{@token.inspect})"
497
+ end
498
+ end
499
+
500
+ class AsmSection < GroupPart
501
+ def initialize(asm_line, endasm_line)
502
+ @asm_line = asm_line
503
+ @endasm_line = endasm_line
504
+ end
505
+
506
+ attr_reader :asm_line
507
+ attr_reader :endasm_line
508
+
509
+ def location
510
+ @asm_line.location
511
+ end
512
+
513
+ def inspect(indent = 0)
514
+ [" " * indent + short_class_name,
515
+ @asm_line.inspect(indent + 1),
516
+ @endasm_line.inspect(indent + 1)].join("\n")
517
+ end
518
+ end
519
+
520
+ class AsmLine < SyntaxNode
521
+ def initialize(keyword)
522
+ @keyword = keyword
523
+ end
524
+
525
+ attr_reader :keyword
526
+
527
+ def location
528
+ @keyword.location
529
+ end
530
+
531
+ def inspect(indent = 0)
532
+ " " * indent + "#{short_class_name} (#{@keyword.inspect})"
533
+ end
534
+ end
535
+
536
+ class EndasmLine < SyntaxNode
537
+ def initialize(keyword)
538
+ @keyword = keyword
539
+ end
540
+
541
+ attr_reader :keyword
542
+
543
+ def location
544
+ @keyword.location
545
+ end
546
+
547
+ def inspect(indent = 0)
548
+ " " * indent + "#{short_class_name} (#{@keyword.inspect})"
549
+ end
550
+ end
551
+
552
+ class PPTokens < SyntaxNode
553
+ def initialize
554
+ super
555
+ @tokens = []
556
+ end
557
+
558
+ attr_reader :tokens
559
+
560
+ def push(token)
561
+ @tokens.push(token)
562
+ self
563
+ end
564
+
565
+ def location
566
+ @tokens.first.location
567
+ end
568
+
569
+ def may_represent_expression?
570
+ return false if @tokens.size < 2
571
+
572
+ @tokens.all? do |pp_token|
573
+ case pp_token.value
574
+ when "{", "}"
575
+ false
576
+ when ";"
577
+ false
578
+ when "while", "do", "for", "if", "else", "switch", "case", "default",
579
+ "goto", "return", "break", "continue"
580
+ false
581
+ when "typedef", "extern", "static", "auto", "regisiter"
582
+ false
583
+ else
584
+ true
585
+ end
586
+ end
587
+ end
588
+
589
+ def may_represent_initializer?
590
+ return false if @tokens.size < 2
591
+
592
+ if @tokens.first.value == "{" && @tokens.last.value == "}"
593
+ @tokens.all? do |pp_token|
594
+ case pp_token.value
595
+ when "while", "do", "for", "if", "else", "switch", "case", "default",
596
+ "goto", "return", "break", "continue"
597
+ false
598
+ when ";"
599
+ false
600
+ else
601
+ true
602
+ end
603
+ end
604
+ else
605
+ false
606
+ end
607
+ end
608
+
609
+ def may_represent_block?
610
+ return false if @tokens.size < 2
611
+
612
+ if @tokens.first.value == "{" && @tokens.last.value == "}"
613
+ @tokens.any? { |pp_token| pp_token.value == ";" }
614
+ else
615
+ false
616
+ end
617
+ end
618
+
619
+ def may_represent_do_while_zero_idiom?
620
+ return false if @tokens.size < 4
621
+
622
+ @tokens[0].value == "do" && @tokens[-4].value == "while" &&
623
+ @tokens[-3].value == "(" && @tokens[-2].value == "0" &&
624
+ @tokens[-1].value == ")"
625
+ end
626
+
627
+ def may_represent_specifier_qualifier_list?
628
+ @tokens.select { |pp_token|
629
+ case pp_token.value
630
+ when "const", "volatile", "restrict"
631
+ true
632
+ when "*"
633
+ true
634
+ when "void", "signed", "unsigned", "char", "short", "int", "long",
635
+ "float", "double"
636
+ true
637
+ else
638
+ false
639
+ end
640
+ }.size > 1
641
+ end
642
+
643
+ def may_represent_declaration_specifiers_head?
644
+ @tokens.all? do |pp_token|
645
+ case pp_token.value
646
+ when "typedef", "extern", "static", "auto", "register"
647
+ true
648
+ when "const", "volatile", "restrict"
649
+ true
650
+ else
651
+ false
652
+ end
653
+ end
654
+ end
655
+
656
+ PUNCTUATORS = [
657
+ "[", "]", "(", ")", "{", "}", ".", "->", "++", "--", "&", "*", "+", "-",
658
+ "~", "!", "/", "%", "<<", ">>", "<", ">", "<=", ">=", "==", "!=", "^",
659
+ "|", "&&", "||", "?", ":", ";", "...", "=", "*=", "/=", "%=", "+=", "-=",
660
+ "<<=", ">>=", "&=", "^=", "|=", ",", "#", "##", "<:", ":>", "<%", "%>",
661
+ "%:", "%:%:"
662
+ ].to_set.freeze
663
+ private_constant :PUNCTUATORS
664
+
665
+ def may_represent_punctuator?
666
+ @tokens.size == 1 && PUNCTUATORS.include?(@tokens.first.value)
667
+ end
668
+
669
+ def may_represent_controlling_keyword?
670
+ return false if @tokens.size > 1
671
+
672
+ case @tokens.first.value
673
+ when "while", "do", "for", "if", "else", "switch", "case", "default",
674
+ "goto", "return", "break", "continue"
675
+ true
676
+ else
677
+ false
678
+ end
679
+ end
680
+
681
+ def inspect(indent = 0)
682
+ " " * indent + @tokens.map { |t| t.value }.join(" ")
683
+ end
684
+ end
685
+
686
+ class Expression < SyntaxNode
687
+ def initialize(value)
688
+ @value = value
689
+ end
690
+
691
+ attr_reader :value
692
+
693
+ def to_s
694
+ subclass_responsibility
695
+ end
696
+ end
697
+
698
+ class ErrorExpression < Expression
699
+ def initialize(error_token)
700
+ super(0)
701
+ @error_token = error_token
702
+ end
703
+
704
+ attr_reader :error_token
705
+
706
+ def location
707
+ @error_token.location
708
+ end
709
+
710
+ def to_s
711
+ ""
712
+ end
713
+
714
+ def inspect(indent = 0)
715
+ " " * indent + "#{short_class_name} (#{@error_token.inspect})"
716
+ end
717
+ end
718
+
719
+ class PrimaryExpression < Expression; end
720
+
721
+ class ConstantSpecifier < PrimaryExpression
722
+ def initialize(value, constant)
723
+ super(value)
724
+ @constant = constant
725
+ end
726
+
727
+ attr_reader :constant
728
+
729
+ def location
730
+ @constant.location
731
+ end
732
+
733
+ def to_s
734
+ @constant.value
735
+ end
736
+
737
+ def inspect(indent = 0)
738
+ " " * indent + "#{short_class_name} (#{constant.inspect})"
739
+ end
740
+ end
741
+
742
+ class GroupedExpression < PrimaryExpression
743
+ def initialize(value, expression)
744
+ super(value)
745
+ @expression = expression
746
+ end
747
+
748
+ attr_reader :expression
749
+
750
+ def location
751
+ @expression.location
752
+ end
753
+
754
+ def to_s
755
+ "(#{@expression.to_s})"
756
+ end
757
+
758
+ def inspect(indent = 0)
759
+ " " * indent + "#{short_class_name}\n" +
760
+ @expression.inspect(indent + 1)
761
+ end
762
+ end
763
+
764
+ class UnaryExpression < Expression
765
+ def initialize(value, operator)
766
+ super(value)
767
+ @operator = operator
768
+ end
769
+
770
+ attr_reader :operator
771
+
772
+ def location
773
+ @operator.location
774
+ end
775
+ end
776
+
777
+ class UnaryArithmeticExpression < UnaryExpression
778
+ def initialize(value, operator, expression)
779
+ super(value, operator)
780
+ @expression = expression
781
+ end
782
+
783
+ attr_reader :expression
784
+
785
+ def to_s
786
+ "#{operator.value} #{@expression.to_s}"
787
+ end
788
+
789
+ def inspect(indent = 0)
790
+ " " * indent + "#{short_class_name} (#{operator.inspect})\n" +
791
+ @expression.inspect(indent + 1)
792
+ end
793
+ end
794
+
795
+ class DefinedExpression < UnaryExpression
796
+ def initialize(value, operator, identifier)
797
+ super(value, operator)
798
+ @identifier = identifier
799
+ end
800
+
801
+ attr_reader :identifier
802
+
803
+ def to_s
804
+ "#{operator.value}(#{@identifier.value})"
805
+ end
806
+
807
+ def inspect(indent = 0)
808
+ " " * indent + "#{short_class_name} " +
809
+ "(#{operator.inspect} #{@identifier.inspect}"
810
+ end
811
+ end
812
+
813
+ class BinaryExpression < Expression
814
+ def initialize(value, operator, lhs_expression, rhs_expression)
815
+ super(value)
816
+ @operator = operator
817
+ @lhs_expression = lhs_expression
818
+ @rhs_expression = rhs_expression
819
+ end
820
+
821
+ attr_reader :operator
822
+ attr_reader :lhs_expression
823
+ attr_reader :rhs_expression
824
+
825
+ def location
826
+ @lhs_expression.location
827
+ end
828
+
829
+ def to_s
830
+ "#{@lhs_expression.to_s} #{@operator.value} #{@rhs_expression.to_s}"
831
+ end
832
+
833
+ def inspect(indent = 0)
834
+ " " * indent + "#{short_class_name} (#{@operator.inspect})\n" +
835
+ @lhs_expression.inspect(indent + 1) + "\n" +
836
+ @rhs_expression.inspect(indent + 1)
837
+ end
838
+ end
839
+
840
+ class MultiplicativeExpression < BinaryExpression; end
841
+
842
+ class AdditiveExpression < BinaryExpression; end
843
+
844
+ class ShiftExpression < BinaryExpression; end
845
+
846
+ class RelationalExpression < BinaryExpression; end
847
+
848
+ class EqualityExpression < BinaryExpression; end
849
+
850
+ class AndExpression < BinaryExpression; end
851
+
852
+ class ExclusiveOrExpression < BinaryExpression; end
853
+
854
+ class InclusiveOrExpression < BinaryExpression; end
855
+
856
+ class LogicalAndExpression < BinaryExpression; end
857
+
858
+ class LogicalOrExpression < BinaryExpression; end
859
+
860
+ class ConditionalExpression < Expression
861
+ def initialize(value, condition, first_expression, second_expression)
862
+ super(value)
863
+ @condition = condition
864
+ @first_expression = first_expression
865
+ @second_expression = second_expression
866
+ end
867
+
868
+ attr_reader :condition
869
+ attr_reader :first_expression
870
+ attr_reader :second_expression
871
+
872
+ def location
873
+ @condition.location
874
+ end
875
+
876
+ def to_s
877
+ "#{@condition.to_s}? " +
878
+ "#{@first_expression.to_s} : #{@second_expression.to_s}"
879
+ end
880
+
881
+ def inspect(indent = 0)
882
+ " " * indent + "#{short_class_name} (#{@condition.inspect})\n" +
883
+ @first_expression.inspect(indent + 1) + "\n" +
884
+ @second_expression.inspect(indent + 1)
885
+ end
886
+ end
887
+
888
+ class CommaSeparatedExpression < Expression
889
+ def initialize(value)
890
+ super(value)
891
+ @expressions = []
892
+ end
893
+
894
+ attr_writer :expressions
895
+
896
+ def location
897
+ @expressions.first.location
898
+ end
899
+
900
+ def to_s
901
+ @expressions.map { |expr| expr.to_s }.join(",")
902
+ end
903
+
904
+ def push(expression)
905
+ @expressions.push(expression)
906
+ self
907
+ end
908
+
909
+ def inspect(indent = 0)
910
+ ([" " * indent + short_class_name] +
911
+ @expressions.map { |expr| expr.inspect(indent + 1) }).join("\n")
912
+ end
913
+ end
914
+
915
+ class SyntaxTreeVisitor
916
+ def visit_identifier_list(node)
917
+ end
918
+
919
+ def visit_preprocessing_file(node)
920
+ node.group.accept(self) if node.group
921
+ end
922
+
923
+ def visit_group(node)
924
+ node.group_parts.each { |group_part| group_part.accept(self) }
925
+ end
926
+
927
+ def visit_if_section(node)
928
+ node.if_group.accept(self) if node.if_group
929
+ node.elif_groups.accept(self) if node.elif_groups
930
+ node.else_group.accept(self) if node.else_group
931
+ node.endif_line.accept(self) if node.endif_line
932
+ end
933
+
934
+ def visit_if_statement(node)
935
+ node.expression.accept(self)
936
+ node.group.accept(self) if node.group
937
+ end
938
+
939
+ def visit_ifdef_statement(node)
940
+ node.group.accept(self) if node.group
941
+ end
942
+
943
+ def visit_ifndef_statement(node)
944
+ node.group.accept(self) if node.group
945
+ end
946
+
947
+ def visit_elif_groups(node)
948
+ node.elif_statements.each { |elif_stmt| elif_stmt.accept(self) }
949
+ end
950
+
951
+ def visit_elif_statement(node)
952
+ node.expression.accept(self)
953
+ node.group.accept(self) if node.group
954
+ end
955
+
956
+ def visit_else_statement(node)
957
+ node.group.accept(self) if node.group
958
+ end
959
+
960
+ def visit_endif_line(node)
961
+ end
962
+
963
+ def visit_user_include_line(node)
964
+ end
965
+
966
+ def visit_system_include_line(node)
967
+ end
968
+
969
+ def visit_user_include_next_line(node)
970
+ end
971
+
972
+ def visit_system_include_next_line(node)
973
+ end
974
+
975
+ def visit_object_like_define_line(node)
976
+ end
977
+
978
+ def visit_function_like_define_line(node)
979
+ end
980
+
981
+ def visit_va_function_like_define_line(node)
982
+ end
983
+
984
+ def visit_undef_line(node)
985
+ end
986
+
987
+ def visit_line_line(node)
988
+ end
989
+
990
+ def visit_error_line(node)
991
+ end
992
+
993
+ def visit_pragma_line(node)
994
+ end
995
+
996
+ def visit_text_line(node)
997
+ end
998
+
999
+ def visit_null_directive(node)
1000
+ end
1001
+
1002
+ def visit_asm_section(node)
1003
+ end
1004
+
1005
+ def visit_pp_tokens(node)
1006
+ end
1007
+
1008
+ def visit_error_expression(node)
1009
+ end
1010
+
1011
+ def visit_constant_specifier(node)
1012
+ end
1013
+
1014
+ def visit_grouped_expression(node)
1015
+ node.expression.accept(self)
1016
+ end
1017
+
1018
+ def visit_unary_arithmetic_expression(node)
1019
+ node.expression.accept(self)
1020
+ end
1021
+
1022
+ def visit_defined_expression(node)
1023
+ end
1024
+
1025
+ def visit_multiplicative_expression(node)
1026
+ node.lhs_expression.accept(self)
1027
+ node.rhs_expression.accept(self)
1028
+ end
1029
+
1030
+ def visit_additive_expression(node)
1031
+ node.lhs_expression.accept(self)
1032
+ node.rhs_expression.accept(self)
1033
+ end
1034
+
1035
+ def visit_shift_expression(node)
1036
+ node.lhs_expression.accept(self)
1037
+ node.rhs_expression.accept(self)
1038
+ end
1039
+
1040
+ def visit_relational_expression(node)
1041
+ node.lhs_expression.accept(self)
1042
+ node.rhs_expression.accept(self)
1043
+ end
1044
+
1045
+ def visit_equality_expression(node)
1046
+ node.lhs_expression.accept(self)
1047
+ node.rhs_expression.accept(self)
1048
+ end
1049
+
1050
+ def visit_and_expression(node)
1051
+ node.lhs_expression.accept(self)
1052
+ node.rhs_expression.accept(self)
1053
+ end
1054
+
1055
+ def visit_exclusive_or_expression(node)
1056
+ node.lhs_expression.accept(self)
1057
+ node.rhs_expression.accept(self)
1058
+ end
1059
+
1060
+ def visit_inclusive_or_expression(node)
1061
+ node.lhs_expression.accept(self)
1062
+ node.rhs_expression.accept(self)
1063
+ end
1064
+
1065
+ def visit_logical_and_expression(node)
1066
+ node.lhs_expression.accept(self)
1067
+ node.rhs_expression.accept(self)
1068
+ end
1069
+
1070
+ def visit_logical_or_expression(node)
1071
+ node.lhs_expression.accept(self)
1072
+ node.rhs_expression.accept(self)
1073
+ end
1074
+
1075
+ def visit_conditional_expression(node)
1076
+ node.condition.accept(self)
1077
+ node.first_expression.accept(self)
1078
+ node.second_expression.accept(self)
1079
+ end
1080
+
1081
+ def visit_comma_separated_expression(node)
1082
+ node.expressions.each { |expression| expression.accept(self) }
1083
+ end
1084
+ end
1085
+
1086
+ class SyntaxTreeMulticastVisitor < SyntaxTreeVisitor
1087
+ extend Pluggable
1088
+
1089
+ def_plugin :enter_identifier_list
1090
+ def_plugin :leave_identifier_list
1091
+ def_plugin :enter_preprocessing_file
1092
+ def_plugin :leave_preprocessing_file
1093
+ def_plugin :enter_group
1094
+ def_plugin :leave_group
1095
+ def_plugin :enter_if_section
1096
+ def_plugin :leave_if_section
1097
+ def_plugin :enter_if_statement
1098
+ def_plugin :leave_if_statement
1099
+ def_plugin :enter_ifdef_statement
1100
+ def_plugin :leave_ifdef_statement
1101
+ def_plugin :enter_ifndef_statement
1102
+ def_plugin :leave_ifndef_statement
1103
+ def_plugin :enter_elif_groups
1104
+ def_plugin :leave_elif_groups
1105
+ def_plugin :enter_elif_statement
1106
+ def_plugin :leave_elif_statement
1107
+ def_plugin :enter_else_statement
1108
+ def_plugin :leave_else_statement
1109
+ def_plugin :enter_endif_line
1110
+ def_plugin :leave_endif_line
1111
+ def_plugin :enter_user_include_line
1112
+ def_plugin :leave_user_include_line
1113
+ def_plugin :enter_system_include_line
1114
+ def_plugin :leave_system_include_line
1115
+ def_plugin :enter_user_include_next_line
1116
+ def_plugin :leave_user_include_next_line
1117
+ def_plugin :enter_system_include_next_line
1118
+ def_plugin :leave_system_include_next_line
1119
+ def_plugin :enter_object_like_define_line
1120
+ def_plugin :leave_object_like_define_line
1121
+ def_plugin :enter_function_like_define_line
1122
+ def_plugin :leave_function_like_define_line
1123
+ def_plugin :enter_va_function_like_define_line
1124
+ def_plugin :leave_va_function_like_define_line
1125
+ def_plugin :enter_undef_line
1126
+ def_plugin :leave_undef_line
1127
+ def_plugin :enter_line_line
1128
+ def_plugin :leave_line_line
1129
+ def_plugin :enter_error_line
1130
+ def_plugin :leave_error_line
1131
+ def_plugin :enter_pragma_line
1132
+ def_plugin :leave_pragma_line
1133
+ def_plugin :enter_text_line
1134
+ def_plugin :leave_text_line
1135
+ def_plugin :enter_null_directive
1136
+ def_plugin :leave_null_directive
1137
+ def_plugin :enter_pp_tokens
1138
+ def_plugin :leave_pp_tokens
1139
+ def_plugin :enter_error_expression
1140
+ def_plugin :leave_error_expression
1141
+ def_plugin :enter_constant_specifier
1142
+ def_plugin :leave_constant_specifier
1143
+ def_plugin :enter_grouped_expression
1144
+ def_plugin :leave_grouped_expression
1145
+ def_plugin :enter_unary_arithmetic_expression
1146
+ def_plugin :leave_unary_arithmetic_expression
1147
+ def_plugin :enter_defined_expression
1148
+ def_plugin :leave_defined_expression
1149
+ def_plugin :enter_multiplicative_expression
1150
+ def_plugin :leave_multiplicative_expression
1151
+ def_plugin :enter_additive_expression
1152
+ def_plugin :leave_additive_expression
1153
+ def_plugin :enter_shift_expression
1154
+ def_plugin :leave_shift_expression
1155
+ def_plugin :enter_relational_expression
1156
+ def_plugin :leave_relational_expression
1157
+ def_plugin :enter_equality_expression
1158
+ def_plugin :leave_equality_expression
1159
+ def_plugin :enter_and_expression
1160
+ def_plugin :leave_and_expression
1161
+ def_plugin :enter_exclusive_or_expression
1162
+ def_plugin :leave_exclusive_or_expression
1163
+ def_plugin :enter_inclusive_or_expression
1164
+ def_plugin :leave_inclusive_or_expression
1165
+ def_plugin :enter_logical_and_expression
1166
+ def_plugin :leave_logical_and_expression
1167
+ def_plugin :enter_logical_or_expression
1168
+ def_plugin :leave_logical_or_expression
1169
+ def_plugin :enter_conditional_expression
1170
+ def_plugin :leave_conditional_expression
1171
+ def_plugin :enter_comma_separated_expression
1172
+ def_plugin :leave_comma_separated_expression
1173
+
1174
+ def visit_identifier_list(node)
1175
+ visit_with_notifying(__method__, node) { super }
1176
+ end
1177
+
1178
+ def visit_preprocessing_file(node)
1179
+ visit_with_notifying(__method__, node) { super }
1180
+ end
1181
+
1182
+ def visit_group(node)
1183
+ visit_with_notifying(__method__, node) { super }
1184
+ end
1185
+
1186
+ def visit_if_section(node)
1187
+ visit_with_notifying(__method__, node) { super }
1188
+ end
1189
+
1190
+ def visit_if_statement(node)
1191
+ visit_with_notifying(__method__, node) { super }
1192
+ end
1193
+
1194
+ def visit_ifdef_statement(node)
1195
+ visit_with_notifying(__method__, node) { super }
1196
+ end
1197
+
1198
+ def visit_ifndef_statement(node)
1199
+ visit_with_notifying(__method__, node) { super }
1200
+ end
1201
+
1202
+ def visit_elif_groups(node)
1203
+ visit_with_notifying(__method__, node) { super }
1204
+ end
1205
+
1206
+ def visit_elif_statement(node)
1207
+ visit_with_notifying(__method__, node) { super }
1208
+ end
1209
+
1210
+ def visit_else_statement(node)
1211
+ visit_with_notifying(__method__, node) { super }
1212
+ end
1213
+
1214
+ def visit_endif_line(node)
1215
+ visit_with_notifying(__method__, node) { super }
1216
+ end
1217
+
1218
+ def visit_user_include_line(node)
1219
+ visit_with_notifying(__method__, node) { super }
1220
+ end
1221
+
1222
+ def visit_system_include_line(node)
1223
+ visit_with_notifying(__method__, node) { super }
1224
+ end
1225
+
1226
+ def visit_user_include_next_line(node)
1227
+ visit_with_notifying(__method__, node) { super }
1228
+ end
1229
+
1230
+ def visit_system_include_next_line(node)
1231
+ visit_with_notifying(__method__, node) { super }
1232
+ end
1233
+
1234
+ def visit_object_like_define_line(node)
1235
+ visit_with_notifying(__method__, node) { super }
1236
+ end
1237
+
1238
+ def visit_function_like_define_line(node)
1239
+ visit_with_notifying(__method__, node) { super }
1240
+ end
1241
+
1242
+ def visit_va_function_like_define_line(node)
1243
+ visit_with_notifying(__method__, node) { super }
1244
+ end
1245
+
1246
+ def visit_undef_line(node)
1247
+ visit_with_notifying(__method__, node) { super }
1248
+ end
1249
+
1250
+ def visit_line_line(node)
1251
+ visit_with_notifying(__method__, node) { super }
1252
+ end
1253
+
1254
+ def visit_error_line(node)
1255
+ visit_with_notifying(__method__, node) { super }
1256
+ end
1257
+
1258
+ def visit_pragma_line(node)
1259
+ visit_with_notifying(__method__, node) { super }
1260
+ end
1261
+
1262
+ def visit_text_line(node)
1263
+ visit_with_notifying(__method__, node) { super }
1264
+ end
1265
+
1266
+ def visit_null_directive(node)
1267
+ visit_with_notifying(__method__, node) { super }
1268
+ end
1269
+
1270
+ def visit_pp_tokens(node)
1271
+ visit_with_notifying(__method__, node) { super }
1272
+ end
1273
+
1274
+ def visit_error_expression(node)
1275
+ visit_with_notifying(__method__, node) { super }
1276
+ end
1277
+
1278
+ def visit_constant_specifier(node)
1279
+ visit_with_notifying(__method__, node) { super }
1280
+ end
1281
+
1282
+ def visit_grouped_expression(node)
1283
+ visit_with_notifying(__method__, node) { super }
1284
+ end
1285
+
1286
+ def visit_unary_arithmetic_expression(node)
1287
+ visit_with_notifying(__method__, node) { super }
1288
+ end
1289
+
1290
+ def visit_defined_expression(node)
1291
+ visit_with_notifying(__method__, node) { super }
1292
+ end
1293
+
1294
+ def visit_multiplicative_expression(node)
1295
+ visit_with_notifying(__method__, node) { super }
1296
+ end
1297
+
1298
+ def visit_additive_expression(node)
1299
+ visit_with_notifying(__method__, node) { super }
1300
+ end
1301
+
1302
+ def visit_shift_expression(node)
1303
+ visit_with_notifying(__method__, node) { super }
1304
+ end
1305
+
1306
+ def visit_relational_expression(node)
1307
+ visit_with_notifying(__method__, node) { super }
1308
+ end
1309
+
1310
+ def visit_equality_expression(node)
1311
+ visit_with_notifying(__method__, node) { super }
1312
+ end
1313
+
1314
+ def visit_and_expression(node)
1315
+ visit_with_notifying(__method__, node) { super }
1316
+ end
1317
+
1318
+ def visit_exclusive_or_expression(node)
1319
+ visit_with_notifying(__method__, node) { super }
1320
+ end
1321
+
1322
+ def visit_inclusive_or_expression(node)
1323
+ visit_with_notifying(__method__, node) { super }
1324
+ end
1325
+
1326
+ def visit_logical_and_expression(node)
1327
+ visit_with_notifying(__method__, node) { super }
1328
+ end
1329
+
1330
+ def visit_logical_or_expression(node)
1331
+ visit_with_notifying(__method__, node) { super }
1332
+ end
1333
+
1334
+ def visit_conditional_expression(node)
1335
+ visit_with_notifying(__method__, node) { super }
1336
+ end
1337
+
1338
+ def visit_comma_separated_expression(node)
1339
+ visit_with_notifying(__method__, node) { super }
1340
+ end
1341
+
1342
+ private
1343
+ def visit_with_notifying(caller_method, node, &block)
1344
+ suffix = caller_method.to_s.sub(/\Avisit_/, "")
1345
+ __send__("enter_#{suffix}").invoke(node)
1346
+ yield
1347
+ __send__("leave_#{suffix}").invoke(node)
1348
+ end
1349
+ end
1350
+
1351
+ module SyntaxNodeCollector
1352
+ def collect_define_lines(node)
1353
+ if node
1354
+ DefineLineCollector.new.tap { |collector|
1355
+ node.accept(collector)
1356
+ }.define_lines
1357
+ else
1358
+ []
1359
+ end
1360
+ end
1361
+ module_function :collect_define_lines
1362
+
1363
+ def collect_undef_lines(node)
1364
+ if node
1365
+ UndefLineCollector.new.tap { |collector|
1366
+ node.accept(collector)
1367
+ }.undef_lines
1368
+ else
1369
+ []
1370
+ end
1371
+ end
1372
+ module_function :collect_undef_lines
1373
+ end
1374
+
1375
+ class DefineLineCollector < SyntaxTreeVisitor
1376
+ def initialize
1377
+ @define_lines = []
1378
+ end
1379
+
1380
+ attr_reader :define_lines
1381
+
1382
+ def visit_object_like_define_line(node)
1383
+ super
1384
+ @define_lines.push(node)
1385
+ end
1386
+
1387
+ def visit_function_like_define_line(node)
1388
+ super
1389
+ @define_lines.push(node)
1390
+ end
1391
+
1392
+ def visit_va_function_like_define_line(node)
1393
+ super
1394
+ @define_lines.push(node)
1395
+ end
1396
+ end
1397
+
1398
+ class UndefLineCollector < SyntaxTreeVisitor
1399
+ def initialize
1400
+ @undef_lines = []
1401
+ end
1402
+
1403
+ attr_reader :undef_lines
1404
+
1405
+ def visit_undef_line(node)
1406
+ super
1407
+ @undef_lines.push(node)
1408
+ end
1409
+ end
1410
+
1411
+ end
1412
+ end