reg 0.4.7 → 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- data/forward_to.rb +4 -4
- data/item_thattest.rb +3 -3
- data/reg.gemspec +5 -3
- data/reg.rb +2 -1
- data/regarray.rb +3 -3
- data/regcore.rb +6 -7
- data/regdeferred.rb +2 -2
- data/regitem_that.rb +4 -4
- data/reglookab.rb +7 -3
- data/regold.rb +3 -3
- data/regprogress.rb +25 -38
- data/regsugar.rb +6 -6
- data/regtest.rb +10 -7
- metadata +50 -42
data/forward_to.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
=begin copyright
|
2
2
|
reg - the ruby extended grammar
|
3
|
-
Copyright (C) 2005 Caleb Clausen
|
3
|
+
Copyright (C) 2005,2009 Caleb Clausen
|
4
4
|
|
5
5
|
This library is free software; you can redistribute it and/or
|
6
6
|
modify it under the terms of the GNU Lesser General Public
|
@@ -37,13 +37,13 @@ protected
|
|
37
37
|
|
38
38
|
eval names.pop.map{|myname,targetname|
|
39
39
|
"def #{myname}(*args,&block) (#{target}).#{targetname}(*args,&block) end\n"
|
40
|
-
}.
|
40
|
+
}.join if Hash===names.last
|
41
41
|
eval names.map{|name|
|
42
42
|
"def #{name}(*args,&block) (#{target}).#{name}(*args,&block) end\n"
|
43
|
-
}.
|
43
|
+
}.join
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
class Module
|
48
48
|
public :forward_to
|
49
|
-
end
|
49
|
+
end
|
data/item_thattest.rb
CHANGED
@@ -24,11 +24,11 @@ require 'test/unit'
|
|
24
24
|
res=pristine_inspect
|
25
25
|
res[/^#</] or return res
|
26
26
|
res=["#<",self.class,": ",instance_variables.sort.collect{|v|
|
27
|
-
[v,"=",instance_variable_get(v).inspect," "]
|
27
|
+
[v,"=",instance_variable_get(v).inspect," "].join
|
28
28
|
}]
|
29
|
-
res.last.
|
29
|
+
res.last.chop!
|
30
30
|
res.push('>')
|
31
|
-
res.
|
31
|
+
res.join
|
32
32
|
end
|
33
33
|
end
|
34
34
|
class T411 < Test::Unit::TestCase
|
data/reg.gemspec
CHANGED
@@ -3,7 +3,7 @@ require 'rubygems'
|
|
3
3
|
spec = Gem::Specification.new do |s|
|
4
4
|
s.name = 'reg'
|
5
5
|
s.rubyforge_project = 'reg'
|
6
|
-
s.version = '0.4.
|
6
|
+
s.version = '0.4.8'
|
7
7
|
s.summary = 'The reg pattern matching/replacement language'
|
8
8
|
s.files = %w[item_thattest.rb regbackref.rb regknows.rb regtest.rb
|
9
9
|
numberset.rb regbind.rb reglogic.rb regvar.rb
|
@@ -16,12 +16,14 @@ spec = Gem::Specification.new do |s|
|
|
16
16
|
s.require_path = '.'
|
17
17
|
s.has_rdoc = false
|
18
18
|
s.requirements=["none"]
|
19
|
-
s.add_dependency("
|
19
|
+
s.add_dependency("sequence", [">= 0.2.3"])
|
20
20
|
s.author = 'Caleb Clausen'
|
21
|
+
s.email = 'caleb @at@ inforadical.net'
|
22
|
+
s.homepage = 'http://github.com/coatl/reg'
|
21
23
|
end
|
22
24
|
|
23
25
|
|
24
26
|
if $0==__FILE__
|
25
|
-
Gem::manage_gems
|
27
|
+
# Gem::manage_gems
|
26
28
|
Gem::Builder.new(spec).build
|
27
29
|
end
|
data/reg.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
=begin copyright
|
2
2
|
reg - the ruby extended grammar
|
3
|
-
Copyright (C) 2005 Caleb Clausen
|
3
|
+
Copyright (C) 2005,2009 Caleb Clausen
|
4
4
|
|
5
5
|
This library is free software; you can redistribute it and/or
|
6
6
|
modify it under the terms of the GNU Lesser General Public
|
@@ -16,6 +16,7 @@
|
|
16
16
|
License along with this library; if not, write to the Free Software
|
17
17
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
18
18
|
=end
|
19
|
+
|
19
20
|
require 'regcore'
|
20
21
|
require 'reglogic'
|
21
22
|
require 'reghash'
|
data/regarray.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
=begin copyright
|
2
2
|
reg - the ruby extended grammar
|
3
|
-
Copyright (C) 2005 Caleb Clausen
|
3
|
+
Copyright (C) 2005,2009 Caleb Clausen
|
4
4
|
|
5
5
|
This library is free software; you can redistribute it and/or
|
6
6
|
modify it under the terms of the GNU Lesser General Public
|
@@ -253,7 +253,7 @@ module Reg
|
|
253
253
|
INFINITY
|
254
254
|
else
|
255
255
|
rl*tl
|
256
|
-
|
256
|
+
end
|
257
257
|
end
|
258
258
|
|
259
259
|
|
@@ -358,7 +358,7 @@ module Reg
|
|
358
358
|
|
359
359
|
private
|
360
360
|
def mmatch_multiple(arr,start)
|
361
|
-
mat=
|
361
|
+
mat=nil
|
362
362
|
@regs.each_with_index{|r,i|
|
363
363
|
if r.respond_to? :mmatch
|
364
364
|
mat=r.mmatch(arr,start) or next
|
data/regcore.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
=begin copyright
|
2
2
|
reg - the ruby extended grammar
|
3
|
-
Copyright (C) 2005 Caleb Clausen
|
3
|
+
Copyright (C) 2005,2009 Caleb Clausen
|
4
4
|
|
5
5
|
This library is free software; you can redistribute it and/or
|
6
6
|
modify it under the terms of the GNU Lesser General Public
|
@@ -28,7 +28,7 @@ module Reg #namespace
|
|
28
28
|
result= [ Float::MAX**Float::MAX, Float::MAX**2, Float::MAX*2].max
|
29
29
|
result.infinite? ? result :
|
30
30
|
begin result=1.0/0
|
31
|
-
rescue
|
31
|
+
rescue; Float::MAX #maybe 1.0/0 doesn't work on some systems?
|
32
32
|
end
|
33
33
|
)
|
34
34
|
#there's also this way: 999999999999999999999999999999999999999999999999e999999999999999999999999999999
|
@@ -137,7 +137,7 @@ module Reg #namespace
|
|
137
137
|
#--------------------------
|
138
138
|
def Reg.interesting_matcher?(mat) #a hack
|
139
139
|
case mat
|
140
|
-
when ItemThatLike,BackrefLike,Module,Set,Regexp,Range,::Reg::Reg
|
140
|
+
when ItemThatLike,BackrefLike,Module,Set,Regexp,Range,::Reg::Reg; true
|
141
141
|
#when Symbol,Pathname: false
|
142
142
|
else
|
143
143
|
/^#<UnboundMethod: .*\(Kernel\)#===>$/===mat.method(:===).unbind.inspect and return false
|
@@ -204,20 +204,19 @@ module Reg #namespace
|
|
204
204
|
#--------------------------
|
205
205
|
|
206
206
|
#eventually, this will be a list of all tla mappings
|
207
|
+
::Reg::TLAs=Hash.new{|h,k| h[k]={} }
|
207
208
|
RegMethods=proc do
|
208
|
-
@@TLAs={}
|
209
209
|
define_method :assign_TLA do |*args|
|
210
210
|
hash=args.pop #extract hash from args
|
211
211
|
noconst,*bogus=*args #peel noconst off front of args
|
212
212
|
hash.each{|k,v|
|
213
|
-
v
|
213
|
+
v=TLAs[self][k]= noconst ? [v,true] : v #fold noconst into v (longname) and store in ::Reg::TLAs
|
214
214
|
TLA_aliases k,v #always alias the TLA into ::Reg namespace
|
215
215
|
}
|
216
216
|
end
|
217
217
|
|
218
218
|
|
219
219
|
alias_method :assign_TLAs, :assign_TLA
|
220
|
-
|
221
220
|
define_method :TLA_aliases do |short,long_args,*rest| myself=rest.first||::Object
|
222
221
|
long=nil
|
223
222
|
if ::Array===long_args
|
@@ -236,7 +235,7 @@ module Reg #namespace
|
|
236
235
|
(class<<mod;self;end).instance_eval( &RegMethods )
|
237
236
|
end
|
238
237
|
|
239
|
-
TLA_pirate= proc {
|
238
|
+
TLA_pirate= proc { ::Reg::TLAs[self].each{|k,v| Reg.TLA_aliases k,v,self} }
|
240
239
|
|
241
240
|
|
242
241
|
end
|
data/regdeferred.rb
CHANGED
@@ -50,7 +50,7 @@ module Reg
|
|
50
50
|
othermod.instance_eval {
|
51
51
|
instance_methods.each { |m|
|
52
52
|
alias_method "##{m}", m #archive m
|
53
|
-
undef_method m unless m =~ /^__/ || m=='instance_eval'
|
53
|
+
undef_method m unless m =~ /^__/ || m=='instance_eval' || m==:instance_eval
|
54
54
|
}
|
55
55
|
extend BlankSlate::ClassMethods
|
56
56
|
}
|
@@ -131,4 +131,4 @@ module Reg
|
|
131
131
|
|
132
132
|
|
133
133
|
|
134
|
-
end
|
134
|
+
end
|
data/regitem_that.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
=begin copyright
|
2
2
|
reg - the ruby extended grammar
|
3
|
-
Copyright (C) 2005 Caleb Clausen
|
3
|
+
Copyright (C) 2005,2009 Caleb Clausen
|
4
4
|
|
5
5
|
This library is free software; you can redistribute it and/or
|
6
6
|
modify it under the terms of the GNU Lesser General Public
|
@@ -51,7 +51,7 @@ module Reg
|
|
51
51
|
def eeee(val)
|
52
52
|
@klass and @klass===val || return
|
53
53
|
begin call(val)
|
54
|
-
rescue
|
54
|
+
rescue; false
|
55
55
|
end
|
56
56
|
end
|
57
57
|
alias === eeee #does nothing in includers.... why?
|
@@ -67,7 +67,7 @@ module Reg
|
|
67
67
|
#just an ancestor for ItemThat and RegThat
|
68
68
|
def eee(item)
|
69
69
|
begin formula_value item
|
70
|
-
rescue
|
70
|
+
rescue; false
|
71
71
|
end
|
72
72
|
end
|
73
73
|
alias === eee #this doesn't work!!! WHY????
|
@@ -143,4 +143,4 @@ module Reg
|
|
143
143
|
|
144
144
|
end
|
145
145
|
|
146
|
-
end
|
146
|
+
end
|
data/reglookab.rb
CHANGED
@@ -31,13 +31,15 @@ module Reg
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def mmatch(pr)
|
34
|
-
@reg.mmatch(pr.subprogress pr.cursor.position,@reg)
|
34
|
+
@reg.mmatch(pr.subprogress( pr.cursor.position,@reg ))
|
35
35
|
end
|
36
36
|
|
37
37
|
def itemrange; 0..0 end
|
38
38
|
|
39
|
-
|
39
|
+
def subregs; [@reg] end
|
40
40
|
|
41
|
+
#most methods should be forwarded to @reg... tbd
|
42
|
+
|
41
43
|
end
|
42
44
|
|
43
45
|
|
@@ -88,7 +90,9 @@ module Reg
|
|
88
90
|
#the subsequence and all but it's middle element.
|
89
91
|
end
|
90
92
|
|
93
|
+
def subregs; [@reg] end
|
94
|
+
|
91
95
|
#most methods should be forwarded to @reg... tbd
|
92
96
|
end
|
93
97
|
|
94
|
-
end
|
98
|
+
end
|
data/regold.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
=begin copyright
|
2
2
|
reg - the ruby extended grammar
|
3
|
-
Copyright (C) 2005 Caleb Clausen
|
3
|
+
Copyright (C) 2005,2009 Caleb Clausen
|
4
4
|
|
5
5
|
This library is free software; you can redistribute it and/or
|
6
6
|
modify it under the terms of the GNU Lesser General Public
|
@@ -35,7 +35,7 @@ for name in ["And", "Array","Equals", "Fixed", "Hash", "Literal",
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
endeval
|
38
|
-
|
38
|
+
else
|
39
39
|
eval <<-endeval
|
40
40
|
module ::Reg#{name}; include Reg::#{name}
|
41
41
|
def self.included(*args,&block)
|
@@ -45,7 +45,7 @@ for name in ["And", "Array","Equals", "Fixed", "Hash", "Literal",
|
|
45
45
|
end
|
46
46
|
endeval
|
47
47
|
|
48
|
-
|
48
|
+
end
|
49
49
|
|
50
50
|
# Object.const_set "Reg"+name, (Reg.const_get name)
|
51
51
|
end
|
data/regprogress.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
=begin copyright
|
2
2
|
reg - the ruby extended grammar
|
3
|
-
Copyright (C) 2005 Caleb Clausen
|
3
|
+
Copyright (C) 2005,2009 Caleb Clausen
|
4
4
|
|
5
5
|
This library is free software; you can redistribute it and/or
|
6
6
|
modify it under the terms of the GNU Lesser General Public
|
@@ -18,11 +18,11 @@
|
|
18
18
|
=end
|
19
19
|
begin
|
20
20
|
require 'rubygems'
|
21
|
-
rescue #do nothing
|
21
|
+
rescue LoadError #do nothing
|
22
22
|
end
|
23
23
|
|
24
|
-
require '
|
25
|
-
require '
|
24
|
+
require 'sequence'
|
25
|
+
require 'sequence/indexed'
|
26
26
|
|
27
27
|
|
28
28
|
=begin the internal api
|
@@ -128,7 +128,7 @@ module Reg
|
|
128
128
|
#matchset_stack should be 1 smaller than matchfail_todo
|
129
129
|
assert @matchfail_todo.size-1==@matchset_stack.size
|
130
130
|
|
131
|
-
@cursor.
|
131
|
+
@cursor.move inc #do nothing if no param given
|
132
132
|
@position_stack.push @cursor.pos #push the start position of the next match
|
133
133
|
@matchfail_todo.last.position_inc+=1
|
134
134
|
@regsidx+=1
|
@@ -197,7 +197,7 @@ module Reg
|
|
197
197
|
result.matchfail_todo=[MatchFailRec.new]
|
198
198
|
result.cursor=
|
199
199
|
if cursor
|
200
|
-
unless
|
200
|
+
unless Sequence===cursor
|
201
201
|
huh #convert other data to a cursor...
|
202
202
|
end
|
203
203
|
cursor
|
@@ -337,13 +337,13 @@ module Reg
|
|
337
337
|
assert @cursor.pos <= @cursor.size
|
338
338
|
assert origpos >= 0
|
339
339
|
assert posinc >= 0
|
340
|
-
assert( (0
|
340
|
+
assert( (0...match_steps)===@regsidx)
|
341
341
|
assert Integer===@position_stack.first
|
342
342
|
assert check_result
|
343
343
|
loop do #loop over regs to match
|
344
344
|
assert @cursor.pos <= @cursor.size
|
345
345
|
assert posinc >= 0
|
346
|
-
assert( (0
|
346
|
+
assert( (0...match_steps)===@regsidx)
|
347
347
|
|
348
348
|
if trace_enabled?
|
349
349
|
puts [@matcher, clean_result].map{|i| i.inspect }.join(' ')
|
@@ -371,7 +371,7 @@ module Reg
|
|
371
371
|
m=nil
|
372
372
|
end
|
373
373
|
else
|
374
|
-
if r===(item=@cursor.
|
374
|
+
if r===(item=@cursor.readahead1)
|
375
375
|
mat=RR[item]
|
376
376
|
matchlen=1
|
377
377
|
end
|
@@ -405,7 +405,7 @@ module Reg
|
|
405
405
|
|
406
406
|
assert check_result
|
407
407
|
return to_result,posinc,@regsidx if @regsidx>=match_steps
|
408
|
-
assert( (0
|
408
|
+
assert( (0...match_steps)===@regsidx)
|
409
409
|
|
410
410
|
end #loop
|
411
411
|
|
@@ -449,7 +449,7 @@ module Reg
|
|
449
449
|
|
450
450
|
assert diinc
|
451
451
|
assert @cursor.pos+diinc <= @cursor.size
|
452
|
-
@cursor.
|
452
|
+
@cursor.move diinc
|
453
453
|
#@regsidx-=matchfail_todo.position_inc #should be done in push_match...
|
454
454
|
@matchfail_todo.push MatchFailRec.new
|
455
455
|
push_match
|
@@ -484,7 +484,7 @@ module Reg
|
|
484
484
|
|
485
485
|
|
486
486
|
#verify correct types in @-variables
|
487
|
-
assert
|
487
|
+
assert Sequence===@cursor
|
488
488
|
assert @matcher.respond_to?( :update_di)
|
489
489
|
assert @regsidx >=0
|
490
490
|
@matchset_stack.each{|ms| assert MatchSet===ms }
|
@@ -496,10 +496,10 @@ module Reg
|
|
496
496
|
@undos_stack.each {|i|
|
497
497
|
case i
|
498
498
|
#every element of @variables should also be a sym in @undos_stack
|
499
|
-
when Symbol
|
499
|
+
when Symbol
|
500
500
|
vars_copy.delete(i) or assert(false)
|
501
501
|
|
502
|
-
when Later
|
502
|
+
when Later
|
503
503
|
else assert(false)
|
504
504
|
end
|
505
505
|
}
|
@@ -526,8 +526,8 @@ module Reg
|
|
526
526
|
def succ_stack_ok(stk=@matchsucceed_stack)
|
527
527
|
stk.each{|elem|
|
528
528
|
case elem
|
529
|
-
when Array
|
530
|
-
when Later
|
529
|
+
when Array; succ_stack_ok(elem)
|
530
|
+
when Later; true
|
531
531
|
else
|
532
532
|
end or return
|
533
533
|
}
|
@@ -548,9 +548,7 @@ module Reg
|
|
548
548
|
ms.clean_result
|
549
549
|
|
550
550
|
else
|
551
|
-
@cursor
|
552
|
-
@cursor[@position_stack[i], @position_stack[i+1]-@position_stack[i]]
|
553
|
-
}
|
551
|
+
@cursor[@position_stack[i], @position_stack[i+1]-@position_stack[i]]
|
554
552
|
end
|
555
553
|
}
|
556
554
|
|
@@ -617,7 +615,7 @@ if defined? $MMATCH_PROGRESS #ultimately, mmatch will take a progress, but unti
|
|
617
615
|
result,di,bogus=pr.bt_match
|
618
616
|
result and SubseqMatchSet.new(pr,di)
|
619
617
|
end
|
620
|
-
|
618
|
+
end
|
621
619
|
|
622
620
|
#---------------------------------------------
|
623
621
|
class Repeat
|
@@ -627,7 +625,7 @@ if defined? $MMATCH_PROGRESS #ultimately, mmatch will take a progress, but unti
|
|
627
625
|
start=cu.pos
|
628
626
|
start+@times.begin <= cu.size or return nil #enough room left in input?
|
629
627
|
i=-1
|
630
|
-
(0...@times.end).each do |i
|
628
|
+
(0...@times.end).each do |i2| i=i2
|
631
629
|
start+i<cu.size or break(i-=1)
|
632
630
|
@reg===cu.read1 or break(i-=1)
|
633
631
|
end
|
@@ -755,14 +753,14 @@ else #... not $MMATCH_PROGRESS
|
|
755
753
|
def mmatch_multiple(arr,start)
|
756
754
|
#in this version, at least one of @regs is a multiple reg
|
757
755
|
assert( (0..arr.size).include?( start))
|
758
|
-
cu=
|
756
|
+
cu=Sequence::Indexed.new(arr); cu.pos=start
|
759
757
|
pr=Progress.new(self,cu)
|
760
758
|
result,di,bogus=pr.bt_match
|
761
759
|
result and SubseqMatchSet.new(pr,di)
|
762
760
|
end
|
763
761
|
end
|
764
762
|
|
765
|
-
class ::
|
763
|
+
class ::Sequence
|
766
764
|
class Indexed
|
767
765
|
def data?; @data end
|
768
766
|
end
|
@@ -771,7 +769,7 @@ else #... not $MMATCH_PROGRESS
|
|
771
769
|
class Repeat
|
772
770
|
def mmatch(arr,start)
|
773
771
|
i=-1
|
774
|
-
(0...@times.end).each do |i
|
772
|
+
(0...@times.end).each do |i2| i=i2
|
775
773
|
start+i<arr.size or break(i-=1)
|
776
774
|
@reg===arr[start+i] or break(i-=1)
|
777
775
|
end
|
@@ -788,7 +786,7 @@ else #... not $MMATCH_PROGRESS
|
|
788
786
|
assert start <= arr.size
|
789
787
|
r=[RR[]]
|
790
788
|
|
791
|
-
cu=
|
789
|
+
cu=Sequence::Indexed.new(arr); cu.pos=start
|
792
790
|
pr=Progress.new(self,cu)
|
793
791
|
|
794
792
|
#first match the minimum number
|
@@ -1044,7 +1042,8 @@ end # $MMATCH_PROGRESS
|
|
1044
1042
|
class Array
|
1045
1043
|
def ===(other)
|
1046
1044
|
::Array===other or return false #need to be more generous eventually
|
1047
|
-
|
1045
|
+
@regs.empty? and return other.empty?
|
1046
|
+
progress=Progress.new(self,(Sequence::Indexed.new other))
|
1048
1047
|
result,di,bogus=progress.bt_match
|
1049
1048
|
assert di.nil? || di <= other.size
|
1050
1049
|
return(di==other.size && result)
|
@@ -1053,15 +1052,3 @@ end # $MMATCH_PROGRESS
|
|
1053
1052
|
|
1054
1053
|
end
|
1055
1054
|
|
1056
|
-
#if false #work-around warnings in cursor
|
1057
|
-
propNiller=proc do
|
1058
|
-
old_init=instance_method:initialize
|
1059
|
-
|
1060
|
-
define_method:initialize do|*args|
|
1061
|
-
@positions||=@prop||=nil
|
1062
|
-
old_init.bind(self)[*args]
|
1063
|
-
end
|
1064
|
-
end
|
1065
|
-
Cursor::Indexed.instance_eval( &propNiller)
|
1066
|
-
Cursor::Position.instance_eval( &propNiller)
|
1067
|
-
#end
|
data/regsugar.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
=begin copyright
|
2
2
|
reg - the ruby extended grammar
|
3
|
-
Copyright (C) 2005 Caleb Clausen
|
3
|
+
Copyright (C) 2005,2009 Caleb Clausen
|
4
4
|
|
5
5
|
This library is free software; you can redistribute it and/or
|
6
6
|
modify it under the terms of the GNU Lesser General Public
|
@@ -134,7 +134,7 @@ module ::Reg
|
|
134
134
|
end
|
135
135
|
|
136
136
|
|
137
|
-
module Kernel
|
137
|
+
module ::Kernel
|
138
138
|
forward_to ::Reg, :item_that, :item_is, :regproc #last need a better name
|
139
139
|
end
|
140
140
|
|
@@ -180,10 +180,10 @@ module ::Reg
|
|
180
180
|
|
181
181
|
def alphabetic_name(meth)
|
182
182
|
@@oplookup[meth] or case meth
|
183
|
-
when
|
184
|
-
when
|
185
|
-
when
|
186
|
-
when /^op_
|
183
|
+
when /\?$/; :"op_#{meth[0...-1]}_p"
|
184
|
+
when /!$/; :"op_#{meth[0...-1]}_bang"
|
185
|
+
when /=$/; :"op_#{meth[0...-1]}_setter"
|
186
|
+
when /^op_/; :"op_#{meth}"
|
187
187
|
else meth
|
188
188
|
end
|
189
189
|
end
|
data/regtest.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
=begin copyright
|
3
3
|
reg - the ruby extended grammar
|
4
|
-
Copyright (C) 2005 Caleb Clausen
|
4
|
+
Copyright (C) 2005,2009 Caleb Clausen
|
5
5
|
|
6
6
|
This library is free software; you can redistribute it and/or
|
7
7
|
modify it under the terms of the GNU Lesser General Public
|
@@ -30,7 +30,7 @@ require 'getoptlong'
|
|
30
30
|
|
31
31
|
#require 'test/unit' #gets in the way of my debug output
|
32
32
|
class TC_Reg #< Test::Unit::TestCase
|
33
|
-
|
33
|
+
class <<self
|
34
34
|
|
35
35
|
|
36
36
|
def randsym
|
@@ -105,13 +105,13 @@ class TC_Reg #< Test::Unit::TestCase
|
|
105
105
|
product=1
|
106
106
|
nestlevel.times {
|
107
107
|
op=case rand(3)
|
108
|
-
when 0
|
109
|
-
when 1
|
110
|
-
when 2
|
108
|
+
when 0; :*
|
109
|
+
when 1; :+
|
110
|
+
when 2; :-
|
111
111
|
end
|
112
112
|
num=rand(6)+1
|
113
113
|
product*=num
|
114
|
-
pat=["(",pat,")",op,num].
|
114
|
+
pat=["(",pat,")",op,num].join
|
115
115
|
product>50 and break
|
116
116
|
}
|
117
117
|
|
@@ -133,11 +133,11 @@ eat_unworking=<<'#end unworking'
|
|
133
133
|
|
134
134
|
|
135
135
|
|
136
|
-
$RegTraceEnable=1 #debugging zone:
|
137
136
|
h={}
|
138
137
|
h.default=:b
|
139
138
|
test_hash_matcher Rah(:a=>:b), :matches=>h
|
140
139
|
|
140
|
+
$RegTraceEnable=1 #debugging zone:
|
141
141
|
$RegTraceEnable=false#end debug zone
|
142
142
|
|
143
143
|
assert_eee Reg[OB*2*(1..2)*2, OB*2], [:foo]*6
|
@@ -184,8 +184,11 @@ $RegTraceEnable=false#end debug zone
|
|
184
184
|
|
185
185
|
assert_eee( +[], [] )
|
186
186
|
assert_ene( +[], [:q] )
|
187
|
+
assert_ene( +[], [nil] )
|
187
188
|
assert_eee( +[:q], [:q] )
|
188
189
|
assert_eee( +[-[]], [] )
|
190
|
+
assert_ene( +[-[]], [:q] )
|
191
|
+
assert_ene( +[-[]], [nil] )
|
189
192
|
assert_eee( +[-[:q]], [:q] )
|
190
193
|
assert_eee( +[-[:q]*1], [:q] )
|
191
194
|
assert_eee( +[-[:q, :q]*1], [:q,:q] )
|
metadata
CHANGED
@@ -1,33 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.0
|
3
|
-
specification_version: 1
|
4
2
|
name: reg
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.4.
|
7
|
-
date: 2006-10-30 00:00:00 -08:00
|
8
|
-
summary: The reg pattern matching/replacement language
|
9
|
-
require_paths:
|
10
|
-
- .
|
11
|
-
email:
|
12
|
-
homepage:
|
13
|
-
rubyforge_project: reg
|
14
|
-
description:
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: false
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 0.4.8
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- Caleb Clausen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-01-03 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: sequence
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.2.3
|
24
|
+
version:
|
25
|
+
description:
|
26
|
+
email: caleb @at@ inforadical.net
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files: []
|
32
|
+
|
31
33
|
files:
|
32
34
|
- item_thattest.rb
|
33
35
|
- regbackref.rb
|
@@ -63,25 +65,31 @@ files:
|
|
63
65
|
- regarrayold.rb
|
64
66
|
- regitem_that.rb
|
65
67
|
- regsugar.rb
|
66
|
-
|
67
|
-
|
68
|
+
has_rdoc: false
|
69
|
+
homepage: http://github.com/coatl/reg
|
70
|
+
post_install_message:
|
68
71
|
rdoc_options: []
|
69
72
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
73
|
+
require_paths:
|
74
|
+
- .
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: "0"
|
80
|
+
version:
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: "0"
|
86
|
+
version:
|
76
87
|
requirements:
|
77
88
|
- none
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
version: "0.9"
|
87
|
-
version:
|
89
|
+
rubyforge_project: reg
|
90
|
+
rubygems_version: 1.3.1
|
91
|
+
signing_key:
|
92
|
+
specification_version: 2
|
93
|
+
summary: The reg pattern matching/replacement language
|
94
|
+
test_files: []
|
95
|
+
|