expressir 0.2.17 → 0.2.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) 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 +45 -29
  6. data/ext/express-parser/extconf.rb +2 -0
  7. data/lib/expressir/express_exp/cache.rb +48 -0
  8. data/lib/expressir/express_exp/formatter.rb +2 -2
  9. data/lib/expressir/express_exp/hyperlink_formatter.rb +10 -15
  10. data/lib/expressir/express_exp/model_visitor.rb +23 -0
  11. data/lib/expressir/express_exp/parser.rb +18 -3
  12. data/lib/expressir/express_exp/resolve_references_model_visitor.rb +33 -0
  13. data/lib/expressir/express_exp/visitor.rb +19 -18
  14. data/lib/expressir/model.rb +3 -1
  15. data/lib/expressir/model/attribute.rb +12 -5
  16. data/lib/expressir/model/cache.rb +13 -0
  17. data/lib/expressir/model/constant.rb +9 -2
  18. data/lib/expressir/model/entity.rb +10 -8
  19. data/lib/expressir/model/enumeration_item.rb +7 -0
  20. data/lib/expressir/model/expressions/aggregate_initializer.rb +1 -1
  21. data/lib/expressir/model/expressions/aggregate_item.rb +2 -2
  22. data/lib/expressir/model/expressions/attribute_reference.rb +2 -2
  23. data/lib/expressir/model/expressions/binary_expression.rb +3 -3
  24. data/lib/expressir/model/expressions/call.rb +2 -2
  25. data/lib/expressir/model/expressions/entity_constructor.rb +2 -2
  26. data/lib/expressir/model/expressions/group_reference.rb +2 -2
  27. data/lib/expressir/model/expressions/index_reference.rb +3 -3
  28. data/lib/expressir/model/expressions/interval.rb +5 -5
  29. data/lib/expressir/model/expressions/query_expression.rb +5 -3
  30. data/lib/expressir/model/expressions/simple_reference.rb +5 -1
  31. data/lib/expressir/model/expressions/unary_expression.rb +2 -2
  32. data/lib/expressir/model/function.rb +13 -11
  33. data/lib/expressir/model/identifier.rb +6 -3
  34. data/lib/expressir/model/interface.rb +3 -3
  35. data/lib/expressir/model/interface_item.rb +2 -2
  36. data/lib/expressir/model/interfaced_item.rb +9 -8
  37. data/lib/expressir/model/literals/binary.rb +1 -1
  38. data/lib/expressir/model/literals/integer.rb +1 -1
  39. data/lib/expressir/model/literals/logical.rb +1 -1
  40. data/lib/expressir/model/literals/real.rb +1 -1
  41. data/lib/expressir/model/literals/string.rb +2 -2
  42. data/lib/expressir/model/model_element.rb +46 -21
  43. data/lib/expressir/model/parameter.rb +9 -2
  44. data/lib/expressir/model/procedure.rb +12 -10
  45. data/lib/expressir/model/{informal_proposition.rb → remark_item.rb} +3 -6
  46. data/lib/expressir/model/repository.rb +1 -1
  47. data/lib/expressir/model/rule.rb +14 -12
  48. data/lib/expressir/model/schema.rb +13 -11
  49. data/lib/expressir/model/statements/alias.rb +5 -3
  50. data/lib/expressir/model/statements/assignment.rb +2 -2
  51. data/lib/expressir/model/statements/call.rb +2 -2
  52. data/lib/expressir/model/statements/case.rb +3 -3
  53. data/lib/expressir/model/statements/case_action.rb +2 -2
  54. data/lib/expressir/model/statements/compound.rb +1 -1
  55. data/lib/expressir/model/statements/if.rb +3 -3
  56. data/lib/expressir/model/statements/repeat.rb +9 -7
  57. data/lib/expressir/model/statements/return.rb +1 -1
  58. data/lib/expressir/model/subtype_constraint.rb +11 -4
  59. data/lib/expressir/model/type.rb +6 -4
  60. data/lib/expressir/model/types/aggregate.rb +8 -1
  61. data/lib/expressir/model/types/array.rb +5 -5
  62. data/lib/expressir/model/types/bag.rb +3 -3
  63. data/lib/expressir/model/types/binary.rb +2 -2
  64. data/lib/expressir/model/types/enumeration.rb +4 -4
  65. data/lib/expressir/model/types/generic.rb +7 -0
  66. data/lib/expressir/model/types/generic_entity.rb +7 -0
  67. data/lib/expressir/model/types/list.rb +4 -4
  68. data/lib/expressir/model/types/real.rb +1 -1
  69. data/lib/expressir/model/types/select.rb +5 -5
  70. data/lib/expressir/model/types/set.rb +3 -3
  71. data/lib/expressir/model/types/string.rb +2 -2
  72. data/lib/expressir/model/unique.rb +8 -1
  73. data/lib/expressir/model/variable.rb +9 -2
  74. data/lib/expressir/model/where.rb +8 -1
  75. data/lib/expressir/version.rb +1 -1
  76. data/original/examples/syntax/multiple.yaml +18 -0
  77. data/original/examples/syntax/remark.exp +12 -10
  78. data/original/examples/syntax/remark.yaml +24 -3
  79. data/original/examples/syntax/remark_formatted.exp +3 -1
  80. data/original/examples/syntax/single.exp +1 -0
  81. data/original/examples/syntax/single.yaml +7 -0
  82. data/original/examples/syntax/single_formatted.exp +4 -0
  83. data/original/examples/syntax/single_formatted.yaml +15 -0
  84. data/original/examples/syntax/syntax.yaml +82 -0
  85. data/original/examples/syntax/syntax_hyperlink_formatted.exp +902 -0
  86. data/spec/expressir/express_exp/cache_spec.rb +64 -0
  87. data/spec/expressir/express_exp/formatter_spec.rb +17 -0
  88. data/spec/expressir/express_exp/parser_spec.rb +9 -9
  89. data/spec/expressir/model/model_element_spec.rb +32 -29
  90. metadata +9 -3
