fhlow 1.91.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/bin/fhlow +186 -0
- data/lib/module_cmdparse/cmdparse.rb +480 -0
- data/lib/module_cmdparse/cmdparse/wrappers/optparse.rb +65 -0
- data/lib/module_config/config.rb +67 -0
- data/lib/module_config/configexception.rb +18 -0
- data/lib/module_config/configitems/complex.rb +71 -0
- data/lib/module_config/configitems/complexpackage.rb +67 -0
- data/lib/module_config/configitems/complexunit.rb +76 -0
- data/lib/module_config/configitems/simple.rb +56 -0
- data/lib/module_config/configitems/simplearchitecture.rb +52 -0
- data/lib/module_config/configitems/simplepackage.rb +47 -0
- data/lib/module_config/configitems/simpleunit.rb +53 -0
- data/lib/module_config/configs.test +24 -0
- data/lib/module_config/item.rb +34 -0
- data/lib/module_config/itemfactory.rb +55 -0
- data/lib/module_config/section.rb +69 -0
- data/lib/module_config/test.flw +20 -0
- data/lib/module_config/test.rb +85 -0
- data/lib/module_config/tmp +3 -0
- data/lib/module_config/unittests/config_1.flw +14 -0
- data/lib/module_config/unittests/config_1_fixed.flw +14 -0
- data/lib/module_config/unittests/config_2.flw +15 -0
- data/lib/module_config/unittests/config_3a.flw +16 -0
- data/lib/module_config/unittests/config_3b.flw +15 -0
- data/lib/module_config/unittests/config_test.rb +579 -0
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-configexception_rb.html +647 -0
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-configitems-complex_rb.html +700 -0
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-configitems-complexpackage_rb.html +694 -0
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-configitems-complexunit_rb.html +704 -0
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-configitems-simple_rb.html +685 -0
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-configitems-simplepackage_rb.html +676 -0
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-configitems-simpleunit_rb.html +682 -0
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-item_rb.html +663 -0
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-itemfactory_rb.html +687 -0
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-myconfig_rb.html +687 -0
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-section_rb.html +692 -0
- data/lib/module_config/unittests/coverage/index.html +689 -0
- data/lib/module_fhlow/fhlowexception.rb +55 -0
- data/lib/module_fhlow/leaf.rb +197 -0
- data/lib/module_fhlow/leaf.rb~ +202 -0
- data/lib/module_fhlow/leaffactory.rb +97 -0
- data/lib/module_fhlow/leafs/Package.rb +55 -0
- data/lib/module_fhlow/leafs/Unit.rb +152 -0
- data/lib/module_fhlow/log.rb +100 -0
- data/lib/module_fhlow/node.rb +206 -0
- data/lib/module_fhlow/pen.rb +101 -0
- data/lib/module_fhlow/plugin.rb +54 -0
- data/lib/module_fhlow/pluginpool.rb +81 -0
- data/lib/module_fhlow/rootnode.rb +98 -0
- data/lib/module_fhlow/test.rb +15 -0
- data/lib/module_term/ansicolor.rb +102 -0
- data/tests/testsuite.rb +20 -0
- metadata +106 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'item'
|
2
|
+
require 'itemfactory'
|
3
|
+
require 'configexception'
|
4
|
+
|
5
|
+
module Config
|
6
|
+
|
7
|
+
class SimplePackageFactory < ItemFactory
|
8
|
+
def SimplePackageFactory.match(_str)
|
9
|
+
_str.sub!(SimplePackage.getRegex, '')
|
10
|
+
return $&
|
11
|
+
end
|
12
|
+
|
13
|
+
def SimplePackageFactory.create(*_args)
|
14
|
+
SimplePackage.new(*_args)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
class SimplePackage < Item
|
20
|
+
@@regex = /^\s*(\w*Package\w*)\s*=\s*([\w,.;\s]+)\s*$/
|
21
|
+
|
22
|
+
attr_reader :name
|
23
|
+
attr_reader :value
|
24
|
+
|
25
|
+
def initialize(_str)
|
26
|
+
if _str =~ @@regex
|
27
|
+
@name = $1
|
28
|
+
@value = $2.strip
|
29
|
+
else
|
30
|
+
raise ConfigWrongFormatException.new(self.class), "Configuration item <#{_str}> has wrong format."
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def merge(_item)
|
35
|
+
raise ConfigMergeException.new(self.class), "Merge: Configuration items do not fit! <#{_item}> is not of type #{self.class.to_s}." unless _item.instance_of?(self.class)
|
36
|
+
raise ConfigMergeException.new(self.class), "Merge: Configuration items do not have the same name! <#{_item.name}> vs. <#{@name}>" unless _item.name == @name
|
37
|
+
|
38
|
+
@value = _item.value
|
39
|
+
end
|
40
|
+
|
41
|
+
def SimplePackage.getRegex()
|
42
|
+
@@regex
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'item'
|
2
|
+
require 'itemfactory'
|
3
|
+
require 'configexception'
|
4
|
+
|
5
|
+
module Config
|
6
|
+
|
7
|
+
class SimpleUnitFactory < ItemFactory
|
8
|
+
def SimpleUnitFactory.match(_str)
|
9
|
+
_str.sub!(SimpleUnit.getRegex, '')
|
10
|
+
return $&
|
11
|
+
end
|
12
|
+
|
13
|
+
def SimpleUnitFactory.create(*_args)
|
14
|
+
SimpleUnit.new(*_args)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
class SimpleUnit < Item
|
20
|
+
@@regex = /^\s*(\w*Unit\w*)\s*=\s*([\w,.;\s]+)\((.*)\)\s*$/
|
21
|
+
|
22
|
+
attr_reader :name
|
23
|
+
attr_reader :value
|
24
|
+
|
25
|
+
def initialize(_str)
|
26
|
+
if _str =~ @@regex
|
27
|
+
@name = $1
|
28
|
+
@value = Hash.new
|
29
|
+
@value["deppath"] = $2
|
30
|
+
@value["archs"] = $3.split(/,\s*/)
|
31
|
+
else
|
32
|
+
raise ConfigWrongFormatException.new(self.class), "Configuration item <#{_str}> has wrong format."
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def merge(_item)
|
37
|
+
raise ConfigMergeException.new(self.class), "Merge: Configuration items do not fit! <#{_item}> is not of type #{self.class.to_s}." unless _item.instance_of?(self.class)
|
38
|
+
raise ConfigMergeException.new(self.class), "Merge: Configuration items do not have the same name! <#{_item.name}> vs. <#{@name}>" unless _item.name == @name
|
39
|
+
|
40
|
+
@value = _item.value
|
41
|
+
end
|
42
|
+
|
43
|
+
def print
|
44
|
+
puts "<#{self.class.to_s}> -> ".ljust(40)+" #{@name} = #{@value["deppath"]}(#{@value["archs"].join(", ")})"
|
45
|
+
end
|
46
|
+
|
47
|
+
def SimpleUnit.getRegex()
|
48
|
+
@@regex
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Config
|
2
|
+
|
3
|
+
class Item
|
4
|
+
attr_reader :priority
|
5
|
+
|
6
|
+
protected
|
7
|
+
def initialize
|
8
|
+
end
|
9
|
+
|
10
|
+
public
|
11
|
+
|
12
|
+
def print
|
13
|
+
puts "<#{self.class.to_s}> -> ".ljust(40)+" #{@name} = #{@value}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def merge(_item)
|
17
|
+
raise NotImplementedError, "You have to implement merge() in sublcasses inherited from Config::Item!"
|
18
|
+
end
|
19
|
+
|
20
|
+
def name
|
21
|
+
raise NotImplementedError, "You have to implement name() in sublcasses inherited from Config::Item!"
|
22
|
+
end
|
23
|
+
|
24
|
+
def value
|
25
|
+
raise NotImplementedError, "You have to implement value() in sublcasses inherited from Config::Item!"
|
26
|
+
end
|
27
|
+
|
28
|
+
def Item.getRegex()
|
29
|
+
raise NotImplementedError, "You have to implement getRegex() in sublcasses inherited from Config::Item!"
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "configexception"
|
2
|
+
|
3
|
+
module Config
|
4
|
+
|
5
|
+
class ItemFactory
|
6
|
+
|
7
|
+
@@factories = []
|
8
|
+
|
9
|
+
def ItemFactory.inherited(_if)
|
10
|
+
@@factories.push(_if)
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
def ItemFactory.factories()
|
15
|
+
@@factories
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
def ItemFactory.getItemFor(_str)
|
20
|
+
@@factories.each do |subclass|
|
21
|
+
match = subclass.match(_str) # the matched string will be removed from _str by subclass.match()
|
22
|
+
if !match.nil?
|
23
|
+
return subclass.create(match)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
raise ConfigException.new(self.class), "There were some wrong entries in your configfile:\n -----\n #{_str.strip}\n -----"
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
def ItemFactory.load(_dir)
|
32
|
+
Dir.open(_dir).each do |file|
|
33
|
+
if file =~ /[.]rb$/
|
34
|
+
require _dir+"/"+file
|
35
|
+
end
|
36
|
+
end
|
37
|
+
@@factories.sort! { |x,y| x.priority <=> y.priority }
|
38
|
+
end
|
39
|
+
|
40
|
+
def ItemFactory.match(_str)
|
41
|
+
raise NotImplementedError, "You have to implement match() in sublcasses inherited from Config::ItemFactory!"
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
def ItemFactory.create()
|
46
|
+
raise NotImplementedError, "You have to implement create() in sublcasses inherited from Config::ItemFactory!"
|
47
|
+
end
|
48
|
+
|
49
|
+
def ItemFactory.priority()
|
50
|
+
0
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'itemfactory'
|
2
|
+
require 'configexception'
|
3
|
+
|
4
|
+
module Config
|
5
|
+
|
6
|
+
class Section
|
7
|
+
@@beginName = '[\[]'
|
8
|
+
@@name = '[\w\s]+'
|
9
|
+
@@endName = '[\]]'
|
10
|
+
@@regex = /#{@@beginName}#{@@name}#{@@endName}[^\[]+/
|
11
|
+
|
12
|
+
attr_reader :name
|
13
|
+
|
14
|
+
|
15
|
+
def initialize(_str)
|
16
|
+
@items = []
|
17
|
+
str = _str.sub(/#{@@beginName}(#{@@name})#{@@endName}/, '')
|
18
|
+
@name = $1
|
19
|
+
|
20
|
+
|
21
|
+
while !str.strip.empty?
|
22
|
+
begin
|
23
|
+
@items.push(ItemFactory.getItemFor(str)) # the matched string will be deleted from str by ItemFactory.getItemFor()
|
24
|
+
|
25
|
+
rescue ConfigException => e
|
26
|
+
raise ConfigException.new(self.class), " Section: #{@name}\n Error: #{e.message}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
def each(&block)
|
33
|
+
@items.each(&block)
|
34
|
+
end
|
35
|
+
|
36
|
+
def [](_name)
|
37
|
+
ifnotfound = lambda { raise Fhlow::FhlowException.new("Config::Section"), "No such section. <#{_name}>" }
|
38
|
+
i = @items.detect(ifnotfound) { |item| item.name == _name }
|
39
|
+
i.value
|
40
|
+
end
|
41
|
+
|
42
|
+
def merge(_section)
|
43
|
+
begin
|
44
|
+
_section.each do |arg_item|
|
45
|
+
if i = @items.detect { |item| item.name == arg_item.name }
|
46
|
+
i.merge(arg_item)
|
47
|
+
else
|
48
|
+
@items.push(arg_item)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
rescue ConfigException => e
|
53
|
+
raise ConfigException.new(self.class), " Section: #{@name}\n Error: #{e.message}"
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def print()
|
59
|
+
puts "[#{@name}]"
|
60
|
+
@items.each { |i| i.print() }
|
61
|
+
end
|
62
|
+
|
63
|
+
def Section.getRegex()
|
64
|
+
@@regex
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
$:.unshift("../module_fhlow")
|
2
|
+
|
3
|
+
require 'profile' if $DEBUG
|
4
|
+
|
5
|
+
def show_regexp(a, re)
|
6
|
+
if a =~ re
|
7
|
+
puts "#{$`}<<#{$&}>>#{$'}"
|
8
|
+
puts "<#{$1}>"
|
9
|
+
puts "<#{$2}>"
|
10
|
+
else
|
11
|
+
puts "no match"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def dummy(_str)
|
17
|
+
_str.sub!("h", 'H')
|
18
|
+
end
|
19
|
+
|
20
|
+
=begin
|
21
|
+
str = "hallo"
|
22
|
+
dummy(str)
|
23
|
+
puts str
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
a = IO.read("configs.test")
|
28
|
+
puts a
|
29
|
+
=end
|
30
|
+
|
31
|
+
=begin
|
32
|
+
|
33
|
+
puts "---------------------------------------------"
|
34
|
+
#show_regexp(a, /^\s*.*[;]*/)
|
35
|
+
#show_regexp(a, /(\w+)\s*=(\s*|[\n]*)\{((\s*.*[;][\s\n]*)+(\s*.*[;]*[\s\n]*))\}/)
|
36
|
+
#show_regexp(a, /(\w+)\s*=(\s*|[\n]*)\{((\s*.*[;][\s\n]*)*(\s*.*[;]*[\s\n]*))\}/)
|
37
|
+
a = "\n \n gaga = hallo\n \n \n\n \n\n\n\n\n"
|
38
|
+
a = "\n Architectures = Rtl, SomeArch\n tbArchitectures = Bhv, SomeTbArch\n bhvArchitectures = Bhv, SomeBhvArch\n\n"
|
39
|
+
a = "UnitComplex = { 1,2,3(bla); \n \n 11, 12, 13(blub) } \n\n Unit = 21,22,23(glob) \n\n PackageComplex = { a,b,c; \n c,d,e } \n Package = f,g,h \n"
|
40
|
+
|
41
|
+
p IO.read("/home/simon/tmp/fhlow.v2/grpProl16/unitAlu/config.flw")
|
42
|
+
|
43
|
+
a = "Packages = {\n Prol16, Prol16;\n }\n\n Units = {\n }\n\n BhvUnits = { \n }\n\n tbUnits = {\n Prol16, Alu,(Bhv)\n }\n"
|
44
|
+
#show_regexp(a, /(\w*Unit\w*)\s*=\s*\{((\s*.*[;]\s*)*(\s*.*\(.*\)[;]*\s*)?)*\}/)
|
45
|
+
show_regexp(a, /(\w*Unit\w*)\s*=\s*\{((\s*.*[;]\s*)*(\s*.*\(.*\)[;]*\s*)?)\s*\}/)
|
46
|
+
|
47
|
+
=end
|
48
|
+
|
49
|
+
=begin
|
50
|
+
show_regexp(a, /(\w+)\s*=(\s*|[\n]*)\{((\s*.*[;][\s\n]*)*(\s*.*\(.*\)[;]*[\s\n]*))\}/)
|
51
|
+
puts "-------------------"
|
52
|
+
show_regexp(a, /(\w+)\s*=(\s*|[\n]*)\{((\s*[^\(\)]*[;][\s\n]*)*(\s*[^\(\)]*[;]*[\s\n]*))\}/)
|
53
|
+
puts "-------------------"
|
54
|
+
show_regexp(a, /^\s*(\w+)\s*=\s*([\w,.;\s\(\)]+)\s*$/)
|
55
|
+
puts "-------------------"
|
56
|
+
show_regexp(a, /^\s*(\w+)\s*=\s*([\w,.;\s]+)\s$/)
|
57
|
+
puts "-------------------"
|
58
|
+
|
59
|
+
a = "ComplexUnits = {\n 1,2,3(bla);\n 4,5,6(bhv)\n }\n\n ComplexPackage = {\n a,b,c;\n d,e,f\n }\n\n Unit = blablablal(bla)\n\n Package = asdfja\n some = thing else"
|
60
|
+
str = 'ComplexUnits = {
|
61
|
+
1,2,3(bla);
|
62
|
+
4,5,6(bhv)
|
63
|
+
}
|
64
|
+
|
65
|
+
ComplexPackage = {
|
66
|
+
a,b,c;
|
67
|
+
d,e,f
|
68
|
+
}
|
69
|
+
|
70
|
+
Unit = blablablal(bla)
|
71
|
+
|
72
|
+
Package = asdfja
|
73
|
+
some = thing else'
|
74
|
+
|
75
|
+
show_regexp(show_regexp(str, /^\s*(\w+)\s*=\s*([\w,.;\s]+)\s*$/), /^\s*(\w+)\s*=\s*([\w,.;\s]+)\s*$/)
|
76
|
+
=end
|
77
|
+
|
78
|
+
require 'myconfig'
|
79
|
+
|
80
|
+
begin
|
81
|
+
cfg = Config::Config.new("/home/simon/tmp/fhlow.v2/grpProl16/unitCpu/config.flw")
|
82
|
+
cfg.print
|
83
|
+
rescue Config::ConfigException => e
|
84
|
+
puts "Error:\n#{e.message}"
|
85
|
+
end
|