rubylexer 0.6.2 → 0.7.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/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
data/test/data/heart.rb
ADDED
data/test/data/if.rb
ADDED
data/test/data/jarh.rb
ADDED
@@ -0,0 +1,369 @@
|
|
1
|
+
print ',rekcah ybuR rehtona tsuJ'.reverse
|
2
|
+
|
3
|
+
print %q/92G5S="!A;F]T:&5R(%)U8GD@:&%C:V5R+```/.unpack('u')
|
4
|
+
|
5
|
+
print %q/SnVzdCBhbm90aGVyIFJ1YnkgaGFja2VyLA==/.unpack('m')
|
6
|
+
|
7
|
+
print 'Whfg nabgure Ehol unpxre,'.tr('A-Za-z', 'N-ZA-Mn-za-m')
|
8
|
+
|
9
|
+
print({'ruby' => 'Just another Ruby hacker,'}['ruby'])
|
10
|
+
|
11
|
+
print 'jUsT aNoThEr '.capitalize, 'RuBy HaCkEr,'.capitalize
|
12
|
+
|
13
|
+
print ['Just another Ruby hacker,'][0]
|
14
|
+
|
15
|
+
print ['hacker,', 'Ruby ', 'another ', 'Just '].reverse
|
16
|
+
|
17
|
+
proc {print 'Just another Ruby hacker,'}.call
|
18
|
+
|
19
|
+
def pri() print 'Just another Ruby hacker,' end; pri
|
20
|
+
|
21
|
+
for i in 'Just another Ruby hacker,' do print i end
|
22
|
+
|
23
|
+
print `echo -n Just another Ruby hacker,`
|
24
|
+
|
25
|
+
print 'Just another Ruby hacker,'.split('')
|
26
|
+
|
27
|
+
print 'JQust aQnotQher RQuby hQackQer,'.delete('Q')
|
28
|
+
|
29
|
+
'Just another Ruby hacker,'.scan(/(.)/) {print $1}
|
30
|
+
|
31
|
+
print 'Just ' + 'another ' + 'Ruby ' + 'hacker,'
|
32
|
+
|
33
|
+
print ['4a75737420616e6f746865722052756279206861636b65722c'].pack('H*')
|
34
|
+
|
35
|
+
print 'Just another Ruby hacker,'.split(/(.)/)
|
36
|
+
|
37
|
+
print %w(Just another Ruby hacker,).join(' ')
|
38
|
+
|
39
|
+
print({'another '=>'Just ', 'hacker,'=>'Ruby '}.invert.sort)
|
40
|
+
|
41
|
+
print eval(%-eval %: %|Just another Ruby hacker,| :-)
|
42
|
+
|
43
|
+
#;eval %qPprint eval %-eval %:'Just another Ruby hacker,' :-P
|
44
|
+
|
45
|
+
print Hash.new('Just another Ruby hacker,')[:Ruby]
|
46
|
+
|
47
|
+
print ['Just ', ['another ', ['Ruby ', ['hacker,']]]].flatten
|
48
|
+
|
49
|
+
print Struct.new(*%w|Ruby Just another Ruby hacker,|)[*[0]*4].members.join(' ')
|
50
|
+
|
51
|
+
print Time.now.strftime('Just another Ruby hacker,')
|
52
|
+
|
53
|
+
print " Just another Ruby hacker, \r\n".strip
|
54
|
+
|
55
|
+
print ['Just ', nil, 'another ', nil, 'Ruby ', nil, 'hacker,'].compact
|
56
|
+
|
57
|
+
['hacker,', 'Ruby ', 'another ', 'Just '].reverse_each do |x| print x end
|
58
|
+
|
59
|
+
/Just another Ruby hacker,/.source.display
|
60
|
+
|
61
|
+
send :print, 'Just another Ruby hacker,'
|
62
|
+
|
63
|
+
print ['Just ', 'another ', 'Ruby '] | ['another ', 'Ruby ', 'hacker,']
|
64
|
+
|
65
|
+
print ['Just ', 'another ', 'Perl', 'Ruby ', 'hacker,'] - ['Perl']
|
66
|
+
|
67
|
+
print [['', 'Just another Ruby hacker,']].assoc('')
|
68
|
+
|
69
|
+
print ['Just another Ruby hacker,'].pack('a*')
|
70
|
+
|
71
|
+
print 'Just another Ruby hacker,'.unpack('a*')
|
72
|
+
|
73
|
+
print [['Just another Ruby hacker,'].pop].sort.shift
|
74
|
+
|
75
|
+
print [['Just another Ruby hacker,', '']].rassoc('')
|
76
|
+
|
77
|
+
{'Just another ' => 'Ruby hacker,'}.to_a.display
|
78
|
+
|
79
|
+
print 'Just another Ruby hackeq,'.succ
|
80
|
+
|
81
|
+
print 'jUST ANOTHER rUBY HACKER,'.swapcase
|
82
|
+
|
83
|
+
print ['Just another Ruby hacker,'].find {|x| x}
|
84
|
+
|
85
|
+
print %w(Just another Ruby hacker,).find_all {|x| x}.join(' ')
|
86
|
+
|
87
|
+
print %w(Just another Ruby hacker,).grep(/./).join(' ')
|
88
|
+
|
89
|
+
Ruby = 'Just another Ruby hacker,' and print Object.const_get(:Ruby)
|
90
|
+
|
91
|
+
Proc.new {print 'Just another Ruby hacker,'}[]
|
92
|
+
|
93
|
+
print 'JJuusstt aannootthheerr RRuubbyy hhaacckkeerr,,'.squeeze
|
94
|
+
|
95
|
+
print [1249211252, 543256175, 1952998770, 542274914, 2032167009, 1667982706].pack('N*'), ','
|
96
|
+
|
97
|
+
$> << 'Just ' << 'another ' << 'Ruby ' << 'hacker,'
|
98
|
+
|
99
|
+
5.times do|i|'Jaebcunrykso ettRhr hua,'.scan(/.{5}/) do print $&[i,1] end end
|
100
|
+
|
101
|
+
a=',rekcah ybuR rehtona tsuJ'.split('');print a.pop while not a.empty?
|
102
|
+
|
103
|
+
print ',Pr-eok,c"a$h! kypbquuRA %roeqhbtaoon;ab rtesbujJ&'.gsub(/(.)./, '\1').reverse
|
104
|
+
|
105
|
+
print /.*/.match('Just another Ruby hacker,')
|
106
|
+
|
107
|
+
print $& if /.*/ === 'Just another Ruby hacker,'
|
108
|
+
|
109
|
+
case 'Just another Ruby hacker,' when /.*/; print $~[0] end
|
110
|
+
|
111
|
+
print Marshal.load(Marshal.dump("Just another Ruby hacker,"))
|
112
|
+
|
113
|
+
'Just another Ruby hacker,'.each_byte do |x| print x.chr end
|
114
|
+
|
115
|
+
print '/hacker,/another /Ruby /Just '.split('/').sort.values_at(1,3,2,4)
|
116
|
+
|
117
|
+
print 'Just another Perl hacker,'.sub('Perl', 'Ruby')
|
118
|
+
|
119
|
+
#$><<'RbyckJust another,'.split('').values_at(5..16,9,0,6,1,2,9,14,10,3,4,15..17)
|
120
|
+
|
121
|
+
('a'..'y').to_a.join.tr('a-y','Just another Ruby hacker,').display
|
122
|
+
|
123
|
+
begin print 'Just another ' ensure print 'Ruby hacker,' end
|
124
|
+
|
125
|
+
'J,ursetk caanho tyhbeurR Rruebhyt ohnaac ktesru,J'.scan(/.(.)/).reverse.display
|
126
|
+
|
127
|
+
'J,ursetk caanho tyhbeurR Rruebhyt ohnaac ktesru,J'.gsub(/(.)./,'\1').display
|
128
|
+
|
129
|
+
a='J,ursetk caanho tyhbeurR ';0.step(24,2){|i|print a[i,1]};23.step(1,-2){|i|print a[i,1]}
|
130
|
+
|
131
|
+
a='Js nte uyhce,rka bRrhoatu'.split('');12.times{print a.shift,a.pop};print a
|
132
|
+
|
133
|
+
a='Js nte uyhce,rka bRrhoatu';begin a.sub!(/^(.)(.*)(.)$/){print $1,$3;$2}end while$1;print a
|
134
|
+
|
135
|
+
a='J Ruby hacker,ust another';11.times{a.sub!(/^(.)(.*)(.)$/,'\1\3\2')};print a
|
136
|
+
|
137
|
+
print 'Just. another! -Ruby? $hacker,'.tr_s('-.!?$ ', ' ')
|
138
|
+
|
139
|
+
' e m r,yJaRnafatbpcuekewhjhskvngohrlrxsctdtiubuoyq'.scan(/(.)(.)/).collect!{|x|[x[1],x[0]]}.sort.collect!{|x|x[1]}.display
|
140
|
+
|
141
|
+
'e m r y,aJnRfatapbuckewejhshvkgnholrxrcsdtitbuouqy'.scan(/../).sort.collect!{|x|x[1,1]}.display
|
142
|
+
|
143
|
+
'4a75737420616e6f746865722052756279206861636b65722c'.scan(/../){print $&.hex.chr}
|
144
|
+
|
145
|
+
print ['Just another Perl hacker,'].fill('Just another Ruby hacker,')
|
146
|
+
|
147
|
+
$><<{1=>'Just ',2=>'another ',3=>'Ruby ',4=>'hacker,'}.sort.to_s.delete('1-4')
|
148
|
+
|
149
|
+
Kernel.print %q<Just another Ruby hacker,>
|
150
|
+
|
151
|
+
class Just_another_Ruby_hackerq;end;print Just_another_Ruby_hackerq.to_s.tr('_q',' ,')
|
152
|
+
|
153
|
+
Kust_another_Ruby_hacker=0;print Module.constants.grep(/Kust/)[0].tr('K_','J '), ','
|
154
|
+
|
155
|
+
module Lust_another_Ruby_hackerq; print name.tr('L_q', 'J ,') end
|
156
|
+
|
157
|
+
class Bar; print 'Just another Ruby hacker,' end
|
158
|
+
|
159
|
+
class Baz; def initialize() print 'Just another Ruby hacker,' end end; Baz.new
|
160
|
+
|
161
|
+
eval "A<')I;G0@)TIU<W0@86YO=&AE<B!2=6)Y(&AA8VME<BPG".unpack('u')[0]
|
162
|
+
|
163
|
+
eval "cHJpbnQgJ0p1c3QgYW5vdGhlciBSdWJ5IGhhY2tlciwn".unpack('m')[0]
|
164
|
+
|
165
|
+
$stdout.write 'Just another Ruby hacker,'
|
166
|
+
|
167
|
+
"Just \nanother \nRuby \nhacker,\n".each do |x| print x.chomp end
|
168
|
+
|
169
|
+
print $' if /\n/x === "\nJust another Ruby hacker,"
|
170
|
+
|
171
|
+
raise 'Just another Ruby hacker,' rescue print $!
|
172
|
+
|
173
|
+
print File.basename('~/Just another Ruby hacker,.rb','.*')
|
174
|
+
|
175
|
+
proc{|x|x['Just another Ruby hacker,']}[proc{|x|print x}]
|
176
|
+
|
177
|
+
method(:print)['Just another Ruby hacker,']
|
178
|
+
|
179
|
+
'Just another Ruby hacker,'.method(:display)[]
|
180
|
+
|
181
|
+
print ''.replace('Just another Ruby hacker,')
|
182
|
+
|
183
|
+
instance_eval do print 'Just another Ruby hacker,' end
|
184
|
+
|
185
|
+
Kernel.module_eval do print 'Just another Ruby hacker,' end
|
186
|
+
|
187
|
+
print %%\%s%%%%Just another Ruby hacker,%%%%%%%%%
|
188
|
+
|
189
|
+
print !?????:???%?Just another Ruby hacker,?:??
|
190
|
+
|
191
|
+
#({}.default='Just another Ruby hacker,')[0].display
|
192
|
+
|
193
|
+
print Hash['Just another ', 'Ruby hacker,']
|
194
|
+
|
195
|
+
print 'Just ' 'another ' 'Ruby ' 'hacker,'
|
196
|
+
|
197
|
+
print File.dirname('Just another Ruby hacker,/Just another Ruby porter,')
|
198
|
+
|
199
|
+
def $_.singleton_method_added(*) print 'Just another Ruby hacker,' end
|
200
|
+
|
201
|
+
print ['Just another Ruby hacker,'].delete_at(0)
|
202
|
+
|
203
|
+
print '%s %s %s %s' % %w[Just another Ruby hacker,]
|
204
|
+
|
205
|
+
'cker,by haer RuanothJust '.scan(/.{5}/).reverse.display
|
206
|
+
|
207
|
+
(97..121).to_a.pack('c*').tr('a-y','Just another Ruby hacker,').display
|
208
|
+
|
209
|
+
'abcdefghijklmnopqrstuvwxy'.tr('a-y','Just another Ruby hacker,').display
|
210
|
+
|
211
|
+
',rekcah ybuR rehtona tsuJ'.scan(/.{1}/).reverse.display
|
212
|
+
|
213
|
+
print 'Just another Ruby hacker,'%%; (^_^;;;
|
214
|
+
|
215
|
+
print('Just another Ruby hacker,'% %- ;-)
|
216
|
+
|
217
|
+
'r,keac hbyRur heotant usJ'.scan(/.{1,2}/).reverse.display
|
218
|
+
|
219
|
+
print 'Just another Ruby hacker,' * ('Just another Ruby hacker,' =~ /u/)
|
220
|
+
|
221
|
+
print 'uJtsa onhtreR bu yahkcre,'.unpack('v12c').pack('n12c')
|
222
|
+
|
223
|
+
print 'uJtsa onhtreR bu yahkcre,'.gsub(/(.)(.?)/, '\2\1')
|
224
|
+
|
225
|
+
'uJtsa onhtreR bu yahkcre,'.scan(/(.)(.?)/){|x,y| print y+x}
|
226
|
+
|
227
|
+
print 'Just another Ruby hacker,'['Just another Ruby hacker,']
|
228
|
+
|
229
|
+
print 'Just another Ruby hacker,'[/.*/]
|
230
|
+
|
231
|
+
print [].push('Just ', 'another ', 'Ruby ', 'hacker,')
|
232
|
+
|
233
|
+
print 'Just another Ruby hacker,'[0..-1]
|
234
|
+
|
235
|
+
print 'Just another Ruby hacker,'.instance_eval{self}
|
236
|
+
|
237
|
+
class String; def +@() print self end; +'Just another Ruby hacker,' end
|
238
|
+
|
239
|
+
print '1J2u3s4t5 6a7n8o9t0h1e2r3 4R5u6b7y8 9h0a1c2k3e4r5,'.delete('0-9')
|
240
|
+
|
241
|
+
'Jaubsctd eafngohtihjekrl mRnuobpyq rhsatcukvewrx,y'.gsub(/(.)./, '\1').display
|
242
|
+
|
243
|
+
#$><<{'Just another Ruby hacker,'=>''}.default=0
|
244
|
+
|
245
|
+
print eval('Just another Ruby hacker,'.dump)
|
246
|
+
|
247
|
+
print 'Just another Ruby hacker'.concat(?,)
|
248
|
+
|
249
|
+
print 'Just another Ruby hacker,'.intern.to_s
|
250
|
+
|
251
|
+
print 'Just another Ruby hacker,'.dump[1..-2]
|
252
|
+
|
253
|
+
'Just another Ruby hacker,'.each_line do |x| print x end
|
254
|
+
|
255
|
+
['JUST ANOTHER ', 'RUBY HACKER,'].each do |x| print x.capitalize end
|
256
|
+
|
257
|
+
printf '%.25s', 'Just another Ruby hacker,JARH'
|
258
|
+
|
259
|
+
print 'Just another Ruby hacker,'.split(/Z/)[0]
|
260
|
+
|
261
|
+
print 'Just another Ruby hacker,'.split(//)
|
262
|
+
|
263
|
+
print %w.J u s t \ a n o t h e r \ R u b y \ h a c k e r ,.
|
264
|
+
|
265
|
+
print String([%[Just another Ruby hacker,]])
|
266
|
+
|
267
|
+
print catch(:x){throw :x, 'Just another Ruby hacker,'}
|
268
|
+
|
269
|
+
r,w = IO::pipe;w.print 'Just another Ruby hacker,';w.close;print r.gets
|
270
|
+
|
271
|
+
print sprintf('%s', format('%s' % '%s', 'Just another Ruby hacker,'))
|
272
|
+
|
273
|
+
print eval('Just another Ruby hacker,'.inspect)
|
274
|
+
|
275
|
+
/#{print 'Just another Ruby hacker,'}/
|
276
|
+
|
277
|
+
print 'Just another Ruby hacker,'.scan(/./).collect{|x|x[0]}.pack('U*')
|
278
|
+
|
279
|
+
print 'Just another Ruby hacker,'.scan(/./).pack('a'*25)
|
280
|
+
|
281
|
+
'Just another Ruby hacker,'.send 'yalpsid'.reverse.intern
|
282
|
+
|
283
|
+
print %w.Just another Ruby Ruby Ruby hacker,..uniq.join(' ')
|
284
|
+
|
285
|
+
{}.fetch(:x){'Just another Ruby hacker,'}.display
|
286
|
+
|
287
|
+
{}.delete(:x){'Just another Ruby hacker,'}.display
|
288
|
+
|
289
|
+
print [:x].map{'Just another Ruby hacker,'}
|
290
|
+
|
291
|
+
{'Ruby hacker,'=>'Just another'}.each{|*x|print x.reverse.join(' ')}
|
292
|
+
|
293
|
+
print [].unshift('Ruby hacker,').unshift('Just another').join(' ')
|
294
|
+
|
295
|
+
{3=>'Ruby ',2=>'another ',4=>'hacker,',1=>'Just '}.values_at(1,2,3,4).display
|
296
|
+
|
297
|
+
print [[0,'Just another Ruby hacker,'],1].first.last
|
298
|
+
|
299
|
+
{''=>'JARH'}.update(''=>'Just another Ruby hacker,').display
|
300
|
+
|
301
|
+
{:JARH => 'Just another Ruby hacker,'}.values.display
|
302
|
+
|
303
|
+
{'Just another Ruby hacker,'=>:JARH}.invert[:JARH].display
|
304
|
+
|
305
|
+
print ['Just another Ruby hacker,'=>:JARH][0].keys
|
306
|
+
|
307
|
+
print [{}].slice(0..0)[0].store('', 'Just another Ruby hacker,')
|
308
|
+
|
309
|
+
print 'Just another Ruby hacker,'.split.join(' ')
|
310
|
+
|
311
|
+
begin print 'Just another Ruby hacker,' end while false
|
312
|
+
|
313
|
+
begin rescue then else print 'Just another Ruby hacker,' end
|
314
|
+
|
315
|
+
print //.match('Just another Ruby hacker,').string
|
316
|
+
|
317
|
+
callcc{print 'Just another Ruby hacker,'}
|
318
|
+
|
319
|
+
Thread.start{print'Just another Ruby hacker,'}.join
|
320
|
+
|
321
|
+
('JARH'..'Just another Ruby hacker,').end.display
|
322
|
+
|
323
|
+
('Just another'..'Ruby hacker,').to_s.tr_s('.', ' ').display
|
324
|
+
|
325
|
+
unless true then else 'Just another Ruby hacker,' end.display
|
326
|
+
|
327
|
+
loop do print 'Just another Ruby hacker,'; break end
|
328
|
+
|
329
|
+
1.times do print 'Just another Ruby hacker,' end
|
330
|
+
|
331
|
+
0.upto(0) do print 'Just another Ruby hacker,' end
|
332
|
+
|
333
|
+
0.downto(0) do print 'Just another Ruby hacker,' end
|
334
|
+
|
335
|
+
print Struct.new('Just_another_Ruby_hacker').to_s.split(':')[2].tr('_',' '),','
|
336
|
+
|
337
|
+
def (x='Just another Ruby hacker,').foo() print self end; x.foo
|
338
|
+
|
339
|
+
begin print 'Just another Ruby hacker,' end until true
|
340
|
+
|
341
|
+
for i in %w[Just\ another\ Ruby\ hacker,] do print i end
|
342
|
+
|
343
|
+
'Just another Ruby hacker,'.each_byte do |x| putc x end
|
344
|
+
|
345
|
+
',rekcah ybuR rehtona tsuJ'.scan(/./).reverse_each do |x| putc x end
|
346
|
+
|
347
|
+
print Regexp.quote('Just another Ruby hacker,').delete('\\')
|
348
|
+
|
349
|
+
print true ? "Just another Ruby hacker," :-P
|
350
|
+
|
351
|
+
print true ? "Just another Ruby hacker," :-D
|
352
|
+
|
353
|
+
print *("Just another Ruby hacker,".."Just another Ruby hacker,").to_a
|
354
|
+
|
355
|
+
print eval(%<%%Just another Ruby hacker,%>)
|
356
|
+
|
357
|
+
print case when true then "Just another Ruby hacker," end
|
358
|
+
|
359
|
+
print %w[Just another Ruby hacker,] * " "
|
360
|
+
|
361
|
+
begin end if print "Just another Ruby hacker,"
|
362
|
+
|
363
|
+
print begin "Just another Ruby hacker," end
|
364
|
+
|
365
|
+
print "Just another Ruby hacker,".center(10000).strip
|
366
|
+
|
367
|
+
print "Just " or print "another " or print "Ruby " or print "hacker,"
|
368
|
+
|
369
|
+
print :"Just another Ruby hacker,"
|
data/test/data/lbrace.rb
ADDED
data/test/data/lbrack.rb
ADDED
File without changes
|
File without changes
|
data/test/data/p-op.rb
ADDED
data/{testdata → test/data}/p.rb
RENAMED
@@ -1,13 +1,551 @@
|
|
1
|
+
if false
|
2
|
+
return {}.size
|
3
|
+
1.return {}.size
|
4
|
+
|
5
|
+
break {}.size
|
6
|
+
1.break {}.size
|
7
|
+
|
8
|
+
next {}.size
|
9
|
+
1.next {}.size
|
10
|
+
|
11
|
+
raise {}.to_s+"****"
|
12
|
+
1.raise {}.to_s+"****"
|
13
|
+
|
14
|
+
throw {}.to_s+"****"
|
15
|
+
1.throw {}.to_s+"****"
|
16
|
+
end
|
17
|
+
|
18
|
+
module SR
|
19
|
+
def SelfReferencing
|
20
|
+
#old name alias
|
21
|
+
end
|
22
|
+
|
23
|
+
def SelfReferencing #old name alias
|
24
|
+
end
|
25
|
+
|
26
|
+
def SelfReferencing#old name alias
|
27
|
+
end
|
28
|
+
|
29
|
+
def SelfReferencing;end#old name alias
|
30
|
+
end
|
31
|
+
|
32
|
+
P ::Class
|
33
|
+
|
34
|
+
p <<Class
|
35
|
+
zzzz
|
36
|
+
Class
|
37
|
+
|
38
|
+
p(String <<Class)
|
39
|
+
sgsdfgf
|
40
|
+
Class
|
41
|
+
Class
|
42
|
+
|
43
|
+
proc{q=1;def q.foo; end} #q should be varnametoken, both times
|
44
|
+
module Defined_p_syntax_tests
|
45
|
+
def self.defined?(foo) :baz end #should be methname
|
46
|
+
def defined?(foo) :bar end #should be methname
|
47
|
+
def ameth
|
48
|
+
p(defined? 44) #should be keyword
|
49
|
+
p(self.defined? 44) #should be methname
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
p 2**3[4] #should be nowstoken before bracket
|
54
|
+
|
55
|
+
proc{
|
56
|
+
p /$/ #regexp
|
57
|
+
p /=$/ #operator
|
58
|
+
p /$/ #operator
|
59
|
+
}
|
60
|
+
|
61
|
+
proc{
|
62
|
+
p %=b=
|
63
|
+
2
|
64
|
+
p %(1)
|
65
|
+
}
|
66
|
+
|
67
|
+
proc{
|
68
|
+
p *=5
|
69
|
+
p %(1)
|
70
|
+
}
|
71
|
+
|
72
|
+
proc{
|
73
|
+
p &nil
|
74
|
+
p &=1
|
75
|
+
p %(1)
|
76
|
+
}
|
77
|
+
|
78
|
+
p %(1)
|
79
|
+
|
80
|
+
p %\hah, backslash as string delimiter\
|
81
|
+
def foo(bar=5,tt=6) end
|
82
|
+
wwww,eeee=1,2
|
83
|
+
proc{a.b,c.d=1,2}
|
84
|
+
proc{|a.b,c.d|}
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
p foo
|
92
|
+
|
93
|
+
if false
|
94
|
+
p % foo
|
95
|
+
p % foo
|
96
|
+
p %
|
97
|
+
foo
|
98
|
+
|
99
|
+
p(% foo )
|
100
|
+
p(% foo )
|
101
|
+
p(%
|
102
|
+
foo
|
103
|
+
|
104
|
+
)
|
105
|
+
end
|
106
|
+
|
107
|
+
p eval "%\sfoo\s"
|
108
|
+
|
109
|
+
p eval "%\tfoo\t"
|
110
|
+
p eval "%\vfoo\v"
|
111
|
+
p eval "%\rfoo\r"
|
112
|
+
p eval "%\nfoo\n"
|
113
|
+
p eval "%\0foo\0"
|
114
|
+
|
115
|
+
p eval "%\r\nfoo\r\n"
|
116
|
+
|
117
|
+
#foo
|
118
|
+
|
119
|
+
=begin
|
120
|
+
|
121
|
+
=end
|
122
|
+
|
123
|
+
p <<p
|
124
|
+
\
|
125
|
+
p
|
126
|
+
p
|
127
|
+
|
128
|
+
p <<'p'
|
129
|
+
\
|
130
|
+
p
|
131
|
+
p
|
132
|
+
|
133
|
+
p <<p
|
134
|
+
\n\t\r\v\\
|
135
|
+
p
|
136
|
+
|
137
|
+
p <<'p'
|
138
|
+
\n\t\r\v\\
|
139
|
+
p
|
140
|
+
|
141
|
+
p <<p
|
142
|
+
\
|
143
|
+
|
144
|
+
p
|
145
|
+
|
146
|
+
|
147
|
+
p %W[\
|
148
|
+
] #ruby interprets this one as a single (totally unescaped) newline,
|
149
|
+
#but i suspect that might be a bug.
|
150
|
+
|
151
|
+
p "\
|
152
|
+
"
|
153
|
+
|
154
|
+
p '\
|
155
|
+
'
|
156
|
+
|
157
|
+
p /\
|
158
|
+
/
|
159
|
+
|
160
|
+
p `\
|
161
|
+
`
|
162
|
+
|
163
|
+
p %w[\
|
164
|
+
]
|
165
|
+
|
166
|
+
p %[\
|
167
|
+
]
|
168
|
+
|
169
|
+
p "
|
170
|
+
|
171
|
+
"
|
172
|
+
|
173
|
+
p %{
|
174
|
+
|
175
|
+
}
|
176
|
+
|
177
|
+
p <<END
|
178
|
+
|
179
|
+
END
|
180
|
+
|
181
|
+
p <<'END'
|
182
|
+
|
183
|
+
END
|
184
|
+
|
185
|
+
|
186
|
+
p
|
187
|
+
p(1,2) #these 2 lines should tokenize identically
|
188
|
+
p (1,2) #except for the extra space on this one
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
p File
|
194
|
+
module Y19 #limit lvar scope
|
195
|
+
a,b,c,(d,e)=1,2,3,[4,5]
|
196
|
+
p a %(4)
|
197
|
+
p c %(4)
|
198
|
+
p d %(4)
|
199
|
+
p e %(4)
|
200
|
+
end
|
201
|
+
|
202
|
+
def printem___1 a
|
203
|
+
a
|
204
|
+
end
|
205
|
+
|
206
|
+
class F0000; end
|
207
|
+
def F0000; end
|
208
|
+
|
209
|
+
f0000=1
|
210
|
+
def f0000; end
|
211
|
+
|
212
|
+
def printem__1 a
|
213
|
+
p(a +77)
|
214
|
+
end
|
215
|
+
def printem_1 a,b
|
216
|
+
p(a +77)
|
217
|
+
p(b +77)
|
218
|
+
end
|
219
|
+
def printem1 a,b,c
|
220
|
+
p(a +77)
|
221
|
+
p(b +77)
|
222
|
+
p(c +77)
|
223
|
+
end
|
224
|
+
def printem10 a,b,c,d,e,f
|
225
|
+
p(a +77)
|
226
|
+
p(b +77)
|
227
|
+
p(c +77)
|
228
|
+
p(d +77)
|
229
|
+
p(e +77)
|
230
|
+
p(f +77)
|
231
|
+
end
|
232
|
+
def printem100 a,b,c,d,e,f,*g,&h
|
233
|
+
p(a +77)
|
234
|
+
p(b +77)
|
235
|
+
p(c +77)
|
236
|
+
p(d +77)
|
237
|
+
p(e +77)
|
238
|
+
p(f +77)
|
239
|
+
p(g +77)
|
240
|
+
p(h +77)
|
241
|
+
end
|
242
|
+
#<<'abc123def'
|
243
|
+
ddd="ddd"
|
244
|
+
|
245
|
+
#@@ddd=@ddd=$ddd=nil
|
246
|
+
def DDD;end
|
247
|
+
def ddd2; "asdAds" end
|
248
|
+
def (DDD()).foofarendle;end
|
249
|
+
def Integer.foofarendle;end
|
250
|
+
def @@ddd.foofarendle; 33;end
|
251
|
+
def @ddd.foofarendle; 33;end
|
252
|
+
def $ddd.foofarendle; 33;end
|
253
|
+
def ddd.foofarendle; 33;end
|
254
|
+
def ddd2.foofarendle; 33;end
|
255
|
+
def (ddd).foofarendle2; end
|
256
|
+
def (ddd()).foofarendle2; end
|
257
|
+
|
258
|
+
|
259
|
+
def (ddd2).foofarendle;end
|
260
|
+
def ddd2.foofarendle;end
|
261
|
+
|
262
|
+
|
263
|
+
def (is_a?(File::Stat)).foofarendle;end
|
264
|
+
|
265
|
+
p()
|
266
|
+
|
267
|
+
p((4\
|
268
|
+
+5))
|
269
|
+
p((4\
|
270
|
+
|
271
|
+
+5))
|
272
|
+
p((4+\
|
273
|
+
|
274
|
+
+5))
|
275
|
+
p((4+\
|
276
|
+
|
277
|
+
5))
|
278
|
+
|
279
|
+
p(<<-jjj \
|
280
|
+
dsfgdf
|
281
|
+
jjj
|
282
|
+
)
|
283
|
+
|
284
|
+
p(<<-jjj
|
285
|
+
dsfgdf
|
286
|
+
jjj
|
287
|
+
)
|
288
|
+
|
289
|
+
p(<<-jjj \
|
290
|
+
dsfgdf
|
291
|
+
jjj
|
292
|
+
+"dfsdfs"
|
293
|
+
)
|
294
|
+
|
295
|
+
p(<<-jjj +
|
296
|
+
dsfgdf
|
297
|
+
jjj
|
298
|
+
"dfsdfs"
|
299
|
+
)
|
300
|
+
|
301
|
+
|
302
|
+
p( {:rest=>99})
|
303
|
+
p %{{{{#{"}}}"}}}}}
|
304
|
+
case 1
|
305
|
+
when *[2]: p 1
|
306
|
+
else p 2
|
307
|
+
end
|
308
|
+
|
309
|
+
p :"jim";
|
310
|
+
p :'jim';
|
311
|
+
p %s/jim/;
|
312
|
+
p %s"jim";
|
313
|
+
p %s'jim';
|
314
|
+
p %s`jim`;
|
315
|
+
p %s[jim];
|
316
|
+
p %s{jim};
|
317
|
+
p %s(jim);
|
318
|
+
p %s<jim>;
|
319
|
+
p %s jim ;
|
320
|
+
for bob in [100] do p(bob %(22)) end
|
321
|
+
|
322
|
+
|
323
|
+
proc{
|
324
|
+
foo bar=>baz
|
325
|
+
bar %(1)
|
326
|
+
}
|
327
|
+
|
328
|
+
module Y2534534
|
329
|
+
def foo1
|
330
|
+
p (1..10).method(:each) #implicit parens around the whole thing
|
331
|
+
end
|
332
|
+
|
333
|
+
def foo2()
|
334
|
+
p((1..10).method(:each)) #explicitly parenthesized... no implicit parens needed
|
335
|
+
end
|
336
|
+
|
337
|
+
def foo3()
|
338
|
+
p (1..10).method(:each) #implicit parens around the whole thing
|
339
|
+
#matz ruby parses this differently than identical line in foo1!?
|
340
|
+
end
|
341
|
+
|
342
|
+
end
|
343
|
+
|
344
|
+
|
345
|
+
module Y668
|
346
|
+
p [1,2,3,]
|
347
|
+
#p {1=>2,3=>4,} #syntax error
|
348
|
+
#p aaa,bbb,ccc,=1,2,3 #syntax error
|
349
|
+
p aaa
|
350
|
+
p bbb
|
351
|
+
p ccc
|
352
|
+
proc{|a,b,c,| p a,b,c }.call(1,2,3)
|
353
|
+
p proc{|
|
354
|
+
a,b,(c,d,),e|
|
355
|
+
p a %(1)
|
356
|
+
p b %(2)
|
357
|
+
p c %(3)
|
358
|
+
p d %(4)
|
359
|
+
p e %(5)
|
360
|
+
[ a,b,c,d,e]}.call(1,2,[3,4],5)
|
361
|
+
p (Module.instance_methods - Object.instance_methods).sort # an outer set of implicit parens is needed
|
362
|
+
p(Module.instance_methods - Object.instance_methods).sort #no outer implicit parens
|
363
|
+
"foo".slice (1-2).nil? #no outer implicit parens
|
364
|
+
p (1-2).nil? #outer implicit parens needed
|
365
|
+
p(1-2).nil? #no outer implicit parens needed
|
366
|
+
|
367
|
+
def self.z(*); end
|
368
|
+
def self.zz(*,&x); end
|
369
|
+
def self.zzz(&x); end
|
370
|
+
|
371
|
+
z z z z z z {}
|
372
|
+
z z z z z z do end
|
373
|
+
|
374
|
+
(/ 1/)
|
375
|
+
p(/ 1/)
|
376
|
+
# (p / 1/) #ruby no like
|
377
|
+
|
378
|
+
def ggg(x=nil) p x;9 end
|
379
|
+
(ggg / 1)
|
380
|
+
|
381
|
+
false and( true ? f : g )
|
382
|
+
false and( f .. g )
|
383
|
+
false and( f ... g )
|
384
|
+
p 1&2 #should be OperatorToken, not KeywordToken
|
385
|
+
p 1|2 #ditto
|
386
|
+
p 1**2
|
387
|
+
p 1*2
|
388
|
+
p 1%(2)
|
389
|
+
p 1^2
|
390
|
+
p 1+2
|
391
|
+
p 1-2
|
392
|
+
p 1/2
|
393
|
+
|
394
|
+
p 1?2:3 #keyword
|
395
|
+
|
396
|
+
p 1 ?2:3 #keyword
|
397
|
+
|
398
|
+
p 1? 2:3 #keyword
|
399
|
+
|
400
|
+
p 1?2 :3 #keyword
|
401
|
+
|
402
|
+
p 1?2: 3 #keyword
|
403
|
+
|
404
|
+
p 1 ? 2:3 #keyword
|
405
|
+
|
406
|
+
p 1 ?2 :3 #keyword
|
407
|
+
|
408
|
+
p 1 ?2: 3 #keyword
|
409
|
+
|
410
|
+
p 1? 2 :3 #keyword
|
411
|
+
|
412
|
+
p 1? 2: 3 #keyword
|
413
|
+
|
414
|
+
p 1?2 : 3 #keyword
|
415
|
+
|
416
|
+
p 1 ? 2 : 3 #keyword
|
417
|
+
|
418
|
+
p 1==2
|
419
|
+
p 1===2
|
420
|
+
p 1[2] #keyword
|
421
|
+
p 1;2 #keyword
|
422
|
+
p 1,2 #keyword
|
423
|
+
p 1.2
|
424
|
+
p 1.class #keyword
|
425
|
+
p 1..2 #keyword
|
426
|
+
p 1...2 #keyword
|
427
|
+
p 1<2
|
428
|
+
p 1>2
|
429
|
+
p 1<=2
|
430
|
+
p 1>=2
|
431
|
+
p 1<<2
|
432
|
+
p 1>>2
|
433
|
+
p 1!=2 #this is keyword
|
434
|
+
p 1=~2
|
435
|
+
p 1!~2 #this is keyword
|
436
|
+
p 1&&2 #...
|
437
|
+
p 1||2 #...
|
438
|
+
p 1<=>2
|
439
|
+
|
440
|
+
define_method(:foo, &proc{:bar})
|
441
|
+
define_method :foo, &proc{:bar}
|
442
|
+
define_method(:foo) &proc{:bar}
|
443
|
+
define_method :foo &proc{:bar}
|
444
|
+
p :k, *nil
|
445
|
+
p :k, *nil, &nil
|
446
|
+
p *nil
|
447
|
+
p *nil, &nil
|
448
|
+
end
|
449
|
+
|
450
|
+
|
451
|
+
module Y19 #limit lvar scope
|
452
|
+
a,b,c,(d,e)=1,2,3,[4,5]
|
453
|
+
p a %(4)
|
454
|
+
p c %(4)
|
455
|
+
p d %(4)
|
456
|
+
p e %(4)
|
457
|
+
|
458
|
+
|
459
|
+
|
460
|
+
a=[1,2,3,4,5]
|
461
|
+
|
462
|
+
def self.g(x=nil); 3 end
|
463
|
+
def a.g=(x) p x end
|
464
|
+
|
465
|
+
g = 5
|
466
|
+
|
467
|
+
self.g = 55
|
468
|
+
|
469
|
+
|
470
|
+
class<<a
|
471
|
+
def bb=(x) p :bb=, x end
|
472
|
+
end
|
473
|
+
|
474
|
+
A=a
|
475
|
+
class<<self
|
476
|
+
def aa; :aa end
|
477
|
+
def bb(arg=nil); p :bb; A end
|
478
|
+
alias bbb bb
|
479
|
+
|
480
|
+
def m; self end
|
481
|
+
def n; self end
|
482
|
+
|
483
|
+
def +(other) self end
|
484
|
+
def kk; nil end
|
485
|
+
def kk=(foo); nil end
|
486
|
+
end
|
487
|
+
|
488
|
+
|
489
|
+
proc{|a[4]|}.call 6
|
490
|
+
proc{|a[b]|}.call 7
|
491
|
+
proc{|a.bb| bb %(9) }.call 9
|
492
|
+
proc{|a[f]| f %(9) }.call 8
|
493
|
+
proc{|bb(aa).bb| aa %(10) }.call 10
|
494
|
+
proc{|bbb(aa).bb| bbb %(11) }.call 11
|
495
|
+
proc{|t,u,(v,w,x),(y,),z|
|
496
|
+
t %(12)
|
497
|
+
u %(12)
|
498
|
+
v %(12)
|
499
|
+
w %(12)
|
500
|
+
x %(12)
|
501
|
+
y %(12)
|
502
|
+
z %(12)
|
503
|
+
}.call(1,2,[3,4,5],[6],7)
|
504
|
+
proc{|(m).kk,(m+n).kk|
|
505
|
+
m %(13)
|
506
|
+
n %(13)
|
507
|
+
kk %(13)
|
508
|
+
}.call(13,14)
|
509
|
+
|
510
|
+
proc{|a.g| g %(9)}
|
511
|
+
|
512
|
+
p a
|
513
|
+
|
514
|
+
end
|
515
|
+
|
516
|
+
|
517
|
+
module R34634534
|
518
|
+
#how do I avoid getting into trouble with this test case?
|
519
|
+
#seems like I should be seeing local vars in the param list of
|
520
|
+
#the 2nd call to p....
|
521
|
+
class<<self
|
522
|
+
alias q p
|
523
|
+
alias r p
|
524
|
+
alias s p
|
525
|
+
end
|
526
|
+
|
527
|
+
p(q,r,s)
|
528
|
+
|
529
|
+
q %(1)
|
530
|
+
r %(1)
|
531
|
+
s %(1)
|
532
|
+
|
533
|
+
p (q,r,s)
|
534
|
+
|
535
|
+
q %(1)
|
536
|
+
r %(1)
|
537
|
+
s %(1)
|
538
|
+
end
|
539
|
+
|
540
|
+
|
541
|
+
|
542
|
+
p p :c, :d
|
1
543
|
p true ?
|
2
544
|
1 : 2
|
3
|
-
#breakpoint
|
4
545
|
module M555
|
5
546
|
def r;4 end
|
6
|
-
#breakpoint
|
7
547
|
r=r.nil? #2nd r seems like it should be MethNameToken, but is VarNameToken (for matz too)
|
8
|
-
#breakpoint
|
9
548
|
end
|
10
|
-
#breakpoint
|
11
549
|
|
12
550
|
p ?e.+?y
|
13
551
|
p ?e.+ ?y
|
@@ -19,7 +557,6 @@ p ?e.%?y
|
|
19
557
|
p ?e.**?y
|
20
558
|
p ?e.&?y
|
21
559
|
|
22
|
-
p %s/jim/;
|
23
560
|
|
24
561
|
p "#{<<foobar0.each('|'){|s| '\nthort: '+s} }"
|
25
562
|
jbvd|g4543ghb|!@G$dfsd|fafr|e
|
@@ -61,16 +598,30 @@ p eval "%\nfoo\n"
|
|
61
598
|
p eval "%\0foo\0"
|
62
599
|
|
63
600
|
p eval "%\r\nfoo\r\n"
|
601
|
+
|
602
|
+
#given that \n\r is not considered a valid eol
|
603
|
+
#sequence in ruby (unlike \r\n), the next 2 are ok
|
64
604
|
p eval "%\n\rfoo\n\r" #ruby get this wrong
|
65
605
|
p eval "%\n\rfoo\n" #this shouldn't work but does
|
606
|
+
|
607
|
+
#seems like just \r isn't valid newline either, which is
|
608
|
+
#puzzling but the following are are correct.
|
609
|
+
#does ruby do these all correctly? seems kinda inconsistant
|
610
|
+
#either both of these should fail, or both should succeed
|
66
611
|
p eval "%\r\nfoo\r" #this does not work,
|
67
612
|
p eval "%\r\nfoo\n" #this shouldn't work but does
|
68
613
|
|
614
|
+
p eval "%\rfoo\r" #this works
|
615
|
+
p eval "%\rfoo\n" #this does not work,
|
616
|
+
p eval "%\rfoo\r\n" #this does not work,
|
617
|
+
|
618
|
+
p eval "%\nfoo\r" #this does not work
|
619
|
+
p eval "%\nfoo\n" #this works
|
620
|
+
p eval "%\nfoo\r\n" #this works,
|
69
621
|
|
70
622
|
p "Hi, my name is #{"Slim #{(4)>2?"Whitman":"Shady"} "}."
|
71
623
|
p "Hi, my name is #{"Slim #{(4)<2?"Whitman":"Shady"} "}."
|
72
624
|
|
73
|
-
#breakpoint
|
74
625
|
|
75
626
|
p(String *Class)
|
76
627
|
class String
|
@@ -82,6 +633,7 @@ def String.*(right) [self,right] end
|
|
82
633
|
def String.<<(right) [self,:<<,right] end
|
83
634
|
def String./(right) [self,:/,right] end
|
84
635
|
def String.[](right) [self,:[],right] end
|
636
|
+
def Class.-@; [:-@, self] end
|
85
637
|
p(String::Class)
|
86
638
|
p(String:: Class)
|
87
639
|
p(String ::Class)
|
@@ -90,8 +642,32 @@ p(String<<Class)
|
|
90
642
|
p(String<< Class)
|
91
643
|
p(String <<Class)
|
92
644
|
sgsdfgf
|
645
|
+
Class
|
93
646
|
Class
|
94
647
|
p(String << Class)
|
648
|
+
p(String<<-Class)
|
649
|
+
p(String<< -Class)
|
650
|
+
p(String <<-Class)
|
651
|
+
sgsdfgf
|
652
|
+
Class
|
653
|
+
Class
|
654
|
+
p(String <<-Class)
|
655
|
+
sgsdfgf
|
656
|
+
Class
|
657
|
+
Class
|
658
|
+
Class
|
659
|
+
p(String << -Class)
|
660
|
+
|
661
|
+
p(String<<- Class)
|
662
|
+
p(String<< - Class)
|
663
|
+
p(String <<- Class)
|
664
|
+
Class
|
665
|
+
Class
|
666
|
+
p(String <<- Class)
|
667
|
+
Class
|
668
|
+
Class
|
669
|
+
Class
|
670
|
+
p(String << - Class)
|
95
671
|
p(String/Class)
|
96
672
|
p(String/ Class)
|
97
673
|
p(String /Class/)
|
@@ -114,16 +690,16 @@ p(false::to_s)
|
|
114
690
|
p(false ::to_s)
|
115
691
|
p(false:: to_s)
|
116
692
|
p(false :: to_s)
|
117
|
-
|
693
|
+
|
118
694
|
|
119
695
|
class C2
|
120
|
-
class <<self
|
696
|
+
class <<self
|
121
697
|
def self.p8; p 8 end
|
122
698
|
alias p? p
|
123
699
|
alias P? p
|
124
700
|
alias [] p
|
125
701
|
alias <=> p
|
126
|
-
end
|
702
|
+
end
|
127
703
|
|
128
704
|
q=9
|
129
705
|
Q=99
|
@@ -178,7 +754,6 @@ self <=>:p8
|
|
178
754
|
self <=> :p8
|
179
755
|
#false ? self <=> : p8 #gives ruby indigestion
|
180
756
|
end
|
181
|
-
#breakpoint
|
182
757
|
|
183
758
|
p <<stuff+'foobar'.tr('j-l','d-f')
|
184
759
|
"more stuff"
|
@@ -192,12 +767,9 @@ sdfsfdf^^^^@@@
|
|
192
767
|
p
|
193
768
|
mix=nil
|
194
769
|
p / 5/mix
|
195
|
-
#breakpoint
|
196
770
|
|
197
771
|
module M33
|
198
|
-
#breakpoint
|
199
772
|
p="var:"
|
200
|
-
#breakpoint
|
201
773
|
Q="func:"
|
202
774
|
def Q.method_missing(name,*args)
|
203
775
|
self+name.to_s+(args.join' ')
|
@@ -330,10 +902,9 @@ module M33
|
|
330
902
|
p(p> 2)
|
331
903
|
p(p > 2)
|
332
904
|
|
333
|
-
#breakpoint
|
334
905
|
end
|
335
906
|
|
336
|
-
|
907
|
+
|
337
908
|
module M34
|
338
909
|
p(p~6)
|
339
910
|
p(p ~6)
|
@@ -489,9 +1060,11 @@ p :`
|
|
489
1060
|
|
490
1061
|
p{}
|
491
1062
|
p {}
|
1063
|
+
module Y7284
|
492
1064
|
a=5
|
493
1065
|
p p +5
|
494
1066
|
p a +5
|
1067
|
+
end
|
495
1068
|
|
496
1069
|
def nil.+(x) ~x end
|
497
1070
|
def nil.[](*x) [x] end
|
@@ -507,6 +1080,9 @@ class Foou
|
|
507
1080
|
public
|
508
1081
|
def [] x=-100,&y; p x; 100 end
|
509
1082
|
end
|
1083
|
+
|
1084
|
+
|
1085
|
+
module Y345636
|
510
1086
|
a0=8
|
511
1087
|
p Foou.new.[]!false #value
|
512
1088
|
p Foou.new.[] !false #value
|
@@ -537,7 +1113,9 @@ p({:foo=>:bar}) #why does this work? i'd think that ':foo=' would be 1 token
|
|
537
1113
|
p EMPTY = 0
|
538
1114
|
p BLACK = 1
|
539
1115
|
p WHITE = - BLACK
|
1116
|
+
end
|
540
1117
|
|
1118
|
+
module Y8576456
|
541
1119
|
a=b=c=0
|
542
1120
|
a ? b:c
|
543
1121
|
a ?b:c
|
@@ -545,7 +1123,6 @@ p WHITE = - BLACK
|
|
545
1123
|
p(a ? b:c)
|
546
1124
|
p(a ?b:c)
|
547
1125
|
|
548
|
-
|
549
1126
|
p~4
|
550
1127
|
p:f
|
551
1128
|
p(~4){}
|
@@ -557,7 +1134,10 @@ p def (h="foobar").default= v; p @v=v;v end
|
|
557
1134
|
p h
|
558
1135
|
|
559
1136
|
p h.default=:b
|
1137
|
+
end
|
1138
|
+
|
560
1139
|
|
1140
|
+
module Y6543423
|
561
1141
|
x, (*y) = [:x, :y, :z]
|
562
1142
|
p x
|
563
1143
|
p y
|
@@ -568,7 +1148,7 @@ p y
|
|
568
1148
|
|
569
1149
|
x, * = [:x, :y, :z]
|
570
1150
|
p x
|
571
|
-
|
1151
|
+
end
|
572
1152
|
|
573
1153
|
|
574
1154
|
p Array("foo\nbar")
|
@@ -607,7 +1187,6 @@ without_creating=widgetname=nil
|
|
607
1187
|
|
608
1188
|
|
609
1189
|
|
610
|
-
=begin disable for now
|
611
1190
|
|
612
1191
|
#class, module, and def should temporarily hide local variables
|
613
1192
|
def mopsdfjskdf arg; arg*2 end
|
@@ -627,9 +1206,8 @@ p d
|
|
627
1206
|
p mopsdfjskdf %(6) #reads variable
|
628
1207
|
p proc{mopsdfjskdf %(7)}[] #reads variable
|
629
1208
|
|
630
|
-
#fancy symbols
|
1209
|
+
#fancy symbols
|
631
1210
|
p %s{symbol}
|
632
|
-
=end
|
633
1211
|
|
634
1212
|
#multiple assignment test
|
635
1213
|
proc {
|
@@ -640,8 +1218,9 @@ proc {
|
|
640
1218
|
p(p %(c))
|
641
1219
|
}.call
|
642
1220
|
|
643
|
-
|
644
1221
|
=begin disable for now
|
1222
|
+
|
1223
|
+
|
645
1224
|
p "#{<<kekerz}#{"foob"
|
646
1225
|
zimpler
|
647
1226
|
kekerz
|
@@ -664,9 +1243,26 @@ proc {
|
|
664
1243
|
p "jentawz: #{baz=200}"
|
665
1244
|
p( baz %(9))
|
666
1245
|
}.call
|
667
|
-
|
1246
|
+
|
1247
|
+
#scope of local variables always includes the here document
|
1248
|
+
#body if it includes the head
|
1249
|
+
p %w[well, whaddaya know].map{|j| <<-END }
|
1250
|
+
#{j #previous j should be local var, not method
|
1251
|
+
}45634543
|
1252
|
+
END
|
1253
|
+
|
1254
|
+
|
1255
|
+
|
1256
|
+
=end disable for now
|
1257
|
+
|
668
1258
|
|
669
1259
|
=begin ought to work...ruby doesn't like
|
1260
|
+
p :$1
|
1261
|
+
p :$98349576875974523789734582394578
|
1262
|
+
|
1263
|
+
(p / 1/) #ruby no like
|
1264
|
+
|
1265
|
+
class F34534334
|
670
1266
|
class A
|
671
1267
|
class B
|
672
1268
|
class C
|
@@ -677,9 +1273,6 @@ def A::B::C::d() :abcd end
|
|
677
1273
|
def A::B::d() :abd end #this used to work as well... i think
|
678
1274
|
|
679
1275
|
|
680
|
-
p :$1
|
681
|
-
p :$98349576875974523789734582394578
|
682
|
-
|
683
1276
|
def nil.d=; end #this works
|
684
1277
|
def (;).d=; end
|
685
1278
|
def ().d=; end
|
@@ -690,22 +1283,37 @@ p~4{}
|
|
690
1283
|
p:f{}
|
691
1284
|
p ~4{}
|
692
1285
|
p :f{}
|
1286
|
+
p ~4 {}
|
1287
|
+
p :f {}
|
1288
|
+
p ~ 4{}
|
693
1289
|
|
694
1290
|
def g a=:g; [a] end
|
695
1291
|
g g g #this works
|
696
1292
|
g *g #this works
|
697
1293
|
g *g g #this doesn't
|
1294
|
+
g+g 5 #this doesn't
|
698
1295
|
|
699
1296
|
[nil,p 5]
|
700
1297
|
"foo"+[1].join' '
|
1298
|
+
if x=p :a,:b then end
|
1299
|
+
{:nil?=> 1}
|
1300
|
+
|
1301
|
+
1+[1,2,3][1..-1].index 3
|
1302
|
+
|
1303
|
+
_=@cu.fixup_match_result 'md' #works
|
1304
|
+
_=md=@cu.fixup_match_result 'md' #don't work
|
701
1305
|
|
702
|
-
|
1306
|
+
3+"".slice 1
|
1307
|
+
|
1308
|
+
""+p ""
|
1309
|
+
|
1310
|
+
#given:
|
703
1311
|
def foo; end
|
704
1312
|
|
705
|
-
|
1313
|
+
foo.===/#/ #syntax error
|
706
1314
|
|
707
|
-
|
708
|
-
|
1315
|
+
foo.=== /#/ #no error
|
1316
|
+
foo===/#/ #no error
|
709
1317
|
|
710
1318
|
#these work:
|
711
1319
|
(not true)
|
@@ -723,9 +1331,21 @@ p(true and false) #etc
|
|
723
1331
|
p(undef foo)
|
724
1332
|
p(alias bar foo)
|
725
1333
|
p(BEGIN{p :yyy})
|
1334
|
+
p 1{2}
|
1335
|
+
p 1 {2}
|
1336
|
+
p(false ? Q :p8 )
|
1337
|
+
p(false ? Q:p8 )
|
726
1338
|
end
|
727
1339
|
|
728
|
-
|
1340
|
+
|
1341
|
+
if false
|
1342
|
+
equal?(p) or Position===p && equal? p.data #syntax error unless add parens, but why?
|
1343
|
+
end
|
1344
|
+
|
1345
|
+
raise LexerError, "expected >=#{tok.offset}, got #{endpos}, "\
|
1346
|
+
"token #{tok}:#{tok.class}" #there's a space after the backslash
|
1347
|
+
|
1348
|
+
=end disable for now
|
729
1349
|
|
730
1350
|
proc {
|
731
1351
|
}
|
@@ -753,54 +1373,16 @@ end
|
|
753
1373
|
func
|
754
1374
|
|
755
1375
|
|
1376
|
+
|
756
1377
|
p( %r{\/$})
|
757
1378
|
p( %r~<!include:([\/\w\.\-]+)>~m)
|
758
1379
|
|
759
|
-
p <<end
|
760
|
-
#{compile_body}\
|
761
|
-
#{outvar}
|
762
|
-
end
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
1380
|
proc {
|
769
1381
|
h={:a=>(foo=100)}
|
770
1382
|
p( foo %(5))
|
771
1383
|
}.call
|
772
1384
|
|
773
1385
|
|
774
|
-
p "#{<<foobar3}"
|
775
|
-
bim
|
776
|
-
baz
|
777
|
-
bof
|
778
|
-
foobar3
|
779
|
-
|
780
|
-
p "#{<<foobar2
|
781
|
-
bim
|
782
|
-
baz
|
783
|
-
bof
|
784
|
-
foobar2
|
785
|
-
}"
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
p <<one ; p "#{<<two}"
|
790
|
-
1111111111111111
|
791
|
-
fdsgdfgdsfffff
|
792
|
-
one
|
793
|
-
2222222222222222
|
794
|
-
sdfasdfasdfads
|
795
|
-
two
|
796
|
-
|
797
|
-
p "#{<<foobar1.each('|'){|s| '\nthort: '+s}
|
798
|
-
jbvd|g4543ghb|!@G$dfsd|fafr|e
|
799
|
-
|s4e5rrwware|BBBBB|*&^(*&^>"PMK:njs;d|
|
800
|
-
|
801
|
-
foobar1
|
802
|
-
}"
|
803
|
-
|
804
1386
|
|
805
1387
|
def foo(a=<<a,b=<<b,c=<<c)
|
806
1388
|
jfksdkjf
|
@@ -897,6 +1479,8 @@ def ==(o) 444 end
|
|
897
1479
|
def String.ffff4() self.to_s+"ffff" end
|
898
1480
|
|
899
1481
|
p *[]
|
1482
|
+
#abc123def
|
1483
|
+
module Y23423423
|
900
1484
|
for i in \
|
901
1485
|
[44,55,66,77,88] do p i**Math.sqrt(i) end
|
902
1486
|
|
@@ -905,6 +1489,7 @@ for i in \
|
|
905
1489
|
for i in if
|
906
1490
|
false then foob12345; else [44,55,66,77,88] end do p i**Math.sqrt(i) end
|
907
1491
|
#)
|
1492
|
+
#end
|
908
1493
|
(
|
909
1494
|
for i in if false then
|
910
1495
|
foob12345; else [44,55,66,77,88] end do p i**Math.sqrt(i) end
|
@@ -937,6 +1522,7 @@ for i in (
|
|
937
1522
|
[44,55,66,77,88]) do p i**Math.sqrt(i) end
|
938
1523
|
|
939
1524
|
)
|
1525
|
+
end
|
940
1526
|
|
941
1527
|
|
942
1528
|
|
@@ -980,7 +1566,8 @@ d e f
|
|
980
1566
|
|
981
1567
|
p "\""
|
982
1568
|
|
983
|
-
|
1569
|
+
module Y89567567999
|
1570
|
+
a='a'
|
984
1571
|
class <<a
|
985
1572
|
def foobar
|
986
1573
|
self*101
|
@@ -989,11 +1576,13 @@ class <<a
|
|
989
1576
|
end
|
990
1577
|
|
991
1578
|
p a.foobar
|
992
|
-
|
1579
|
+
end
|
993
1580
|
|
994
1581
|
p(/^\s*(([+-\/*&\|^]|<<|>>|\|\||\&\&)=|\&\&|\|\|)/)
|
995
1582
|
p(:%)
|
1583
|
+
module Y45234234234223567675
|
996
1584
|
p( { :class => class_=0})
|
1585
|
+
end
|
997
1586
|
p cls_name = {}[:class]
|
998
1587
|
|
999
1588
|
|
@@ -1026,8 +1615,10 @@ p %w[\]]
|
|
1026
1615
|
p :+
|
1027
1616
|
p 99 / 3
|
1028
1617
|
|
1618
|
+
module Y66
|
1029
1619
|
a=99;b=3
|
1030
1620
|
p 1+(a / b)
|
1621
|
+
end
|
1031
1622
|
p %Q[\"]
|
1032
1623
|
p %Q[ some [nested] text]
|
1033
1624
|
|
@@ -1093,13 +1684,11 @@ p <<stuff+'foobar'.tr('j-l','d-f')
|
|
1093
1684
|
the quick brown fox jumped over the lazy dog
|
1094
1685
|
stuff
|
1095
1686
|
|
1096
|
-
=begin doesn't work
|
1097
1687
|
p <<stuff+'foobar'.tr('j-l','d-f')\
|
1098
1688
|
+"more stuff"
|
1099
1689
|
12345678
|
1100
1690
|
the quick brown fox jumped over the lazy dog
|
1101
1691
|
stuff
|
1102
|
-
=end
|
1103
1692
|
|
1104
1693
|
p ENV["AmritaCacheDir"]
|
1105
1694
|
p <<-BEGIN + <<-END
|
@@ -1118,13 +1707,16 @@ koomblatz!() p 'jdkfsk' end
|
|
1118
1707
|
|
1119
1708
|
koomblatz!
|
1120
1709
|
|
1710
|
+
module Y3423454
|
1121
1711
|
p f = 3.7517675036461267e+17
|
1712
|
+
end
|
1122
1713
|
p $10
|
1123
1714
|
p $1001
|
1124
1715
|
p( <<end )
|
1125
1716
|
nine time nine men have stood untold.
|
1126
1717
|
end
|
1127
1718
|
|
1719
|
+
|
1128
1720
|
def jd_to_wday(jd) (jd + 1) % 7 end
|
1129
1721
|
p jd_to_wday(98)
|
1130
1722
|
|
@@ -1162,6 +1754,7 @@ clist.each do |str|
|
|
1162
1754
|
end
|
1163
1755
|
|
1164
1756
|
S
|
1757
|
+
|
1165
1758
|
def printem1 a,b,c
|
1166
1759
|
p(a +77)
|
1167
1760
|
p(b +77)
|
@@ -1175,11 +1768,6 @@ end
|
|
1175
1768
|
def printem0(a)
|
1176
1769
|
p(a +77)
|
1177
1770
|
end
|
1178
|
-
def printem0(a,b,c)
|
1179
|
-
p(a +77)
|
1180
|
-
p(b +77)
|
1181
|
-
p(c +77)
|
1182
|
-
end
|
1183
1771
|
def printem2 a,b,c; p(a +77); p(b +77); p(c +77) end
|
1184
1772
|
def three() (1+2) end
|
1185
1773
|
|
@@ -1194,11 +1782,12 @@ def printem a,b,c
|
|
1194
1782
|
end
|
1195
1783
|
printem 1,2,3
|
1196
1784
|
|
1785
|
+
module Y24345678756
|
1197
1786
|
a=1
|
1198
1787
|
p(a +77)
|
1199
1788
|
|
1200
1789
|
def hhh(a=(1+2)) a end
|
1201
|
-
|
1790
|
+
end
|
1202
1791
|
|
1203
1792
|
|
1204
1793
|
END {
|
@@ -1213,11 +1802,14 @@ p <<-what
|
|
1213
1802
|
? that's
|
1214
1803
|
what
|
1215
1804
|
p proc{||}
|
1805
|
+
|
1806
|
+
module Y5566342346
|
1216
1807
|
for i in if false
|
1217
1808
|
foob12345; else [44,55,66,77,88] end do p i**Math.sqrt(i) end
|
1218
1809
|
p "\v"
|
1219
1810
|
c=0
|
1220
1811
|
while c == /[ \t\f\r\13]/; end
|
1812
|
+
end
|
1221
1813
|
|
1222
1814
|
|
1223
1815
|
|