mbt-gen 0.0.14.2 → 0.0.14.3

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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mbt-gen.rb +47 -22
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3176e95c2bc110640523d69ff0c4cfea0f8e9bb88b4548589c63538c880d6780
4
- data.tar.gz: bc0ebcde2d51db9ab014af418f7d802fc0cba82b94a4bc8b4d416210f793fd43
3
+ metadata.gz: 13d918d0f3a00531a412669c0bcfb9cf0162c80c754b10c2eca6957d31c06c3e
4
+ data.tar.gz: 394f97de41ebf357f02568da55c38b69541d01f70358d6a10f12ef02458826b7
5
5
  SHA512:
6
- metadata.gz: 27b59f856e37fcb50ceee1cf3c75868c15ca337325ce4900a078aa26bc06dac2376f0a683575bb86b5da21f6c57a2dbb59652c8967f664ea0d78a1bf215d69cc
7
- data.tar.gz: 074aadce686f0d9af3fd6b6bf281e821dc3d8634f53d5ddba1545919453612440beb31e054f725c3562ce3cd46c70ed13e589aeb54d6bda64a6107f243f5c6a3
6
+ metadata.gz: bc652237dc0adb070594e90fc44cb5342fff9e1ab2fcbb14f4e07642d88622036b9e2f043b7f7e0582d2d667e04a47afc70e4af0c03ace5bd6ecc793c9798ddd
7
+ data.tar.gz: 82859f8923dfe404b79ed80eb36fe4a3011be424dd4086c6d0be369571cb64ca3a39d5caf67867e2a36f399456ba7f49ed5e95650a4db60768f000c2096ae056
data/lib/mbt-gen.rb CHANGED
@@ -382,7 +382,7 @@ def translate_substructure_to_SMTLIB(progress, solver, struct, hash = {})
382
382
  if field == :additional_smtlib then
383
383
  solver.to_solver(progress, "; additional SMTLIB of structure #{prefix}")
384
384
  solver.to_solver(progress, translate_validation_rule_to_SMTLIB(definition, struct, prefix, config, options, "<additional SMTLIB of structure #{prefix}>"))
385
- elsif field == :validation_rules || field == :predicates || field == :parent_link || field == :struct_xpath_prefix
385
+ elsif field == :validation_rules || field == :predicates || field == :parent_links || field == :struct_xpath_prefix
386
386
  next
387
387
  else
388
388
  solver.to_solver(progress, "; #{field.to_s}")
@@ -539,15 +539,25 @@ def resolve_struct_path(path, relative_to_struct, prefix)
539
539
  raise RuntimeError.new("could not resolve field path: #{path.inspect} relative to struct #{relative_to_struct.inspect}")
540
540
  end
541
541
  if segment == "." then
542
- result = current[:struct_xpath_prefix]
542
+ result = prefix
543
543
  elsif segment == ".." then
544
- current = current[:parent_link]
545
544
  if prefix then
546
- prefix_segs = prefix.split("/")
547
- prefix = prefix_segs[0,prefix_segs.size()-1].join("/")
545
+ next_current = current[:parent_links].find{ |link| prefix.start_with?(link[:struct_xpath_prefix]) }
546
+ if next_current then
547
+ current = next_current
548
+ prefix = current[:struct_xpath_prefix]
549
+ else
550
+ raise RuntimeError.new("failure to resolve segment '..' of path #{path.inspect}: none of the parent-links (#{current[:parent_links].map{|p| p[:struct_xpath_prefix]}.join(', ')}) of struct #{current[:struct_xpath_prefix]} matched the prefix #{prefix.inspect}")
551
+ end
548
552
  else
549
- prefix = current[:struct_xpath_prefix]
553
+ if current[:parent_links].size > 1 then
554
+ raise RuntimeError.new("could not resolve segment '..' in path #{path.inspect} as it is ambiguous: structure #{current[:struct_xpath_prefix]} has multiple parent-links (#{current[:parent_links].map{|p| p[:struct_xpath_prefix]}.join(', ')})")
555
+ else
556
+ current = current[:parent_links].first
557
+ prefix = current[:struct_xpath_prefix]
558
+ end
550
559
  end
560
+ result = prefix
551
561
  else
552
562
  field_def = current[segment.to_sym]
553
563
  unless field_def then
@@ -564,6 +574,7 @@ def resolve_struct_path(path, relative_to_struct, prefix)
564
574
  end
565
575
  end
566
576
  end
577
+ puts "DEBUG: resolve_struct_path(#{path.inspect}, #{relative_to_struct[:struct_xpath_prefix].inspect}, #{prefix.inspect}) returned #{result.inspect}"
567
578
  return result
568
579
  end
569
580
 
@@ -577,7 +588,17 @@ def resolve_struct_def(path, relative_to_struct, prefix, context_desc = "")
577
588
  if segment == "." then