@@ -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]
@@ -28,7 +29,8 @@ module Expressir
28
29
 
29
30
  def children
30
31
  [
31
- self
32
+ self,
33
+ *remark_items
32
34
  ]
33
35
  end
34
36
  end
@@ -2,7 +2,7 @@ module Expressir
2
2
  module Model
3
3
  module Statements
4
4
  class Return < ModelElement
5
- attr_accessor :expression
5
+ model_attr_accessor :expression
6
6
 
7
7
  def initialize(options = {})
8
8
  @expression = options[:expression]
@@ -3,14 +3,15 @@ module Expressir
3
3
  class SubtypeConstraint < ModelElement
4
4
  include Identifier
5
5
 
6
- attr_accessor :applies_to
7
- attr_accessor :abstract
8
- attr_accessor :total_over
9
- attr_accessor :supertype_expression
6
+ model_attr_accessor :applies_to
7
+ model_attr_accessor :abstract
8
+ model_attr_accessor :total_over
9
+ model_attr_accessor :supertype_expression
10
10
 
11
11
  def initialize(options = {})
12
12
  @id = options[:id]
13
13
  @remarks = options.fetch(:remarks, [])
14
+ @remark_items = options.fetch(:remark_items, [])
14
15
  @source = options[:source]
15
16
 
16
17
  @applies_to = options[:applies_to]
@@ -20,6 +21,12 @@ module Expressir
20
21
 
21
22
  super
22
23
  end
24
+
25
+ def children
26
+ [
27
+ *remark_items
28
+ ]
29
+ end
23
30
  end
24
31
  end
25
32
  end
@@ -3,13 +3,14 @@ module Expressir
3
3
  class Type < ModelElement
4
4
  include Identifier
5
5
 
6
- attr_accessor :type
7
- attr_accessor :where
8
- attr_accessor :informal_propositions
6
+ model_attr_accessor :type
7
+ model_attr_accessor :where
8
+ model_attr_accessor :informal_propositions
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
  @type = options[:type]
@@ -27,7 +28,8 @@ module Expressir
27
28
  [
28
29
  *enumeration_items,
29
30
  *where,
30
- *informal_propositions
31
+ *informal_propositions,
32
+ *remark_items
31
33
  ]
32
34
  end
33
35
  end
@@ -4,17 +4,24 @@ module Expressir
4
4
  class Aggregate < ModelElement
5
5
  include Identifier
6
6
 
7
- attr_accessor :base_type
7
+ model_attr_accessor :base_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
  @base_type = options[:base_type]
15
16
 
16
17
  super
17
18
  end
19
+
20
+ def children
21
+ [
22
+ *remark_items
23
+ ]
24
+ end
18
25
  end
19
26
  end
20
27
  end
@@ -2,11 +2,11 @@ module Expressir
2
2
  module Model
3
3
  module Types
