langscan 1.2-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. data/AUTHORS.txt +19 -0
  2. data/History.txt +126 -0
  3. data/Manifest.txt +167 -0
  4. data/README.rdoc +91 -0
  5. data/Rakefile +40 -0
  6. data/ext/langscan/_make_c.rb +20 -0
  7. data/ext/langscan/_make_h.rb +30 -0
  8. data/ext/langscan/_template.c +134 -0
  9. data/ext/langscan/_template.h +53 -0
  10. data/ext/langscan/c/c/Makefile +188 -0
  11. data/ext/langscan/c/c/c.c +134 -0
  12. data/ext/langscan/c/c/c.h +66 -0
  13. data/ext/langscan/c/c/ctok.c +4629 -0
  14. data/ext/langscan/c/c/ctok.l +212 -0
  15. data/ext/langscan/c/c/extconf.rb +3 -0
  16. data/ext/langscan/c/c/modulename.txt +1 -0
  17. data/ext/langscan/c/c/tokenlist.txt +13 -0
  18. data/ext/langscan/csharp/csharp/Makefile +188 -0
  19. data/ext/langscan/csharp/csharp/csharp.c +134 -0
  20. data/ext/langscan/csharp/csharp/csharp.h +65 -0
  21. data/ext/langscan/csharp/csharp/csharptok.c +2971 -0
  22. data/ext/langscan/csharp/csharp/csharptok.l +200 -0
  23. data/ext/langscan/csharp/csharp/extconf.rb +3 -0
  24. data/ext/langscan/csharp/csharp/modulename.txt +1 -0
  25. data/ext/langscan/csharp/csharp/tokenlist.txt +12 -0
  26. data/ext/langscan/d/d/Makefile +188 -0
  27. data/ext/langscan/d/d/d.c +134 -0
  28. data/ext/langscan/d/d/d.h +64 -0
  29. data/ext/langscan/d/d/dtok.c +5468 -0
  30. data/ext/langscan/d/d/dtok.l +282 -0
  31. data/ext/langscan/d/d/extconf.rb +3 -0
  32. data/ext/langscan/d/d/modulename.txt +1 -0
  33. data/ext/langscan/d/d/tokenlist.txt +11 -0
  34. data/ext/langscan/elisp/elisp/Makefile +188 -0
  35. data/ext/langscan/elisp/elisp/elisp.c +134 -0
  36. data/ext/langscan/elisp/elisp/elisp.h +62 -0
  37. data/ext/langscan/elisp/elisp/elisptok.c +2108 -0
  38. data/ext/langscan/elisp/elisp/elisptok.l +151 -0
  39. data/ext/langscan/elisp/elisp/extconf.rb +3 -0
  40. data/ext/langscan/elisp/elisp/modulename.txt +1 -0
  41. data/ext/langscan/elisp/elisp/tokenlist.txt +9 -0
  42. data/ext/langscan/java/java/Makefile +188 -0
  43. data/ext/langscan/java/java/extconf.rb +3 -0
  44. data/ext/langscan/java/java/java.c +134 -0
  45. data/ext/langscan/java/java/java.h +64 -0
  46. data/ext/langscan/java/java/javatok.c +2097 -0
  47. data/ext/langscan/java/java/javatok.l +155 -0
  48. data/ext/langscan/java/java/modulename.txt +1 -0
  49. data/ext/langscan/java/java/tokenlist.txt +11 -0
  50. data/ext/langscan/javascript/javascript/Makefile +188 -0
  51. data/ext/langscan/javascript/javascript/extconf.rb +3 -0
  52. data/ext/langscan/javascript/javascript/javascript.c +134 -0
  53. data/ext/langscan/javascript/javascript/javascript.h +63 -0
  54. data/ext/langscan/javascript/javascript/javascripttok.c +2058 -0
  55. data/ext/langscan/javascript/javascript/javascripttok.l +147 -0
  56. data/ext/langscan/javascript/javascript/modulename.txt +1 -0
  57. data/ext/langscan/javascript/javascript/tokenlist.txt +10 -0
  58. data/ext/langscan/pairmatcher/pairmatcher/Makefile +188 -0
  59. data/ext/langscan/pairmatcher/pairmatcher/extconf.rb +3 -0
  60. data/ext/langscan/pairmatcher/pairmatcher/pairmatcher.c +890 -0
  61. data/ext/langscan/php/php/Makefile +188 -0
  62. data/ext/langscan/php/php/extconf.rb +3 -0
  63. data/ext/langscan/php/php/modulename.txt +1 -0
  64. data/ext/langscan/php/php/php.c +134 -0
  65. data/ext/langscan/php/php/php.h +64 -0
  66. data/ext/langscan/php/php/phptok.c +2413 -0
  67. data/ext/langscan/php/php/phptok.l +212 -0
  68. data/ext/langscan/php/php/tokenlist.txt +11 -0
  69. data/ext/langscan/post-distclean.rb +21 -0
  70. data/ext/langscan/pre-config.rb +57 -0
  71. data/ext/langscan/python/python/Makefile +188 -0
  72. data/ext/langscan/python/python/extconf.rb +3 -0
  73. data/ext/langscan/python/python/modulename.txt +1 -0
  74. data/ext/langscan/python/python/python.c +134 -0
  75. data/ext/langscan/python/python/python.h +61 -0
  76. data/ext/langscan/python/python/pythontok.c +2109 -0
  77. data/ext/langscan/python/python/pythontok.l +155 -0
  78. data/ext/langscan/python/python/tokenlist.txt +8 -0
  79. data/ext/langscan/ruby/compat/ripper/Makefile +189 -0
  80. data/ext/langscan/ruby/compat/ripper/depend +1 -0
  81. data/ext/langscan/ruby/compat/ripper/extconf.rb +4 -0
  82. data/ext/langscan/ruby/compat/ripper/include/eventids1.c +251 -0
  83. data/ext/langscan/ruby/compat/ripper/include/eventids2.c +277 -0
  84. data/ext/langscan/ruby/compat/ripper/include/lex.c +138 -0
  85. data/ext/langscan/ruby/compat/ripper/ripper.c +14420 -0
  86. data/ext/langscan/scheme/scheme/Makefile +188 -0
  87. data/ext/langscan/scheme/scheme/extconf.rb +3 -0
  88. data/ext/langscan/scheme/scheme/modulename.txt +1 -0
  89. data/ext/langscan/scheme/scheme/scheme.c +134 -0
  90. data/ext/langscan/scheme/scheme/scheme.h +60 -0
  91. data/ext/langscan/scheme/scheme/schemetok.c +2454 -0
  92. data/ext/langscan/scheme/scheme/schemetok.l +177 -0
  93. data/ext/langscan/scheme/scheme/tokenlist.txt +7 -0
  94. data/ext/langscan/sh/sh/Makefile +188 -0
  95. data/ext/langscan/sh/sh/extconf.rb +3 -0
  96. data/ext/langscan/sh/sh/modulename.txt +1 -0
  97. data/ext/langscan/sh/sh/sh.c +134 -0
  98. data/ext/langscan/sh/sh/sh.h +61 -0
  99. data/ext/langscan/sh/sh/shtok.c +2477 -0
  100. data/ext/langscan/sh/sh/shtok.l +325 -0
  101. data/ext/langscan/sh/sh/tokenlist.txt +8 -0
  102. data/lib/langscan.rb +124 -0
  103. data/lib/langscan/_common.rb +50 -0
  104. data/lib/langscan/_easyscanner.rb +78 -0
  105. data/lib/langscan/_pairmatcher.rb +46 -0
  106. data/lib/langscan/_type.rb +125 -0
  107. data/lib/langscan/autoconf.rb +51 -0
  108. data/lib/langscan/automake.rb +51 -0
  109. data/lib/langscan/brainfuck.rb +48 -0
  110. data/lib/langscan/c.rb +144 -0
  111. data/lib/langscan/c/c.so +0 -0
  112. data/lib/langscan/csharp.rb +101 -0
  113. data/lib/langscan/csharp/csharp.so +0 -0
  114. data/lib/langscan/css.rb +109 -0
  115. data/lib/langscan/d.rb +201 -0
  116. data/lib/langscan/d/d.so +0 -0
  117. data/lib/langscan/eiffel.rb +167 -0
  118. data/lib/langscan/elisp.rb +132 -0
  119. data/lib/langscan/elisp/elisp.so +0 -0
  120. data/lib/langscan/io.rb +84 -0
  121. data/lib/langscan/java.rb +95 -0
  122. data/lib/langscan/java/java.so +0 -0
  123. data/lib/langscan/javascript.rb +97 -0
  124. data/lib/langscan/javascript/javascript.so +0 -0
  125. data/lib/langscan/lua.rb +116 -0
  126. data/lib/langscan/ocaml.rb +298 -0
  127. data/lib/langscan/ocaml/camlexer.ml +28 -0
  128. data/lib/langscan/ocaml/lexer.mll +230 -0
  129. data/lib/langscan/ocaml/types.ml +36 -0
  130. data/lib/langscan/pairmatcher/pairmatcher.so +0 -0
  131. data/lib/langscan/perl.rb +87 -0
  132. data/lib/langscan/perl/tokenizer.pl +231 -0
  133. data/lib/langscan/php.rb +80 -0
  134. data/lib/langscan/php/php.so +0 -0
  135. data/lib/langscan/python.rb +101 -0
  136. data/lib/langscan/python/python.so +0 -0
  137. data/lib/langscan/rpmspec.rb +71 -0
  138. data/lib/langscan/ruby.rb +164 -0
  139. data/lib/langscan/ruby/compat/README +5 -0
  140. data/lib/langscan/ruby/compat/ripper.rb +4 -0
  141. data/lib/langscan/ruby/compat/ripper.so +0 -0
  142. data/lib/langscan/ruby/compat/ripper/core.rb +918 -0
  143. data/lib/langscan/ruby/compat/ripper/filter.rb +70 -0
  144. data/lib/langscan/ruby/compat/ripper/lexer.rb +179 -0
  145. data/lib/langscan/ruby/compat/ripper/sexp.rb +100 -0
  146. data/lib/langscan/scheme.rb +160 -0
  147. data/lib/langscan/scheme/scheme.so +0 -0
  148. data/lib/langscan/sh.rb +116 -0
  149. data/lib/langscan/sh/sh.so +0 -0
  150. data/lib/langscan/text.rb +37 -0
  151. data/metaconfig +2 -0
  152. data/script/console +10 -0
  153. data/script/destroy +14 -0
  154. data/script/generate +14 -0
  155. data/script/makemanifest.rb +21 -0
  156. data/setup.rb +1604 -0
  157. data/tasks/extconf.rake +13 -0
  158. data/tasks/extconf/langscan.rake +42 -0
  159. data/test/langscan/brainfuck/test/test_scan.rb +55 -0
  160. data/test/langscan/c/test/test_scan.rb +216 -0
  161. data/test/langscan/c/test/test_token.rb +41 -0
  162. data/test/langscan/csharp/test/test_scan.rb +157 -0
  163. data/test/langscan/css/test/test_css.rb +79 -0
  164. data/test/langscan/d/test/test_scan.rb +233 -0
  165. data/test/langscan/d/test/test_token.rb +205 -0
  166. data/test/langscan/eiffel/test/test_eiffel.rb +95 -0
  167. data/test/langscan/elisp/test/test_elisp.rb +177 -0
  168. data/test/langscan/io/test/test_io.rb +79 -0
  169. data/test/langscan/java/test/test_java.rb +74 -0
  170. data/test/langscan/javascript/test/test_javascript.rb +39 -0
  171. data/test/langscan/lua/test/test_lua.rb +69 -0
  172. data/test/langscan/ocaml/test/test_ocaml.rb +161 -0
  173. data/test/langscan/php/test/test_scan.rb +138 -0
  174. data/test/langscan/python/test/test_scan.rb +105 -0
  175. data/test/langscan/rpmspec/test/test_rpmspec.rb +51 -0
  176. data/test/langscan/ruby/test/test_scan.rb +71 -0
  177. data/test/langscan/scheme/test/test_scan.rb +198 -0
  178. data/test/test_helper.rb +7 -0
  179. data/test/test_langscan.rb +123 -0
  180. metadata +320 -0
