expressir 0.2.16-x86-linux → 0.2.24-x86-linux

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 (109) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +5 -0
  3. data/.github/workflows/release.yml +31 -3
  4. data/README.adoc +3 -3
  5. data/exe/format +66 -12
  6. data/lib/expressir/express_exp/2.4/express_parser.so +0 -0
  7. data/lib/expressir/express_exp/2.5/express_parser.so +0 -0
  8. data/lib/expressir/express_exp/2.6/express_parser.so +0 -0
  9. data/lib/expressir/express_exp/2.7/express_parser.so +0 -0
  10. data/lib/expressir/express_exp/3.0/express_parser.so +0 -0
  11. data/lib/expressir/express_exp/cache.rb +48 -0
  12. data/lib/expressir/express_exp/formatter.rb +185 -135
  13. data/lib/expressir/express_exp/parser.rb +33 -29
  14. data/lib/expressir/express_exp/schema_head_formatter.rb +1 -4
  15. data/lib/expressir/express_exp/visitor.rb +29 -23
  16. data/lib/expressir/model.rb +3 -1
  17. data/lib/expressir/model/attribute.rb +12 -5
  18. data/lib/expressir/model/cache.rb +13 -0
  19. data/lib/expressir/model/constant.rb +9 -2
  20. data/lib/expressir/model/entity.rb +15 -13
  21. data/lib/expressir/model/enumeration_item.rb +7 -0
  22. data/lib/expressir/model/expressions/aggregate_initializer.rb +1 -1
  23. data/lib/expressir/model/expressions/aggregate_item.rb +2 -2
  24. data/lib/expressir/model/expressions/attribute_reference.rb +2 -2
  25. data/lib/expressir/model/expressions/binary_expression.rb +3 -3
  26. data/lib/expressir/model/expressions/call.rb +2 -2
  27. data/lib/expressir/model/expressions/entity_constructor.rb +2 -2
  28. data/lib/expressir/model/expressions/group_reference.rb +2 -2
  29. data/lib/expressir/model/expressions/index_reference.rb +3 -3
  30. data/lib/expressir/model/expressions/interval.rb +5 -5
  31. data/lib/expressir/model/expressions/query_expression.rb +7 -5
  32. data/lib/expressir/model/expressions/simple_reference.rb +1 -1
  33. data/lib/expressir/model/expressions/unary_expression.rb +2 -2
  34. data/lib/expressir/model/function.rb +27 -21
  35. data/lib/expressir/model/identifier.rb +6 -3
  36. data/lib/expressir/model/interface.rb +3 -3
  37. data/lib/expressir/model/interface_item.rb +2 -2
  38. data/lib/expressir/model/interfaced_item.rb +11 -3
  39. data/lib/expressir/model/literals/binary.rb +1 -1
  40. data/lib/expressir/model/literals/integer.rb +1 -1
  41. data/lib/expressir/model/literals/logical.rb +1 -1
  42. data/lib/expressir/model/literals/real.rb +1 -1
  43. data/lib/expressir/model/literals/string.rb +2 -2
  44. data/lib/expressir/model/model_element.rb +54 -19
  45. data/lib/expressir/model/parameter.rb +9 -2
  46. data/lib/expressir/model/procedure.rb +26 -20
  47. data/lib/expressir/model/{informal_proposition.rb → remark_item.rb} +3 -3
  48. data/lib/expressir/model/repository.rb +4 -4
  49. data/lib/expressir/model/rule.rb +29 -23
  50. data/lib/expressir/model/schema.rb +63 -54
  51. data/lib/expressir/model/statements/alias.rb +7 -5
  52. data/lib/expressir/model/statements/assignment.rb +2 -2
  53. data/lib/expressir/model/statements/call.rb +2 -2
  54. data/lib/expressir/model/statements/case.rb +3 -3
  55. data/lib/expressir/model/statements/case_action.rb +2 -2
  56. data/lib/expressir/model/statements/compound.rb +1 -1
  57. data/lib/expressir/model/statements/if.rb +3 -3
  58. data/lib/expressir/model/statements/repeat.rb +11 -9
  59. data/lib/expressir/model/statements/return.rb +1 -1
  60. data/lib/expressir/model/subtype_constraint.rb +9 -7
  61. data/lib/expressir/model/type.rb +14 -8
  62. data/lib/expressir/model/types/aggregate.rb +8 -1
  63. data/lib/expressir/model/types/array.rb +5 -5
  64. data/lib/expressir/model/types/bag.rb +3 -3
  65. data/lib/expressir/model/types/binary.rb +2 -2
  66. data/lib/expressir/model/types/enumeration.rb +4 -4
  67. data/lib/expressir/model/types/generic.rb +7 -0
  68. data/lib/expressir/model/types/generic_entity.rb +7 -0
  69. data/lib/expressir/model/types/list.rb +4 -4
  70. data/lib/expressir/model/types/real.rb +1 -1
  71. data/lib/expressir/model/types/select.rb +5 -5
  72. data/lib/expressir/model/types/set.rb +3 -3
  73. data/lib/expressir/model/types/string.rb +2 -2
  74. data/lib/expressir/model/unique.rb +8 -1
  75. data/lib/expressir/model/variable.rb +9 -2
  76. data/lib/expressir/model/where.rb +8 -1
  77. data/lib/expressir/version.rb +1 -1
  78. data/original/examples/syntax/{hyperlink.exp → multiple.exp} +8 -8
  79. data/original/examples/syntax/multiple.yaml +184 -0
  80. data/original/examples/syntax/multiple_formatted.exp +71 -0
  81. data/original/examples/syntax/multiple_hyperlink_formatted.exp +71 -0
  82. data/original/examples/syntax/multiple_schema_head_hyperlink_formatted.exp +13 -0
  83. data/original/examples/syntax/remark.exp +52 -50
  84. data/original/examples/syntax/remark.yaml +452 -0
  85. data/original/examples/syntax/remark_formatted.exp +64 -50
  86. data/original/examples/syntax/{simple.exp → single.exp} +1 -1
  87. data/original/examples/syntax/single.yaml +9 -0
  88. data/original/examples/syntax/single_formatted.exp +6 -0
  89. data/original/examples/syntax/single_formatted.yaml +19 -0
  90. data/original/examples/syntax/syntax.exp +29 -19
  91. data/original/examples/syntax/syntax.yaml +3439 -0
  92. data/original/examples/syntax/syntax_formatted.exp +271 -131
  93. data/original/examples/syntax/syntax_schema_head_formatted.exp +18 -0
  94. data/spec/expressir/express_exp/cache_spec.rb +64 -0
  95. data/spec/expressir/express_exp/formatter_spec.rb +111 -0
  96. data/spec/expressir/express_exp/parser_spec.rb +98 -0
  97. data/spec/expressir/model/{model_element/find_spec.rb → model_element_spec.rb} +96 -10
  98. metadata +21 -17
  99. data/original/examples/syntax/hyperlink_formatted.exp +0 -51
  100. data/original/examples/syntax/source.exp +0 -16
  101. data/spec/expressir/express_exp/formatter/remark_spec.rb +0 -28
  102. data/spec/expressir/express_exp/formatter/syntax_spec.rb +0 -28
  103. data/spec/expressir/express_exp/hyperlink_formatter_spec.rb +0 -28
  104. data/spec/expressir/express_exp/parser/multiple_spec.rb +0 -37
  105. data/spec/expressir/express_exp/parser/remark_spec.rb +0 -411
  106. data/spec/expressir/express_exp/parser/source_spec.rb +0 -29
  107. data/spec/expressir/express_exp/parser/syntax_spec.rb +0 -3086
  108. data/spec/expressir/express_exp/schema_head_formatter_spec.rb +0 -40
  109. data/spec/expressir/model/model_element/hash_spec.rb +0 -66