578
589
  result = current
579
590
  elsif segment == ".." then
580
- current = current[:parent_link]
591
+ if prefix then
592
+ current = current[:parent_links].find{|link| prefix.start_with?(link[:struct_xpath_prefix]) }
593
+ prefix = current[:struct_xpath_prefix]
594
+ else
595
+ if current[:parent_links].size > 1 then
596
+ raise RuntimeError.new("could not resolve segment '..' in path #{path.inspect} as it is ambiguous: structure #{current[:struct_xpath_prefix]} has multiple parent-links (#{current[:parent_links].map{|p| p[:struct_xpath_prefix]}.join(', ')})")
597
+ else
598
+ current = current[:parent_links].first
599
+ prefix = current[:struct_xpath_prefix]
600
+ end
601
+ end
581
602
  if prefix then
582
603
  prefix_segs = prefix.split("/")
583
604
  prefix = prefix_segs[0,prefix_segs.size()-1].join("/")
@@ -606,8 +627,8 @@ end
606
627
  def translate_validation_rules_to_SMTLIB(progress, solver, struct, prefix, config, options)
607
628
  solver.to_solver(progress, "; --- Validation Rules ---")
608
629
  translate_validation_rules_for_structure_to_SMTLIB(progress, solver, struct, prefix, config, options)
609
- struct.each_pair do |key, value|
610
- next if key == :validation_rules || key == :predicates || key == :parent_link || key == :struct_xpath_prefix || key == :additional_smtlib
630
+ struct.each_pair do |key, value|
631
+ next if key == :validation_rules || key == :predicates || key == :parent_links || key == :struct_xpath_prefix || key == :additional_smtlib
611
632
  if value[:type] == :structure then
612
633
  if prefix then
613
634
  new_prefix = "#{prefix.to_s}/#{key}"
@@ -885,7 +906,7 @@ end
885
906
 
886
907
  def add_max_struct_to_doc(progress, struct, doc, prefix = nil)
887
908
  struct.each do |key, value|
888
- next if key == :validation_rules || key == :predicates || key == :parent_link || key == :struct_xpath_prefix || key == :additional_smtlib
909
+ next if key == :validation_rules || key == :predicates || key == :parent_links || key == :struct_xpath_prefix || key == :additional_smtlib
889
910
  if prefix then
890
911
  xpath = "#{prefix}/#{key}"
891
912
  else
@@ -953,7 +974,7 @@ end
953
974
 
954
975
  def add_model_struct_to_doc(progress, struct, doc, model, prefix = nil)
955
976
  struct.each do |key, value|
956
- next if key == :validation_rules || key == :predicates || key == :parent_link || key == :struct_xpath_prefix || key == :additional_smtlib
977
+ next if key == :validation_rules || key == :predicates || key == :parent_links || key == :struct_xpath_prefix || key == :additional_smtlib
957
978
  if prefix then
958
979
  xpath = "#{prefix}/#{key}"
959
980
  else
@@ -1016,7 +1037,7 @@ end
1016
1037
  def collect_validation_rule_names(struct)
1017
1038
  result = []
1018
1039
  struct.each do |key, value|
1019
- next if key == :predicates || key == :parent_link || key == :struct_xpath_prefix || key == :additional_smtlib
1040
+ next if key == :predicates || key == :parent_links || key == :struct_xpath_prefix || key == :additional_smtlib
1020
1041
  if key == :validation_rules
1021
1042
  value.each do |key, value|
1022
1043
  result << key
@@ -1038,7 +1059,7 @@ end
1038
1059
 
1039
1060
  def each_structure_and_field_in(struct, prefix = nil, &block)
1040
1061
  struct.each do |key, value|
1041
- next if key == :validation_rules || key == :predicates || key == :parent_link || key == :struct_xpath_prefix || key == :additional_smtlib
1062
+ next if key == :validation_rules || key == :predicates || key == :parent_links || key == :struct_xpath_prefix || key == :additional_smtlib
1042
1063
 
1043
1064
  if prefix then
1044
1065
  xpath = "#{prefix}/#{key}"
@@ -1519,7 +1540,7 @@ end
1519
1540
  def collect_key_fields(fkey, struct, prefix = nil)
1520
1541
  result = {}
1521
1542
  struct.each do |key, value|
1522
- next if key == :validation_rules || key == :predicates || key == :parent_link || key == :struct_xpath_prefix || key == :additional_smtlib
1543
+ next if key == :validation_rules || key == :predicates || key == :parent_links || key == :struct_xpath_prefix || key == :additional_smtlib
1523
1544
  if value[:type] == :structure
1524
1545
  if value.has_key?(:keys) and value[:keys].include?(fkey) then
1525
1546
  xpath = key.to_s