@@ -0,0 +1,80 @@
1
+ #
2
+ # php.rb - a PHP module of LangScan
3
+ #
4
+ # Copyright (C) 2005 MATSUNO Tokuhiro <tokuhirom at yahoo.co.jp>
5
+ # All rights reserved.
6
+ # This is free software with ABSOLUTELY NO WARRANTY.
7
+ #
8
+ # You can redistribute it and/or modify it under the terms of
9
+ # the GNU General Public License version 2.
10
+ #
11
+
12
+ require 'langscan/php/php'
13
+ require 'langscan/_common'
14
+
15
+ module LangScan
16
+ module PHP
17
+ module_function
18
+
19
+ def name
20
+ "PHP"
21
+ end
22
+
23
+ def abbrev
24
+ "php"
25
+ end
26
+
27
+ def extnames
28
+ [".php"]
29
+ end
30
+
31
+ # LangScan::PHP.scan iterates over PHP program.
32
+ # It yields for each Fragment.
33
+ def scan(input, &block)
34
+ each_fragment(input, &block)
35
+ end
36
+
37
+ # LangScan::PHP.each_fragment iterates over PHP-language fragments in _input_.
38
+ # The fragments contains tokens and inter-token spaces and comments.
39
+ #
40
+ # If a String is specified, the String itself is assumed as a PHP-program.
41
+ # If a IO is specified, the content of the IO is assumed as a PHP-program.
42
+ def each_fragment(input) # :yields: token
43
+ begin
44
+ tokenizer = Tokenizer.new(input)
45
+ while token_info = tokenizer.get_token
46
+ type, text, beg_lineno, beg_columnno, beg_byteno, end_lineno, end_columnno, end_byteno = token_info
47
+ token = Fragment.new(type, text, beg_lineno, beg_byteno)
48
+ if (token.type == :ident or token.type == :funcall) and KeywordsHash[token.text]
49
+ token.type = :keyword
50
+ end
51
+ yield token
52
+ end
53
+ ensure
54
+ tokenizer.close
55
+ end
56
+ end
57
+
58
+ Keywords = %w(
59
+ and or xor __FILE__ exception php_user_filter
60
+ __LINE__ array as break case
61
+ class const continue declare default
62
+ die do echo else elseif
63
+ empty enddeclare endfor endforeach endif
64
+ endswitch endwhile eval exit extends
65
+ for foreach function global if
66
+ include include_once isset list new
67
+ print require require_once return static
68
+ switch unset use var while
69
+ __FUNCTION__ __CLASS__ __METHOD__ final php_user_filter
70
+ interface implements extends public private
71
+ protected abstract clone try catch
72
+ throw cfunction old_function
73
+ )
74
+ KeywordsHash = {}
75
+ Keywords.each {|k| KeywordsHash[k] = k }
76
+
77
+ LangScan.register(self)
78
+ end
79
+ end
80
+
Binary file
@@ -0,0 +1,101 @@
1
+ #
2
+ # python.rb - a python module of LangScan
3
+ #
4
+ # Copyright (C) 2005 Yoshinori K. Okuji <okuji@enbug.org>
5
+ # All rights reserved.
6
+ # This is free software with ABSOLUTELY NO WARRANTY.
7
+ #
8
+ # You can redistribute it and/or modify it under the terms of
9
+ # the GNU General Public License version 2.
10
+ #
11
+
12
+ require 'langscan/python/python'
13
+ require 'langscan/_common'
14
+
15
+ module LangScan
16
+ module Python
17
+ module_function
18
+ def name
19
+ "Python"
20
+ end
21
+
22
+ def abbrev
23
+ "python"
24
+ end
25
+
26
+ def extnames
27
+ [".py"]
28
+ end
29
+
30
+ # LangScan::Python.scan iterates over Python program.
31
+ # It yields for each Fragment.
32
+ def scan(input, &block)
33
+ last_token = nil
34
+ each_fragment(input) {|t|
35
+ if t.type == :space
36
+ yield t
37
+ next
38
+ end
39
+ if last_token
40
+ if t.type == :ident and last_token.type == :keyword
41
+ case last_token.text
42
+ when 'def'
43
+ t.type = :fundef
44
+ when 'class'
45
+ t.type = :classdef
46
+ end
47
+ elsif t.type == :punct and t.text == '(' and last_token.type == :ident
48
+ last_token.type = :funcall
49
+ end
50
+ yield last_token
51
+ last_token = nil
52
+ end
53
+ if t.type == :ident or t.type == :keyword
54
+ last_token = t
55
+ else
56
+ yield t
57
+ end
58
+ }
59
+ if last_token
60
+ yield last_token
61
+ end
62
+ end
63
+
64
+ # LangScan::Python.each_fragment iterates over Python-language fragments in _input_.
65
+ # The fragments contains tokens and inter-token spaces and comments.
66
+ #
67
+ # If a String is specified, the String itself is assumed as a Python-program.
68
+ # If a IO is specified, the content of the IO is assumed as a Python-program.
69
+ def each_fragment(input) # :yields: token
70
+ begin
71
+ tokenizer = Tokenizer.new(input)
72
+ while token_info = tokenizer.get_token
73
+ type, text, beg_lineno, beg_columnno, beg_byteno, end_lineno, end_columnno, end_byteno = token_info
74
+ token = Fragment.new(type, text, beg_lineno, beg_byteno)
75
+ if token.type == :ident
76
+ if KeywordsHash[token.text]
77
+ token.type = :keyword
78
+ end
79
+ end
80
+ yield token
81
+ end
82
+ ensure
83
+ tokenizer.close
84
+ end
85
+ end
86
+
87
+ Keywords = %w(
88
+ and assert break class continue def del elif else except exec finally
89
+ for from global if import in is lambda not or pass print raise return
90
+ try while yield
91
+ )
92
+ FutureKeywords = %w(
93
+ as None
94
+ )
95
+ KeywordsHash = {}
96
+ Keywords.each {|k| KeywordsHash[k] = k }
97
+ FutureKeywords.each {|k| KeywordsHash[k] = k }
98
+
99
+ LangScan.register(self)
100
+ end
101
+ end
@@ -0,0 +1,71 @@
1
+ #
2
+ # rpmspec.rb - RPM SPEC module of LangScan
3
+ #
4
+ # Copyright (C) 2005 Yoshinori KUNIGA <kuniga@users.sourceforge.net>
5
+ # All rights reserved.
6
+ # This is free software with ABSOLUTELY NO WARRANTY.
7
+ #
8
+ # You can redistribute it and/or modify it under the terms of
9
+ # the GNU General Public License version 2.
10
+ #
11
+
12
+ require 'langscan/_easyscanner'
13
+
14
+ module LangScan
15
+ module RPMSpec
16
+ module_function
17
+ def name
18
+ "RPM SPEC"
19
+ end
20
+
21
+ def abbrev
22
+ "rpmspec"
23
+ end
24
+
25
+ def extnames
26
+ [".spec"]
27
+ end
28
+
29
+ # From RPM 4.4.1-21 sources, file build/parsePreamble.c: preambleList[].
30
+ preamble_list = %w(
31
+ name version release epoch serial summary copyright
32
+ license distribution disturl vendor group packager url
33
+ source patch nosource nopatch excludearch exclusivearch
34
+ excludeos exclusiveos icon provides requires prereq
35
+ conflicts obsoletes prefixes prefix buildroot
36
+ buildarchitectures buildarch buildconflicts buildprereq
37
+ buildrequires autoreqprov autoreq autoprov docdir
38
+ rhnplatform disttag
39
+ ).map{|word| [:keyword, "\\A(?i)#{word}\\d*"] }
40
+
41
+ # From RPM 4.4.1-21 sources, file build/parseSpec.c: partList[].
42
+ part_list = %w(
43
+ package prep build install check clean preun postun
44
+ pretrans posttrans pre post files changelog description
45
+ triggerpostun triggerun triggerin trigger verifyscript
46
+ ).map{|word| [:keyword, "\\A%#{word}"] }
47
+
48
+ other_pattern = [[:comment, "#.*"],
49
+ # [:string, "'", "'"],
50
+ [:string, "\"", "\""],
51
+ [:ident, "%\\{\\w+\\}"],
52
+ [:ident, "%\\w+"],
53
+ [:word, "[-\\.\\w]+"]
54
+ ]
55
+
56
+ Pattern = preamble_list + part_list + other_pattern
57
+
58
+ Types = []
59
+
60
+ Keywords = []
61
+
62
+ # LangScan::RPMSpec.scan iterates over RPM SPEC file.
63
+ # It yields for each Fragment.
64
+ def scan(input, &block)
65
+ scanner = EasyScanner.new(Pattern, Types, Keywords)
66
+ scanner.scan(input, &block)
67
+ end
68
+
69
+ LangScan.register(self)
70
+ end
71
+ end
@@ -0,0 +1,164 @@
1
+ #
2
+ # ruby.rb - a Ruby module of LangScan
3
+ #
4
+ # Copyright (C) 2004-2005 Akira Tanaka <akr@m17n.org>
5
+ # All rights reserved.
6
+ # This is free software with ABSOLUTELY NO WARRANTY.
7
+ #
8
+ # You can redistribute it and/or modify it under the terms of
9
+ # the GNU General Public License version 2.
10
+ #
11
+
12
+ begin
13
+ require 'ripper'
14
+ rescue LoadError
15
+ require 'langscan/ruby/compat/ripper'
16
+ end
17
+
18
+ require 'langscan/_common'
19
+
20
+ module LangScan
21
+ module Ruby
22
+ module_function
23
+ def name
24
+ "Ruby"
25
+ end
26
+
27
+ def abbrev
28
+ "ruby"
29
+ end
30
+
31
+ def extnames
32
+ [".rb"]
33
+ end
34
+
35
+ # LangScan::Ruby.scan iterates over Ruby program.
36
+ # It yields for each Fragment.
37
+ def scan(input, &block)
38
+ Parser.new(input).parse(&block)
39
+ end
40
+
41
+ class Parser < Ripper
42
+ def initialize(src)
43
+ super
44
+ @fragments = {}
45
+ @found = {}
46
+ end
47
+ attr_reader :fragments
48
+
49
+ FragmentType = {
50
+ :rparen => :punct,
51
+ :lbrace => :punct,
52
+ :embexpr_end => :punct,
53
+ :__end__ => :punct,
54
+ :tstring_end => :punct,
55
+ :qwords_beg => :punct,
56
+ :ident => :ident,
57
+ :cvar => :ident,
58
+ :semicolon => :punct,
59
+ :lbracket => :punct,
60
+ :embvar => :punct,
61
+ :backref => :punct,
62
+ :words_beg => :punct,
63
+ :rbrace => :punct,
64
+ :ignored_nl => :punct,
65
+ :embdoc => :punct,
66
+ :sp => :space,
67
+ :lparen => :punct,
68
+ :float => :punct,
69
+ :backtick => :punct,
70
+ :words_sep => :punct,
71
+ :rbracket => :punct,
72
+ :int => :integer,
73
+ :embdoc_beg => :punct,
74
+ :symbeg => :punct,
75
+ :nl => :space,
76
+ :gvar => :ident,
77
+ :comma => :punct,
78
+ :regexp_beg => :punct,
79
+ :ivar => :ident,
80
+ :embdoc_end => :punct,
81
+ :tstring_beg => :punct,
82
+ :op => :punct,
83
+ :heredoc_beg => :punct,
84
+ :comment => :comment,
85
+ :regexp_end => :punct,
86
+ :kw => :keyword,
87
+ :embexpr_beg => :punct,
88
+ :tstring_content => :string,
89
+ :period => :punct,
90
+ :heredoc_end => :punct,
91
+ :const => :const,
92
+ :CHAR => :integer,
93
+ }
94
+
95
+ Ripper::SCANNER_EVENTS.each {|ev|
96
+ type = FragmentType[ev]
97
+ define_method("on_#{ev}") {|text|
98
+ key = [lineno, column]
99
+ @fragments[key] = [type, text]
100
+ [text, key]
101
+ }
102
+ }
103
+
104
+ def on_class(*args)
105
+ name_key, * = args
106
+ name, key = name_key
107
+ @found[key] = :classdef
108
+ end
109
+
110
+ def on_module(*args)
111
+ name_key, * = args
112
+ name, key = name_key
113
+ @found[key] = :moduledef
114
+ end
115
+
116
+ def on_def(*args)
117
+ name_key, * = args
118
+ name, key = name_key
119
+ @found[key] = :fundef
120
+ end
121
+
122
+ def on_defs(*args)
123
+ obj, _, name_key, * = args
124
+ name, key = name_key
125
+ @found[key] = :fundef
126
+ end
127
+
128
+ def on_call(recv, _, meth)
129
+ name, key = meth
130
+ @found[key] = :funcall
131
+ end
132
+
133
+ def on_symbol_literal(*args)
134
+ name_key, * = args
135
+ name, key = name_key
136
+ @found[key] = :symbol
137
+ end
138
+
139
+ def parse
140
+ super
141
+ byteno = 0
142
+ @fragments.keys.sort.each {|key|
143
+ type, text = @fragments[key]
144
+ len = text.length
145
+ l1, c1 = key
146
+ if /\n/ =~ text
147
+ l2 = l1+text.count("\n")
148
+ else
149
+ l2 = l1
150
+ end
151
+ byteno2 = byteno+len
152
+ fragment = Fragment.new(type, text, l1, byteno)
153
+ if type = @found[key]
154
+ fragment.type = type
155
+ end
156
+ yield fragment
157
+ byteno = byteno2
158
+ }
159
+ end
160
+ end
161
+
162
+ LangScan.register(self)
163
+ end
164
+ end
@@ -0,0 +1,5 @@
1
+ This directory contains Ripper for Ruby-1.8.
2
+ It is a backport of Ripper distributed as part of Ruby-1.9 (2005-08-29).
3
+
4
+ Ripper is licensed under Ruby license which is a dual license of GPL and
5
+ original one.
@@ -0,0 +1,4 @@
1
+ require 'langscan/ruby/compat/ripper/core'
2
+ require 'langscan/ruby/compat/ripper/lexer'
3
+ require 'langscan/ruby/compat/ripper/filter'
4
+ require 'langscan/ruby/compat/ripper/sexp'
@@ -0,0 +1,918 @@
1
+ # This file is automatically generated from core.rb.in and parse.y.
2
+ # DO NOT MODIFY!!!!!!
3
+
4
+ #
5
+ # ripper/core.rb
6
+ #
7
+ # Copyright (C) 2003,2004 Minero Aoki
8
+ #
9
+ # This program is free software.
10
+ # You can distribute and/or modify this program under the Ruby License.
11
+ # For details of Ruby License, see ruby/COPYING.
12
+ #
13
+
14
+ require 'langscan/ruby/compat/ripper.so'
15
+
16
+ class Ripper
17
+ # Parses Ruby program read from _src_.
18
+ # _src_ must be a String or a IO or a object which has #gets method.
19
+ def Ripper.parse(src, filename = '(ripper)', lineno = 1)
20
+ new(src, filename, lineno).parse
21
+ end
22
+
23
+ # This table contains name of parser events and its arity.
24
+ PARSER_EVENT_TABLE = {
25
+ :BEGIN => 1,
26
+ :END => 1,
27
+ :alias => 2,
28
+ :alias_error => 1,
29
+ :aref => 2,
30
+ :aref_field => 2,
31
+ :arg_ambiguous => 0,
32
+ :arg_paren => 1,
33
+ :arglist_add => 2,
34
+ :arglist_add_block => 2,
35
+ :arglist_add_star => 2,
36
+ :arglist_new => 0,
37
+ :arglist_prepend => 2,
38
+ :array => 1,
39
+ :assign => 2,
40
+ :assign_error => 1,
41
+ :assoc_new => 2,
42
+ :assoclist_from_args => 1,
43
+ :bare_assoc_hash => 1,
44
+ :begin => 1,
45
+ :binary => 3,
46
+ :blockvar_add_block => 2,
47
+ :blockvar_add_star => 2,
48
+ :blockvar_new => 1,
49
+ :bodystmt => 4,
50
+ :brace_block => 2,
51
+ :break => 1,
52
+ :call => 3,
53
+ :case => 2,
54
+ :class => 3,
55
+ :class_name_error => 1,
56
+ :command => 2,
57
+ :command_call => 4,
58
+ :const_ref => 1,
59
+ :constpath_field => 2,
60
+ :constpath_ref => 2,
61
+ :def => 3,
62
+ :defined => 1,
63
+ :defs => 5,
64
+ :do_block => 1,
65
+ :do_block => 2,
66
+ :dot2 => 2,
67
+ :dot3 => 2,
68
+ :dyna_symbol => 1,
69
+ :else => 1,
70
+ :elsif => 3,
71
+ :ensure => 1,
72
+ :fcall => 1,
73
+ :field => 3,
74
+ :for => 3,
75
+ :hash => 1,
76
+ :if => 3,
77
+ :if_mod => 2,
78
+ :ifop => 3,
79
+ :iter_block => 2,
80
+ :lambda => 2,
81
+ :massign => 2,
82
+ :method_add_arg => 2,
83
+ :mlhs_add => 2,
84
+ :mlhs_add_star => 2,
85
+ :mlhs_new => 0,
86
+ :mlhs_paren => 1,
87
+ :module => 2,
88
+ :mrhs_add => 2,
89
+ :mrhs_add_star => 2,
90
+ :mrhs_new => 0,
91
+ :mrhs_new_from_arglist => 1,
92
+ :next => 1,
93
+ :opassign => 3,
94
+ :param_error => 1,
95
+ :params => 4,
96
+ :paren => 1,
97
+ :parse_error => 1,
98
+ :pragma => 2,
99
+ :program => 1,
100
+ :qwords_add => 2,
101
+ :qwords_new => 0,
102
+ :redo => 0,
103
+ :regexp_literal => 2,
104
+ :rescue => 4,
105
+ :rescue_mod => 2,
106
+ :restparam => 1,
107
+ :retry => 0,
108
+ :return => 1,
109
+ :return0 => 0,
110
+ :sclass => 2,
111
+ :space => 1,
112
+ :stmts_add => 2,
113
+ :stmts_new => 0,
114
+ :string_add => 2,
115
+ :string_concat => 2,
116
+ :string_content => 0,
117
+ :string_dvar => 1,
118
+ :string_embexpr => 1,
119
+ :string_literal => 1,
120
+ :super => 1,
121
+ :symbol => 1,
122
+ :symbol_literal => 1,
123
+ :topconst_field => 1,
124
+ :topconst_ref => 1,
125
+ :unary => 2,
126
+ :undef => 1,
127
+ :unless => 3,
128
+ :unless_mod => 2,
129
+ :until => 2,
130
+ :until_mod => 2,
131
+ :var_alias => 2,
132
+ :var_field => 1,
133
+ :var_ref => 1,
134
+ :void_stmt => 0,
135
+ :when => 3,
136
+ :while => 2,
137
+ :while_mod => 2,
138
+ :word_add => 2,
139
+ :word_new => 0,
140
+ :words_add => 2,
141
+ :words_new => 0,
142
+ :xstring_add => 2,
143
+ :xstring_literal => 1,
144
+ :xstring_new => 0,
145
+ :yield => 1,
146
+ :yield0 => 0,
147
+ :zsuper => 0
148
+ }
149
+
150
+ # This array contains name of parser events.
151
+ PARSER_EVENTS = PARSER_EVENT_TABLE.keys
152
+
153
+ # This table contains name of scanner events and its arity
154
+ # (arity is always 1 for all scanner events).
155
+ SCANNER_EVENT_TABLE = {
156
+ :CHAR => 1,
157
+ :__end__ => 1,
158
+ :backref => 1,
159
+ :backtick => 1,
160
+ :comma => 1,
161
+ :comment => 1,
162
+ :const => 1,
163
+ :cvar => 1,
164
+ :embdoc => 1,
165
+ :embdoc_beg => 1,
166
+ :embdoc_end => 1,
167
+ :embexpr_beg => 1,
168
+ :embexpr_end => 1,
169
+ :embvar => 1,
170
+ :float => 1,
171
+ :gvar => 1,
172
+ :heredoc_beg => 1,
173
+ :heredoc_end => 1,
174
+ :ident => 1,
175
+ :ignored_nl => 1,
176
+ :int => 1,
177
+ :ivar => 1,
178
+ :kw => 1,
179
+ :label => 1,
180
+ :lambda => 1,
181
+ :lambda_arg => 1,
182
+ :lambeg => 1,
183
+ :lbrace => 1,
184
+ :lbracket => 1,
185
+ :lparen => 1,
186
+ :nl => 1,
187
+ :op => 1,
188
+ :period => 1,
189
+ :qwords_beg => 1,
190
+ :rbrace => 1,
191
+ :rbracket => 1,
192
+ :regexp_beg => 1,
193
+ :regexp_end => 1,
194
+ :rparen => 1,
195
+ :semicolon => 1,
196
+ :sp => 1,
197
+ :symbeg => 1,
198
+ :tstring_beg => 1,
199
+ :tstring_content => 1,
200
+ :tstring_end => 1,
201
+ :words_beg => 1,
202
+ :words_sep => 1
203
+ }
204
+
205
+ # This array contains name of scanner events.
206
+ SCANNER_EVENTS = SCANNER_EVENT_TABLE.keys
207
+
208
+ # This table contains name of all ripper events.
209
+ EVENTS = PARSER_EVENTS + SCANNER_EVENTS
210
+
211
+ ### ###
212
+ ### Event Handlers ###
213
+ ### ###
214
+
215
+ private
216
+
217
+ # This method is called when weak warning is produced by the parser.
218
+ # _fmt_ and _args_ is printf style.
219
+ def warn(fmt, *args)
220
+ end
221
+
222
+ # This method is called when strong warning is produced by the parser.
223
+ # _fmt_ and _args_ is printf style.
224
+ def warning(fmt, *args)
225
+ end
226
+
227
+ # This method is called when the parser found syntax error.
228
+ def compile_error(msg)
229
+ end
230
+
231
+ #
232
+ # Parser Events
233
+ #
234
+
235
+ def on_BEGIN(a)
236
+ a
237
+ end
238
+
239
+ def on_END(a)
240
+ a
241
+ end
242
+
243
+ def on_alias(a, b)
244
+ a
245
+ end
246
+
247
+ def on_alias_error(a)
248
+ a
249
+ end
250
+
251
+ def on_aref(a, b)
252
+ a
253
+ end
254
+
255
+ def on_aref_field(a, b)
256
+ a
257
+ end
258
+
259
+ def on_arg_ambiguous
260
+ nil
261
+ end
262
+
263
+ def on_arg_paren(a)
264
+ a
265
+ end
266
+
267
+ def on_arglist_add(a, b)
268
+ a
269
+ end
270
+
271
+ def on_arglist_add_block(a, b)
272
+ a
273
+ end
274
+
275
+ def on_arglist_add_star(a, b)
276
+ a
277
+ end
278
+
279
+ def on_arglist_new
280
+ nil
281
+ end
282
+
283
+ def on_arglist_prepend(a, b)
284
+ a
285
+ end
286
+
287
+ def on_array(a)
288
+ a
289
+ end
290
+
291
+ def on_assign(a, b)
292
+ a
293
+ end
294
+
295
+ def on_assign_error(a)
296
+ a
297
+ end
298
+
299
+ def on_assoc_new(a, b)
300
+ a
301
+ end
302
+
303
+ def on_assoclist_from_args(a)
304
+ a
305
+ end
306
+
307
+ def on_bare_assoc_hash(a)
308
+ a
309
+ end
310
+
311
+ def on_begin(a)
312
+ a
313
+ end
314
+
315
+ def on_binary(a, b, c)
316
+ a
317
+ end
318
+
319
+ def on_blockvar_add_block(a, b)
320
+ a
321
+ end
322
+
323
+ def on_blockvar_add_star(a, b)
324
+ a
325
+ end
326
+
327
+ def on_blockvar_new(a)
328
+ a
329
+ end
330
+
331
+ def on_bodystmt(a, b, c, d)
332
+ a
333
+ end
334
+
335
+ def on_brace_block(a, b)
336
+ a
337
+ end
338
+
339
+ def on_break(a)
340
+ a
341
+ end
342
+
343
+ def on_call(a, b, c)
344
+ a
345
+ end
346
+
347
+ def on_case(a, b)
348
+ a
349
+ end
350
+
351
+ def on_class(a, b, c)
352
+ a
353
+ end
354
+
355
+ def on_class_name_error(a)
356
+ a
357
+ end
358
+
359
+ def on_command(a, b)
360
+ a
361
+ end
362
+
363
+ def on_command_call(a, b, c, d)
364
+ a
365
+ end
366
+
367
+ def on_const_ref(a)
368
+ a
369
+ end
370
+
371
+ def on_constpath_field(a, b)
372
+ a
373
+ end
374
+
375
+ def on_constpath_ref(a, b)
376
+ a
377
+ end
378
+
379
+ def on_def(a, b, c)
380
+ a
381
+ end
382
+
383
+ def on_defined(a)
384
+ a
385
+ end
386
+
387
+ def on_defs(a, b, c, d, e)
388
+ a
389
+ end
390
+
391
+ def on_do_block(a)
392
+ a
393
+ end
394
+
395
+ def on_do_block(a, b)
396
+ a
397
+ end
398
+
399
+ def on_dot2(a, b)
400
+ a
401
+ end
402
+
403
+ def on_dot3(a, b)
404
+ a
405
+ end
406
+
407
+ def on_dyna_symbol(a)
408
+ a
409
+ end
410
+
411
+ def on_else(a)
412
+ a
413
+ end
414
+
415
+ def on_elsif(a, b, c)
416
+ a
417
+ end
418
+
419
+ def on_ensure(a)
420
+ a
421
+ end
422
+
423
+ def on_fcall(a)
424
+ a
425
+ end
426
+
427
+ def on_field(a, b, c)
428
+ a
429
+ end
430
+
431
+ def on_for(a, b, c)
432
+ a
433
+ end
434
+
435
+ def on_hash(a)
436
+ a
437
+ end
438
+
439
+ def on_if(a, b, c)
440
+ a
441
+ end
442
+
443
+ def on_if_mod(a, b)
444
+ a
445
+ end
446
+
447
+ def on_ifop(a, b, c)
448
+ a
449
+ end
450
+
451
+ def on_iter_block(a, b)
452
+ a
453
+ end
454
+
455
+ def on_lambda(a, b)
456
+ a
457
+ end
458
+
459
+ def on_massign(a, b)
460
+ a
461
+ end
462
+
463
+ def on_method_add_arg(a, b)
464
+ a
465
+ end
466
+
467
+ def on_mlhs_add(a, b)
468
+ a
469
+ end
470
+
471
+ def on_mlhs_add_star(a, b)
472
+ a
473
+ end
474
+
475
+ def on_mlhs_new
476
+ nil
477
+ end
478
+
479
+ def on_mlhs_paren(a)
480
+ a
481
+ end
482
+
483
+ def on_module(a, b)
484
+ a
485
+ end
486
+
487
+ def on_mrhs_add(a, b)
488
+ a
489
+ end
490
+
491
+ def on_mrhs_add_star(a, b)
492
+ a
493
+ end
494
+
495
+ def on_mrhs_new
496
+ nil
497
+ end
498
+
499
+ def on_mrhs_new_from_arglist(a)
500
+ a
501
+ end
502
+
503
+ def on_next(a)
504
+ a
505
+ end
506
+
507
+ def on_opassign(a, b, c)
508
+ a
509
+ end
510
+
511
+ def on_param_error(a)
512
+ a
513
+ end
514
+
515
+ def on_params(a, b, c, d)
516
+ a
517
+ end
518
+
519
+ def on_paren(a)
520
+ a
521
+ end
522
+
523
+ def on_parse_error(a)
524
+ a
525
+ end
526
+
527
+ def on_pragma(a, b)
528
+ a
529
+ end
530
+
531
+ def on_program(a)
532
+ a
533
+ end
534
+
535
+ def on_qwords_add(a, b)
536
+ a
537
+ end
538
+
539
+ def on_qwords_new
540
+ nil
541
+ end
542
+
543
+ def on_redo
544
+ nil
545
+ end
546
+
547
+ def on_regexp_literal(a, b)
548
+ a
549
+ end
550
+
551
+ def on_rescue(a, b, c, d)
552
+ a
553
+ end
554
+
555
+ def on_rescue_mod(a, b)
556
+ a
557
+ end
558
+
559
+ def on_restparam(a)
560
+ a
561
+ end
562
+
563
+ def on_retry
564
+ nil
565
+ end
566
+
567
+ def on_return(a)
568
+ a
569
+ end
570
+
571
+ def on_return0
572
+ nil
573
+ end
574
+
575
+ def on_sclass(a, b)
576
+ a
577
+ end
578
+
579
+ def on_space(a)
580
+ a
581
+ end
582
+
583
+ def on_stmts_add(a, b)
584
+ a
585
+ end
586
+
587
+ def on_stmts_new
588
+ nil
589
+ end
590
+
591
+ def on_string_add(a, b)
592
+ a
593
+ end
594
+
595
+ def on_string_concat(a, b)
596
+ a
597
+ end
598
+
599
+ def on_string_content
600
+ nil
601
+ end
602
+
603
+ def on_string_dvar(a)
604
+ a
605
+ end
606
+
607
+ def on_string_embexpr(a)
608
+ a
609
+ end
610
+
611
+ def on_string_literal(a)
612
+ a
613
+ end
614
+
615
+ def on_super(a)
616
+ a
617
+ end
618
+
619
+ def on_symbol(a)
620
+ a
621
+ end
622
+
623
+ def on_symbol_literal(a)
624
+ a
625
+ end
626
+
627
+ def on_topconst_field(a)
628
+ a
629
+ end
630
+
631
+ def on_topconst_ref(a)
632
+ a
633
+ end
634
+
635
+ def on_unary(a, b)
636
+ a
637
+ end
638
+
639
+ def on_undef(a)
640
+ a
641
+ end
642
+
643
+ def on_unless(a, b, c)
644
+ a
645
+ end
646
+
647
+ def on_unless_mod(a, b)
648
+ a
649
+ end
650
+
651
+ def on_until(a, b)
652
+ a
653
+ end
654
+
655
+ def on_until_mod(a, b)
656
+ a
657
+ end
658
+
659
+ def on_var_alias(a, b)
660
+ a
661
+ end
662
+
663
+ def on_var_field(a)
664
+ a
665
+ end
666
+
667
+ def on_var_ref(a)
668
+ a
669
+ end
670
+
671
+ def on_void_stmt
672
+ nil
673
+ end
674
+
675
+ def on_when(a, b, c)
676
+ a
677
+ end
678
+
679
+ def on_while(a, b)
680
+ a
681
+ end
682
+
683
+ def on_while_mod(a, b)
684
+ a
685
+ end
686
+
687
+ def on_word_add(a, b)
688
+ a
689
+ end
690
+
691
+ def on_word_new
692
+ nil
693
+ end
694
+
695
+ def on_words_add(a, b)
696
+ a
697
+ end
698
+
699
+ def on_words_new
700
+ nil
701
+ end
702
+
703
+ def on_xstring_add(a, b)
704
+ a
705
+ end
706
+
707
+ def on_xstring_literal(a)
708
+ a
709
+ end
710
+
711
+ def on_xstring_new
712
+ nil
713
+ end
714
+
715
+ def on_yield(a)
716
+ a
717
+ end
718
+
719
+ def on_yield0
720
+ nil
721
+ end
722
+
723
+ def on_zsuper
724
+ nil
725
+ end
726
+
727
+ #
728
+ # Lexer Events
729
+ #
730
+
731
+ def on_CHAR(token)
732
+ token
733
+ end
734
+
735
+ def on___end__(token)
736
+ token
737
+ end
738
+
739
+ def on_backref(token)
740
+ token
741
+ end
742
+
743
+ def on_backtick(token)
744
+ token
745
+ end
746
+
747
+ def on_comma(token)
748
+ token
749
+ end
750
+
751
+ def on_comment(token)
752
+ token
753
+ end
754
+
755
+ def on_const(token)
756
+ token
757
+ end
758
+
759
+ def on_cvar(token)
760
+ token
761
+ end
762
+
763
+ def on_embdoc(token)
764
+ token
765
+ end
766
+
767
+ def on_embdoc_beg(token)
768
+ token
769
+ end
770
+
771
+ def on_embdoc_end(token)
772
+ token
773
+ end
774
+
775
+ def on_embexpr_beg(token)
776
+ token
777
+ end
778
+
779
+ def on_embexpr_end(token)
780
+ token
781
+ end
782
+
783
+ def on_embvar(token)
784
+ token
785
+ end
786
+
787
+ def on_float(token)
788
+ token
789
+ end
790
+
791
+ def on_gvar(token)
792
+ token
793
+ end
794
+
795
+ def on_heredoc_beg(token)
796
+ token
797
+ end
798
+
799
+ def on_heredoc_end(token)
800
+ token
801
+ end
802
+
803
+ def on_ident(token)
804
+ token
805
+ end
806
+
807
+ def on_ignored_nl(token)
808
+ token
809
+ end
810
+
811
+ def on_int(token)
812
+ token
813
+ end
814
+
815
+ def on_ivar(token)
816
+ token
817
+ end
818
+
819
+ def on_kw(token)
820
+ token
821
+ end
822
+
823
+ def on_label(token)
824
+ token
825
+ end
826
+
827
+ def on_lambda(token)
828
+ token
829
+ end
830
+
831
+ def on_lambda_arg(token)
832
+ token
833
+ end
834
+
835
+ def on_lambeg(token)
836
+ token
837
+ end
838
+
839
+ def on_lbrace(token)
840
+ token
841
+ end
842
+
843
+ def on_lbracket(token)
844
+ token
845
+ end
846
+
847
+ def on_lparen(token)
848
+ token
849
+ end
850
+
851
+ def on_nl(token)
852
+ token
853
+ end
854
+
855
+ def on_op(token)
856
+ token
857
+ end
858
+
859
+ def on_period(token)
860
+ token
861
+ end
862
+
863
+ def on_qwords_beg(token)
864
+ token
865
+ end
866
+
867
+ def on_rbrace(token)
868
+ token
869
+ end
870
+
871
+ def on_rbracket(token)
872
+ token
873
+ end
874
+
875
+ def on_regexp_beg(token)
876
+ token
877
+ end
878
+
879
+ def on_regexp_end(token)
880
+ token
881
+ end
882
+
883
+ def on_rparen(token)
884
+ token
885
+ end
886
+
887
+ def on_semicolon(token)
888
+ token
889
+ end
890
+
891
+ def on_sp(token)
892
+ token
893
+ end
894
+
895
+ def on_symbeg(token)
896
+ token
897
+ end
898
+
899
+ def on_tstring_beg(token)
900
+ token
901
+ end
902
+
903
+ def on_tstring_content(token)
904
+ token
905
+ end
906
+
907
+ def on_tstring_end(token)
908
+ token
909
+ end
910
+
911
+ def on_words_beg(token)
912
+ token
913
+ end
914
+
915
+ def on_words_sep(token)
916
+ token
917
+ end
918
+ end