@@ -3,19 +3,20 @@ module Expressir
3
3
  class Procedure < ModelElement
4
4
  include Identifier
5
5
 
6
- attr_accessor :parameters
7
- attr_accessor :types
8
- attr_accessor :entities
9
- attr_accessor :subtype_constraints
10
- attr_accessor :functions
11
- attr_accessor :procedures
12
- attr_accessor :constants
13
- attr_accessor :variables
14
- attr_accessor :statements
6
+ model_attr_accessor :parameters
7
+ model_attr_accessor :types
8
+ model_attr_accessor :entities
9
+ model_attr_accessor :subtype_constraints
10
+ model_attr_accessor :functions
11
+ model_attr_accessor :procedures
12
+ model_attr_accessor :constants
13
+ model_attr_accessor :variables
14
+ model_attr_accessor :statements
15
15
 
16
16
  def initialize(options = {})
17
17
  @id = options[:id]
18
18
  @remarks = options.fetch(:remarks, [])
19
+ @remark_items = options.fetch(:remark_items, [])
19
20
  @source = options[:source]
20
21
 
21
22
  @parameters = options.fetch(:parameters, [])
@@ -31,18 +32,23 @@ module Expressir
31
32
  super
32
33
  end
33
34
 
35
+ def enumeration_items
36
+ types.flat_map{|x| x.enumeration_items}
37
+ end
38
+
34
39
  def children
