langscan 1.2-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS.txt +19 -0
- data/History.txt +126 -0
- data/Manifest.txt +167 -0
- data/README.rdoc +91 -0
- data/Rakefile +40 -0
- data/ext/langscan/_make_c.rb +20 -0
- data/ext/langscan/_make_h.rb +30 -0
- data/ext/langscan/_template.c +134 -0
- data/ext/langscan/_template.h +53 -0
- data/ext/langscan/c/c/Makefile +188 -0
- data/ext/langscan/c/c/c.c +134 -0
- data/ext/langscan/c/c/c.h +66 -0
- data/ext/langscan/c/c/ctok.c +4629 -0
- data/ext/langscan/c/c/ctok.l +212 -0
- data/ext/langscan/c/c/extconf.rb +3 -0
- data/ext/langscan/c/c/modulename.txt +1 -0
- data/ext/langscan/c/c/tokenlist.txt +13 -0
- data/ext/langscan/csharp/csharp/Makefile +188 -0
- data/ext/langscan/csharp/csharp/csharp.c +134 -0
- data/ext/langscan/csharp/csharp/csharp.h +65 -0
- data/ext/langscan/csharp/csharp/csharptok.c +2971 -0
- data/ext/langscan/csharp/csharp/csharptok.l +200 -0
- data/ext/langscan/csharp/csharp/extconf.rb +3 -0
- data/ext/langscan/csharp/csharp/modulename.txt +1 -0
- data/ext/langscan/csharp/csharp/tokenlist.txt +12 -0
- data/ext/langscan/d/d/Makefile +188 -0
- data/ext/langscan/d/d/d.c +134 -0
- data/ext/langscan/d/d/d.h +64 -0
- data/ext/langscan/d/d/dtok.c +5468 -0
- data/ext/langscan/d/d/dtok.l +282 -0
- data/ext/langscan/d/d/extconf.rb +3 -0
- data/ext/langscan/d/d/modulename.txt +1 -0
- data/ext/langscan/d/d/tokenlist.txt +11 -0
- data/ext/langscan/elisp/elisp/Makefile +188 -0
- data/ext/langscan/elisp/elisp/elisp.c +134 -0
- data/ext/langscan/elisp/elisp/elisp.h +62 -0
- data/ext/langscan/elisp/elisp/elisptok.c +2108 -0
- data/ext/langscan/elisp/elisp/elisptok.l +151 -0
- data/ext/langscan/elisp/elisp/extconf.rb +3 -0
- data/ext/langscan/elisp/elisp/modulename.txt +1 -0
- data/ext/langscan/elisp/elisp/tokenlist.txt +9 -0
- data/ext/langscan/java/java/Makefile +188 -0
- data/ext/langscan/java/java/extconf.rb +3 -0
- data/ext/langscan/java/java/java.c +134 -0
- data/ext/langscan/java/java/java.h +64 -0
- data/ext/langscan/java/java/javatok.c +2097 -0
- data/ext/langscan/java/java/javatok.l +155 -0
- data/ext/langscan/java/java/modulename.txt +1 -0
- data/ext/langscan/java/java/tokenlist.txt +11 -0
- data/ext/langscan/javascript/javascript/Makefile +188 -0
- data/ext/langscan/javascript/javascript/extconf.rb +3 -0
- data/ext/langscan/javascript/javascript/javascript.c +134 -0
- data/ext/langscan/javascript/javascript/javascript.h +63 -0
- data/ext/langscan/javascript/javascript/javascripttok.c +2058 -0
- data/ext/langscan/javascript/javascript/javascripttok.l +147 -0
- data/ext/langscan/javascript/javascript/modulename.txt +1 -0
- data/ext/langscan/javascript/javascript/tokenlist.txt +10 -0
- data/ext/langscan/pairmatcher/pairmatcher/Makefile +188 -0
- data/ext/langscan/pairmatcher/pairmatcher/extconf.rb +3 -0
- data/ext/langscan/pairmatcher/pairmatcher/pairmatcher.c +890 -0
- data/ext/langscan/php/php/Makefile +188 -0
- data/ext/langscan/php/php/extconf.rb +3 -0
- data/ext/langscan/php/php/modulename.txt +1 -0
- data/ext/langscan/php/php/php.c +134 -0
- data/ext/langscan/php/php/php.h +64 -0
- data/ext/langscan/php/php/phptok.c +2413 -0
- data/ext/langscan/php/php/phptok.l +212 -0
- data/ext/langscan/php/php/tokenlist.txt +11 -0
- data/ext/langscan/post-distclean.rb +21 -0
- data/ext/langscan/pre-config.rb +57 -0
- data/ext/langscan/python/python/Makefile +188 -0
- data/ext/langscan/python/python/extconf.rb +3 -0
- data/ext/langscan/python/python/modulename.txt +1 -0
- data/ext/langscan/python/python/python.c +134 -0
- data/ext/langscan/python/python/python.h +61 -0
- data/ext/langscan/python/python/pythontok.c +2109 -0
- data/ext/langscan/python/python/pythontok.l +155 -0
- data/ext/langscan/python/python/tokenlist.txt +8 -0
- data/ext/langscan/ruby/compat/ripper/Makefile +189 -0
- data/ext/langscan/ruby/compat/ripper/depend +1 -0
- data/ext/langscan/ruby/compat/ripper/extconf.rb +4 -0
- data/ext/langscan/ruby/compat/ripper/include/eventids1.c +251 -0
- data/ext/langscan/ruby/compat/ripper/include/eventids2.c +277 -0
- data/ext/langscan/ruby/compat/ripper/include/lex.c +138 -0
- data/ext/langscan/ruby/compat/ripper/ripper.c +14420 -0
- data/ext/langscan/scheme/scheme/Makefile +188 -0
- data/ext/langscan/scheme/scheme/extconf.rb +3 -0
- data/ext/langscan/scheme/scheme/modulename.txt +1 -0
- data/ext/langscan/scheme/scheme/scheme.c +134 -0
- data/ext/langscan/scheme/scheme/scheme.h +60 -0
- data/ext/langscan/scheme/scheme/schemetok.c +2454 -0
- data/ext/langscan/scheme/scheme/schemetok.l +177 -0
- data/ext/langscan/scheme/scheme/tokenlist.txt +7 -0
- data/ext/langscan/sh/sh/Makefile +188 -0
- data/ext/langscan/sh/sh/extconf.rb +3 -0
- data/ext/langscan/sh/sh/modulename.txt +1 -0
- data/ext/langscan/sh/sh/sh.c +134 -0
- data/ext/langscan/sh/sh/sh.h +61 -0
- data/ext/langscan/sh/sh/shtok.c +2477 -0
- data/ext/langscan/sh/sh/shtok.l +325 -0
- data/ext/langscan/sh/sh/tokenlist.txt +8 -0
- data/lib/langscan.rb +124 -0
- data/lib/langscan/_common.rb +50 -0
- data/lib/langscan/_easyscanner.rb +78 -0
- data/lib/langscan/_pairmatcher.rb +46 -0
- data/lib/langscan/_type.rb +125 -0
- data/lib/langscan/autoconf.rb +51 -0
- data/lib/langscan/automake.rb +51 -0
- data/lib/langscan/brainfuck.rb +48 -0
- data/lib/langscan/c.rb +144 -0
- data/lib/langscan/c/c.so +0 -0
- data/lib/langscan/csharp.rb +101 -0
- data/lib/langscan/csharp/csharp.so +0 -0
- data/lib/langscan/css.rb +109 -0
- data/lib/langscan/d.rb +201 -0
- data/lib/langscan/d/d.so +0 -0
- data/lib/langscan/eiffel.rb +167 -0
- data/lib/langscan/elisp.rb +132 -0
- data/lib/langscan/elisp/elisp.so +0 -0
- data/lib/langscan/io.rb +84 -0
- data/lib/langscan/java.rb +95 -0
- data/lib/langscan/java/java.so +0 -0
- data/lib/langscan/javascript.rb +97 -0
- data/lib/langscan/javascript/javascript.so +0 -0
- data/lib/langscan/lua.rb +116 -0
- data/lib/langscan/ocaml.rb +298 -0
- data/lib/langscan/ocaml/camlexer.ml +28 -0
- data/lib/langscan/ocaml/lexer.mll +230 -0
- data/lib/langscan/ocaml/types.ml +36 -0
- data/lib/langscan/pairmatcher/pairmatcher.so +0 -0
- data/lib/langscan/perl.rb +87 -0
- data/lib/langscan/perl/tokenizer.pl +231 -0
- data/lib/langscan/php.rb +80 -0
- data/lib/langscan/php/php.so +0 -0
- data/lib/langscan/python.rb +101 -0
- data/lib/langscan/python/python.so +0 -0
- data/lib/langscan/rpmspec.rb +71 -0
- data/lib/langscan/ruby.rb +164 -0
- data/lib/langscan/ruby/compat/README +5 -0
- data/lib/langscan/ruby/compat/ripper.rb +4 -0
- data/lib/langscan/ruby/compat/ripper.so +0 -0
- data/lib/langscan/ruby/compat/ripper/core.rb +918 -0
- data/lib/langscan/ruby/compat/ripper/filter.rb +70 -0
- data/lib/langscan/ruby/compat/ripper/lexer.rb +179 -0
- data/lib/langscan/ruby/compat/ripper/sexp.rb +100 -0
- data/lib/langscan/scheme.rb +160 -0
- data/lib/langscan/scheme/scheme.so +0 -0
- data/lib/langscan/sh.rb +116 -0
- data/lib/langscan/sh/sh.so +0 -0
- data/lib/langscan/text.rb +37 -0
- data/metaconfig +2 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/makemanifest.rb +21 -0
- data/setup.rb +1604 -0
- data/tasks/extconf.rake +13 -0
- data/tasks/extconf/langscan.rake +42 -0
- data/test/langscan/brainfuck/test/test_scan.rb +55 -0
- data/test/langscan/c/test/test_scan.rb +216 -0
- data/test/langscan/c/test/test_token.rb +41 -0
- data/test/langscan/csharp/test/test_scan.rb +157 -0
- data/test/langscan/css/test/test_css.rb +79 -0
- data/test/langscan/d/test/test_scan.rb +233 -0
- data/test/langscan/d/test/test_token.rb +205 -0
- data/test/langscan/eiffel/test/test_eiffel.rb +95 -0
- data/test/langscan/elisp/test/test_elisp.rb +177 -0
- data/test/langscan/io/test/test_io.rb +79 -0
- data/test/langscan/java/test/test_java.rb +74 -0
- data/test/langscan/javascript/test/test_javascript.rb +39 -0
- data/test/langscan/lua/test/test_lua.rb +69 -0
- data/test/langscan/ocaml/test/test_ocaml.rb +161 -0
- data/test/langscan/php/test/test_scan.rb +138 -0
- data/test/langscan/python/test/test_scan.rb +105 -0
- data/test/langscan/rpmspec/test/test_rpmspec.rb +51 -0
- data/test/langscan/ruby/test/test_scan.rb +71 -0
- data/test/langscan/scheme/test/test_scan.rb +198 -0
- data/test/test_helper.rb +7 -0
- data/test/test_langscan.rb +123 -0
- 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
|