adlint 1.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.
- data/AUTHORS +27 -0
- data/COPYING +674 -0
- data/ChangeLog +820 -0
- data/INSTALL +78 -0
- data/MANIFEST +464 -0
- data/NEWS +38 -0
- data/README +74 -0
- data/Rakefile +167 -0
- data/TODO +29 -0
- data/bin/adlint +141 -0
- data/bin/adlint_chk +129 -0
- data/bin/adlint_cma +122 -0
- data/bin/adlint_sma +129 -0
- data/bin/adlintize +286 -0
- data/etc/conf.d/fallback/cinit.erb +11 -0
- data/etc/conf.d/fallback/traits.erb +216 -0
- data/etc/conf.d/i686-cygwin/cinit-gcc_4.3.4.erb +149 -0
- data/etc/conf.d/i686-cygwin/traits-gcc_4.3.4.erb +227 -0
- data/etc/conf.d/i686-devkit/cinit-gcc_4.5.2.erb +224 -0
- data/etc/conf.d/i686-devkit/traits-gcc_4.5.2.erb +226 -0
- data/etc/conf.d/i686-linux/cinit-gcc_4.5.1.erb +219 -0
- data/etc/conf.d/i686-linux/traits-gcc_4.5.1.erb +224 -0
- data/etc/conf.d/i686-mingw/cinit-gcc_4.6.1.erb +234 -0
- data/etc/conf.d/i686-mingw/traits-gcc_4.6.1.erb +226 -0
- data/etc/conf.d/noarch/GNUmakefile.erb +119 -0
- data/etc/conf.d/noarch/adlint_all_bat.erb +9 -0
- data/etc/conf.d/noarch/adlint_all_sh.erb +10 -0
- data/etc/conf.d/noarch/pinit.erb +11 -0
- data/etc/mesg.d/en_US/messages.yml +784 -0
- data/etc/mesg.d/ja_JP/messages.yml +784 -0
- data/lib/adlint/analyzer.rb +294 -0
- data/lib/adlint/c/branch.rb +251 -0
- data/lib/adlint/c/builtin.rb +92 -0
- data/lib/adlint/c/code.rb +490 -0
- data/lib/adlint/c/const.rb +465 -0
- data/lib/adlint/c/conv.rb +212 -0
- data/lib/adlint/c/ctrlexpr.rb +949 -0
- data/lib/adlint/c/domain.rb +7499 -0
- data/lib/adlint/c/environ.rb +133 -0
- data/lib/adlint/c/expr.rb +1725 -0
- data/lib/adlint/c/format.rb +3209 -0
- data/lib/adlint/c/interp.rb +1740 -0
- data/lib/adlint/c/lexer.rb +241 -0
- data/lib/adlint/c/mediator.rb +313 -0
- data/lib/adlint/c/message.rb +13597 -0
- data/lib/adlint/c/metric.rb +765 -0
- data/lib/adlint/c/object.rb +1018 -0
- data/lib/adlint/c/parser.rb +3800 -0
- data/lib/adlint/c/parser.y +2054 -0
- data/lib/adlint/c/phase.rb +712 -0
- data/lib/adlint/c/resolver.rb +270 -0
- data/lib/adlint/c/scanner.rb +248 -0
- data/lib/adlint/c/scope.rb +74 -0
- data/lib/adlint/c/syntax.rb +4279 -0
- data/lib/adlint/c/type.rb +7506 -0
- data/lib/adlint/c/util.rb +91 -0
- data/lib/adlint/c/value.rb +2310 -0
- data/lib/adlint/c.rb +56 -0
- data/lib/adlint/code.rb +500 -0
- data/lib/adlint/cpp/code.rb +189 -0
- data/lib/adlint/cpp/constexpr.rb +721 -0
- data/lib/adlint/cpp/constexpr.y +389 -0
- data/lib/adlint/cpp/eval.rb +1012 -0
- data/lib/adlint/cpp/lexer.rb +860 -0
- data/lib/adlint/cpp/macro.rb +637 -0
- data/lib/adlint/cpp/message.rb +992 -0
- data/lib/adlint/cpp/phase.rb +176 -0
- data/lib/adlint/cpp/scanner.rb +93 -0
- data/lib/adlint/cpp/source.rb +169 -0
- data/lib/adlint/cpp/subst.rb +300 -0
- data/lib/adlint/cpp/syntax.rb +1412 -0
- data/lib/adlint/cpp/util.rb +97 -0
- data/lib/adlint/cpp.rb +43 -0
- data/lib/adlint/driver.rb +147 -0
- data/lib/adlint/error.rb +179 -0
- data/lib/adlint/lang.rb +97 -0
- data/lib/adlint/ld/message.rb +259 -0
- data/lib/adlint/ld/metric.rb +57 -0
- data/lib/adlint/ld/object.rb +542 -0
- data/lib/adlint/ld/phase.rb +193 -0
- data/lib/adlint/ld/typedef.rb +109 -0
- data/lib/adlint/ld/util.rb +88 -0
- data/lib/adlint/ld.rb +37 -0
- data/lib/adlint/lexer.rb +293 -0
- data/lib/adlint/message.rb +368 -0
- data/lib/adlint/metric.rb +805 -0
- data/lib/adlint/monitor.rb +144 -0
- data/lib/adlint/phase.rb +90 -0
- data/lib/adlint/prelude.rb +314 -0
- data/lib/adlint/report.rb +617 -0
- data/lib/adlint/source.rb +155 -0
- data/lib/adlint/symbol.rb +127 -0
- data/lib/adlint/token.rb +215 -0
- data/lib/adlint/traits.rb +643 -0
- data/lib/adlint/util.rb +524 -0
- data/lib/adlint/version.rb +71 -0
- data/lib/adlint.rb +66 -0
- data/share/HEADER +45 -0
- data/share/demo/Makefile +110 -0
- data/share/demo/ambig_operator/ambig_operator.c +289 -0
- data/share/demo/arg_points_unset/arg_points_unset.c +37 -0
- data/share/demo/array_range/array_range.c +62 -0
- data/share/demo/bad_bitfields/bad_bitfields.c +74 -0
- data/share/demo/bad_brace/bad_brace.c +19 -0
- data/share/demo/bad_charset/abcde$.h +0 -0
- data/share/demo/bad_charset/bad_charset.c +22 -0
- data/share/demo/bad_comment/bad_comment.c +3 -0
- data/share/demo/bad_const/bad_const.c +19 -0
- data/share/demo/bad_conv/bad_conv.c +48 -0
- data/share/demo/bad_indent/bad_indent.c +50 -0
- data/share/demo/bad_init/bad_init.c +49 -0
- data/share/demo/bad_macro/bad_macro.c +97 -0
- data/share/demo/bitwise_expr/bitwise_expr.c +19 -0
- data/share/demo/call_by_value/call_by_value.c +26 -0
- data/share/demo/cross_ref/cross_ref.c +21 -0
- data/share/demo/dangling_else/dangling_else.c +20 -0
- data/share/demo/dead_code/dead_code.c +237 -0
- data/share/demo/deep_nest/deep_nest.c +57 -0
- data/share/demo/dense_switch/dense_switch.c +62 -0
- data/share/demo/direct_recur/direct_recur.c +15 -0
- data/share/demo/div_by_zero/div_by_zero.c +35 -0
- data/share/demo/dos_source/dos_source.c +7 -0
- data/share/demo/funptr_cast/funptr_cast.c +26 -0
- data/share/demo/goto_stmt/goto_stmt.c +19 -0
- data/share/demo/id_hiding/id_hiding.c +19 -0
- data/share/demo/ill_defined/ill_defined.c +13 -0
- data/share/demo/implicit_conv/implicit_conv.c +60 -0
- data/share/demo/implicit_int/implicit_int.c +14 -0
- data/share/demo/incomplete_type/incomplete_type.c +49 -0
- data/share/demo/indirect_recur/indirect_recur_1.c +14 -0
- data/share/demo/indirect_recur/indirect_recur_1.h +7 -0
- data/share/demo/indirect_recur/indirect_recur_2.c +12 -0
- data/share/demo/indirect_recur/indirect_recur_2.h +6 -0
- data/share/demo/indirect_recur/indirect_recur_3.c +6 -0
- data/share/demo/indirect_recur/indirect_recur_3.h +6 -0
- data/share/demo/indirect_recur/indirect_recur_4.c +25 -0
- data/share/demo/intro_demo/intro_demo.c +76 -0
- data/share/demo/intro_demo/intro_demo.h +12 -0
- data/share/demo/intro_demo/useless_header.h +5 -0
- data/share/demo/invalid_call/invalid_call.c +32 -0
- data/share/demo/kandr_fundef/kandr_fundef.c +10 -0
- data/share/demo/line_comment/line_comment.c +12 -0
- data/share/demo/local_decl/local_decl.c +9 -0
- data/share/demo/logical_trick/logical_trick.c +36 -0
- data/share/demo/long_sym/long_sym.c +5 -0
- data/share/demo/loop_var/loop_var.c +92 -0
- data/share/demo/malloc_or_die/malloc_or_die.c +43 -0
- data/share/demo/may_be_null/may_be_null.c +52 -0
- data/share/demo/may_be_null_arith/may_be_null_arith.c +15 -0
- data/share/demo/may_be_unset/may_be_unset.c +34 -0
- data/share/demo/mmapped_io/mmapped_io.c +23 -0
- data/share/demo/multi_break/multi_break.c +33 -0
- data/share/demo/multi_decl/multi_decl_1.c +17 -0
- data/share/demo/multi_decl/multi_decl_1.h +6 -0
- data/share/demo/multi_decl/multi_decl_2.c +13 -0
- data/share/demo/multi_decl/multi_decl_2.h +6 -0
- data/share/demo/multi_decl/multi_decl_3.c +22 -0
- data/share/demo/multi_def/multi_def_1.c +36 -0
- data/share/demo/multi_def/multi_def_1.h +6 -0
- data/share/demo/multi_def/multi_def_2.c +22 -0
- data/share/demo/multi_def/multi_def_2.h +6 -0
- data/share/demo/multi_def/multi_def_3.c +6 -0
- data/share/demo/multi_typedef/multi_typedef.c +11 -0
- data/share/demo/multi_typedef/multi_typedef_1.h +1 -0
- data/share/demo/multi_typedef/multi_typedef_2.h +1 -0
- data/share/demo/must_be_false/must_be_false.c +53 -0
- data/share/demo/must_be_null/must_be_null.c +13 -0
- data/share/demo/must_be_null_arith/must_be_null_arith.c +14 -0
- data/share/demo/must_be_true/must_be_true.c +21 -0
- data/share/demo/no_eof_nl/no_eof_nl.c +4 -0
- data/share/demo/no_void_arg/no_void_arg.c +14 -0
- data/share/demo/null_stmt/null_stmt.c +19 -0
- data/share/demo/octal_const/octal_const.c +20 -0
- data/share/demo/output_by_param/output_by_param.c +17 -0
- data/share/demo/overflow/overflow.c +74 -0
- data/share/demo/press_release/press_release.c +40 -0
- data/share/demo/retn_lvar_addr/retn_lvar_addr.c +47 -0
- data/share/demo/shift_expr/shift_expr.c +14 -0
- data/share/demo/should_be_typedef/should_be_typedef.c +51 -0
- data/share/demo/static_paths/static_paths.c +153 -0
- data/share/demo/static_vars/static_vars.c +39 -0
- data/share/demo/tag_hiding/tag_hiding.c +18 -0
- data/share/demo/tricky_incdec/tricky_incdec.c +12 -0
- data/share/demo/undefined_macro/undefined_macro.c +17 -0
- data/share/demo/uninit_vars/uninit_vars.c +28 -0
- data/share/demo/union_type/union_type.c +23 -0
- data/share/demo/unmatch_decl/unmatch_decl_1.c +12 -0
- data/share/demo/unmatch_decl/unmatch_decl_1.h +8 -0
- data/share/demo/unmatch_decl/unmatch_decl_2.c +10 -0
- data/share/demo/unmatch_decl/unmatch_decl_2.h +8 -0
- data/share/demo/unmatch_decl/unmatch_decl_3.c +7 -0
- data/share/demo/unmatch_paren_macro/unmatch_paren_macro.c +15 -0
- data/share/demo/unreachable/unreachable.c +34 -0
- data/share/demo/useless_exp_funs/useless_exp_funs_1.c +14 -0
- data/share/demo/useless_exp_funs/useless_exp_funs_1.h +1 -0
- data/share/demo/useless_exp_funs/useless_exp_funs_2.c +6 -0
- data/share/demo/useless_exp_vars/useless_export_1.c +8 -0
- data/share/demo/useless_exp_vars/useless_export_1.h +1 -0
- data/share/demo/useless_exp_vars/useless_export_2.c +7 -0
- data/share/demo/useless_expr/useless_expr.c +17 -0
- data/share/demo/useless_funs/useless_funs_1.c +21 -0
- data/share/demo/useless_funs/useless_funs_1.h +8 -0
- data/share/demo/useless_funs/useless_funs_2.c +6 -0
- data/share/demo/useless_header/useless_header.c +9 -0
- data/share/demo/useless_header/useless_header_1.h +12 -0
- data/share/demo/useless_header/useless_header_2.h +6 -0
- data/share/demo/useless_header/useless_header_3.h +9 -0
- data/share/demo/useless_header/useless_header_4.h +3 -0
- data/share/demo/useless_vars/useless_vars.c +17 -0
- data/share/demo/va_funcall/va_funcall.c +25 -0
- data/share/demo/various_fundef/various_fundef.c +36 -0
- data/share/demo/wchar_wstring/wchar_wstring.c +7 -0
- data/share/demo/wrap_around/wrap_around.c +38 -0
- data/share/doc/Makefile +16 -0
- data/share/doc/adlint_on_adqua.png +0 -0
- data/share/doc/adlint_on_eclipse_en.png +0 -0
- data/share/doc/adlint_on_eclipse_ja.png +0 -0
- data/share/doc/adlint_on_vim_en.png +0 -0
- data/share/doc/adlint_on_vim_ja.png +0 -0
- data/share/doc/developers_guide_ja.html +171 -0
- data/share/doc/developers_guide_ja.texi +87 -0
- data/share/doc/gen_mesg_sections.rb +39 -0
- data/share/doc/samples/GNUmakefile +162 -0
- data/share/doc/samples/adlint_traits.yml +238 -0
- data/share/doc/texinfo.css +22 -0
- data/share/doc/users_guide_en.html +39975 -0
- data/share/doc/users_guide_en.texi +32640 -0
- data/share/doc/users_guide_ja.html +40505 -0
- data/share/doc/users_guide_ja.texi +33189 -0
- data/share/logo/adlint-110.png +0 -0
- data/share/logo/adlint-524.png +0 -0
- data/share/logo/adlint.svg +4637 -0
- data/share/sample/README +6 -0
- data/share/sample/bison-2.5/adlint/GNUmakefile +170 -0
- data/share/sample/bison-2.5/adlint/adlint_traits.yml +225 -0
- data/share/sample/bison-2.5/adlint/lib/GNUmakefile +198 -0
- data/share/sample/bison-2.5/adlint/lib/adlint_cinit.h +228 -0
- data/share/sample/bison-2.5/adlint/lib/adlint_pinit.h +21 -0
- data/share/sample/bison-2.5/adlint/lib/adlint_traits.yml +238 -0
- data/share/sample/bison-2.5/adlint/src/GNUmakefile +166 -0
- data/share/sample/bison-2.5/adlint/src/adlint_cinit.h +228 -0
- data/share/sample/bison-2.5/adlint/src/adlint_pinit.h +21 -0
- data/share/sample/bison-2.5/adlint/src/adlint_traits.yml +239 -0
- data/share/sample/ctags-5.8/adlint/GNUmakefile +169 -0
- data/share/sample/ctags-5.8/adlint/adlint_cinit.h +219 -0
- data/share/sample/ctags-5.8/adlint/adlint_pinit.h +13 -0
- data/share/sample/ctags-5.8/adlint/adlint_traits.yml +225 -0
- data/share/sample/flex-2.5.35/adlint/GNUmakefile +140 -0
- data/share/sample/flex-2.5.35/adlint/adlint_cinit.h +219 -0
- data/share/sample/flex-2.5.35/adlint/adlint_pinit.h +14 -0
- data/share/sample/flex-2.5.35/adlint/adlint_traits.yml +225 -0
- data/share/sample/ruby-1.9.3-p0/adlint/GNUmakefile +314 -0
- data/share/sample/ruby-1.9.3-p0/adlint/adlint_traits.yml +225 -0
- data/share/sample/ruby-1.9.3-p0/adlint/core/GNUmakefile +204 -0
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_pinit.h +28 -0
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_traits.yml +240 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc/GNUmakefile +163 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_traits.yml +240 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/GNUmakefile +149 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_traits.yml +240 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/GNUmakefile +134 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/GNUmakefile +132 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/GNUmakefile +132 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/GNUmakefile +132 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/GNUmakefile +132 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/GNUmakefile +134 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/GNUmakefile +140 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/GNUmakefile +134 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/GNUmakefile +162 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/GNUmakefile +135 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/GNUmakefile +132 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/GNUmakefile +144 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/GNUmakefile +140 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_traits.yml +241 -0
- data/share/sample/screen-4.0.3/adlint/GNUmakefile +162 -0
- data/share/sample/screen-4.0.3/adlint/adlint_cinit.h +228 -0
- data/share/sample/screen-4.0.3/adlint/adlint_pinit.h +21 -0
- data/share/sample/screen-4.0.3/adlint/adlint_traits.yml +238 -0
- data/share/sample/vim-7.3/adlint/vim/GNUmakefile +185 -0
- data/share/sample/vim-7.3/adlint/vim/adlint_cinit.h +228 -0
- data/share/sample/vim-7.3/adlint/vim/adlint_pinit.h +25 -0
- data/share/sample/vim-7.3/adlint/vim/adlint_traits.yml +250 -0
- data/share/sample/vim-7.3/adlint/xxd/GNUmakefile +131 -0
- data/share/sample/vim-7.3/adlint/xxd/adlint_cinit.h +228 -0
- data/share/sample/vim-7.3/adlint/xxd/adlint_pinit.h +24 -0
- data/share/sample/vim-7.3/adlint/xxd/adlint_traits.yml +237 -0
- data/share/sample/zsh-4.3.15/adlint/GNUmakefile +146 -0
- data/share/sample/zsh-4.3.15/adlint/adlint_traits.yml +225 -0
- data/share/sample/zsh-4.3.15/adlint/builtins/GNUmakefile +132 -0
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_cinit.h +228 -0
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_pinit.h +24 -0
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_traits.yml +240 -0
- data/share/sample/zsh-4.3.15/adlint/core/GNUmakefile +153 -0
- data/share/sample/zsh-4.3.15/adlint/core/adlint_cinit.h +228 -0
- data/share/sample/zsh-4.3.15/adlint/core/adlint_pinit.h +23 -0
- data/share/sample/zsh-4.3.15/adlint/core/adlint_traits.yml +239 -0
- data/share/sample/zsh-4.3.15/adlint/modules/GNUmakefile +147 -0
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_cinit.h +228 -0
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_pinit.h +24 -0
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_traits.yml +240 -0
- data/share/sample/zsh-4.3.15/adlint/zle/GNUmakefile +144 -0
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_cinit.h +228 -0
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_pinit.h +24 -0
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_traits.yml +239 -0
- data/spec/MUST_WRITE_SPECS_WITH_RSPEC +0 -0
- metadata +532 -0
data/lib/adlint/lexer.rb
ADDED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
# Lexical analyzer base classes.
|
|
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/token"
|
|
33
|
+
require "adlint/source"
|
|
34
|
+
require "adlint/traits"
|
|
35
|
+
require "adlint/error"
|
|
36
|
+
require "adlint/util"
|
|
37
|
+
|
|
38
|
+
module AdLint #:nodoc:
|
|
39
|
+
|
|
40
|
+
# == DESCRIPTION
|
|
41
|
+
# Token queue to interface to the parser.
|
|
42
|
+
class TokenQueue < Array
|
|
43
|
+
# === DESCRIPTION
|
|
44
|
+
# Constructs an empty token queue or a solid token queue from specified
|
|
45
|
+
# token array.
|
|
46
|
+
#
|
|
47
|
+
# === PARAMETER
|
|
48
|
+
# _token_array_:: TokenArray -- Array of tokens.
|
|
49
|
+
def initialize(token_array = nil)
|
|
50
|
+
if token_array
|
|
51
|
+
super
|
|
52
|
+
else
|
|
53
|
+
super()
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def expect(token_type)
|
|
58
|
+
token = self.first
|
|
59
|
+
token && token.type == token_type ? true : false
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# == DESCRIPTION
|
|
64
|
+
# Object represents the whole content of something.
|
|
65
|
+
class Content
|
|
66
|
+
def location
|
|
67
|
+
subclass_responsibility
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def empty?
|
|
71
|
+
subclass_responsibility
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# == DESCRIPTION
|
|
76
|
+
# Object represents the whole content of the string.
|
|
77
|
+
class StringContent < Content
|
|
78
|
+
include CodingStyleAccessor
|
|
79
|
+
extend Memoizable
|
|
80
|
+
|
|
81
|
+
# === DESCRIPTION
|
|
82
|
+
# Constructs the content object of the string.
|
|
83
|
+
#
|
|
84
|
+
# === PARAMETER
|
|
85
|
+
# _str_:: String -- Target string.
|
|
86
|
+
# _fpath_:: Pathname -- File path name contains the target string.
|
|
87
|
+
# _line_no_:: Integer -- Initial line-no of the target string.
|
|
88
|
+
def initialize(str, fpath = nil, line_no = 1, column_no = 1)
|
|
89
|
+
@scanner = StringScanner.new(str)
|
|
90
|
+
@fpath = fpath
|
|
91
|
+
@line_no = line_no
|
|
92
|
+
@column_no = column_no
|
|
93
|
+
@appearance_column_no = column_no
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def location
|
|
97
|
+
Location.new(@fpath, @line_no, @column_no, @appearance_column_no)
|
|
98
|
+
end
|
|
99
|
+
memoize :location
|
|
100
|
+
|
|
101
|
+
# === DESCRIPTION
|
|
102
|
+
# Scans a token.
|
|
103
|
+
#
|
|
104
|
+
# === PARAMETER
|
|
105
|
+
# _regexp_:: Regexp -- Token pattern.
|
|
106
|
+
#
|
|
107
|
+
# === RETURN VALUE
|
|
108
|
+
# String -- Token string or nil.
|
|
109
|
+
def scan(regexp)
|
|
110
|
+
token = @scanner.scan(regexp)
|
|
111
|
+
if token
|
|
112
|
+
update_location(token)
|
|
113
|
+
token
|
|
114
|
+
else
|
|
115
|
+
nil
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def check(regexp)
|
|
120
|
+
@scanner.check(regexp)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# === DESCRIPTION
|
|
124
|
+
# Skips a content.
|
|
125
|
+
#
|
|
126
|
+
# === PARAMETER
|
|
127
|
+
# _length_:: Integer -- Skipping content length.
|
|
128
|
+
#
|
|
129
|
+
# === RETURN VALUE
|
|
130
|
+
# String -- Eaten string.
|
|
131
|
+
def eat!(length = 1)
|
|
132
|
+
scan(/.{#{length}}/m)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# === DESCRIPTION
|
|
136
|
+
# Checks whether this content is currently empty or not.
|
|
137
|
+
#
|
|
138
|
+
# === RETURN VALUE
|
|
139
|
+
# Boolean -- Returns true if already empty.
|
|
140
|
+
def empty?
|
|
141
|
+
@scanner.eos?
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
private
|
|
145
|
+
def update_location(token)
|
|
146
|
+
if (nl_count = token.count("\n")) > 0
|
|
147
|
+
@line_no += nl_count
|
|
148
|
+
last_line = token[token.rindex("\n")..-1]
|
|
149
|
+
@column_no = last_line.length
|
|
150
|
+
@appearance_column_no = last_line.gsub(/\t/, " " * tab_width).length
|
|
151
|
+
else
|
|
152
|
+
@column_no += token.length
|
|
153
|
+
@appearance_column_no += token.gsub(/\t/, " " * tab_width).length
|
|
154
|
+
end
|
|
155
|
+
forget_location_memo
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# == DESCRIPTION
|
|
160
|
+
# Object represents the whole content of the source file.
|
|
161
|
+
class SourceContent < StringContent
|
|
162
|
+
# === DESCRIPTION
|
|
163
|
+
# Constructs the content object of the source file.
|
|
164
|
+
#
|
|
165
|
+
# === PARAMETER
|
|
166
|
+
# _source_:: Source -- Target source object.
|
|
167
|
+
def initialize(source)
|
|
168
|
+
super(source.open { |io| io.read }, source.fpath)
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
class TokensContent < Content
|
|
173
|
+
def initialize(token_array)
|
|
174
|
+
@token_array = token_array
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def location
|
|
178
|
+
empty? ? nil : @token_array.first.location
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def empty?
|
|
182
|
+
@token_array.empty?
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
def next_token
|
|
186
|
+
empty? ? nil : @token_array.shift
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# == DESCRIPTION
|
|
191
|
+
# Generic lexical analysis context.
|
|
192
|
+
class LexerContext
|
|
193
|
+
# === DESCRIPTION
|
|
194
|
+
# Constructs a lexical analysis context object.
|
|
195
|
+
#
|
|
196
|
+
# === PARAMETER
|
|
197
|
+
# _content_:: SourceContent | StringContent -- Target content.
|
|
198
|
+
def initialize(content)
|
|
199
|
+
@content = content
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
# === VALUE
|
|
203
|
+
# SourceContent | StringContent -- The target content of this context.
|
|
204
|
+
attr_reader :content
|
|
205
|
+
|
|
206
|
+
# === DESCRIPTION
|
|
207
|
+
# Reads the current location of the target content.
|
|
208
|
+
#
|
|
209
|
+
# === RETURN VALUE
|
|
210
|
+
# Location -- Current location.
|
|
211
|
+
def location
|
|
212
|
+
@content.location
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
# == DESCRIPTION
|
|
217
|
+
# Base class of the lexical analyzer of the string.
|
|
218
|
+
class StringLexer
|
|
219
|
+
# === DESCRIPTION
|
|
220
|
+
# Constructs a lexical analyzer of the string.
|
|
221
|
+
#
|
|
222
|
+
# === PARAMETER
|
|
223
|
+
# _str_:: String -- Target string.
|
|
224
|
+
def initialize(str)
|
|
225
|
+
@str = str
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
# === DESCRIPTION
|
|
229
|
+
# Executes the lexical analysis.
|
|
230
|
+
#
|
|
231
|
+
# === RETURN VALUE
|
|
232
|
+
# TokenArray -- Scanned tokens.
|
|
233
|
+
def execute
|
|
234
|
+
context = create_context(@str)
|
|
235
|
+
tokenize(context)
|
|
236
|
+
rescue Error
|
|
237
|
+
raise
|
|
238
|
+
rescue => ex
|
|
239
|
+
if context
|
|
240
|
+
raise InternalError.new(ex, context.location)
|
|
241
|
+
else
|
|
242
|
+
raise InternalError.new(ex, nil)
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
private
|
|
247
|
+
# === DESCRIPTION
|
|
248
|
+
# Creates the context object.
|
|
249
|
+
#
|
|
250
|
+
# Subclasses must implement this method.
|
|
251
|
+
#
|
|
252
|
+
# === PARAMETER
|
|
253
|
+
# _str_:: String -- Target string object.
|
|
254
|
+
def create_context(str)
|
|
255
|
+
subclass_responsibility
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
# === DESCRIPTION
|
|
259
|
+
# Tokenize the target content.
|
|
260
|
+
#
|
|
261
|
+
# Subclasses must implement this method.
|
|
262
|
+
#
|
|
263
|
+
# === PARAMETER
|
|
264
|
+
# _context_:: LexerContext -- Lexical analysis context.
|
|
265
|
+
def tokenize(context)
|
|
266
|
+
subclass_responsibility
|
|
267
|
+
end
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
class TokensRelexer
|
|
271
|
+
def initialize(token_array)
|
|
272
|
+
@context = create_context(token_array)
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
def next_token
|
|
276
|
+
tokenize(@context)
|
|
277
|
+
rescue Error
|
|
278
|
+
raise
|
|
279
|
+
rescue => ex
|
|
280
|
+
raise InternalError.new(ex, @context.location)
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
private
|
|
284
|
+
def create_context(token_array)
|
|
285
|
+
subclass_responsibility
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
def tokenize(context)
|
|
289
|
+
subclass_responsibility
|
|
290
|
+
end
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
end
|
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
# Base classes of the warning and the error messages.
|
|
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/traits"
|
|
33
|
+
require "adlint/token"
|
|
34
|
+
require "adlint/error"
|
|
35
|
+
require "adlint/version"
|
|
36
|
+
|
|
37
|
+
module AdLint #:nodoc:
|
|
38
|
+
|
|
39
|
+
# == DESCRIPTION
|
|
40
|
+
# Base class of all messages.
|
|
41
|
+
class Message
|
|
42
|
+
# === DESCRIPTION
|
|
43
|
+
# Creates a fatal error message from exception object.
|
|
44
|
+
#
|
|
45
|
+
# === PARAMETER
|
|
46
|
+
# _exception_:: Exception -- Cause exception.
|
|
47
|
+
def self.from_exception(exception)
|
|
48
|
+
FatalErrorMessage.new(exception)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# === DESCRIPTION
|
|
52
|
+
# Constructs a message.
|
|
53
|
+
#
|
|
54
|
+
# === PARAMETER
|
|
55
|
+
# _id_:: Symbol -- Message ID symbol.
|
|
56
|
+
# _location_:: Location -- Location where the message detected.
|
|
57
|
+
# _parts_:: Array< Object > -- Message formatting parts.
|
|
58
|
+
def initialize(id, location, *parts)
|
|
59
|
+
@id, @location = id, location
|
|
60
|
+
@parts = parts
|
|
61
|
+
validate_id(@id, @location)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
attr_reader :id
|
|
65
|
+
|
|
66
|
+
# === DESCRIPTION
|
|
67
|
+
# Reads the type of this message.
|
|
68
|
+
#
|
|
69
|
+
# Subclasses must implement this method.
|
|
70
|
+
#
|
|
71
|
+
# === RETURN VALUE
|
|
72
|
+
# Symbol -- Message type symbol.
|
|
73
|
+
def type
|
|
74
|
+
subclass_responsibility
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# === DESCRIPTION
|
|
78
|
+
# Reads the type string of this message.
|
|
79
|
+
#
|
|
80
|
+
# Subclasses must implement this method.
|
|
81
|
+
#
|
|
82
|
+
# === RETURN VALUE
|
|
83
|
+
# String -- Message type string.
|
|
84
|
+
def type_str
|
|
85
|
+
subclass_responsibility
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# === DESCRIPTION
|
|
89
|
+
# Converts this message into an array of message elements.
|
|
90
|
+
#
|
|
91
|
+
# === RETURN VALUE
|
|
92
|
+
# Array< Object > -- Array of message elements.
|
|
93
|
+
def to_a
|
|
94
|
+
if templ = MessageCatalog.instance[@id]
|
|
95
|
+
begin
|
|
96
|
+
mesg = templ.to_default_external %
|
|
97
|
+
@parts.map { |obj| obj.to_s.to_default_external }
|
|
98
|
+
[type.to_s, @location.fpath, @location.line_no, @location.column_no,
|
|
99
|
+
@id, mesg]
|
|
100
|
+
rescue
|
|
101
|
+
raise InvalidMessageFormatError.new(@id, @location)
|
|
102
|
+
end
|
|
103
|
+
else
|
|
104
|
+
raise InvalidMessageIdError.new(@id, @location)
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# === DESCRIPTION
|
|
109
|
+
# Converts this message into a string for human readable output.
|
|
110
|
+
#
|
|
111
|
+
# === RETURN VALUE
|
|
112
|
+
# String -- String representation of this message.
|
|
113
|
+
def to_s
|
|
114
|
+
@location.to_s.to_default_external +
|
|
115
|
+
":#{type_str.to_default_external}:%5$s:%6$s".to_default_external %
|
|
116
|
+
to_a.map { |obj| obj.to_s.to_default_external }
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def to_csv
|
|
120
|
+
to_a.map { |obj| obj ? obj.to_s.to_default_external : nil }.to_csv
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def eql?(rhs)
|
|
124
|
+
@id == rhs.id && @location == rhs.location && @parts == rhs.parts
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def hash
|
|
128
|
+
[@id, @location, @parts].hash
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
protected
|
|
132
|
+
attr_reader :location
|
|
133
|
+
attr_reader :parts
|
|
134
|
+
|
|
135
|
+
private
|
|
136
|
+
# === DESCRIPTION
|
|
137
|
+
# Validates the message ID.
|
|
138
|
+
#
|
|
139
|
+
# === PARAMETER
|
|
140
|
+
# _id_:: String -- Message ID string.
|
|
141
|
+
# _location_:: Location -- Location where the message detected.
|
|
142
|
+
#
|
|
143
|
+
# === RETURN VALUE
|
|
144
|
+
# None.
|
|
145
|
+
def validate_id(id, location)
|
|
146
|
+
MessageCatalog.instance[id] or
|
|
147
|
+
raise InvalidMessageIdError.new(id, location)
|
|
148
|
+
nil
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# == DESCRIPTION
|
|
153
|
+
# Syntactical error message.
|
|
154
|
+
class ErrorMessage < Message
|
|
155
|
+
# === DESCRIPTION
|
|
156
|
+
# Reads the type of this message.
|
|
157
|
+
#
|
|
158
|
+
# === RETURN VALUE
|
|
159
|
+
# Symbol -- Message type symbol.
|
|
160
|
+
def type
|
|
161
|
+
:E
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# === DESCRIPTION
|
|
165
|
+
# Reads the type string of this message.
|
|
166
|
+
#
|
|
167
|
+
# === RETURN VALUE
|
|
168
|
+
# String -- Message type string.
|
|
169
|
+
def type_str
|
|
170
|
+
"error"
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# == DESCRIPTION
|
|
175
|
+
# AdLint specific internal fatal error message.
|
|
176
|
+
class FatalErrorMessage < Message
|
|
177
|
+
# === DESCRIPTION
|
|
178
|
+
# Constructs a AdLint specific internal fatal error message.
|
|
179
|
+
#
|
|
180
|
+
# === PARAMETER
|
|
181
|
+
# _exception_:: Exception -- Cause exception.
|
|
182
|
+
def initialize(exception)
|
|
183
|
+
super(exception.id,
|
|
184
|
+
exception.location ? exception.location : Location.new,
|
|
185
|
+
*exception.parts)
|
|
186
|
+
@exception = exception
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# === DESCRIPTION
|
|
190
|
+
# Reads the type of this message.
|
|
191
|
+
#
|
|
192
|
+
# === RETURN VALUE
|
|
193
|
+
# Symbol -- Message type symbol.
|
|
194
|
+
def type
|
|
195
|
+
:X
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
# === DESCRIPTION
|
|
199
|
+
# Reads the type string of this message.
|
|
200
|
+
#
|
|
201
|
+
# === RETURN VALUE
|
|
202
|
+
# String -- Message type string.
|
|
203
|
+
def type_str
|
|
204
|
+
"fatal error"
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
# == DESCRIPTION
|
|
209
|
+
# Semantical warning message.
|
|
210
|
+
class WarningMessage < Message
|
|
211
|
+
# === DESCRIPTION
|
|
212
|
+
# Reads the type of this message.
|
|
213
|
+
#
|
|
214
|
+
# === RETURN VALUE
|
|
215
|
+
# Symbol -- Message type symbol.
|
|
216
|
+
def type
|
|
217
|
+
:W
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# === DESCRIPTION
|
|
221
|
+
# Reads the type string of this message.
|
|
222
|
+
#
|
|
223
|
+
# === RETURN VALUE
|
|
224
|
+
# String -- Message type string.
|
|
225
|
+
def type_str
|
|
226
|
+
"warning"
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
# == DESCRIPTION
|
|
231
|
+
# Message complements other messages.
|
|
232
|
+
class ContextMessage < Message
|
|
233
|
+
# === DESCRIPTION
|
|
234
|
+
# Reads the type of this message.
|
|
235
|
+
#
|
|
236
|
+
# === RETURN VALUE
|
|
237
|
+
# Symbol -- Message type symbol.
|
|
238
|
+
def type
|
|
239
|
+
:C
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
# === DESCRIPTION
|
|
243
|
+
# Reads the type string of this message.
|
|
244
|
+
#
|
|
245
|
+
# === RETURN VALUE
|
|
246
|
+
# String -- Message type string.
|
|
247
|
+
def type_str
|
|
248
|
+
"context"
|
|
249
|
+
end
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
# == DESCRIPTION
|
|
253
|
+
# Message catalog entry.
|
|
254
|
+
class MessageTemplate < String; end
|
|
255
|
+
|
|
256
|
+
# == DESCRIPTION
|
|
257
|
+
# Message catalog.
|
|
258
|
+
class MessageCatalog < Hash
|
|
259
|
+
include Singleton
|
|
260
|
+
|
|
261
|
+
DEFAULT_DNAME = Pathname.new("mesg.d")
|
|
262
|
+
private_constant :DEFAULT_DNAME
|
|
263
|
+
|
|
264
|
+
DEFAULT_FNAME = Pathname.new("messages.yml")
|
|
265
|
+
private_constant :DEFAULT_FNAME
|
|
266
|
+
|
|
267
|
+
def load(fpath = nil)
|
|
268
|
+
unless fpath
|
|
269
|
+
mesg_dpath = DEFAULT_DNAME.expand_path($etcdir)
|
|
270
|
+
lang_dpath = Pathname.new(Traits.instance.of_message.language)
|
|
271
|
+
fpath = mesg_dpath.join(lang_dpath).join(DEFAULT_FNAME)
|
|
272
|
+
end
|
|
273
|
+
File.open(fpath, "r:utf-8") { |io| read_from(io) }
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
# === DESCRIPTION
|
|
277
|
+
# Loads message templates from the message definition file.
|
|
278
|
+
#
|
|
279
|
+
# === PARAMETER
|
|
280
|
+
# _io_:: IO -- I/O object for the message definition file.
|
|
281
|
+
#
|
|
282
|
+
# === RETURN VALUE
|
|
283
|
+
# MessageCatalog -- Self.
|
|
284
|
+
def read_from(io)
|
|
285
|
+
case array_or_stream = YAML.load_stream(io)
|
|
286
|
+
when Array
|
|
287
|
+
# NOTE: YAML.load_stream returns Array in Ruby 1.9.3-preview1.
|
|
288
|
+
doc = array_or_stream.first
|
|
289
|
+
when YAML::Stream
|
|
290
|
+
doc = array_or_stream.documents.first
|
|
291
|
+
end
|
|
292
|
+
version = doc["version"]
|
|
293
|
+
validate_version(version)
|
|
294
|
+
if message_definition = doc["message_definition"]
|
|
295
|
+
message_definition.each do |id, text|
|
|
296
|
+
if changed = Traits.instance.of_message.change_list[id.intern]
|
|
297
|
+
self[id.intern] = MessageTemplate.new(changed)
|
|
298
|
+
else
|
|
299
|
+
self[id.intern] = MessageTemplate.new(text)
|
|
300
|
+
end
|
|
301
|
+
end
|
|
302
|
+
else
|
|
303
|
+
raise "invalid form of the message definition file."
|
|
304
|
+
end
|
|
305
|
+
self
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
private
|
|
309
|
+
# === DESCRIPTION
|
|
310
|
+
# Validates the version of the message definition file.
|
|
311
|
+
#
|
|
312
|
+
# === RETURN VALUE
|
|
313
|
+
# None.
|
|
314
|
+
def validate_version(version)
|
|
315
|
+
version =~ SCHEMA_VERSION_RE or
|
|
316
|
+
raise "invalid version of the message definition file."
|
|
317
|
+
nil
|
|
318
|
+
end
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
# == DESCRIPTION
|
|
322
|
+
# Base of message detection classes.
|
|
323
|
+
class MessageDetection
|
|
324
|
+
# === DESCRIPTION
|
|
325
|
+
# Constructs a message detecting object.
|
|
326
|
+
#
|
|
327
|
+
# === PARAMETER
|
|
328
|
+
# _context_:: PhaseContext -- Analysis context.
|
|
329
|
+
def initialize(context)
|
|
330
|
+
@context = context
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
# === DESCRIPTION
|
|
334
|
+
# Executes a message detecting.
|
|
335
|
+
def execute
|
|
336
|
+
do_prepare(@context)
|
|
337
|
+
do_execute(@context)
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
private
|
|
341
|
+
# === DESCRIPTION
|
|
342
|
+
# Initializes a message.
|
|
343
|
+
#
|
|
344
|
+
# Subclasses must implement this method.
|
|
345
|
+
def do_prepare(context)
|
|
346
|
+
subclass_responsibility
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
# === DESCRIPTION
|
|
350
|
+
# Detects a message.
|
|
351
|
+
#
|
|
352
|
+
# Subclasses must implement this method.
|
|
353
|
+
def do_execute(context)
|
|
354
|
+
subclass_responsibility
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
def report
|
|
358
|
+
@context.report
|
|
359
|
+
end
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
class PassiveMessageDetection < MessageDetection
|
|
363
|
+
private
|
|
364
|
+
def do_prepare(context) end
|
|
365
|
+
def do_execute(context) end
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
end
|