rubylexer 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. data/History.txt +90 -0
  2. data/Manifest.txt +54 -3
  3. data/README.txt +4 -7
  4. data/Rakefile +3 -2
  5. data/lib/rubylexer.rb +856 -323
  6. data/lib/rubylexer/0.7.0.rb +11 -2
  7. data/lib/rubylexer/0.7.1.rb +2 -0
  8. data/lib/rubylexer/charhandler.rb +4 -4
  9. data/lib/rubylexer/context.rb +86 -9
  10. data/lib/rubylexer/rulexer.rb +455 -101
  11. data/lib/rubylexer/token.rb +166 -43
  12. data/lib/rubylexer/tokenprinter.rb +16 -8
  13. data/lib/rubylexer/version.rb +1 -1
  14. data/rubylexer.vpj +98 -0
  15. data/test/code/all_the_gems.rb +33 -0
  16. data/test/code/all_the_raas.rb +226 -0
  17. data/test/code/all_the_rubies.rb +2 -0
  18. data/test/code/deletewarns.rb +19 -1
  19. data/test/code/dumptokens.rb +39 -8
  20. data/test/code/errscan +2 -0
  21. data/test/code/isolate_error.rb +72 -0
  22. data/test/code/lexloop +14 -0
  23. data/test/code/locatetest.rb +150 -8
  24. data/test/code/regression.rb +109 -0
  25. data/test/code/rubylexervsruby.rb +53 -15
  26. data/test/code/strgen.rb +138 -0
  27. data/test/code/tarball.rb +144 -0
  28. data/test/code/testcases.rb +11 -0
  29. data/test/code/tokentest.rb +115 -24
  30. data/test/data/__eof2.rb +1 -0
  31. data/test/data/__eof5.rb +2 -0
  32. data/test/data/__eof6.rb +2 -0
  33. data/test/data/cvtesc.rb +17 -0
  34. data/test/data/g.rb +6 -0
  35. data/test/data/hd0.rb +3 -0
  36. data/test/data/hdateof.rb +2 -0
  37. data/test/data/hdempty.rb +3 -0
  38. data/test/data/hdr.rb +9 -0
  39. data/test/data/hdr_dos.rb +13 -0
  40. data/test/data/hdr_dos2.rb +18 -0
  41. data/test/data/heart.rb +2 -0
  42. data/test/data/here_escnl.rb +25 -0
  43. data/test/data/here_escnl_dos.rb +20 -0
  44. data/test/data/here_squote.rb +3 -0
  45. data/test/data/heremonsters.rb +140 -0
  46. data/test/data/heremonsters.rb.broken +68 -0
  47. data/test/data/heremonsters.rb.broken.save +68 -0
  48. data/test/data/heremonsters_dos.rb +140 -0
  49. data/test/data/heremonsters_dos.rb.broken +68 -0
  50. data/test/data/illegal_oneliners.rb +1 -0
  51. data/test/data/illegal_stanzas.rb +0 -0
  52. data/test/data/make_ws_strdelim.rb +22 -0
  53. data/test/data/maven2_builer_test.rb +82 -0
  54. data/test/data/migration.rb +8944 -0
  55. data/test/data/modl.rb +6 -0
  56. data/test/data/modl_dos.rb +7 -0
  57. data/test/data/modl_fails.rb +10 -0
  58. data/test/data/multilinestring.rb +6 -0
  59. data/test/data/oneliners.rb +555 -0
  60. data/test/data/p-op.rb +2 -0
  61. data/test/data/p.rb +3 -1710
  62. data/test/data/s.rb +90 -21
  63. data/test/data/simple.rb +1 -0
  64. data/test/data/simple_dos.rb +1 -0
  65. data/test/data/stanzas.rb +1194 -0
  66. data/test/data/strdelim_crlf.rb +6 -0
  67. data/test/data/stuff.rb +6 -0
  68. data/test/data/stuff2.rb +5 -0
  69. data/test/data/stuff3.rb +6 -0
  70. data/test/data/stuff4.rb +6 -0
  71. data/test/data/tkweird.rb +20 -0
  72. data/test/data/unending_stuff.rb +5 -0
  73. data/test/data/whatnot.rb +8 -0
  74. data/test/data/ws_strdelim.rb +0 -0
  75. data/test/test.sh +239 -0
  76. data/testing.txt +39 -50
  77. metadata +110 -12
  78. data/test/code/dl_all_gems.rb +0 -43
  79. data/test/code/unpack_all_gems.rb +0 -15
  80. data/test/data/gemlist.txt +0 -280
data/test/data/s.rb CHANGED
@@ -1,6 +1,68 @@
1
1
  #string content tokens move around in this file; its not really a problem
2
2
 
3
3
  if false
