rubylexer 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +55 -0
- data/Manifest.txt +67 -0
- data/README.txt +103 -0
- data/Rakefile +24 -0
- data/howtouse.txt +9 -6
- data/{assert.rb → lib/assert.rb} +11 -11
- data/{rubylexer.rb → lib/rubylexer.rb} +645 -342
- data/lib/rubylexer/0.6.2.rb +39 -0
- data/lib/rubylexer/0.6.rb +5 -0
- data/lib/rubylexer/0.7.0.rb +2 -0
- data/{charhandler.rb → lib/rubylexer/charhandler.rb} +4 -2
- data/{charset.rb → lib/rubylexer/charset.rb} +4 -3
- data/{context.rb → lib/rubylexer/context.rb} +48 -18
- data/{rubycode.rb → lib/rubylexer/rubycode.rb} +5 -3
- data/{rulexer.rb → lib/rubylexer/rulexer.rb} +180 -102
- data/{symboltable.rb → lib/rubylexer/symboltable.rb} +10 -1
- data/{token.rb → lib/rubylexer/token.rb} +72 -20
- data/{tokenprinter.rb → lib/rubylexer/tokenprinter.rb} +39 -16
- data/lib/rubylexer/version.rb +3 -0
- data/{testcode → test/code}/deletewarns.rb +0 -0
- data/test/code/dl_all_gems.rb +43 -0
- data/{testcode → test/code}/dumptokens.rb +12 -9
- data/test/code/locatetest +30 -0
- data/test/code/locatetest.rb +49 -0
- data/test/code/rubylexervsruby.rb +173 -0
- data/{testcode → test/code}/tokentest.rb +62 -51
- data/{testcode → test/code}/torment +8 -8
- data/test/code/unpack_all_gems.rb +15 -0
- data/{testdata → test/data}/1.rb.broken +0 -0
- data/{testdata → test/data}/23.rb +0 -0
- data/test/data/__end__.rb +2 -0
- data/test/data/__end__2.rb +3 -0
- data/test/data/and.rb +5 -0
- data/test/data/blockassigntest.rb +23 -0
- data/test/data/chunky.plain.rb +75 -0
- data/test/data/chunky_bacon.rb +112 -0
- data/test/data/chunky_bacon2.rb +112 -0
- data/test/data/chunky_bacon3.rb +112 -0
- data/test/data/chunky_bacon4.rb +112 -0
- data/test/data/for.rb +45 -0
- data/test/data/format.rb +6 -0
- data/{testdata → test/data}/g.rb +0 -0
- data/test/data/gemlist.txt +280 -0
- data/test/data/heart.rb +7 -0
- data/test/data/if.rb +6 -0
- data/test/data/jarh.rb +369 -0
- data/test/data/lbrace.rb +4 -0
- data/test/data/lbrack.rb +4 -0
- data/{testdata → test/data}/newsyntax.rb +0 -0
- data/{testdata → test/data}/noeolatend.rb +0 -0
- data/test/data/p-op.rb +8 -0
- data/{testdata → test/data}/p.rb +671 -79
- data/{testdata → test/data}/pleac.rb.broken +0 -0
- data/{testdata → test/data}/pre.rb +0 -0
- data/{testdata → test/data}/pre.unix.rb +0 -0
- data/{testdata → test/data}/regtest.rb +0 -0
- data/test/data/rescue.rb +35 -0
- data/test/data/s.rb +186 -0
- data/test/data/strinc.rb +2 -0
- data/{testdata → test/data}/tokentest.assert.rb.can +0 -0
- data/test/data/untermed_here.rb.broken +2 -0
- data/test/data/untermed_string.rb.broken +1 -0
- data/{testdata → test/data}/untitled1.rb +0 -0
- data/{testdata → test/data}/w.rb +0 -0
- data/{testdata → test/data}/wsdlDriver.rb +0 -0
- data/testing.txt +6 -4
- metadata +163 -59
- data/README +0 -134
- data/Rantfile +0 -37
- data/io.each_til_charset.rb +0 -247
- data/require.rb +0 -103
- data/rlold.rb +0 -12
- data/testcode/locatetest +0 -12
- data/testcode/rubylexervsruby.rb +0 -104
- data/testcode/rubylexervsruby.sh +0 -51
- data/testresults/placeholder +0 -0
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/test/data/rescue.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
begin
|
2
|
+
1 rescue 2
|
3
|
+
rescue; 2
|
4
|
+
end
|
5
|
+
|
6
|
+
def foo
|
7
|
+
|
8
|
+
1 rescue 2
|
9
|
+
rescue; 2
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
class Foo
|
15
|
+
|
16
|
+
1 rescue 2
|
17
|
+
rescue; 2
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
module Moo
|
23
|
+
|
24
|
+
1 rescue 2
|
25
|
+
rescue; 2
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
class <<Foo
|
31
|
+
|
32
|
+
1 rescue 2
|
33
|
+
rescue; 2
|
34
|
+
|
35
|
+
end
|
data/test/data/s.rb
ADDED
@@ -0,0 +1,186 @@
|
|
1
|
+
#string content tokens move around in this file; its not really a problem
|
2
|
+
|
3
|
+
if false
|
4
|
+
t=0
|
5
|
+
t ?'t':0
|
6
|
+
"#{t ?'t':0}"
|
7
|
+
|
8
|
+
e.hour %= 12; ( downcase == 'p')
|
9
|
+
e.hour %= 12; begin downcase == 'p'; end
|
10
|
+
e.hour %= 12; if downcase == 'p'; end
|
11
|
+
e.hour %= 12; (downcase)
|
12
|
+
e.hour %= 12; if downcase; end
|
13
|
+
|
14
|
+
proc do <<EOD
|
15
|
+
[#{dqname}]
|
16
|
+
EOD
|
17
|
+
end
|
18
|
+
|
19
|
+
proc do <<-EOD
|
20
|
+
[#{dqname}]
|
21
|
+
EOD
|
22
|
+
end
|
23
|
+
|
24
|
+
proc do|x| <<-EOD
|
25
|
+
[#{dqname}]
|
26
|
+
EOD
|
27
|
+
end
|
28
|
+
|
29
|
+
proc do|| <<-EOD
|
30
|
+
[#{dqname}]
|
31
|
+
EOD
|
32
|
+
end
|
33
|
+
|
34
|
+
proc { <<-EOD
|
35
|
+
[#{dqname}]
|
36
|
+
EOD
|
37
|
+
}
|
38
|
+
|
39
|
+
proc {|x| <<-EOD
|
40
|
+
[#{dqname}]
|
41
|
+
EOD
|
42
|
+
}
|
43
|
+
|
44
|
+
p <<-EOD
|
45
|
+
[#{dqname}]
|
46
|
+
EOD
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
proc do "
|
52
|
+
[#{dqname}]
|
53
|
+
"
|
54
|
+
end
|
55
|
+
|
56
|
+
proc do `
|
57
|
+
[#{dqname}]
|
58
|
+
`
|
59
|
+
end
|
60
|
+
|
61
|
+
proc do /
|
62
|
+
[#{dqname}]
|
63
|
+
/
|
64
|
+
end
|
65
|
+
|
66
|
+
proc do '
|
67
|
+
[#{dqname}]
|
68
|
+
'
|
69
|
+
end
|
70
|
+
|
71
|
+
proc do %Q{
|
72
|
+
[#{dqname}]
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
proc do %{
|
77
|
+
[#{dqname}]
|
78
|
+
}
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
def SelfReferencing
|
84
|
+
#old name alias
|
85
|
+
end
|
86
|
+
|
87
|
+
def SelfReferencing #old name alias
|
88
|
+
end
|
89
|
+
|
90
|
+
def SelfReferencing#old name alias
|
91
|
+
end
|
92
|
+
|
93
|
+
def SelfReferencing;end#old name alias
|
94
|
+
|
95
|
+
p ?a
|
96
|
+
p :a
|
97
|
+
p :@a
|
98
|
+
p :@@a
|
99
|
+
p :$a
|
100
|
+
p :A
|
101
|
+
p :+
|
102
|
+
p :`#`
|
103
|
+
p ? p : 0
|
104
|
+
|
105
|
+
if false
|
106
|
+
O=0
|
107
|
+
false ? 2:O
|
108
|
+
false ? 2: O
|
109
|
+
false ? 2 :O
|
110
|
+
false ? 2 : O
|
111
|
+
|
112
|
+
eof??n
|
113
|
+
eof? ?n
|
114
|
+
|
115
|
+
eof??nil:true
|
116
|
+
eof? ?nil:true
|
117
|
+
eof?? nil:true
|
118
|
+
eof? ? nil:true
|
119
|
+
|
120
|
+
eof??nil:true
|
121
|
+
eof??nil :true
|
122
|
+
eof??nil: true
|
123
|
+
eof??nil : true
|
124
|
+
|
125
|
+
eof!?nil:true
|
126
|
+
eof! ?nil:true
|
127
|
+
eof!? nil:true
|
128
|
+
eof! ? nil:true
|
129
|
+
|
130
|
+
eof!?nil:true
|
131
|
+
eof!?nil :true
|
132
|
+
eof!?nil: true
|
133
|
+
eof!?nil : true
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
p <<'FOO'.gsub(" ","\n")
|
138
|
+
BAR#{BAZ}
|
139
|
+
FOO
|
140
|
+
|
141
|
+
p "\
|
142
|
+
#{foo}"
|
143
|
+
|
144
|
+
p <<end
|
145
|
+
#{compile_body}\
|
146
|
+
#{outvar}
|
147
|
+
end
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
p "#{<<foobar3}"
|
153
|
+
bim
|
154
|
+
baz
|
155
|
+
bof
|
156
|
+
foobar3
|
157
|
+
|
158
|
+
p "#{<<foobar2
|
159
|
+
bim
|
160
|
+
baz
|
161
|
+
bof
|
162
|
+
foobar2
|
163
|
+
}"
|
164
|
+
|
165
|
+
|
166
|
+
p <<one ; p "#{<<two}"
|
167
|
+
1111111111111111
|
168
|
+
fdsgdfgdsfffff
|
169
|
+
one
|
170
|
+
2222222222222222
|
171
|
+
sdfasdfasdfads
|
172
|
+
two
|
173
|
+
|
174
|
+
p "#{<<foobar1.each('|'){|s| '\nthort: '+s}
|
175
|
+
jbvd|g4543ghb|!@G$dfsd|fafr|e
|
176
|
+
|s4e5rrwware|BBBBB|*&^(*&^>"PMK:njs;d|
|
177
|
+
|
178
|
+
foobar1
|
179
|
+
}"
|
180
|
+
|
181
|
+
|
182
|
+
p <<""
|
183
|
+
foo
|
184
|
+
|
185
|
+
|
186
|
+
bar
|
data/test/data/strinc.rb
ADDED
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
"blah, blah
|
File without changes
|
data/{testdata → test/data}/w.rb
RENAMED
File without changes
|
File without changes
|
data/testing.txt
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
|
2
2
|
Running the tests:
|
3
|
-
the simplest thing to do is run
|
4
|
-
|
5
|
-
to
|
3
|
+
the simplest thing to do is run "ruby -Ilib test/code/locatetest.rb".
|
4
|
+
this will use locate to find as much ruby code on your system and test
|
5
|
+
each specimen to see if it can be tokenized correctly (by feeding it to
|
6
|
+
testcode/rubylexervsruby.rb, the operation of which is outlined below
|
7
|
+
under 'testing strategy').
|
6
8
|
|
7
9
|
Interpreting the output of rubylexervsruby.rb (and locatetest):
|
8
10
|
in rubylexervsruby, i've tried to follow the philosophy that the test program
|
@@ -127,4 +129,4 @@ thinks should be 2 tokens. and in fact, this is the case with strings: ruby divi
|
|
127
129
|
string into string open, string body, and string close tokens with option interpolations,
|
128
130
|
whereas rubylexer has just a single string token (with subtokens, if interpolations are
|
129
131
|
present.) this difference in handling accounts in part for rubylexer's inability
|
130
|
-
to correctly lex certain very complicated strings.
|
132
|
+
to correctly lex certain very complicated strings.
|
metadata
CHANGED
@@ -1,76 +1,180 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.
|
2
|
+
rubygems_version: 0.9.0
|
3
3
|
specification_version: 1
|
4
4
|
name: rubylexer
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date:
|
8
|
-
summary: lexer
|
6
|
+
version: 0.7.0
|
7
|
+
date: 2008-02-17 00:00:00 +00:00
|
8
|
+
summary: RubyLexer is a lexer library for Ruby, written in Ruby.
|
9
9
|
require_paths:
|
10
|
-
|
11
|
-
email:
|
12
|
-
homepage:
|
10
|
+
- lib
|
11
|
+
email: rubylexer-owner @at@ inforadical .dot. net
|
12
|
+
homepage: http://rubylexer.rubyforge.org/
|
13
13
|
rubyforge_project: rubylexer
|
14
|
-
description:
|
14
|
+
description: RubyLexer is a lexer library for Ruby, written in Ruby. Rubylexer is meant as a lexer for Ruby that's complete and correct; all legal Ruby code should be lexed correctly by RubyLexer as well. Just enough parsing capability is included to give RubyLexer enough context to tokenize correctly in all cases. (This turned out to be more parsing than I had thought or wanted to take on at first.) RubyLexer handles the hard things like complicated strings, the ambiguous nature of some punctuation characters and keywords in ruby, and distinguishing methods and local variables.
|
15
15
|
autorequire:
|
16
16
|
default_executable:
|
17
|
-
bindir:
|
18
|
-
has_rdoc:
|
17
|
+
bindir: ""
|
18
|
+
has_rdoc: true
|
19
19
|
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
20
|
requirements:
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
version: 0.0.0
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
25
24
|
version:
|
26
25
|
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
27
29
|
authors:
|
28
|
-
|
30
|
+
- Caleb Clausen
|
29
31
|
files:
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
32
|
+
- COPYING
|
33
|
+
- README.txt
|
34
|
+
- Manifest.txt
|
35
|
+
- Rakefile
|
36
|
+
- howtouse.txt
|
37
|
+
- History.txt
|
38
|
+
- testing.txt
|
39
|
+
- lib/rubylexer/rubycode.rb
|
40
|
+
- lib/rubylexer/context.rb
|
41
|
+
- lib/rubylexer/token.rb
|
42
|
+
- lib/rubylexer/0.6.rb
|
43
|
+
- lib/rubylexer/0.6.2.rb
|
44
|
+
- lib/rubylexer/0.7.0.rb
|
45
|
+
- lib/rubylexer/version.rb
|
46
|
+
- lib/rubylexer/rulexer.rb
|
47
|
+
- lib/rubylexer/tokenprinter.rb
|
48
|
+
- lib/rubylexer/charset.rb
|
49
|
+
- lib/rubylexer/symboltable.rb
|
50
|
+
- lib/rubylexer/charhandler.rb
|
51
|
+
- lib/assert.rb
|
52
|
+
- lib/rubylexer.rb
|
53
|
+
- test/data/gemlist.txt
|
54
|
+
- test/data/blockassigntest.rb
|
55
|
+
- test/data/for.rb
|
56
|
+
- test/data/chunky_bacon.rb
|
57
|
+
- test/data/and.rb
|
58
|
+
- test/data/pre.unix.rb
|
59
|
+
- test/data/untermed_string.rb.broken
|
60
|
+
- test/data/__end__2.rb
|
61
|
+
- test/data/w.rb
|
62
|
+
- test/data/if.rb
|
63
|
+
- test/data/pre.rb
|
64
|
+
- test/data/jarh.rb
|
65
|
+
- test/data/regtest.rb
|
66
|
+
- test/data/chunky_bacon4.rb
|
67
|
+
- test/data/__end__.rb
|
68
|
+
- test/data/strinc.rb
|
69
|
+
- test/data/lbrace.rb
|
70
|
+
- test/data/p.rb
|
71
|
+
- test/data/chunky.plain.rb
|
72
|
+
- test/data/noeolatend.rb
|
73
|
+
- test/data/g.rb
|
74
|
+
- test/data/23.rb
|
75
|
+
- test/data/lbrack.rb
|
76
|
+
- test/data/untitled1.rb
|
77
|
+
- test/data/rescue.rb
|
78
|
+
- test/data/tokentest.assert.rb.can
|
79
|
+
- test/data/pleac.rb.broken
|
80
|
+
- test/data/heart.rb
|
81
|
+
- test/data/s.rb
|
82
|
+
- test/data/wsdlDriver.rb
|
83
|
+
- test/data/p-op.rb
|
84
|
+
- test/data/1.rb.broken
|
85
|
+
- test/data/untermed_here.rb.broken
|
86
|
+
- test/data/newsyntax.rb
|
87
|
+
- test/data/chunky_bacon3.rb
|
88
|
+
- test/data/chunky_bacon2.rb
|
89
|
+
- test/data/format.rb
|
90
|
+
- test/code/locatetest.rb
|
91
|
+
- test/code/rubylexervsruby.rb
|
92
|
+
- test/code/dl_all_gems.rb
|
93
|
+
- test/code/unpack_all_gems.rb
|
94
|
+
- test/code/tokentest.rb
|
95
|
+
- test/code/dumptokens.rb
|
96
|
+
- test/code/torment
|
97
|
+
- test/code/locatetest
|
98
|
+
- test/code/deletewarns.rb
|
99
|
+
test_files:
|
100
|
+
- test/code/locatetest.rb
|
101
|
+
- test/code/rubylexervsruby.rb
|
102
|
+
- test/code/dl_all_gems.rb
|
103
|
+
- test/code/unpack_all_gems.rb
|
104
|
+
- test/code/tokentest.rb
|
105
|
+
- test/code/dumptokens.rb
|
106
|
+
- test/code/torment
|
107
|
+
- test/code/locatetest
|
108
|
+
- test/code/deletewarns.rb
|
109
|
+
- test/data/blockassigntest.rb
|
110
|
+
- test/data/for.rb
|
111
|
+
- test/data/chunky_bacon.rb
|
112
|
+
- test/data/and.rb
|
113
|
+
- test/data/pre.unix.rb
|
114
|
+
- test/data/untermed_string.rb.broken
|
115
|
+
- test/data/__end__2.rb
|
116
|
+
- test/data/w.rb
|
117
|
+
- test/data/if.rb
|
118
|
+
- test/data/pre.rb
|
119
|
+
- test/data/jarh.rb
|
120
|
+
- test/data/regtest.rb
|
121
|
+
- test/data/chunky_bacon4.rb
|
122
|
+
- test/data/__end__.rb
|
123
|
+
- test/data/strinc.rb
|
124
|
+
- test/data/lbrace.rb
|
125
|
+
- test/data/p.rb
|
126
|
+
- test/data/chunky.plain.rb
|
127
|
+
- test/data/noeolatend.rb
|
128
|
+
- test/data/g.rb
|
129
|
+
- test/data/23.rb
|
130
|
+
- test/data/lbrack.rb
|
131
|
+
- test/data/untitled1.rb
|
132
|
+
- test/data/rescue.rb
|
133
|
+
- test/data/tokentest.assert.rb.can
|
134
|
+
- test/data/pleac.rb.broken
|
135
|
+
- test/data/heart.rb
|
136
|
+
- test/data/s.rb
|
137
|
+
- test/data/wsdlDriver.rb
|
138
|
+
- test/data/p-op.rb
|
139
|
+
- test/data/1.rb.broken
|
140
|
+
- test/data/untermed_here.rb.broken
|
141
|
+
- test/data/newsyntax.rb
|
142
|
+
- test/data/chunky_bacon3.rb
|
143
|
+
- test/data/chunky_bacon2.rb
|
144
|
+
- test/data/format.rb
|
145
|
+
- test/results/
|
146
|
+
rdoc_options:
|
147
|
+
- --main
|
148
|
+
- README.txt
|
149
|
+
extra_rdoc_files:
|
150
|
+
- README.txt
|
151
|
+
- Manifest.txt
|
152
|
+
- howtouse.txt
|
153
|
+
- History.txt
|
154
|
+
- testing.txt
|
155
|
+
- test/data/gemlist.txt
|
73
156
|
executables: []
|
157
|
+
|
74
158
|
extensions: []
|
159
|
+
|
75
160
|
requirements: []
|
76
|
-
|
161
|
+
|
162
|
+
dependencies:
|
163
|
+
- !ruby/object:Gem::Dependency
|
164
|
+
name: sequence
|
165
|
+
version_requirement:
|
166
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
167
|
+
requirements:
|
168
|
+
- - ">"
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: 0.0.0
|
171
|
+
version:
|
172
|
+
- !ruby/object:Gem::Dependency
|
173
|
+
name: hoe
|
174
|
+
version_requirement:
|
175
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
176
|
+
requirements:
|
177
|
+
- - ">="
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: 1.5.0
|
180
|
+
version:
|