4
4
  class Array < ModelElement
5
- attr_accessor :bound1
6
- attr_accessor :bound2
7
- attr_accessor :optional
8
- attr_accessor :unique
9
- attr_accessor :base_type
5
+ model_attr_accessor :bound1
6
+ model_attr_accessor :bound2
7
+ model_attr_accessor :optional
8
+ model_attr_accessor :unique
9
+ model_attr_accessor :base_type
10
10
 
11
11
  def initialize(options = {})
12
12
  @bound1 = options[:bound1]
@@ -2,9 +2,9 @@ module Expressir
2
2
  module Model
3
3
  module Types
4
4
  class Bag < ModelElement
5
- attr_accessor :bound1
6
- attr_accessor :bound2
7
- attr_accessor :base_type
5
+ model_attr_accessor :bound1
6
+ model_attr_accessor :bound2
7
+ model_attr_accessor :base_type
8
8
 
9
9
  def initialize(options = {})
10
10
  @bound1 = options[:bound1]
@@ -2,8 +2,8 @@ module Expressir
2
2
  module Model
3
3
  module Types
4
4
  class Binary < ModelElement
5
- attr_accessor :width
6
- attr_accessor :fixed
5
+ model_attr_accessor :width
6
+ model_attr_accessor :fixed
7
7
 
8
8
  def initialize(options = {})
9
9
  @width = options[:width]
@@ -2,10 +2,10 @@ module Expressir
2
2
  module Model
3
3
  module Types
4
4
  class Enumeration < ModelElement
5
- attr_accessor :extensible
6
- attr_accessor :items
7
- attr_accessor :extension_type
8
- attr_accessor :extension_items
5
+ model_attr_accessor :extensible
6
+ model_attr_accessor :items
7
+ model_attr_accessor :extension_type
8
+ model_attr_accessor :extension_items
9
9
 
10
10
  def initialize(options = {})
11
11
  @extensible = options[:extensible]
@@ -7,10 +7,17 @@ module Expressir
7
7
  def initialize(options = {})
8
8
  @id = options[:id]
9
9
  @remarks = options.fetch(:remarks, [])
10
+ @remark_items = options.fetch(:remark_items, [])
10
11
  @source = options[:source]
11
12
 
12
13
  super
13
14
  end
15
+
16
+ def children
17
+ [
18
+ *remark_items
19
+ ]
20
+ end
14
21
  end
15
22
  end
16
23
  end
@@ -7,11 +7,18 @@ module Expressir
7
7
  def initialize(options = {})
8
8
  @id = options[:id]
9
9
  @remarks = options.fetch(:remarks, [])
10
+ @remark_items = options.fetch(:remark_items, [])
10
11
  @source = options[:source]
11
12
 
12
13
  super
13
14
  end
14
15
  end
16
+
17
+ def children
18
+ [
19
+ *remark_items
20
+ ]
21
+ end
15
22
  end
16
23
  end
17
24
  end
@@ -2,10 +2,10 @@ module Expressir
2
2
  module Model
3
3
  module Types
4
4
  class List < ModelElement
5
- attr_accessor :bound1
6
- attr_accessor :bound2
7
- attr_accessor :unique
8
- attr_accessor :base_type
5
+ model_attr_accessor :bound1
6
+ model_attr_accessor :bound2
7
+ model_attr_accessor :unique
8
+ model_attr_accessor :base_type
9
9
 
10
10
  def initialize(options = {})
11
11
  @bound1 = options[:bound1]
@@ -2,7 +2,7 @@ module Expressir
2
2
  module Model
3
3
  module Types
4
4
  class Real < ModelElement
5
- attr_accessor :precision
5
+ model_attr_accessor :precision
6
6
 
7
7
  def initialize(options = {})
8
8
  @precision = options[:precision]
@@ -2,11 +2,11 @@ module Expressir
2
2
  module Model
3
3
  module Types
4
4
  class Select < ModelElement
5
- attr_accessor :extensible
6
- attr_accessor :generic_entity
7
- attr_accessor :items
8
- attr_accessor :extension_type
9
- attr_accessor :extension_items
5
+ model_attr_accessor :extensible
6
+ model_attr_accessor :generic_entity
7
+ model_attr_accessor :items
8
+ model_attr_accessor :extension_type
9
+ model_attr_accessor :extension_items
10
10
 
11
11
  def initialize(options = {})
12
12
  @extensible = options[:extensible]