4
+ p %w[\ .]
5
+ p %w[\\ .]
6
+ p %W[\ .]
7
+ p %W[\\ .]
8
+
9
+ p %W[\
10
+ ] #ruby interprets this one as a single (totally unescaped) newline,
11
+ #but i suspect that might be a bug.
12
+
13
+ p "\
14
+ "
15
+
16
+ p '\
17
+ '
18
+
19
+ p /\
20
+ /
21
+
22
+ p `\
23
+ `
24
+
25
+ p %w[\
26
+ ]
27
+
28
+ p %[\
29
+ ]
30
+
31
+ p "
32
+
33
+ "
34
+
35
+ p %{
36
+
37
+ }
38
+
39
+ p %W(\s .)
40
+
41
+ p %W(\ .)
42
+ p %W(\\ .)
43
+ p %w(\ .)
44
+ p %w(\\ .)
45
+ p %w(\\
46
+ .)
47
+
48
+ p %W(\s .)
49
+ p %r/ \d/
50
+ p %w[\ ]
51
+ p %W[\ ]
52
+
53
+ PROTOCOLS=%w[http ftp]
54
+ EXTENSIONS=%w[tar zip rb tgz tbz2 tbz]
55
+ EXTRA_EXTENSIONS=%w[gz bz2]
56
+ TARBALL=%r<
57
+ \A(?:#{PROTOCOLS.join('|')})://
58
+ (?:[^/]+/)+
59
+ (.*)
60
+ [_-](.*)
61
+ \.(?:#{EXTENSIONS.join('|')})
62
+ (?:\.(?:#{EXTRA_EXTENSIONS.join'|'}))\Z
63
+ >ix
64
+
65
+
4
66
  t=0
5
67
  t ?'t':0
6
68
  "#{t ?'t':0}"
@@ -141,19 +203,42 @@ FOO
141
203
  p "\
142
204
  #{foo}"
143
205
 
206
+ p "#{foo}#{bar}"
207
+
208
+ p "
209
+ #{compile_body}\
210
+ #{outvar}
211
+ "
212
+
213
+ p "
214
+ #{a}\
215
+ #{b}\
216
+ #{c}\
217
+ #{d}\
218
+ #{e}\
219
+ #{f}\
220
+ #{g}\
221
+ #{h}\
222
+ "
223
+
144
224
  p <<end
145
225
  #{compile_body}\
146
226
  #{outvar}
147
227
  end
148
228
 
229
+ p <<end
230
+ #{a}\
231
+ #{b}\
232
+ #{c}\
233
+ #{d}\
234
+ #{e}\
235
+ #{f}\
236
+ #{g}\
237
+ #{h}
238
+ end
149
239
 
150
240
 
151
241
 
152
- p "#{<<foobar3}"
153
- bim
154
- baz
155
- bof
156
- foobar3
157
242
 
158
243
  p "#{<<foobar2
159
244
  bim
@@ -163,22 +248,6 @@ foobar2
163
248
  }"
164
249
 
165
250
 
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
251
  p <<""
183
252
  foo
184
253
 
@@ -0,0 +1 @@
1
+ p simple
@@ -0,0 +1 @@
1
+ p simple
@@ -0,0 +1,1194 @@
1
+ def x; yield end #this must be first!!!!
2
+ #the purpose of x{...} is to prevent the enclosed code from
3
+ #modifying the list of known local variables. it may be omitted
4
+ #in cases where it is known that no local vars are defined.
5
+
6
+ module SR
7
+ def SelfReferencing
8
+ #old name alias
9
+ end
10
+ def SelfReferencing #old name alias
11
+ end
12
+ def SelfReferencing#old name alias
13
+ end
14
+ def SelfReferencing;end#old name alias
15
+ end
16
+
17
+ p <<Class
18
+ zzzz
19
+ Class
20
+
21
+ p(String <<Class)
22
+ sgsdfgf
23
+ Class
24
+ Class
25
+
26
+ def foo; end
27
+ undef
28
+ foo
29
+
30
+ module Defined_p_syntax_tests
31
+ def self.defined?(foo) :baz end #should be methname
32
+ def defined?(foo) :bar end #should be methname
33
+ def ameth
34
+ p(defined? 44) #should be keyword
35
+ p(self.defined? 44) #should be methname
36
+ end
37
+ end
38
+
39
+ proc{
40
+ p /$/ #regexp
41
+ p /=$/ #operator
42
+ p /$/ #operator
43
+ }
44
+
45
+ proc{
46
+ p %=b=
47
+ 2
48
+ p %(1)
49
+ }
50
+
51
+ proc{
52
+ p *=5
53
+ p %(1)
54
+ }
55
+
56
+ proc{
57
+ p &nil
58
+ p &=1
59
+ p %(1)
60
+ }
61
+
62
+
63
+
64
+ =begin
65
+ =end
66
+
67
+ p <<p
68
+ \
69
+ p
70
+ p
71
+
72
+ p <<'p'
73
+ \
74
+ p
75
+ p
76
+
77
+ p <<p
78
+ \n\t\r\v\\
79
+ p
80
+
81
+ p <<'p'
82
+ \n\t\r\v\\
83
+ p
84
+
85
+ p <<'p'
86
+ \n\t\r\v\
87
+ p
88
+ p
89
+
90
+ p <<p
91
+ \
92
+ sdfgd
93
+ p
94
+
95
+
96
+ p <<END
97
+ dfgdfg
98
+ END
99
+
100
+ p <<'END'
101
+ hgjfg
102
+ END
103
+
104
+ x{
105
+ a,b,c,(d,e)=1,2,3,[4,5]
106
+ p a %(4)
107
+ p c %(4)
108
+ p d %(4)
109
+ p e %(4)
110
+ }
111
+
112
+ def printem___1 a
113
+ a
114
+ end
115
+
116
+ class F0000; end
117
+ def F0000; end
118
+
119
+ x{
120
+ f0000=1
121
+ def f0000; end
122
+ }
123
+
124
+ def printem__1 a
125
+ p(a +77)
126
+ end
127
+
128
+ def printem_1 a,b
129
+ p(a +77)
130
+ p(b +77)
131
+ end
132
+
133
+ def printem1 a,b,c
134
+ p(a +77)
135
+ p(b +77)
136
+ p(c +77)
137
+ end
138
+
139
+ def printem10 a,b,c,d,e,f
140
+ p(a +77)
141
+ p(b +77)
142
+ p(c +77)
143
+ p(d +77)
144
+ p(e +77)
145
+ p(f +77)
146
+ end
147
+
148
+ def printem100 a,b,c,d,e,f,*g,&h
149
+ p(a +77)
150
+ p(b +77)
151
+ p(c +77)
152
+ p(d +77)
153
+ p(e +77)
154
+ p(f +77)
155
+ p(g +77)
156
+ p(h +77)
157
+ end
158
+
159
+ ddd="ddd"
160
+
161
+ #@@ddd=@ddd=$ddd=nil
162
+ def DDD;end
163
+ def ddd2; "asdAds" end
164
+ def (DDD()).foofarendle;end
165
+ def Integer.foofarendle;end
166
+ def @@ddd.foofarendle; 33;end
167
+ def @ddd.foofarendle; 33;end
168
+ def $ddd.foofarendle; 33;end
169
+ def ddd.foofarendle; 33;end
170
+ def ddd2.foofarendle; 33;end
171
+ def (ddd).foofarendle2; end
172
+ def (ddd()).foofarendle2; end
173
+ def (ddd2).foofarendle;end
174
+ def ddd2.foofarendle;end
175
+
176
+ p(<<-jjj \
177
+ dsfgdf
178
+ jjj
179
+ )
180
+
181
+ p(<<-jjj \
182
+ dsfgdf
183
+ jjj
184
+ +"dfsdfs"
185
+ )
186
+
187
+ p(<<-jjj
188
+ dsfgdf
189
+ jjj
190
+ )
191
+
192
+ p(<<-jjj +
193
+ dsfgdf
194
+ jjj
195
+ "dfsdfs"
196
+ )
197
+
198
+ case 1
199
+ when *[2]: p 1
200
+ else p 2
201
+ end
202
+
203
+ x{
204
+ foo bar=>baz
205
+ bar %(1)
206
+ }
207
+
208
+ def foo1
209
+ p (1..10).method(:each) #implicit parens around the whole thing
210
+ end
211
+
212
+ def foo2()
213
+ p((1..10).method(:each)) #explicitly parenthesized... no implicit parens needed
214
+ end
215
+
216
+ def foo3()
217
+ p (1..10).method(:each) #implicit parens around the whole thing
218
+ end
219
+
220
+ p proc{|
221
+ a,b,(c,d,),e|
222
+ p a %(1)
223
+ p b %(2)
224
+ p c %(3)
225
+ p d %(4)
226
+ p e %(5)
227
+ [ a,b,c,d,e]}.call(1,2,[3,4],5)
228
+
229
+ def ggg(x=nil) p x;9 end
230
+ (ggg / 1)
231
+
232
+
233
+ module Y19 #limit lvar scope
234
+ a,b,c,(d,e)=1,2,3,[4,5]
235
+ p a %(4)
236
+ p c %(4)
237
+ p d %(4)
238
+ p e %(4)
239
+ a=[1,2,3,4,5]
240
+ def self.g(x=nil); 3 end
241
+ def a.g=(x) p x end
242
+ g = 5
243
+ self.g = 55
244
+ class<<a
245
+ def bb=(x) p :bb=, x end
246
+ end
247
+ A=a
248
+ class<<self
249
+ def aa; :aa end
250
+ def bb(arg=nil); p :bb; A end
251
+ alias bbb bb
252
+ def m; self end
253
+ def n; self end
254
+ def +(other) self end
255
+ def kk; nil end
256
+ def kk=(foo); nil end
257
+ end
258
+ proc{|a[4]|}.call 6
259
+ proc{|a[b]|}.call 7
260
+ proc{|a.bb| bb %(9) }.call 9
261
+ proc{|a[f]| f %(9) }.call 8
262
+ proc{|bb(aa).bb| aa %(10) }.call 10
263
+ proc{|bbb(aa).bb| bbb %(11) }.call 11
264
+ proc{|t,u,(v,w,x),(y,),z|
265
+ t %(12)
266
+ u %(12)
267
+ v %(12)
268
+ w %(12)
269
+ x %(12)
270
+ y %(12)
271
+ z %(12)
272
+ }.call(1,2,[3,4,5],[6],7)
273
+ proc{|(m).kk,(m+n).kk|
274
+ m %(13)
275
+ n %(13)
276
+ kk %(13)
277
+ }.call(13,14)
278
+ proc{|a.g| g %(9)}
279
+ p a
280
+ end
281
+
282
+ x {
283
+ class<<self
284
+ alias q p
285
+ alias r p
286
+ alias s p
287
+ end
288
+ p(q,r,s)
289
+ q %(1)
290
+ r %(1)
291
+ s %(1)
292
+ p (q,r,s)
293
+ q %(1)
294
+ r %(1)
295
+ s %(1)
296
+ }
297
+
298
+ p true ?
299
+ 1 : 2
300
+
301
+ class String
302
+ class Class
303
+ end
304
+ end
305
+
306
+ p(String<<Class)
307
+ p(String<< Class)
308
+ p(String <<Class)
309
+ sgsdfgf
310
+ Class
311
+ Class
312
+ p(String << Class)
313
+
314
+ p(String<<-Class)
315
+ p(String<< -Class)
316
+ p(String <<-Class)
317
+ sgsdfgf
318
+ Class
319
+ Class
320
+ p(String <<-Class)
321
+ sgsdfgf
322
+ Class
323
+ Class
324
+ Class
325
+ p(String << -Class)
326
+
327
+ p(String<<- Class)
328
+ p(String<< - Class)
329
+ p(String <<- Class)
330
+ Class
331
+ Class
332
+ p(String <<- Class)
333
+ Class
334
+ Class
335
+ Class
336
+ p(String << - Class)
337
+
338
+
339
+
340
+ p <<p
341
+ sdfsfdf^^^^@@@
342
+ p
343
+
344
+ module M33
345
+ p="var:"
346
+ Q="func:"
347
+ def Q.method_missing(name,*args)
348
+ self+name.to_s+(args.join' ')
349
+ end
350
+ def p.method_missing(name,*args)
351
+ self+name.to_s+(args.join' ')
352
+ end
353
+ def self.p(*a); super; Q end
354
+ @a=1
355
+ $a=2
356
+ p(p~6)
357
+ p(p ~6)
358
+ p(p~ 6)
359
+ p(p ~ 6)
360
+ p(p*11)
361
+ p(p *11)
362
+ p(p* 11)
363
+ p(p * 11)
364
+ p(p&proc{})
365
+ p(p &proc{})
366
+ p(p& proc{})
367
+ p(p & proc{})
368
+ p(p !1)
369
+ # p(p ?1) #compile error, when p is var
370
+ p(p ! 1)
371
+ p(p ? 1 : 6)
372
+ p(p@a)
373
+ p(p @a)
374
+ # p(p@ a) #wont
375
+ # p(p @ a) #work
376
+ p(p#a
377
+ )
378
+ p(p #a
379
+ )
380
+ p(p# a
381
+ )
382
+ p(p # a
383
+ )
384
+ p(p$a)
385
+ p(p $a)
386
+ # p(p$ a) #wont
387
+ # p(p $ a) #work
388
+ p(p%Q{:foo})
389
+ p(p %Q{:foo})
390
+ p(p% Q{:foo})
391
+ p(p % Q{:foo})
392
+ p(p^6)
393
+ p(p ^6)
394
+ p(p^ 6)
395
+ p(p ^ 6)
396
+ p(p&7)
397
+ p(p &proc{7})
398
+ p(p& 7)
399
+ p(p & 7)
400
+ p(p(2))
401
+ p(p (2))
402
+ p(p( 2))
403
+ p(p ( 2))
404
+ p(p(p))
405
+ p(p())
406
+ p(p (p))
407
+ p(p ())
408
+ p(p ( p))
409
+ p(p ( ))
410
+ p(p( p))
411
+ p(p( ))
412
+ p(p)
413
+ p((p))
414
+ p(p )
415
+ p((p ))
416
+ p((p p))
417
+ p((p p,p))
418
+ p((p p))
419
+ p((p p,p))
420
+ p(p-0)
421
+ p(p -0)
422
+ p(p- 0)
423
+ p(p - 0)
424
+ p(p+9)
425
+ p(p +9)
426
+ p(p+ 9)
427
+ p(p + 9)
428
+ p(p[1])
429
+ p(p [1])
430
+ p(p[ 1])
431
+ p(p [ 1])
432
+ p(p{1})
433
+ p(p {1})
434
+ p(p{ 1})
435
+ p(p { 1})
436
+ p(p/1)
437
+ p(p /22)
438
+ p(p/ 1)
439
+ p(p / 22)
440
+ p(p._)
441
+ p(p ._)
442
+ p(p. _)
443
+ p(p . _)
444
+ p(false ? p:f)
445
+ p(false ? p :f)
446
+ p(false ? p: f)
447
+ p(false ? p : f)
448
+ p((p;1))
449
+ p((p ;1))
450
+ p((p; 1))
451
+ p((p ; 1))
452
+ p(p<1)
453
+ p(p <1)
454
+ p(p< 1)
455
+ p(p < 1)
456
+ p(p<<1)
457
+ p(p <<1)
458
+ p(p<< 1)
459
+ p(p << 1)
460
+ p(p'j')
461
+ p(p 'j')
462
+ p(p' j')
463
+ p(p ' j')
464
+ p(p"k")
465
+ p(p "k")
466
+ p(p" k")
467
+ p(p " k")
468
+ p(p|4)
469
+ p(p |4)
470
+ p(p| 4)
471
+ p(p | 4)
472
+ p(p>2)
473
+ p(p >2)
474
+ p(p> 2)
475
+ p(p > 2)
476
+ end
477
+
478
+ module M34
479
+ p(p~6)
480
+ p(p ~6)
481
+ p(p~ 6)
482
+ p(p ~ 6)
483
+ p(p*[1])
484
+ p(p *[1])
485
+ p(p* [1])
486
+ p(p * [1])
487
+ p(p&proc{})
488
+ p(p &proc{})
489
+ p(p& proc{})
490
+ p(p & proc{})
491
+ p(p !1)
492
+ p(p ?1)
493
+ p(p ! 1)
494
+ p(p ? 1 : 6)
495
+ p(p@a)
496
+ p(p @a)
497
+ # p(p@ a) #wont
498
+ # p(p @ a) #work
499
+ p(p#a
500
+ )
501
+ p(p #a
502
+ )
503
+ p(p# a
504
+ )
505
+ p(p # a
506
+ )
507
+ p(p$a)
508
+ p(p $a)
509
+ # p(p$ a) #wont
510
+ # p(p $ a) #work
511
+ p(p%Q{:foo})
512
+ p(p %Q{:foo})
513
+ p(p% Q{:foo})
514
+ p(p % Q{:foo})
515
+ p(p^6)
516
+ p(p ^6)
517
+ p(p^ 6)
518
+ p(p ^ 6)
519
+ p(p&7)
520
+ p(p &proc{7})
521
+ p(p& 7)
522
+ p(p & 7)
523
+ p(p(2))
524
+ p(p (2))
525
+ p(p( 2))
526
+ p(p ( 2))
527
+ p(p(p))
528
+ p(p())
529
+ p(p (p))
530
+ p(p ())
531
+ p(p ( p))
532
+ p(p ( ))
533
+ p(p( p))
534
+ p(p( ))
535
+ p(p)
536
+ p((p))
537
+ p(p )
538
+ p((p ))
539
+ p((p p))
540
+ p((p p,p))
541
+ p((p p))
542
+ p((p p,p))
543
+ p(p-0)
544
+ p(p -1)
545
+ p(p- 0)
546
+ p(p - 0)
547
+ p(p+9)
548
+ p(p +9)
549
+ p(p+ 9)
550
+ p(p + 9)
551
+ p(p[1])
552
+ p(p [1])
553
+ p(p[ 1])
554
+ p(p [ 1])
555
+ p(p{1})
556
+ p(p {1})
557
+ p(p{ 1})
558
+ p(p { 1})
559
+ p(p/1)
560
+ p(p /22/)
561
+ p(p/ 1)
562
+ p(p / 22)
563
+ p(p._)
564
+ p(p ._)
565
+ p(p. _)
566
+ p(p . _)
567
+ p(p:f)
568
+ p(p :f)
569
+ p(false ? p: f)
570
+ p(false ? p : f)
571
+ p((p;1))
572
+ p((p ;1))
573
+ p((p; 1))
574
+ p((p ; 1))
575
+ p(p<1)
576
+ p(p <1)
577
+ p(p< 1)
578
+ p(p < 1)
579
+ p(p<<1)
580
+ p(p <<1)
581
+ foobar
582
+ 1
583
+ p(p<< 1)
584
+ p(p << 1)
585
+ p(p'j')
586
+ p(p 'j')
587
+ p(p' j')
588
+ p(p ' j')
589
+ p(p"k")
590
+ p(p "k")
591
+ p(p" k")
592
+ p(p " k")
593
+ p(p|4)
594
+ p(p |4)
595
+ p(p| 4)
596
+ p(p | 4)
597
+ p(p>2)
598
+ p(p >2)
599
+ p(p> 2)
600
+ p(p > 2)
601
+ end
602
+
603
+ x{
604
+ def bob(x) x end
605
+ p(bob %(22))
606
+ for bob in [100] do p(bob %(22)) end
607
+ p(bob %(22))
608
+ }
609
+
610
+ x{
611
+ def %(n) to_s+"%#{n}" end
612
+ def bill(x) x end
613
+ p(bill %(22))
614
+ begin sdjkfsjkdfsd; rescue Object => bill; p(bill %(22)) end
615
+ p(bill %(22))
616
+ undef %
617
+ }
618
+
619
+ class Fixnum
620
+ public :`
621
+ def `(s)
622
+ print "bq: #{s}\n"
623
+ end
624
+ end
625
+ 69.`('what a world')
626
+ 79::`('what a word')
627
+
628
+ x{
629
+ a=5
630
+ p p +5
631
+ p a +5
632
+ }
633
+
634
+ class Foou
635
+ public
636
+ def [] x=-100,&y; p x; 100 end
637
+ end
638
+
639
+ p Foou.new.[] <<9 #value
640
+ foobar
641
+ 9
642
+
643
+ x{
644
+ a0=9
645
+ p Foou.new.[]a0 #value
646
+ p Foou.new.[] a0 #value
647
+ }
648
+
649
+ x{
650
+ a=b=c=0
651
+ a ? b:c
652
+ a ?b:c
653
+ p(a ? b:c)
654
+ p(a ?b:c)
655
+ }
656
+
657
+ x{
658
+ h={}
659
+ h.default=:foo
660
+ p def h.default= v; p @v=v;v end
661
+ p def (h).default= v; p @v=v;v end
662
+ p def (h="foobar").default= v; p @v=v;v end
663
+ p h
664
+ p h.default=:b
665
+ }
666
+
667
+ x do
668
+ x, (*y) = [:x, :y, :z]
669
+ p x
670
+ p y
671
+ x, *y = [:x, :y, :z]
672
+ p x
673
+ p y
674
+ x, * = [:x, :y, :z]
675
+ p x
676
+ end
677
+
678
+ class Foop
679
+ def Foop.bar a,b
680
+ p a,b
681
+ end
682
+ end
683
+ Foop.bar 1,2
684
+ Foop::bar 3,4
685
+
686
+
687
+ class Foop
688
+ def Foop::baz a,b
689
+ p :baz,a,b
690
+ end
691
+ end
692
+ Foop.baz 5,6
693
+ Foop::baz 7,8
694
+
695
+ x{
696
+ without_creating=widgetname=nil
697
+ if without_creating && !widgetname #foo
698
+ fail ArgumentError,
699
+ "if set 'without_creating' to true, need to define 'widgetname'"
700
+ end
701
+ }
702
+
703
+ x{
704
+ #class, module, and def should temporarily hide local variables
705
+ def mopsdfjskdf arg; arg*2 end
706
+ mopsdfjskdf=5
707
+ class C
708
+ p mopsdfjskdf %(3) #calls method
709
+ end
710
+ module M
711
+ p mopsdfjskdf %(4) #calls method
712
+ end
713
+ def d
714
+ p mopsdfjskdf %(5) #calls method
715
+ end
716
+ p d
717
+ p mopsdfjskdf %(6) #reads variable
718
+ p proc{mopsdfjskdf %(7)}[] #reads variable
719
+ }
720
+
721
+ #multiple assignment test
722
+ x {
723
+ a,b,c,d,e,f,g,h,i,j,k=1,2,3,4,5,6,7,8,9,10,11
724
+ p(b %(c))
725
+ p(a %(c))
726
+ p(k %(c))
727
+ p(p %(c))
728
+ }
729
+
730
+ =begin not supported yet
731
+ p "#{<<kekerz}#{"foob"
732
+ zimpler
733
+ kekerz
734
+ }"
735
+ =end
736
+
737
+ =begin not supported yet
738
+ aaa=<<whatnot; p "#{'uh,yeah'
739
+ gonna take it down, to the nitty-grit
740
+ gonna tell you mother-fuckers why you ain't shit
741
+ cause suckers like you just make me strong
742
+ you been pumpin' that bullshit all day long
743
+ whatnot
744
+ }"
745
+ p aaa
746
+ =end
747
+
748
+ #test variable creation in string inclusion
749
+ #currently broken because string inclusions
750
+ #are lexed by a separate lexer!
751
+ proc {
752
+ p "jentawz: #{baz=200}"
753
+ p( baz %(9))
754
+ }.call
755
+
756
+ #scope of local variables always includes the here document
757
+ #body if it includes the head
758
+ p %w[well, whaddaya know].map{|j| <<-END }
759
+ #{j #previous j should be local var, not method
760
+ }45634543
761
+ END
762
+
763
+ =begin not supported yet
764
+ p "#{<<foobar3}"
765
+ bim
766
+ baz
767
+ bof
768
+ foobar3
769
+ =end
770
+
771
+ x do
772
+ a,b,* = [1,2,3,4,5,6,7,8]
773
+ p a,b
774
+ a,b, = [1,2,3,4,5,6,7,8]
775
+ p a,b
776
+ a,b = [1,2,3,4,5,6,7,8]
777
+ p a,b
778
+ a,*b = [1,2,3,4,5,6,7,8]
779
+ p a,b
780
+ a,b,*c=[1,2,3,4,5,6,7,8]
781
+ a,b,* c=[1,2,3,4,5,6,7,8]
782
+ end
783
+
784
+ x {
785
+ h={:a=>(foo=100)}
786
+ p( foo %(5))
787
+ }
788
+
789
+ def foo(a=<<a,b=<<b,c=<<c)
790
+ jfksdkjf
791
+ dkljjkf
792
+ a
793
+ kdljfjkdg
794
+ dfglkdfkgjdf
795
+ dkf
796
+ b
797
+ lkdffdjksadhf
798
+ sdflkdjgsfdkjgsdg
799
+ dsfg;lkdflisgffd
800
+ g
801
+ c
802
+ a+b+c
803
+ end
804
+
805
+
806
+ class AA; class BB; class CC
807
+ FFOO=1
808
+ end end end
809
+ p AA::BB::CC::FFOO
810
+
811
+ x do
812
+ method_src = c.compile(template, (HtmlCompiler::AnyData.new)).join("\n") +
813
+ "\n# generated by PartsTemplate::compile_partstemplate at #{Time.new}\n"
814
+ rescu -1
815
+ end
816
+
817
+ p('rb_out', 'args', <<-'EOL')
818
+ regsub -all {!} $args {\\!} args
819
+ regsub -all "{" $args "\\{" args
820
+ if {[set st [catch {ruby [format "TkCore.callback %%Q!%s!" $args]} ret]] != 0} {
821
+ return -code $st $ret
822
+ } {
823
+ return $ret
824
+ }
825
+ EOL
826
+
827
+
828
+ def add(*args)
829
+ self.<<(*args)
830
+ end
831
+
832
+
833
+ x{
834
+ val=%[13,17,22,"hike", ?\s]
835
+ if val.include? ?\s
836
+ p val.split.collect{|v| (v)}
837
+ end
838
+ }
839
+
840
+ class Hosts
841
+ end
842
+ class DNS < Hosts
843
+ end
844
+
845
+
846
+ def ssssss &block
847
+ end
848
+
849
+ def params_quoted(field_name, default)
850
+ if block_given? then yield field_name else default end
851
+ end
852
+
853
+ x{
854
+ def yy;yield end
855
+ block=proc{p "blah blah"}
856
+ yy &block
857
+ }
858
+
859
+ p(proc do
860
+ p=123
861
+ end.call)
862
+
863
+ p proc {
864
+ p=123
865
+ }.call
866
+
867
+ p def pppp
868
+ p=123
869
+ end
870
+
871
+ p module Ppp
872
+ p=123
873
+ end
874
+
875
+ p class Pppp < String
876
+ p=123
877
+ end
878
+
879
+ def _make_regex(str) /([#{Regexp.escape(str)}])/n end
880
+ p _make_regex("8smdf,34rh\#@\#$%$gfm/[]dD")
881
+
882
+ p "#$a #@b #@@c
883
+ d e f
884
+ #$a #@b #@@c
885
+ "
886
+
887
+ x do
888
+ a='a'
889
+ class <<a
890
+ def foobar
891
+ self*101
892
+ end
893
+ alias eql? ==
894
+ end
895
+ p a.foobar
896
+ end
897
+
898
+ p %w[a b c
899
+ d e f]
900
+
901
+ p %w[a b c\n
902
+ d e f]
903
+
904
+ formatter.format_element(element) do
905
+ amrita_expand_and_format1(element, context, formatter)
906
+ end
907
+
908
+ ret = <<-END
909
+ @@parts_template = #{template.to_ruby}
910
+ def parts_template
911
+ @@parts_template
912
+ end
913
+ #{c.const_def_src.join("\n")}
914
+ def amrita_expand_and_format(element, context, formatter)
915
+ if element.tagname_symbol == :span and element.attrs.size == 0
916
+ amrita_expand_and_format1(element, context, formatter)
917
+ else
918
+ formatter.format_element(element) do
919
+ amrita_expand_and_format1(element, context, formatter)
920
+ end
921
+ end
922
+ end
923
+ def amrita_expand_and_format1(element, context, formatter)
924
+ #{method_src}
925
+ end
926
+ END
927
+
928
+ p '
929
+ '
930
+
931
+ p "
932
+ "
933
+
934
+ p %w/
935
+ /
936
+
937
+ p %W/
938
+ /
939
+
940
+ p(/
941
+ /)
942
+
943
+ p `
944
+ `
945
+
946
+ p <<stuff+'foobar'.tr('j-l','d-f')
947
+ "more stuff"
948
+ 12345678
949
+ the quick brown fox jumped over the lazy dog
950
+ stuff
951
+
952
+ p <<stuff+'foobar'.tr('j-l','d-f')
953
+ "more stuff"
954
+ 12345678
955
+ the quick brown fox jumped over the lazy dog
956
+ stuff
957
+
958
+ p <<stuff+'foobar'.tr('j-l','d-f')\
959
+ +"more stuff"
960
+ 12345678
961
+ the quick brown fox jumped over the lazy dog
962
+ stuff
963
+
964
+ p <<stuff+'foobar'\
965
+ +"more stuff"
966
+ 12345678
967
+ the quick brown fox jumped over the lazy dog
968
+ stuff
969
+
970
+
971
+ p <<-BEGIN + <<-END
972
+ def element_downcase(attributes = {})
973
+ BEGIN
974
+ end
975
+ END
976
+
977
+ p <<ggg; def
978
+ kleegarts() p 'kkkkkkk' end
979
+ dfgdgfdf
980
+ ggg
981
+ koomblatz!() p 'jdkfsk' end
982
+ koomblatz!
983
+
984
+ p( <<end )
985
+ nine time nine men have stood untold.
986
+ end
987
+
988
+ =begin
989
+ =end
990
+
991
+ p <<"..end .."
992
+ cbkvjb
993
+ vb;lkxcvkbxc
994
+ vxlc;kblxckvb
995
+ xcvblcvb
996
+ ..end ..
997
+
998
+ p <<a
999
+ dkflg
1000
+ flk
1001
+ a
1002
+
1003
+ label='label';tab=[1,2,3]
1004
+ p <<S
1005
+ #{label} = arr = Array.new(#{tab.size}, nil)
1006
+ str = a = i = nil
1007
+ idx = 0
1008
+ clist.each do |str|
1009
+ str.split(',', -1).each do |i|
1010
+ arr[idx] = i.to_i unless i.empty?
1011
+ idx += 1
1012
+ end
1013
+ end
1014
+ S
1015
+
1016
+
1017
+ def printem1 a,b,c
1018
+ p(a +77)
1019
+ p(b +77)
1020
+ p(c +77)
1021
+ end
1022
+
1023
+ def foobar() end
1024
+ def foobar2
1025
+ end
1026
+
1027
+ def printem0(a)
1028
+ p(a +77)
1029
+ end
1030
+
1031
+ def printem a,b,c
1032
+ p a;p b;p c
1033
+ p(a +77)
1034
+ p(b %(0.123))
1035
+ end
1036
+ printem 1,2,3
1037
+
1038
+ x do
1039
+ a=1
1040
+ p(a +77)
1041
+ def hhh(a=(1+2)) a end
1042
+ end
1043
+
1044
+ END {
1045
+ p "bye-bye"
1046
+ }
1047
+
1048
+
1049
+ p <<here
1050
+ where?
1051
+ here
1052
+
1053
+ p <<-what
1054
+ ? that's
1055
+ what
1056
+
1057
+ x{
1058
+ for i in if false
1059
+ foob12345; else [44,55,66,77,88] end do p i**Math.sqrt(i) end
1060
+ }
1061
+
1062
+ x{
1063
+ for i in \
1064
+ [44,55,66,77,88] do p i**Math.sqrt(i) end
1065
+ }
1066
+
1067
+ x{
1068
+ for i in if
1069
+ false then foob12345; else [44,55,66,77,88] end do p i**Math.sqrt(i) end
1070
+ }
1071
+
1072
+ x{
1073
+ for i in if false then
1074
+ foob12345; else [44,55,66,77,88] end do p i**Math.sqrt(i) end
1075
+ }
1076
+
1077
+ x{
1078
+ c=j=0
1079
+ until while j<10 do j+=1 end.nil? do p 'pppppppppp' end
1080
+ }
1081
+
1082
+ x{
1083
+ for i in if false then foob12345;
1084
+ else [44,55,66,77,88] end do p i**Math.sqrt(i) end
1085
+ }
1086
+
1087
+ x{
1088
+ for i in if false then foob12345; else
1089
+ [44,55,66,77,88] end do p i**Math.sqrt(i) end
1090
+ }
1091
+
1092
+ x{
1093
+ for i in (c;
1094
+ [44,55,66,77,88]) do p i**Math.sqrt(i) end
1095
+ }
1096
+
1097
+ x{
1098
+ for i in (begin
1099
+ [44,55,66,77,88] end) do p i**Math.sqrt(i) end
1100
+ }
1101
+
1102
+ x{
1103
+ for i in if false then foob12345; else
1104
+ [44,55,66,77,88] end do p i**Math.sqrt(i) end
1105
+ }
1106
+
1107
+ x{
1108
+ for i in (
1109
+ [44,55,66,77,88]) do p i**Math.sqrt(i) end
1110
+ }
1111
+
1112
+ x{
1113
+ for i in (
1114
+ [44,55,66,77,88]) do p i**Math.sqrt(i) end
1115
+ }
1116
+
1117
+
1118
+
1119
+ <<SRC+<<SRC
1120
+ #{headers}
1121
+ SRC
1122
+ #{headers}
1123
+ SRC
1124
+
1125
+
1126
+ A::
1127
+ B
1128
+
1129
+ A::
1130
+ b
1131
+
1132
+ a::
1133
+ B
1134
+
1135
+ a::
1136
+ b
1137
+
1138
+ assert_equal 403291461126605635584000000, 26._!
1139
+ assert_equal 1, 0._!
1140
+ assert_equal 1, 1._!
1141
+ assert_equal 24, 4._!
1142
+
1143
+
1144
+ <<here
1145
+ #{<<there
1146
+ over there, over there, when its over over there.
1147
+ there
1148
+ }
1149
+ here
1150
+
1151
+
1152
+ [a \
1153
+ ,b]
1154
+
1155
+ <<a+<<b
1156
+ #{c}
1157
+ 345234
1158
+ a
1159
+ #{d}
1160
+ 234523452
1161
+ b
1162
+
1163
+ <<a+<<b+\
1164
+ #{c}
1165
+ 345234
1166
+ a
1167
+ #{d}
1168
+ 234523452
1169
+ b
1170
+ "sdfsdf"
1171
+
1172
+ <<a+<<b+
1173
+ #{c}
1174
+ 345234
1175
+ a
1176
+ #{d}
1177
+ 234523452
1178
+ b
1179
+ "sdfsdf"
1180
+
1181
+
1182
+ defined? <<A
1183
+ sdsdfsdfs
1184
+ A
1185
+
1186
+
1187
+
1188
+
1189
+
1190
+ \
1191
+ __END__
1192
+
1193
+
1194
+ __END__