sfp 0.4.1 → 0.4.2

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/sfp/sas_translator.rb +69 -21
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5aaa593d3387a397e9ec0ca4a44adfa88016ff00
4
- data.tar.gz: 443fa1844bef24bb4c1ded0822d0519d600d481c
3
+ metadata.gz: 23b018fd1c5d9bf2cff7ef5902e504f3e3966798
4
+ data.tar.gz: aa1242187f4b5010a93adc6efa813571c318aba9
5
5
  SHA512:
6
- metadata.gz: 721a5319c5ede930324912678407614473f1fdcf2014c00f3622069f1c04e9ec3881e63bcd6a1fb4a8351924d67475c9a0e0d258217d9915572c517e5b7cb2d8
7
- data.tar.gz: eb70b081e1d8618e7de550ab06001b77c6beb5cbc89e90a9c87d84b08dac57c8b194cf4c31c15ff8cc3684537650fbd9fd62bd1cb69687f65f8ec004df9e8a3a
6
+ metadata.gz: e2893d324135fc4dda7a361e48a87faf2ebdf14202c6a8a31940484e63aac0a6f8255b7b9d712965293b7fa1a668af60839511e425faa05f8c4c5f81bb27db4d
7
+ data.tar.gz: 131dcf2321a6f6b558cbef77155b721d647f7658fc856b7f839282c6a1e407535ddaba54da5fec4858c69ecd1c1cda1503f9f8f4bb67d1640e7c5e2a47832975
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.4.2
@@ -291,7 +291,6 @@ module Sfp
291
291
  # actions. Then reduce the size of their domain by 1 only i.e. the possible
292
292
  # value is only their initial value.
293
293
  # BUGGY! -- operator's effects may contain other object's variable
294
- =begin
295
294
  def identify_immutable_variables
296
295
  def is_this(ref)
297
296
  ref.length > 7 and (ref[0,7] == '$.this.' or ref[0,7] == '$.self.')
@@ -325,7 +324,6 @@ module Sfp
325
324
  end
326
325
  end
327
326
  end
328
- =end
329
327
 
330
328
  #####
331
329
  # Method for postprocessing simple global constraints
@@ -916,13 +914,18 @@ module Sfp
916
914
  params = Hash.new