@@ -2,9 +2,9 @@ module Expressir
2
2
  module Model
3
3
  module Types
4
4
  class Set < ModelElement
5
- attr_accessor :bound1
6
- attr_accessor :bound2
7
- attr_accessor :base_type
5
+ model_attr_accessor :bound1
6
+ model_attr_accessor :bound2
7
+ model_attr_accessor :base_type
8
8
 
9
9
  def initialize(options = {})
10
10
  @bound1 = options[:bound1]
@@ -2,8 +2,8 @@ module Expressir
2
2
  module Model
3
3
  module Types
4
4
  class String < ModelElement
5
- attr_accessor :width
6
- attr_accessor :fixed
5
+ model_attr_accessor :width
6
+ model_attr_accessor :fixed
7
7
 
8
8
  def initialize(options = {})
9
9
  @width = options[:width]
@@ -3,17 +3,24 @@ module Expressir
3
3
  class Unique < ModelElement
4
4
  include Identifier
5
5
 
6
- attr_accessor :attributes
6
+ model_attr_accessor :attributes
7
7
 
8
8
  def initialize(options = {})
9
9
  @id = options[:id]
10
10
  @remarks = options.fetch(:remarks, [])
11
+ @remark_items = options.fetch(:remark_items, [])
11
12
  @source = options[:source]
12
13
 
13
14
  @attributes = options.fetch(:attributes, [])
14
15
 
15
16
  super
16
17
  end
18
+
19
+ def children
20
+ [
21
+ *remark_items
22
+ ]
23
+ end
17
24
  end
18
25
  end
19
26
  end
@@ -3,12 +3,13 @@ module Expressir
3
3
  class Variable < ModelElement
4
4
  include Identifier
5
5
 
6
- attr_accessor :type
7
- attr_accessor :expression
6
+ model_attr_accessor :type
7
+ model_attr_accessor :expression
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
  @type = options[:type]
@@ -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,17 +3,24 @@ module Expressir
3
3
  class Where < ModelElement
4
4
  include Identifier
5
5
 
6
- attr_accessor :expression
6
+ model_attr_accessor :expression
7
7
 
8
8
  def initialize(options = {})
9
9
  @id = options[:id]
10
10
  @remarks = options.fetch(:remarks, [])
11
+ @remark_items = options.fetch(:remark_items, [])
11
12
  @source = options[:source]
12
13
 
13
14
  @expression = options[:expression]
14
15
 
15
16
  super
16
17
  end
18
+
19
+ def children
20
+ [
21
+ *remark_items
22
+ ]
23
+ end
17
24
  end
18
25
  end
19
26
  end
@@ -1,3 +1,3 @@
1
1
  module Expressir
2
- VERSION = "0.2.17".freeze
2
+ VERSION = "0.2.25".freeze
3
3
  end
@@ -2,6 +2,7 @@
2
2
  _class: Expressir::Model::Repository
3
3
  schemas:
4
4
  - _class: Expressir::Model::Schema
5
+ file: original/examples/syntax/multiple.exp
5
6
  id: multiple_schema1
6
7
  interfaces:
7
8
  - _class: Expressir::Model::Interface
@@ -9,26 +10,31 @@ schemas:
9
10
  schema:
10
11
  _class: Expressir::Model::Expressions::SimpleReference
11
12
  id: multiple_schema2
13
+ base_path: multiple_schema2
12
14
  - _class: Expressir::Model::Interface
13
15
  kind: :REFERENCE
14
16
  schema:
15
17
  _class: Expressir::Model::Expressions::SimpleReference
16
18
  id: multiple_schema3
19
+ base_path: multiple_schema3
17
20
  items:
18
21
  - _class: Expressir::Model::InterfaceItem
19
22
  ref:
20
23
  _class: Expressir::Model::Expressions::SimpleReference
21
24
  id: attribute_entity3
25
+ base_path: multiple_schema3.attribute_entity3
22
26
  - _class: Expressir::Model::Interface
23
27
  kind: :REFERENCE
24
28
  schema:
25
29
  _class: Expressir::Model::Expressions::SimpleReference
26
30
  id: multiple_schema4
31
+ base_path: multiple_schema4
27
32
  items:
28
33
  - _class: Expressir::Model::InterfaceItem
29
34
  ref:
30
35
  _class: Expressir::Model::Expressions::SimpleReference
31
36
  id: attribute_entity
37
+ base_path: multiple_schema4.attribute_entity
32
38
  id: attribute_entity4