35
- items = []
36
- items.push(*@parameters)
37
- items.push(*@types)
38
- items.push(*@types.flat_map{|x| x.type.is_a?(Types::Enumeration) ? x.type.items : []})
39
- items.push(*@entities)
40
- items.push(*@subtype_constraints)
41
- items.push(*@functions)
42
- items.push(*@procedures)
43
- items.push(*@constants)
44
- items.push(*@variables)
45
- items
40
+ [
41
+ *parameters,
42
+ *types,
43
+ *enumeration_items,
44
+ *entities,
45
+ *subtype_constraints,
46
+ *functions,
47
+ *procedures,
48
+ *constants,
49
+ *variables,
50
+ *remark_items
51
+ ]
46
52
  end
47
53
  end
48
54
  end
@@ -1,12 +1,12 @@
1
1
  module Expressir
2
2
  module Model
3
- class InformalProposition < ModelElement
4
- include Identifier
3
+ class RemarkItem < ModelElement
4
+ model_attr_accessor :id
5
+ model_attr_accessor :remarks
5
6
 
6
7
  def initialize(options = {})
7
8
  @id = options[:id]
8
9
  @remarks = options.fetch(:remarks, [])
9
- @source = options[:source]
10
10
 
11
11
  super
12
12
  end
@@ -1,7 +1,7 @@
1
1
  module Expressir
2
2
  module Model
3
3
  class Repository < ModelElement
4
- attr_accessor :schemas
4
+ model_attr_accessor :schemas
5
5
 
6
6
  def initialize(options = {})
7
7
  @schemas = options.fetch(:schemas, [])
@@ -10,9 +10,9 @@ module Expressir
10
10
  end
11
11
 
12
12
  def children
13
- items = []
14
- items.push(*@schemas)
15
- items
13
+ [
14
+ *schemas
15
+ ]
16
16
  end
17
17
  end
18
18
  end
@@ -3,21 +3,22 @@ module Expressir
3
3
  class Rule < ModelElement
4
4
  include Identifier
5
5
 
6
- attr_accessor :applies_to
7
- attr_accessor :types
8
- attr_accessor :entities
9
- attr_accessor :subtype_constraints
10
- attr_accessor :functions
11
- attr_accessor :procedures
12
- attr_accessor :constants
13
- attr_accessor :variables
14
- attr_accessor :statements
15
- attr_accessor :where
16
- attr_accessor :informal_propositions
6
+ model_attr_accessor :applies_to
7
+ model_attr_accessor :types
8
+ model_attr_accessor :entities
9
+ model_attr_accessor :subtype_constraints
10
+ model_attr_accessor :functions
11
+ model_attr_accessor :procedures
12
+ model_attr_accessor :constants
13
+ model_attr_accessor :variables
14
+ model_attr_accessor :statements
15
+ model_attr_accessor :where
16
+ model_attr_accessor :informal_propositions
17
17
 
18
18
  def initialize(options = {})
19
19
  @id = options[:id]
20
20
  @remarks = options.fetch(:remarks, [])
21
+ @remark_items = options.fetch(:remark_items, [])
21
22
  @source = options[:source]
22
23
 
23
24
  @applies_to = options.fetch(:applies_to, [])
@@ -35,19 +36,24 @@ module Expressir
35
36
  super
36
37
  end
37
38
 
39
+ def enumeration_items
40
+ types.flat_map{|x| x.enumeration_items}
41
+ end
42
+
38
43
  def children
39
- items = []
40
- items.push(*@types)
41
- items.push(*@types.flat_map{|x| x.type.is_a?(Types::Enumeration) ? x.type.items : []})
42
- items.push(*@entities)
43
- items.push(*@subtype_constraints)
44
- items.push(*@functions)
45
- items.push(*@procedures)
46
- items.push(*@constants)
47
- items.push(*@variables)
48
- items.push(*@where)
49
- items.push(*@informal_propositions)
50
- items
44
+ [
45
+ *types,
46
+ *enumeration_items,
47
+ *entities,
48
+ *subtype_constraints,
49
+ *functions,
50
+ *procedures,
51
+ *constants,
52
+ *variables,
53
+ *where,
54
+ *informal_propositions,
55
+ *remark_items
56
+ ]
51
57
  end
52
58
  end
53
59
  end
@@ -1,25 +1,26 @@
1
1
  module Expressir
2
2
  module Model
3
3
  class Schema < ModelElement
4
- attr_accessor :file
4
+ model_attr_accessor :file
5
5
 
6
6
  include Identifier
7
7
 
8
- attr_accessor :version
9
- attr_accessor :interfaces
10
- attr_accessor :constants
11
- attr_accessor :types
12
- attr_accessor :entities
13
- attr_accessor :subtype_constraints
14
- attr_accessor :functions
15
- attr_accessor :procedures
16
- attr_accessor :rules
8
+ model_attr_accessor :version
9
+ model_attr_accessor :interfaces
10
+ model_attr_accessor :constants
11
+ model_attr_accessor :types
12
+ model_attr_accessor :entities
13
+ model_attr_accessor :subtype_constraints
14
+ model_attr_accessor :functions
15
+ model_attr_accessor :rules
16
+ model_attr_accessor :procedures
17
17
 
18
18
  def initialize(options = {})
19
19
  @file = options[:file]
20
20
 
21
21
  @id = options[:id]
22
22
  @remarks = options.fetch(:remarks, [])
23
+ @remark_items = options.fetch(:remark_items, [])
23
24
  @source = options[:source]
24
25
 
25
26
  @version = options[:version]
@@ -29,60 +30,68 @@ module Expressir
29
30
  @entities = options.fetch(:entities, [])
30
31
  @subtype_constraints = options.fetch(:subtype_constraints, [])
31
32
  @functions = options.fetch(:functions, [])
32
- @procedures = options.fetch(:procedures, [])
33
33
  @rules = options.fetch(:rules, [])
34
+ @procedures = options.fetch(:procedures, [])
34
35
 
35
36
  super
36
37
  end
37
38
 
38
- def children(skip_references = false)
39
- items = []
40
- unless skip_references
41
- items.push(*@interfaces.flat_map do |interface|
42
- schema_id = interface.schema.id.downcase
43
- schema = parent.schemas.find{|x| x.id.downcase == schema_id}
44
- if schema
45
- schema_children = schema.children(true) # prevent infinite recursion
46
- if interface.items.length > 0
47
- interface.items.map do |item|
48
- ref_id = item.ref.id.downcase
49
- id = item.id || ref_id
50
- base_item = schema_children.find{|x| x.id and x.id.downcase == ref_id}
51
-
52
- interfaced_item = InterfacedItem.new({
53
- id: id
54
- })
55
- interfaced_item.base_item = base_item # skip overriding parent
56
- interfaced_item.parent = self
57
- interfaced_item
58
- end
59
- else
60
- schema_children.map do |item|
61
- id = item.id
62
- base_item = item
39
+ def create_interfaced_item(id, base_item)
40
+ interfaced_item = InterfacedItem.new({
41
+ id: id
42
+ })
43
+ interfaced_item.base_item = base_item # skip overriding parent
44
+ interfaced_item.parent = self
45
+ interfaced_item
46
+ end
63
47
 
64
- interfaced_item = InterfacedItem.new({
65
- id: id
66
- })
67
- interfaced_item.base_item = base_item # skip overriding parent
68
- interfaced_item.parent = self
69
- interfaced_item
48
+ def interfaced_items
49
+ interfaces.flat_map do |interface|
50
+ schema = parent.children_by_id[interface.schema.id.downcase]
51
+ if schema
52
+ schema_safe_children = schema.safe_children
53
+ schema_safe_children_by_id = schema_safe_children.select{|x| x.id}.map{|x| [x.id.downcase, x]}.to_h
54
+ if interface.items.length > 0
55
+ interface.items.map do |interface_item|
56
+ base_item = schema_safe_children_by_id[interface_item.ref.id.downcase]
57
+ if base_item
58
+ id = interface_item.id || base_item.id
59
+ create_interfaced_item(id, base_item)
70
60
  end
71
61
  end
72
62
  else
73
- []
63
+ schema_safe_children.map do |base_item|
64
+ id = base_item.id
65
+ create_interfaced_item(id, base_item)
66
+ end
74
67
  end
75
- end)
76
- end
77
- items.push(*@constants)
78
- items.push(*@types)
79
- items.push(*@types.flat_map{|x| x.type.is_a?(Types::Enumeration) ? x.type.items : []})
80
- items.push(*@entities)
81
- items.push(*@subtype_constraints)
82
- items.push(*@functions)
83
- items.push(*@procedures)
84
- items.push(*@rules)
85
- items
68
+ end
69
+ end.select{|x| x}
70
+ end
71
+
72
+ def enumeration_items
73
+ types.flat_map{|x| x.enumeration_items}
74
+ end
75
+
76
+ def safe_children
77
+ [
78
+ *constants,
79
+ *types,
80
+ *enumeration_items,
81
+ *entities,
82
+ *subtype_constraints,
83
+ *functions,
84
+ *rules,
85
+ *procedures,
86
+ *remark_items
87
+ ]
88
+ end
89
+
90
+ def children
91
+ [
92
+ *interfaced_items,
93
+ *safe_children
94
+ ]
86
95
  end
87
96
  end
88
97
  end
@@ -4,12 +4,13 @@ module Expressir
4
4
  class Alias < ModelElement
5
5
  include Identifier
6
6
 
7
- attr_accessor :expression
8
- attr_accessor :statements
7
+ model_attr_accessor :expression
8
+ model_attr_accessor :statements
9
9
 
10
10
  def initialize(options = {})
11
11
  @id = options[:id]
12
12
  @remarks = options.fetch(:remarks, [])
13
+ @remark_items = options.fetch(:remark_items, [])
13
14
  @source = options[:source]
14
15
 
15
16
  @expression = options[:expression]
@@ -19,9 +20,10 @@ module Expressir
19
20
  end
20
21
 
21
22
  def children
22
- items = []
23
- items.push(self)
24
- items
23
+ [
24
+ self,
25
+ *remark_items
26
+ ]
25
27
  end
26
28
  end
27
29
  end
@@ -2,8 +2,8 @@ module Expressir
2
2
  module Model
3
3
  module Statements
4
4
  class Assignment < ModelElement
5
- attr_accessor :ref
6
- attr_accessor :expression
5
+ model_attr_accessor :ref
6
+ model_attr_accessor :expression
7
7
 
8
8
  def initialize(options = {})
9
9
  @ref = options[:ref]
@@ -2,8 +2,8 @@ module Expressir
2
2
  module Model
3
3
  module Statements
4
4
  class Call < ModelElement
5
- attr_accessor :ref
6
- attr_accessor :parameters
5
+ model_attr_accessor :ref
6
+ model_attr_accessor :parameters
7
7
 
8
8
  def initialize(options = {})
9
9
  @ref = options[:ref]
@@ -2,9 +2,9 @@ module Expressir
2
2
  module Model
3
3
  module Statements
4
4
  class Case < ModelElement
5
- attr_accessor :expression
6
- attr_accessor :actions
7
- attr_accessor :otherwise_statement
5
+ model_attr_accessor :expression
6
+ model_attr_accessor :actions
7
+ model_attr_accessor :otherwise_statement
8
8
 
9
9
  def initialize(options = {})
10
10
  @expression = options[:expression]
@@ -2,8 +2,8 @@ module Expressir
2
2
  module Model
3
3
  module Statements
4
4
  class CaseAction < ModelElement
5
- attr_accessor :labels
6
- attr_accessor :statement
5
+ model_attr_accessor :labels
6
+ model_attr_accessor :statement
7
7
 
8
8
  def initialize(options = {})
9
9
  @labels = options.fetch(:labels, [])
@@ -2,7 +2,7 @@ module Expressir
2
2
  module Model
3
3
  module Statements
4
4
  class Compound < ModelElement
5
- attr_accessor :statements
5
+ model_attr_accessor :statements
6
6
 
7
7
  def initialize(options = {})
8
8
  @statements = options.fetch(:statements, [])
@@ -2,9 +2,9 @@ module Expressir
2
2
  module Model
3
3
  module Statements
4
4
  class If < ModelElement
5
- attr_accessor :expression
6
- attr_accessor :statements
7
- attr_accessor :else_statements
5
+ model_attr_accessor :expression
6
+ model_attr_accessor :statements
7
+ model_attr_accessor :else_statements
8
8
 
9
9
  def initialize(options = {})
10
10
  @expression = options[:expression]
@@ -4,16 +4,17 @@ module Expressir
4
4
  class Repeat < ModelElement
5
5
  include Identifier
6
6
 
7
- attr_accessor :bound1
8
- attr_accessor :bound2
9
- attr_accessor :increment
10
- attr_accessor :while_expression
11
- attr_accessor :until_expression
12
- attr_accessor :statements
7
+ model_attr_accessor :bound1
8
+ model_attr_accessor :bound2
9
+ model_attr_accessor :increment
10
+ model_attr_accessor :while_expression
11
+ model_attr_accessor :until_expression
12
+ model_attr_accessor :statements
13
13
 
14
14
  def initialize(options = {})
15
15
  @id = options[:id]
16
16
  @remarks = options.fetch(:remarks, [])
17
+ @remark_items = options.fetch(:remark_items, [])
17
18
  @source = options[:source]
18
19
 
19
20
  @bound1 = options[:bound1]
@@ -27,9 +28,10 @@ module Expressir
27
28
  end
28
29
 
29
30
  def children
30
- items = []
31
- items.push(self)
32
- items
31
+ [
32
+ self,
33
+ *remark_items
34
+ ]
33
35
  end
34
36
  end
35
37
  end