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,50 @@
1
+ #
2
+ # _common.rb - a part of LangScan
3
+ #
4
+ # Copyright (C) 2004-2005 Akira Tanaka <akr@m17n.org>
5
+ # Copyright (C) 2004-2005 Satoru Takabayashi <satoru@namazu.org>
6
+ # All rights reserved.
7
+ # This is free software with ABSOLUTELY NO WARRANTY.
8
+ #
9
+ # You can redistribute it and/or modify it under the terms of
10
+ # the GNU General Public License version 2.
11
+ #
12
+
13
+ require 'langscan/_type'
14
+
15
+ module LangScan
16
+ class ScanFailed < StandardError; end
17
+
18
+ Fragment = Struct.new(
19
+ :type, :text,
20
+ :beg_lineno, :beg_byteno)
21
+
22
+ # LangScan::Fragment has following variables.
23
+ # * _type_ is symbol that denotes Type of the fragment(e.g. :string, :comment,...).
24
+ # * _text_ is string that contains text of the fragment.
25
+ # * _lineno_ is number of lines where the fragment appears.
26
+ # * _byteno_ is number of bytes where the fragment appears.
27
+ class Fragment
28
+ alias_method :lineno, :beg_lineno
29
+ alias_method :byteno, :beg_byteno
30
+
31
+ def inspect
32
+ "\#<#{self.class} #{type} #{text.inspect} #{beg_lineno} (#{beg_byteno})>"
33
+ end
34
+
35
+ def pretty_print(q)
36
+ q.text inspect
37
+ end
38
+
39
+ def end_byteno
40
+ self.beg_byteno + self.text.length
41
+ end
42
+ end
43
+
44
+ unless respond_to?(:register)
45
+ # stub
46
+ def register(mod)
47
+ end
48
+ module_function :register
49
+ end
50
+ end
@@ -0,0 +1,78 @@
1
+ #
2
+ # _easyscanner.rb - simple scanner for LangScan
3
+ #
4
+ # Copyright (C) 2005 Keisuke Nishida <knishida@open-cobol.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/_common'
13
+
14
+ module LangScan
15
+ class EasyScanner
16
+ def initialize(pattern, types, keywords)
17
+ @pattern = pattern
18
+
19
+ # build regexp
20
+ regexp = "(\n)|" + @pattern.map {|v| "(" + v[1] + ")"}.join("|")
21
+ @regexp = Regexp.new(regexp)
22
+
23
+ # build type hash
24
+ @type = {}
25
+ types.each {|k| @type[k] = true }
26
+
27
+ # build keyword hash
28
+ @keyword = {}
29
+ keywords.each {|k| @keyword[k] = true }
30
+ end
31
+
32
+ def scan(input, &block)
33
+ lineno = 0
34
+ offset = 0
35
+ while match = @regexp.match(input[offset..-1])
36
+ if match[1]
37
+ # newline
38
+ lineno += 1
39
+ offset += match.end(0)
40
+ else
41
+ for i in 2..match.size-1
42
+ if match[i]
43
+ type = @pattern[i-2][0]
44
+ byteno = offset + match.begin(0)
45
+ if @pattern[i-2][2]
46
+ # pattern with terminator
47
+ start = offset + match.end(0)
48
+ end_match = input[start..-1].match(@pattern[i-2][2])
49
+ if end_match
50
+ offset = start + end_match.end(0)
51
+ else
52
+ # not terminated! what should we do?
53
+ offset = start
54
+ end
55
+ else
56
+ # simple pattern
57
+ offset += match.end(0)
58
+ end
59
+ text = input[byteno..offset-1]
60
+ if type == :ident
61
+ case true
62
+ when @type[text]
63
+ type = :type
64
+ when @keyword[text]
65
+ type = :keyword
66
+ end
67
+ end
68
+ yield(Fragment.new(type, text, lineno, byteno))
69
+ lineno += text.count("\n")
70
+ break
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+
@@ -0,0 +1,46 @@
1
+ #
2
+ # pairmatcher.rb - a pair matching parser
3
+ #
4
+ # Copyright (C) 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
+ require 'langscan/_common'
13
+ require 'langscan/pairmatcher/pairmatcher'
14
+
15
+ class Struct::LangScanPair
16
+ def outmost
17
+ ret = self
18
+ while o = ret.outer
19
+ ret = o
20
+ end
21
+ ret
22
+ end
23
+
24
+ end
25
+
26
+ module LangScan
27
+ def PairMatcher.fragmentsorter(block)
28
+ buf = []
29
+ pos = 0
30
+ lambda {|f|
31
+ if pos == f.beg_byteno
32
+ pos += f.text.length
33
+ block.call(f)
34
+ buf.sort! {|f1, f2| f1.beg_byteno <=> f2.beg_byteno }
35
+ while !buf.empty? && buf.first.beg_byteno == pos
36
+ f = buf.first
37
+ pos += f.text.length
38
+ block.call(f)
39
+ buf.shift
40
+ end
41
+ else
42
+ buf << f
43
+ end
44
+ }
45
+ end
46
+ end
@@ -0,0 +1,125 @@
1
+ #
2
+ # _type.rb - a part of LangScan
3
+ #
4
+ # Copyright (C) 2004-2005 Satoru Takabayashi <satoru@namazu.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
+ module LangScan
13
+ module Type
14
+ def self.N_ (dummy); dummy; end
15
+
16
+ class TypeGroup
17
+ def initialize(name)
18
+ @name = name
19
+ @members = []
20
+ @by_type = {}
21
+ end
22
+ attr_reader :name
23
+
24
+ def << (info)
25
+ @members.push(info)
26
+ @by_type[info.type] = info
27
+ end
28
+
29
+ def has_type?(type)
30
+ @by_type.include?(type)
31
+ end
32
+
33
+ def each
34
+ @members.each {|info| yield(info) }
35
+ end
36
+
37
+ def [] (i)
38
+ if i.is_a?(Integer)
39
+ @members[i]
40
+ else
41
+ @by_type[i]
42
+ end
43
+ end
44
+ end
45
+
46
+ TypeRegistry = {}
47
+
48
+ class TypeInfo
49
+ def initialize(type, name)
50
+ @type = type
51
+ @name = name
52
+ TypeRegistry[@type] = true
53
+ end
54
+ attr_reader :type
55
+ attr_reader :name
56
+ end
57
+
58
+ FunctionGroup = TypeGroup.new(N_("Function"))
59
+ FunctionGroup << TypeInfo.new(:fundef, N_("Function Definition"))
60
+ FunctionGroup << TypeInfo.new(:funcall, N_("Function Call"))
61
+ FunctionGroup << TypeInfo.new(:fundecl, N_("Function Declaration"))
62
+
63
+ ObjectGroup = TypeGroup.new(N_("Object"))
64
+ ObjectGroup << TypeInfo.new(:classdef, N_("Class Definition"))
65
+ ObjectGroup << TypeInfo.new(:classref, N_("Class Reference"))
66
+ ObjectGroup << TypeInfo.new(:moduledef, N_("Module Definition"))
67
+
68
+ LiteralGroup = TypeGroup.new(N_("Literal"))
69
+ LiteralGroup << TypeInfo.new(:const, N_("Constant"))
70
+ LiteralGroup << TypeInfo.new(:word, N_("Word"))
71
+ LiteralGroup << TypeInfo.new(:ident, N_("Identifier"))
72
+ LiteralGroup << TypeInfo.new(:integer, N_("Integer"))
73
+ LiteralGroup << TypeInfo.new(:floating, N_("Floating"))
74
+ LiteralGroup << TypeInfo.new(:imaginary, N_("Imaginary"))
75
+ LiteralGroup << TypeInfo.new(:string, N_("String"))
76
+ LiteralGroup << TypeInfo.new(:symbol, N_("Symbol"))
77
+ LiteralGroup << TypeInfo.new(:character, N_("Character"))
78
+ LiteralGroup << TypeInfo.new(:comment, N_("Comment"))
79
+
80
+ KeywordGroup = TypeGroup.new(N_("Keyword"))
81
+ KeywordGroup << TypeInfo.new(:keyword, N_("Keyword"))
82
+ KeywordGroup << TypeInfo.new(:type, N_("Primitive Type"))
83
+
84
+ TextGroup = TypeGroup.new(N_("Text"))
85
+ TextGroup << TypeInfo.new(:text, N_("Text"))
86
+
87
+ AllGroups = [
88
+ FunctionGroup, ObjectGroup, LiteralGroup,
89
+ KeywordGroup, TextGroup
90
+ ]
91
+
92
+ module_function
93
+ def function?(type)
94
+ FunctionGroup.has_type?(type)
95
+ end
96
+
97
+ def include?(type)
98
+ TypeRegistry.include?(type)
99
+ end
100
+
101
+ SplittableTypes = {}
102
+ [:string, :comment, :text].each {|type| SplittableTypes[type] = true }
103
+ def splittable?(type)
104
+ SplittableTypes.include?(type)
105
+ end
106
+
107
+ def highlightable?(type)
108
+ ! splittable?(type)
109
+ end
110
+
111
+ def each_group
112
+ AllGroups.each {|group|
113
+ yield(group)
114
+ }
115
+ end
116
+
117
+ def each
118
+ each_group {|group|
119
+ group.each {|info|
120
+ yield(info)
121
+ }
122
+ }
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,51 @@
1
+ #
2
+ # autoconf.rb - Autoconf module of LangScan
3
+ #
4
+ # Copyright (C) 2005 Keisuke Nishida <knishida@open-cobol.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/_easyscanner'
13
+
14
+ module LangScan
15
+ module Autoconf
16
+ module_function
17
+ def name
18
+ "Autoconf"
19
+ end
20
+
21
+ def abbrev
22
+ "autoconf"
23
+ end
24
+
25
+ def extnames
26
+ [".ac"]
27
+ end
28
+
29
+ Pattern = [[:comment, "#.*"],
30
+ [:string, "\"", "\""],
31
+ [:string, "'", "'"],
32
+ [:integer, "\\d+"],
33
+ [:ident, "\\w+"],
34
+ [:keyword, "AC_\\w+"]]
35
+
36
+ Types = []
37
+
38
+ Keywords = %w(
39
+ if then else elif fi continue for in do done case esac exit
40
+ )
41
+
42
+ # LangScan::Autoconf.scan iterates over autoconf file.
43
+ # It yields for each Fragment.
44
+ def scan(input, &block)
45
+ scanner = EasyScanner.new(Pattern, Types, Keywords)
46
+ scanner.scan(input, &block)
47
+ end
48
+
49
+ LangScan.register(self)
50
+ end
51
+ end
@@ -0,0 +1,51 @@
1
+ #
2
+ # automake.rb - Automake module of LangScan
3
+ #
4
+ # Copyright (C) 2005 Keisuke Nishida <knishida@open-cobol.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/_easyscanner'
13
+
14
+ module LangScan
15
+ module Automake
16
+ module_function
17
+ def name
18
+ "Automake"
19
+ end
20
+
21
+ def abbrev
22
+ "automake"
23
+ end
24
+
25
+ def extnames
26
+ [".am"]
27
+ end
28
+
29
+ Pattern = [[:comment, "#.*"],
30
+ [:string, "\"", "\""],
31
+ [:string, "'", "'"],
32
+ [:integer, "\\d+"],
33
+ [:ident, "\\w+"],
34
+ [:keyword, "[-\\.\\w]+:"]]
35
+
36
+ Types = []
37
+
38
+ Keywords = %w(
39
+ if then else elif fi continue for in do done case esac exit
40
+ )
41
+
42
+ # LangScan::Automake.scan iterates over automake file.
43
+ # It yields for each Fragment.
44
+ def scan(input, &block)
45
+ scanner = EasyScanner.new(Pattern, Types, Keywords)
46
+ scanner.scan(input, &block)
47
+ end
48
+
49
+ LangScan.register(self)
50
+ end
51
+ end
@@ -0,0 +1,48 @@
1
+ #
2
+ # brainfuck.rb - a Brainfuck 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/_easyscanner'
13
+
14
+ module LangScan
15
+ module Brainfuck
16
+ module_function
17
+ def name
18
+ "BrainFuck"
19
+ end
20
+
21
+ def abbrev
22
+ "bf"
23
+ end
24
+
25
+ def extnames
26
+ [".bf"]
27
+ end
28
+
29
+ Pattern = [
30
+ [:ident, '[<>+\\-.,\[\]]'],
31
+ [:comment, '[^<>+\\-.,\[\]]+'],
32
+ ]
33
+
34
+ Types = []
35
+
36
+ Keywords = []
37
+
38
+ # LangScan::Brainfuck.scan iterates over Brainfuck program.
39
+ # It yields for each Fragment.
40
+ def scan(input, &block)
41
+ EasyScanner.new(Pattern, Types, Keywords).scan(input) {|t|
42
+ yield t
43
+ }
44
+ end
45
+
46
+ LangScan.register(self)
47
+ end
48
+ end