33
39
  entities:
34
40
  - _class: Expressir::Model::Entity
@@ -48,11 +54,13 @@ schemas:
48
54
  subtype_of:
49
55
  - _class: Expressir::Model::Expressions::SimpleReference
50
56
  id: empty_entity
57
+ base_path: multiple_schema1.empty_entity
51
58
  - _class: Expressir::Model::Entity
52
59
  id: subtype_attribute_entity
53
60
  subtype_of:
54
61
  - _class: Expressir::Model::Expressions::SimpleReference
55
62
  id: attribute_entity
63
+ base_path: multiple_schema1.attribute_entity
56
64
  attributes:
57
65
  - _class: Expressir::Model::Attribute
58
66
  kind: :EXPLICIT
@@ -66,6 +74,7 @@ schemas:
66
74
  entity:
67
75
  _class: Expressir::Model::Expressions::SimpleReference
68
76
  id: attribute_entity
77
+ base_path: multiple_schema1.attribute_entity
69
78
  attribute:
70
79
  _class: Expressir::Model::Expressions::SimpleReference
71
80
  id: test
@@ -76,6 +85,7 @@ schemas:
76
85
  subtype_of:
77
86
  - _class: Expressir::Model::Expressions::SimpleReference
78
87
  id: attribute_entity2
88
+ base_path: multiple_schema2.attribute_entity2
79
89
  attributes:
80
90
  - _class: Expressir::Model::Attribute
81
91
  kind: :EXPLICIT
@@ -89,6 +99,7 @@ schemas:
89
99
  entity:
90
100
  _class: Expressir::Model::Expressions::SimpleReference
91
101
  id: attribute_entity2
102
+ base_path: multiple_schema2.attribute_entity2
92
103
  attribute:
93
104
  _class: Expressir::Model::Expressions::SimpleReference
94
105
  id: test
@@ -99,6 +110,7 @@ schemas:
99
110
  subtype_of:
100
111
  - _class: Expressir::Model::Expressions::SimpleReference
101
112
  id: attribute_entity3
113
+ base_path: multiple_schema3.attribute_entity3
102
114
  attributes:
103
115
  - _class: Expressir::Model::Attribute
104
116
  kind: :EXPLICIT
@@ -112,6 +124,7 @@ schemas:
112
124
  entity:
113
125
  _class: Expressir::Model::Expressions::SimpleReference
114
126
  id: attribute_entity3
127
+ base_path: multiple_schema3.attribute_entity3
115
128
  attribute:
116
129
  _class: Expressir::Model::Expressions::SimpleReference
117
130
  id: test
@@ -122,6 +135,7 @@ schemas:
122
135
  subtype_of:
123
136
  - _class: Expressir::Model::Expressions::SimpleReference
124
137
  id: attribute_entity4
138
+ base_path: multiple_schema4.attribute_entity
125
139
  attributes:
126
140
  - _class: Expressir::Model::Attribute
127
141
  kind: :EXPLICIT
@@ -135,6 +149,7 @@ schemas:
135
149
  entity:
136
150
  _class: Expressir::Model::Expressions::SimpleReference
137
151
  id: attribute_entity4
152
+ base_path: multiple_schema4.attribute_entity
138
153
  attribute:
139
154
  _class: Expressir::Model::Expressions::SimpleReference
140
155
  id: test
@@ -146,6 +161,7 @@ schemas:
146
161
  - _class: Expressir::Model::Expressions::SimpleReference
147
162
  id: missing_entity
148
163
  - _class: Expressir::Model::Schema
164
+ file: original/examples/syntax/multiple.exp
149
165
  id: multiple_schema2
150
166
  entities:
151
167
  - _class: Expressir::Model::Entity
@@ -157,6 +173,7 @@ schemas:
157
173
  type:
158
174
  _class: Expressir::Model::Types::Boolean
159
175
  - _class: Expressir::Model::Schema
176
+ file: original/examples/syntax/multiple.exp
160
177
  id: multiple_schema3
161
178
  entities:
162
179
  - _class: Expressir::Model::Entity
@@ -168,6 +185,7 @@ schemas:
168
185
  type:
169
186
  _class: Expressir::Model::Types::Boolean
170
187
  - _class: Expressir::Model::Schema
188
+ file: original/examples/syntax/multiple.exp
171
189
  id: multiple_schema4
172
190
  entities:
173
191
  - _class: Expressir::Model::Entity