917
915
  procedure.each { |k,v|
918
916
  next if k[0,1] == '_'
919
- # if the specified parameter does not have any value,
920
- # then it's invalid procedure
921
- if not @types.has_key?( v['_isa'] )
922
- return nil
923
- end
924
- params[k] = Array.new
925
- type = case v['_context']
917
+ ### debug
918
+ #puts procedure.ref
919
+ #p = Sfp::Helper.deep_clone(procedure)
920
+ #p.accept(Sfp::Visitor::ParentEliminator.new)
921
+ #p.delete('_parent')
922
+ #puts JSON.pretty_generate(p)
923
+ ### end debug
924
+ type = case v
925
+ when Sfp::Undefined
926
+ v.type
927
+ when Hash
928
+ case v['_context']
926
929
  when 'null', 'any_value'
927
930
  v['_isa']
928
931
  when 'set'
@@ -930,11 +933,33 @@ module Sfp
930
933
  else
931
934
  nil
932
935
  end
933
- next if type == nil
934
- raise TypeNotFoundException, type if not @types.has_key?(type)
935
- @types[ type ].each { |val| params[k] << val if not (val.is_a?(Hash) and val.isnull) and
936
+ else
937
+ return nil
938
+ end
939
+
940
+ #if not @types.has_key?( v['_isa'] )
941
+ # return nil
942
+ #end
943
+ #type = case v['_context']
944
+ # when 'null', 'any_value'
945
+ # v['_isa']
946
+ # when 'set'
947
+ # "(#{v['_isa']})"
948
+ # else
949
+ # nil
950
+ # end
951
+
952
+ #next if type == nil
953
+ #raise TypeNotFoundException, type if not @types.has_key?(type)
954
+
955
+ # if the specified parameter does not have any value,
956
+ # then it's invalid procedure (should print a warning)
957
+ return nil if not @types.has_key?(type)
958
+
959
+ params[k] = Array.new
960
+ @types[ type ].each { |val| params[k] << val if
961
+ not (val.is_a?(Hash) and val.isnull) and
936
962
  !val.is_a?(Sfp::Undefined) and !val.is_a?(Sfp::Unknown) }
937
- #puts k.to_s + ": " + params[k].length.to_s
938
963
  }
939
964
  # combinatorial method for all possible values of parameters
940
965
  # using recursive method
@@ -1788,6 +1813,7 @@ module Sfp
1788
1813
  if name[0,1] != '_'
1789
1814
  modified = false
1790
1815
  map.each { |k,v|
1816
+ #puts k + ',' + name if v.is_a?(Sfp::Undefined) or v.is_a?(Sfp::Unknown)
1791
1817
  next if v.is_a?(Sfp::Undefined) or v.is_a?(Sfp::Unknown)
1792
1818
  if name == k
1793
1819
  obj[v] = value
@@ -1797,6 +1823,7 @@ module Sfp
1797
1823
  modified = true
1798
1824
  break
1799
1825
  elsif name.length > k.length and name[k.length,1] == '.' and name[0, k.length] == k
1826
+ #next if v.is_a?(Sfp::Undefined) or v.is_a?(Sfp::Unknown)
1800
1827
  grounded = v + name[k.length, (name.length-k.length)]
1801
1828
  obj[grounded] = value
1802
1829
  obj.delete(name)
@@ -1819,11 +1846,9 @@ module Sfp
1819
1846
  value['_self'] = name if value.is_a?(Hash)
1820
1847
  end
1821
1848
  end
1822
- # TODO
1823
- # ----- HACK! -----
1824
- # these lines should handle nested 'iterator'
1849
+ # TODO ----- HACK! -----
1825
1850
  if obj.is_a?(Hash) and obj.isconstraint and obj['_type'] == 'iterator' and
1826
- value.is_a?(String) and value.isref and map.has_key?(value)
1851
+ value.is_a?(String) and value.isref and map.has_key?(value)
1827
1852
  obj[name] = value = map[value]
1828
1853
  #puts map[value].inspect
1829
1854
  #puts "==>> " + obj.ref.push(name)
@@ -2054,12 +2079,32 @@ module Sfp
2054
2079
  def dump(stream, root, variables)
2055
2080
  prevails = self.values.select { |p| p.post.nil? }
2056
2081
  preposts = self.values.select { |p| not p.post.nil? }
2082
+ =begin
2083
+ pre_lines = []
2084
+ prevails.each do |p|
2085
+ line = p.to_sas(root, variables)
2086
+ return if line[-1] == ' '
2087
+ pre_lines << line
2088
+ end
2089
+ prepost_lines = []
2090
+ preposts.each do |p|
2091
+ line = p.to_sas(root, variables, false)
2092
+ return if line [-1] == ' '
2093
+ prepost_lines << line
2094
+ end
2095
+ =end
2057
2096
 
2058
2097
  stream.write "begin_operator\n#{@name}"
2059
2098
  @params.each do |key,val|
2060
2099
  stream.write " #{key}=#{val}" if key != '$.this'
2061
2100
  end if @params.is_a?(Hash)
2062
2101
 
2102
+ =begin
2103
+ stream.write "\n#{pre_lines.length}"
2104
+ stream.write "\n#{pre_lines.join("\n")}" if pre_lines.length > 0
2105
+ stream.write "\n#{prepost_lines.length}\n"
2106
+ stream.write "#{prepost_lines.join("\n")}\n" if prepost_lines.length > 0
2107
+ =end
2063
2108
  stream.write "\n#{prevails.length}\n"
2064
2109
  prevails.each { |p| p.dump(stream, root, variables) }
2065
2110
 
@@ -2094,6 +2139,9 @@ module Sfp
2094
2139
  if not p['post'].nil?
2095
2140
  sfw['effect'][p['name']] = (p['post'].is_a?(Sfp::Null) ? nil : p['post'])
2096
2141
  end
2142
+
2143
+ #sfw['condition'][ p['name'] ] = p['pre'] if p['pre'] != nil
2144
+ #sfw['effect'][ p['name'] ] = p['post'] if p['post'] != nil
2097
2145
  end
2098
2146
  return sfw
2099
2147
  end
@@ -2219,10 +2267,10 @@ module Sfp
2219
2267
  post = Sfp::Null.new if @post.is_a?(Hash) and @post.isnull
2220
2268
 
2221
2269
  return {
2222
- 'name' => @var.name,
2223
- 'pre' => pre,
2224
- 'post' => post
2225
- }
2270
+ 'name' => @var.name,
2271
+ 'pre' => pre,
2272
+ 'post' => post
2273
+ }
2226
2274
  end
2227
2275
  end
2228
2276
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sfp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Herry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-19 00:00:00.000000000 Z
11
+ date: 2014-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: antlr3
@@ -89,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  version: '0'
90
90
  requirements: []
91
91
  rubyforge_project: sfp
92
- rubygems_version: 2.1.10
92
+ rubygems_version: 2.0.14
93
93
  signing_key:
94
94
  specification_version: 4
95
95
  summary: SFP Parser