@@ -1545,7 +1566,7 @@ def collect_key_fields_and_strctures(fkey, struct, prefix = nil)
1545
1566
  fields = []
1546
1567
  structures = []
1547
1568
  struct.each do |key, value|
1548
- next if key == :validation_rules || key == :predicates || key == :parent_link || key == :struct_xpath_prefix || key == :additional_smtlib
1569
+ next if key == :validation_rules || key == :predicates || key == :parent_links || key == :struct_xpath_prefix || key == :additional_smtlib
1549
1570
  if value[:type] == :structure
1550
1571
  if value.has_key?(:keys) and value[:keys].include?(fkey) then
1551
1572
  xpath = key.to_s
@@ -1572,7 +1593,7 @@ end
1572
1593
  def collect_keys(struct)
1573
1594
  result = []
1574
1595
  struct.each do |key, value|
1575
- next if key == :validation_rules || key == :predicates || key == :parent_link || key == :struct_xpath_prefix || key == :additional_smtlib
1596
+ next if key == :validation_rules || key == :predicates || key == :parent_links || key == :struct_xpath_prefix || key == :additional_smtlib
1576
1597
  if value[:type] == :structure
1577
1598
  if value.has_key?(:keys) then
1578
1599
  result += value[:keys]
@@ -1592,7 +1613,7 @@ end
1592
1613
  def collect_validation_rules(struct)
1593
1614
  result = []
1594
1615
  struct.each do |key, value|
1595
- next if key == :predicates || key == :parent_link || key == :struct_xpath_prefix || key == :additional_smtlib
1616
+ next if key == :predicates || key == :parent_links || key == :struct_xpath_prefix || key == :additional_smtlib
1596
1617
  if key == :validation_rules then
1597
1618
  result += value.keys
1598
1619
  else
@@ -2141,13 +2162,17 @@ end
2141
2162
 
2142
2163
  def introduce_parent_links(message, parent = nil, prefix = nil)
2143
2164
  if parent != nil then
2144
- message[:parent_link] = parent
2165
+ if message.has_key?(:parent_links) then
2166
+ message[:parent_links] << parent
2167
+ else
2168
+ message[:parent_links] = [parent]
2169
+ end
2145
2170
  end
2146
2171
  if prefix != nil then
2147
2172
  message[:struct_xpath_prefix] = prefix
2148
2173
  end
2149
2174
  message.each_pair do |key, value|
2150
- next if key == :validation_rules || key == :predicates || key == :parent_link || key == :struct_xpath_prefix || key == :additional_smtlib
2175
+ next if key == :validation_rules || key == :predicates || key == :parent_links || key == :struct_xpath_prefix || key == :additional_smtlib
2151
2176
  if value[:type] == :structure then
2152
2177
  if prefix then
2153
2178
  new_prefix = "#{prefix}/#{key}"
@@ -2181,7 +2206,7 @@ def validate_model(message, prefix=nil)
2181
2206
  puts "WARN: Model Problem: structure #{prefix}'s predicate #{mkey} does not have an SMTLIB representation. It will be regarded as always true."
2182
2207
  end
2183
2208
  end
2184
- elsif key == :parent_link || key == :struct_xpath_prefix || key == :additional_smtlib
2209
+ elsif key == :parent_links || key == :struct_xpath_prefix || key == :additional_smtlib
2185
2210
  next
2186
2211
  else
2187
2212
  if value[:type] == :structure then
@@ -2294,7 +2319,7 @@ end
2294
2319
 
2295
2320
  def validate_schema_against_doc_struct(struct, doc, prefix = nil)
2296
2321
  struct.each do |key, value|
2297
- next if key == :additional_smtlib || key == :validation_rules || key == :predicates || key == :parent_link || key == :struct_xpath_prefix
2322
+ next if key == :additional_smtlib || key == :validation_rules || key == :predicates || key == :parent_links || key == :struct_xpath_prefix
2298
2323
  if prefix then
2299
2324
  xpath = "#{prefix}/#{key}"
2300
2325
  else
@@ -2369,7 +2394,7 @@ def translate_struct_in_doc_to_SMTLIB(progress, solver, struct, doc, prefix, var
2369
2394
  config = hash[:config]
2370
2395
 
2371
2396
  struct.each do |key, value|
2372
- next if key == :additional_smtlib || key == :validation_rules || key == :predicates || key == :parent_link || key == :struct_xpath_prefix
2397
+ next if key == :additional_smtlib || key == :validation_rules || key == :predicates || key == :parent_links || key == :struct_xpath_prefix
2373
2398
  if prefix then
2374
2399
  xpath = "#{prefix}/#{key.to_s}"
2375
2400
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mbt-gen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14.2
4
+ version: 0.0.14.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - FM-enthusiast
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-11-05 00:00:00.000000000 Z
11
+ date: 2026-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri