expressir 0.2.21-x64-mingw32 → 0.2.24-x64-mingw32

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 (76) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release.yml +22 -6
  3. data/lib/expressir/express_exp/2.4/express_parser.so +0 -0
  4. data/lib/expressir/express_exp/2.5/express_parser.so +0 -0
  5. data/lib/expressir/express_exp/2.6/express_parser.so +0 -0
  6. data/lib/expressir/express_exp/2.7/express_parser.so +0 -0
  7. data/lib/expressir/express_exp/3.0/express_parser.so +0 -0
  8. data/lib/expressir/express_exp/cache.rb +1 -1
  9. data/lib/expressir/express_exp/visitor.rb +19 -18
  10. data/lib/expressir/model.rb +1 -1
  11. data/lib/expressir/model/attribute.rb +12 -5
  12. data/lib/expressir/model/cache.rb +2 -2
  13. data/lib/expressir/model/constant.rb +9 -2
  14. data/lib/expressir/model/entity.rb +10 -8
  15. data/lib/expressir/model/enumeration_item.rb +7 -0
  16. data/lib/expressir/model/expressions/aggregate_initializer.rb +1 -1
  17. data/lib/expressir/model/expressions/aggregate_item.rb +2 -2
  18. data/lib/expressir/model/expressions/attribute_reference.rb +2 -2
  19. data/lib/expressir/model/expressions/binary_expression.rb +3 -3
  20. data/lib/expressir/model/expressions/call.rb +2 -2
  21. data/lib/expressir/model/expressions/entity_constructor.rb +2 -2
  22. data/lib/expressir/model/expressions/group_reference.rb +2 -2
  23. data/lib/expressir/model/expressions/index_reference.rb +3 -3
  24. data/lib/expressir/model/expressions/interval.rb +5 -5
  25. data/lib/expressir/model/expressions/query_expression.rb +5 -3
  26. data/lib/expressir/model/expressions/simple_reference.rb +1 -1
  27. data/lib/expressir/model/expressions/unary_expression.rb +2 -2
  28. data/lib/expressir/model/function.rb +13 -11
  29. data/lib/expressir/model/identifier.rb +6 -3
  30. data/lib/expressir/model/interface.rb +3 -3
  31. data/lib/expressir/model/interface_item.rb +2 -2
  32. data/lib/expressir/model/interfaced_item.rb +11 -6
  33. data/lib/expressir/model/literals/binary.rb +1 -1
  34. data/lib/expressir/model/literals/integer.rb +1 -1
  35. data/lib/expressir/model/literals/logical.rb +1 -1
  36. data/lib/expressir/model/literals/real.rb +1 -1
  37. data/lib/expressir/model/literals/string.rb +2 -2
  38. data/lib/expressir/model/model_element.rb +29 -24
  39. data/lib/expressir/model/parameter.rb +9 -2
  40. data/lib/expressir/model/procedure.rb +12 -10
  41. data/lib/expressir/model/{informal_proposition.rb → remark_item.rb} +3 -6
  42. data/lib/expressir/model/repository.rb +1 -1
  43. data/lib/expressir/model/rule.rb +14 -12
  44. data/lib/expressir/model/schema.rb +13 -11
  45. data/lib/expressir/model/statements/alias.rb +5 -3
  46. data/lib/expressir/model/statements/assignment.rb +2 -2
  47. data/lib/expressir/model/statements/call.rb +2 -2
  48. data/lib/expressir/model/statements/case.rb +3 -3
  49. data/lib/expressir/model/statements/case_action.rb +2 -2
  50. data/lib/expressir/model/statements/compound.rb +1 -1
  51. data/lib/expressir/model/statements/if.rb +3 -3
  52. data/lib/expressir/model/statements/repeat.rb +9 -7
  53. data/lib/expressir/model/statements/return.rb +1 -1
  54. data/lib/expressir/model/subtype_constraint.rb +11 -4
  55. data/lib/expressir/model/type.rb +6 -4
  56. data/lib/expressir/model/types/aggregate.rb +8 -1
  57. data/lib/expressir/model/types/array.rb +5 -5
  58. data/lib/expressir/model/types/bag.rb +3 -3
  59. data/lib/expressir/model/types/binary.rb +2 -2
  60. data/lib/expressir/model/types/enumeration.rb +4 -4
  61. data/lib/expressir/model/types/generic.rb +7 -0
  62. data/lib/expressir/model/types/generic_entity.rb +7 -0
  63. data/lib/expressir/model/types/list.rb +4 -4
  64. data/lib/expressir/model/types/real.rb +1 -1
  65. data/lib/expressir/model/types/select.rb +5 -5
  66. data/lib/expressir/model/types/set.rb +3 -3
  67. data/lib/expressir/model/types/string.rb +2 -2
  68. data/lib/expressir/model/unique.rb +8 -1
  69. data/lib/expressir/model/variable.rb +9 -2
  70. data/lib/expressir/model/where.rb +8 -1
  71. data/lib/expressir/version.rb +1 -1
  72. data/original/examples/syntax/remark.exp +12 -10
  73. data/original/examples/syntax/remark.yaml +9 -3
  74. data/original/examples/syntax/remark_formatted.exp +3 -1
  75. data/spec/expressir/model/model_element_spec.rb +20 -20
  76. metadata +3 -3
@@ -1,9 +1,12 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Identifier
4
- attr_accessor :id
5
- attr_accessor :remarks
6
- attr_accessor :source
4
+ def self.included(mod)
5
+ mod.model_attr_accessor :id
6
+ mod.model_attr_accessor :remarks
7
+ mod.model_attr_accessor :remark_items
8
+ mod.model_attr_accessor :source
9
+ end
7
10
  end
8
11
  end
9
12
  end
@@ -4,9 +4,9 @@ module Expressir
4
4
  USE = :USE
5
5
  REFERENCE = :REFERENCE
6
6
 
7
- attr_accessor :kind
8
- attr_accessor :schema
9
- attr_accessor :items
7
+ model_attr_accessor :kind
8
+ model_attr_accessor :schema
9
+ model_attr_accessor :items
10
10
 
11
11
  def initialize(options = {})
12
12
  @kind = options[:kind]
@@ -1,8 +1,8 @@
1
1
  module Expressir
2
2
  module Model
3
3
  class InterfaceItem < ModelElement
4
- attr_accessor :ref
5
- attr_accessor :id
4
+ model_attr_accessor :ref
5
+ model_attr_accessor :id
6
6
 
7
7
  def initialize(options = {})
8
8
  @ref = options[:ref]
@@ -1,17 +1,16 @@
1
1
  module Expressir
2
2
  module Model
3
3
  class InterfacedItem < ModelElement
4
- include Identifier
4
+ model_attr_accessor :id
5
+ model_attr_accessor :remarks
6
+ model_attr_accessor :remark_items
5
7
 
6
- undef :source
7
- undef :source=
8
-
9
- attr_accessor :base_item
8
+ model_attr_accessor :base_item
10
9
 
11
10
  def initialize(options = {})
12
11
  @id = options[:id]
13
12
  @remarks = options.fetch(:remarks, [])
14
- # @source = options[:source]
13
+ @remark_items = options.fetch(:remark_items, [])
15
14
 
16
15
  @base_item = options[:base_item]
17
16
 
@@ -21,6 +20,12 @@ module Expressir
21
20
  def path
22
21
  base_item.path
23
22
  end
23
+
24
+ def children
25
+ [
26
+ *remark_items
27
+ ]
28
+ end
24
29
  end
25
30
  end
26
31
  end
@@ -2,7 +2,7 @@ module Expressir
2
2
  module Model
3
3
  module Literals
4
4
  class Binary < ModelElement
5
- attr_accessor :value
5
+ model_attr_accessor :value
6
6
 
7
7
  def initialize(options = {})
8
8
  @value = options[:value]
@@ -2,7 +2,7 @@ module Expressir
2
2
  module Model
3
3
  module Literals
4
4
  class Integer < ModelElement
5
- attr_accessor :value
5
+ model_attr_accessor :value
6
6
 
7
7
  def initialize(options = {})
8
8
  @value = options[:value]
@@ -6,7 +6,7 @@ module Expressir
6
6
  FALSE = :FALSE
7
7
  UNKNOWN = :UNKNOWN
8
8
 
9
- attr_accessor :value
9
+ model_attr_accessor :value
10
10
 
11
11
  def initialize(options = {})
12
12
  @value = options[:value]
@@ -2,7 +2,7 @@ module Expressir
2
2
  module Model
3
3
  module Literals
4
4
  class Real < ModelElement
5
- attr_accessor :value
5
+ model_attr_accessor :value
6
6
 
7
7
  def initialize(options = {})
8
8
  @value = options[:value]
@@ -2,8 +2,8 @@ module Expressir
2
2
  module Model
3
3
  module Literals
4
4
  class String < ModelElement
5
- attr_accessor :value
6
- attr_accessor :encoded
5
+ model_attr_accessor :value
6
+ model_attr_accessor :encoded
7
7
 
8
8
  def initialize(options = {})
9
9
  @value = options[:value]
@@ -5,8 +5,6 @@ module Expressir
5
5
  class ModelElement
6
6
  CLASS_KEY = '_class'
7
7
  FILE_KEY = 'file'
8
- PARENT_KEY = 'parent'
9
- CHILDREN_BY_ID_KEY = 'children_by_id'
10
8
  SOURCE_KEY = 'source'
11
9
 
12
10
  attr_accessor :parent
@@ -15,11 +13,6 @@ module Expressir
15
13
  attach_parent_to_children
16
14
  end
17
15
 
18
- def model_instance_variables
19
- skip_variables = [FILE_KEY, PARENT_KEY, CHILDREN_BY_ID_KEY].map{|x| "@#{x}".to_sym}
20
- instance_variables.select{|x| !skip_variables.include?(x)}
21
- end
22
-
23
16
  def path
24
17
  return id if is_a? Statements::Alias or is_a? Statements::Repeat or is_a? Expressions::QueryExpression
25
18
 
@@ -38,8 +31,8 @@ module Expressir
38
31
  end
39
32
 
40
33
  def attach_parent_to_children
41
- model_instance_variables.each do |variable|
42
- value = instance_variable_get(variable)
34
+ self.class.model_attrs.each do |variable|
35
+ value = self.send(variable)
43
36
 
44
37
  if value.is_a? Array
45
38
  value.each do |value|
@@ -100,18 +93,14 @@ module Expressir
100
93
 
101
94
  hash = {}
102
95
  hash[CLASS_KEY] = self.class.name
103
- if self.is_a? Schema and file
104
- hash[FILE_KEY] = root_path ? Pathname.new(file).relative_path_from(root_path).to_s : file
105
- end
106
96
 
107
- model_instance_variables.each do |variable|
108
- key = variable.to_s.sub(/^@/, '')
109
- value = instance_variable_get(variable)
97
+ self.class.model_attrs.each do |variable|
98
+ value = self.send(variable)
110
99
  empty = value.nil? || (value.is_a?(Array) && value.count == 0)
111
100
 
112
101
  # skip empty values
113
102
  if !empty or include_empty
114
- hash[key] = if value.is_a? Array
103
+ hash[variable.to_s] = if value.is_a? Array
115
104
  value.map do |value|
116
105
  if value.is_a? ModelElement
117
106
  value.to_hash(options)
@@ -127,6 +116,10 @@ module Expressir
127
116
  end
128
117
  end
129
118
 
119
+ if self.is_a? Schema and file
120
+ hash[FILE_KEY] = root_path ? Pathname.new(file).relative_path_from(root_path).to_s : file
121
+ end
122
+
130
123
  if self.class.method_defined? :source and formatter
131
124
  hash[SOURCE_KEY] = formatter.format(self)
132
125
  end
@@ -137,16 +130,13 @@ module Expressir
137
130
  def self.from_hash(hash, options = {})
138
131
  root_path = options[:root_path]
139
132
 
140
- node_class = hash[CLASS_KEY]
133
+ node_class = Object.const_get(hash[CLASS_KEY])
141
134
  node_options = {}
