-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.rb
executable file
·49 lines (37 loc) · 909 Bytes
/
test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/ruby -w
# 20130630 schmutzr@post.ch
require "T_rex"
test_prefix = Array.new
test_suffix = Array.new
ARGF.each_line do |line|
break if /^$/.match line
test_prefix << line.chomp
end
ARGF.each_line do |line|
test_suffix << line.chomp
end
prefix = T_rex.new()
test_prefix.each do |line|
new_node = line.chomp # .sub(/^\//,"")
prefix.add_child(new_node)
end
suffix = T_rex.new()
test_suffix.each do |line|
suffix.add_child(line.chomp.sub(/^\//,""))
end
re_t = "#{prefix.to_re}/?#{suffix.to_re}"
puts "re: #{re_t}"
re = Regexp.new re_t
puts ""
puts (prefix.compact_suffix.collect { |p| puts "#{p[0]} -> #{p[1]}" }).join("\n")
#test_prefix.each do |p|
# test_suffix.each do |s|
# test_string = "#{p}/#{s}".gsub(/\.\*/,"X")
# if re.match test_string
# puts "ok : #{test_string}"
# else
# puts "fail: #{test_string}"
# end
# end
#end
#puts prefix.to_dot