142
- if node_class == 'Expressir::Model::Schema' and hash[FILE_KEY]
143
- node_options[FILE_KEY.to_sym] = root_path ? File.expand_path("#{root_path}/#{hash[FILE_KEY]}") : hash[FILE_KEY]
144
- end
145
135
 
146
- hash.select{|x| x != CLASS_KEY && x != FILE_KEY}.each do |variable, value|
147
- key = variable.to_sym
136
+ node_class.model_attrs.each do |variable|
137
+ value = hash[variable.to_s]
148
138
 
149
- node_options[key] = if value.is_a? Array
139
+ node_options[variable] = if value.is_a? Array
150
140
  value.map do |value|
151
141
  if value.is_a? Hash
152
142
  self.from_hash(value, options)
@@ -161,10 +151,25 @@ module Expressir
161
151
  end
162
152
  end
163
153
 
164
- node = Object.const_get(node_class).new(node_options)
154
+ if node_class == Schema and hash[FILE_KEY]
155
+ node_options[FILE_KEY.to_sym] = root_path ? File.expand_path("#{root_path}/#{hash[FILE_KEY]}") : hash[FILE_KEY]
156
+ end
157
+
158
+ node = node_class.new(node_options)
165
159
 
166
160
  node
167
161
  end
162
+
163
+ def self.model_attrs
164
+ @model_attrs ||= []
165
+ end
166
+
167
+ def self.model_attr_accessor(*vars)
168
+ @model_attrs ||= []
169
+ @model_attrs.concat(vars)
170
+
171
+ attr_accessor *vars
172
+ end
168
173
  end
169
174
  end
170
175
  end
@@ -3,12 +3,13 @@ module Expressir
3
3
  class Parameter < ModelElement
4
4
  include Identifier
5
5
 
6
- attr_accessor :var
7
- attr_accessor :type
6
+ model_attr_accessor :var
7
+ model_attr_accessor :type
8
8
 
9
9
  def initialize(options = {})
10
10
  @id = options[:id]
11
11
  @remarks = options.fetch(:remarks, [])
12
+ @remark_items = options.fetch(:remark_items, [])
12
13
  @source = options[:source]
13
14
 
14
15
  @var = options[:var]
@@ -16,6 +17,12 @@ module Expressir
16
17
 
17
18
  super
18
19
  end
20
+
21
+ def children
22
+ [
23
+ *remark_items
24
+ ]
25
+ end
19
26
  end
20
27
  end
21
28
  end
@@ -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, [])
@@ -45,7 +46,8 @@ module Expressir
45
46
  *functions,
46
47
  *procedures,
47
48
  *constants,
48
- *variables
49
+ *variables,
50
+ *remark_items
49
51
  ]
50
52
  end
51
53
  end
@@ -1,15 +1,12 @@
1
1
  module Expressir
2
2
  module Model
3
- class InformalProposition < ModelElement
4
- include Identifier
5
-
6
- undef :source
7
- undef :source=
3
+ class RemarkItem < ModelElement
4
+ model_attr_accessor :id
5
+ model_attr_accessor :remarks
8
6
 
9
7
  def initialize(options = {})
10
8
  @id = options[:id]
11
9
  @remarks = options.fetch(:remarks, [])
12
- # @source = options[:source]
13
10
 
14
11
  super
15
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, [])
@@ -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, [])
@@ -50,7 +51,8 @@ module Expressir
50
51
  *constants,
51
52
  *variables,
52
53
  *where,
53
- *informal_propositions
54
+ *informal_propositions,
55
+ *remark_items
54
56
  ]
55
57
  end
56
58
  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 :rules
16
- attr_accessor :procedures
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]
@@ -81,7 +82,8 @@ module Expressir
81
82
  *subtype_constraints,
82
83
  *functions,
83
84
  *rules,
84
- *procedures
85
+ *procedures,
86
+ *remark_items
85
87
  ]
86
88
  end
87
89
 
@@ -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]
@@ -20,7 +21,8 @@ module Expressir
20
21
 
21
22
  def children
22
23
  [
23
- self
24
+ self,
25
+ *remark_items
24
26
  ]
25
27
  end
26
28
  end