expressir 0.2.12-x86-mingw32 → 0.2.17-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/exe/format +57 -8
  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/formatter.rb +201 -147
  9. data/lib/expressir/express_exp/hyperlink_formatter.rb +6 -4
  10. data/lib/expressir/express_exp/parser.rb +31 -25
  11. data/lib/expressir/express_exp/schema_head_formatter.rb +2 -7
  12. data/lib/expressir/express_exp/visitor.rb +27 -54
  13. data/lib/expressir/model.rb +2 -1
  14. data/lib/expressir/model/entity.rb +6 -6
  15. data/lib/expressir/model/expressions/query_expression.rb +3 -3
  16. data/lib/expressir/model/function.rb +15 -11
  17. data/lib/expressir/model/informal_proposition.rb +4 -1
  18. data/lib/expressir/model/{renamed_ref.rb → interface_item.rb} +2 -2
  19. data/lib/expressir/model/interfaced_item.rb +26 -0
  20. data/lib/expressir/model/model_element.rb +20 -7
  21. data/lib/expressir/model/procedure.rb +15 -11
  22. data/lib/expressir/model/repository.rb +3 -3
  23. data/lib/expressir/model/rule.rb +16 -12
  24. data/lib/expressir/model/schema.rb +60 -17
  25. data/lib/expressir/model/statements/alias.rb +3 -3
  26. data/lib/expressir/model/statements/repeat.rb +3 -3
  27. data/lib/expressir/model/subtype_constraint.rb +1 -6
  28. data/lib/expressir/model/type.rb +9 -5
  29. data/lib/expressir/version.rb +1 -1
  30. data/original/examples/syntax/multiple.exp +23 -0
  31. data/original/examples/syntax/multiple.yaml +180 -0
  32. data/original/examples/syntax/multiple_formatted.exp +71 -0
  33. data/original/examples/syntax/multiple_hyperlink_formatted.exp +71 -0
  34. data/original/examples/syntax/multiple_schema_head_hyperlink_formatted.exp +13 -0
  35. data/original/examples/syntax/remark.exp +41 -41
  36. data/original/examples/syntax/remark.yaml +445 -0
  37. data/original/examples/syntax/remark_formatted.exp +62 -50
  38. data/original/examples/syntax/{simple.exp → single.exp} +1 -1
  39. data/original/examples/syntax/single.yaml +8 -0
  40. data/original/examples/syntax/single_formatted.exp +6 -0
  41. data/original/examples/syntax/single_formatted.yaml +18 -0
  42. data/original/examples/syntax/syntax.exp +29 -19
  43. data/original/examples/syntax/syntax.yaml +3438 -0
  44. data/original/examples/syntax/syntax_formatted.exp +271 -131
  45. data/original/examples/syntax/syntax_schema_head_formatted.exp +18 -0
  46. data/spec/expressir/express_exp/formatter_spec.rb +110 -0
  47. data/spec/expressir/express_exp/parser_spec.rb +98 -0
  48. data/spec/expressir/model/{model_element/find_spec.rb → model_element_spec.rb} +93 -10
  49. metadata +19 -18
  50. data/original/examples/syntax/hyperlink.exp +0 -8
  51. data/original/examples/syntax/hyperlink_formatted.exp +0 -19
  52. data/original/examples/syntax/source.exp +0 -16
  53. data/spec/expressir/express_exp/formatter/remark_spec.rb +0 -28
  54. data/spec/expressir/express_exp/formatter/syntax_spec.rb +0 -28
  55. data/spec/expressir/express_exp/hyperlink_formatter_spec.rb +0 -24
  56. data/spec/expressir/express_exp/parser/head_source_spec.rb +0 -38
  57. data/spec/expressir/express_exp/parser/multiple_spec.rb +0 -32
  58. data/spec/expressir/express_exp/parser/remark_spec.rb +0 -411
  59. data/spec/expressir/express_exp/parser/source_spec.rb +0 -29
  60. data/spec/expressir/express_exp/parser/syntax_spec.rb +0 -3080
  61. data/spec/expressir/express_exp/schema_head_formatter_spec.rb +0 -36
  62. data/spec/expressir/model/model_element/hash_spec.rb +0 -66
@@ -31,18 +31,22 @@ module Expressir
31
31
  super
32
32
  end
33
33
 
34
+ def enumeration_items
35
+ types.flat_map{|x| x.enumeration_items}
36
+ end
37
+
34
38
  def children
35
- items = []
36
- items.push(*@parameters)
37
- items.push(*@types)
38
- items.push(*@types.flat_map{|x| x.type.is_a?(Expressir::Model::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
39
+ [
40
+ *parameters,
41
+ *types,
42
+ *enumeration_items,
43
+ *entities,
44
+ *subtype_constraints,
45
+ *functions,
46
+ *procedures,
47
+ *constants,
48
+ *variables
49
+ ]
46
50
  end
47
51
  end
48
52
  end
@@ -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
@@ -35,19 +35,23 @@ module Expressir
35
35
  super
36
36
  end
37
37
 
38
+ def enumeration_items
39
+ types.flat_map{|x| x.enumeration_items}
40
+ end
41
+
38
42
  def children
39
- items = []
40
- items.push(*@types)
41
- items.push(*@types.flat_map{|x| x.type.is_a?(Expressir::Model::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
43
+ [
44
+ *types,
45
+ *enumeration_items,
46
+ *entities,
47
+ *subtype_constraints,
48
+ *functions,
49
+ *procedures,
50
+ *constants,
51
+ *variables,
52
+ *where,
53
+ *informal_propositions
54
+ ]
51
55
  end
52
56
  end
53
57
  end
@@ -1,9 +1,9 @@
1
1
  module Expressir
2
2
  module Model
3
3
  class Schema < ModelElement
4
- include Identifier
4
+ attr_accessor :file
5
5
 
6
- attr_accessor :head_source
6
+ include Identifier
7
7
 
8
8
  attr_accessor :version
9
9
  attr_accessor :interfaces
@@ -12,14 +12,15 @@ module Expressir
12
12
  attr_accessor :entities
13
13
  attr_accessor :subtype_constraints
14
14
  attr_accessor :functions
15
- attr_accessor :procedures
16
15
  attr_accessor :rules
16
+ attr_accessor :procedures
17
17
 
18
18
  def initialize(options = {})
19
+ @file = options[:file]
20
+
19
21
  @id = options[:id]
20
22
  @remarks = options.fetch(:remarks, [])
21
23
  @source = options[:source]
22
- @head_source = options[:head_source]
23
24
 
24
25
  @version = options[:version]
25
26
  @interfaces = options.fetch(:interfaces, [])
@@ -28,25 +29,67 @@ module Expressir
28
29
  @entities = options.fetch(:entities, [])
29
30
  @subtype_constraints = options.fetch(:subtype_constraints, [])
30
31
  @functions = options.fetch(:functions, [])
31
- @procedures = options.fetch(:procedures, [])
32
32
  @rules = options.fetch(:rules, [])
33
+ @procedures = options.fetch(:procedures, [])
33
34
 
34
35
  super
35
36
  end
36
37
 
38
+ def create_interfaced_item(id, base_item)
39
+ interfaced_item = InterfacedItem.new({
40
+ id: id
41
+ })
42
+ interfaced_item.base_item = base_item # skip overriding parent
43
+ interfaced_item.parent = self
44
+ interfaced_item
45
+ end
46
+
47
+ def interfaced_items
48
+ interfaces.flat_map do |interface|
49
+ schema = parent.children_by_id[interface.schema.id.downcase]
50
+ if schema
51
+ schema_safe_children = schema.safe_children
52
+ schema_safe_children_by_id = schema_safe_children.select{|x| x.id}.map{|x| [x.id.downcase, x]}.to_h
53
+ if interface.items.length > 0
54
+ interface.items.map do |interface_item|
55
+ base_item = schema_safe_children_by_id[interface_item.ref.id.downcase]
56
+ if base_item
57
+ id = interface_item.id || base_item.id
58
+ create_interfaced_item(id, base_item)
59
+ end
60
+ end
61
+ else
62
+ schema_safe_children.map do |base_item|
63
+ id = base_item.id
64
+ create_interfaced_item(id, base_item)
65
+ end
66
+ end
67
+ end
68
+ end.select{|x| x}
69
+ end
70
+
71
+ def enumeration_items
72
+ types.flat_map{|x| x.enumeration_items}
73
+ end
74
+
75
+ def safe_children
76
+ [
77
+ *constants,
78
+ *types,
79
+ *enumeration_items,
80
+ *entities,
81
+ *subtype_constraints,
82
+ *functions,
83
+ *rules,
84
+ *procedures
85
+ ]
86
+ end
87
+
37
88
  def children
38
- items = []
39
- # TODO: select interface items
40
- items.push(*@interfaces.flat_map{|x| parent.schemas.find{|y| x.schema.id == y.id}&.children || []})
41
- items.push(*@constants)
42
- items.push(*@types)
43
- items.push(*@types.flat_map{|x| x.type.is_a?(Expressir::Model::Types::Enumeration) ? x.type.items : []})
44
- items.push(*@entities)
45
- items.push(*@subtype_constraints)
46
- items.push(*@functions)
47
- items.push(*@procedures)
48
- items.push(*@rules)
49
- items
89
+ [
90
+ *interfaced_items,
91
+ *safe_children
92
+ ]
50
93
  end
51
94
  end
52
95
  end
@@ -19,9 +19,9 @@ module Expressir
19
19
  end
20
20
 
21
21
  def children
22
- items = []
23
- items.push(self)
24
- items
22
+ [
23
+ self
24
+ ]
25
25
  end
26
26
  end
27
27
  end
@@ -27,9 +27,9 @@ module Expressir
27
27
  end
28
28
 
29
29
  def children
30
- items = []
31
- items.push(self)
32
- items
30
+ [
31
+ self
32
+ ]
33
33
  end
34
34
  end
35
35
  end
@@ -15,16 +15,11 @@ module Expressir
15
15
 
16
16
  @applies_to = options[:applies_to]
17
17
  @abstract = options[:abstract]
18
- @total_over = options[:total_over]
18
+ @total_over = options.fetch(:total_over, [])
19
19
  @supertype_expression = options[:supertype_expression]
20
20
 
21
21
  super
22
22
  end
23
-
24
- def children
25
- items = []
26
- items
27
- end
28
23
  end
29
24
  end
30
25
  end
@@ -19,12 +19,16 @@ module Expressir
19
19
  super
20
20
  end
21
21
 
22
+ def enumeration_items
23
+ type.is_a?(Types::Enumeration) ? type.items : []
24
+ end
25
+
22
26
  def children
23
- items = []
24
- items.push(*@type.is_a?(Expressir::Model::Types::Enumeration) ? @type.items : [])
25
- items.push(*@where)
26
- items.push(*@informal_propositions)
27
- items
27
+ [
28
+ *enumeration_items,
29
+ *where,
30
+ *informal_propositions
31
+ ]
28
32
  end
29
33
  end
30
34
  end
@@ -1,3 +1,3 @@
1
1
  module Expressir
2
- VERSION = "0.2.12".freeze
2
+ VERSION = "0.2.17".freeze
3
3
  end
@@ -0,0 +1,23 @@
1
+ SCHEMA multiple_schema1;
2
+ REFERENCE FROM multiple_schema2;
3
+ REFERENCE FROM multiple_schema3 (attribute_entity3);
4
+ REFERENCE FROM multiple_schema4 (attribute_entity AS attribute_entity4);
5
+ ENTITY test; END_ENTITY;
6
+ ENTITY empty_entity; END_ENTITY;
7
+ ENTITY attribute_entity; test : BOOLEAN; END_ENTITY;
8
+ ENTITY subtype_empty_entity SUBTYPE OF (empty_entity); END_ENTITY;
9
+ ENTITY subtype_attribute_entity SUBTYPE OF (attribute_entity); SELF\attribute_entity.test : BOOLEAN; END_ENTITY;
10
+ ENTITY subtype_attribute_entity2 SUBTYPE OF (attribute_entity2); SELF\attribute_entity2.test : BOOLEAN; END_ENTITY;
11
+ ENTITY subtype_attribute_entity3 SUBTYPE OF (attribute_entity3); SELF\attribute_entity3.test : BOOLEAN; END_ENTITY;
12
+ ENTITY subtype_attribute_entity4 SUBTYPE OF (attribute_entity4); SELF\attribute_entity4.test : BOOLEAN; END_ENTITY;
13
+ ENTITY subtype_missing_entity SUBTYPE OF (missing_entity); END_ENTITY;
14
+ END_SCHEMA;
15
+ SCHEMA multiple_schema2;
16
+ ENTITY attribute_entity2; test : BOOLEAN; END_ENTITY;
17
+ END_SCHEMA;
18
+ SCHEMA multiple_schema3;
19
+ ENTITY attribute_entity3; test : BOOLEAN; END_ENTITY;
20
+ END_SCHEMA;
21
+ SCHEMA multiple_schema4;
22
+ ENTITY attribute_entity; test : BOOLEAN; END_ENTITY;
23
+ END_SCHEMA;
@@ -0,0 +1,180 @@
1
+ ---
2
+ _class: Expressir::Model::Repository
3
+ schemas:
4
+ - _class: Expressir::Model::Schema
5
+ id: multiple_schema1
6
+ interfaces:
7
+ - _class: Expressir::Model::Interface
8
+ kind: :REFERENCE
9
+ schema:
10
+ _class: Expressir::Model::Expressions::SimpleReference
11
+ id: multiple_schema2
12
+ - _class: Expressir::Model::Interface
13
+ kind: :REFERENCE
14
+ schema:
15
+ _class: Expressir::Model::Expressions::SimpleReference
16
+ id: multiple_schema3
17
+ items:
18
+ - _class: Expressir::Model::InterfaceItem
19
+ ref:
20
+ _class: Expressir::Model::Expressions::SimpleReference
21
+ id: attribute_entity3
22
+ - _class: Expressir::Model::Interface
23
+ kind: :REFERENCE
24
+ schema:
25
+ _class: Expressir::Model::Expressions::SimpleReference
26
+ id: multiple_schema4
27
+ items:
28
+ - _class: Expressir::Model::InterfaceItem
29
+ ref:
30
+ _class: Expressir::Model::Expressions::SimpleReference
31
+ id: attribute_entity
32
+ id: attribute_entity4
33
+ entities:
34
+ - _class: Expressir::Model::Entity
35
+ id: test
36
+ - _class: Expressir::Model::Entity
37
+ id: empty_entity
38
+ - _class: Expressir::Model::Entity
39
+ id: attribute_entity
40
+ attributes:
41
+ - _class: Expressir::Model::Attribute
42
+ id: test
43
+ kind: :EXPLICIT
44
+ type:
45
+ _class: Expressir::Model::Types::Boolean
46
+ - _class: Expressir::Model::Entity
47
+ id: subtype_empty_entity
48
+ subtype_of:
49
+ - _class: Expressir::Model::Expressions::SimpleReference
50
+ id: empty_entity
51
+ - _class: Expressir::Model::Entity
52
+ id: subtype_attribute_entity
53
+ subtype_of:
54
+ - _class: Expressir::Model::Expressions::SimpleReference
55
+ id: attribute_entity
56
+ attributes:
57
+ - _class: Expressir::Model::Attribute
58
+ kind: :EXPLICIT
59
+ supertype_attribute:
60
+ _class: Expressir::Model::Expressions::AttributeReference
61
+ ref:
62
+ _class: Expressir::Model::Expressions::GroupReference
63
+ ref:
64
+ _class: Expressir::Model::Expressions::SimpleReference
65
+ id: SELF
66
+ entity:
67
+ _class: Expressir::Model::Expressions::SimpleReference
68
+ id: attribute_entity
69
+ attribute:
70
+ _class: Expressir::Model::Expressions::SimpleReference
71
+ id: test
72
+ type:
73
+ _class: Expressir::Model::Types::Boolean
74
+ - _class: Expressir::Model::Entity
75
+ id: subtype_attribute_entity2
76
+ subtype_of:
77
+ - _class: Expressir::Model::Expressions::SimpleReference
78
+ id: attribute_entity2
79
+ attributes:
80
+ - _class: Expressir::Model::Attribute
81
+ kind: :EXPLICIT
82
+ supertype_attribute:
83
+ _class: Expressir::Model::Expressions::AttributeReference
84
+ ref:
85
+ _class: Expressir::Model::Expressions::GroupReference
86
+ ref:
87
+ _class: Expressir::Model::Expressions::SimpleReference
88
+ id: SELF
89
+ entity:
90
+ _class: Expressir::Model::Expressions::SimpleReference
91
+ id: attribute_entity2
92
+ attribute:
93
+ _class: Expressir::Model::Expressions::SimpleReference
94
+ id: test
95
+ type:
96
+ _class: Expressir::Model::Types::Boolean
97
+ - _class: Expressir::Model::Entity
98
+ id: subtype_attribute_entity3
99
+ subtype_of:
100
+ - _class: Expressir::Model::Expressions::SimpleReference
101
+ id: attribute_entity3
102
+ attributes:
103
+ - _class: Expressir::Model::Attribute
104
+ kind: :EXPLICIT
105
+ supertype_attribute:
106
+ _class: Expressir::Model::Expressions::AttributeReference
107
+ ref:
108
+ _class: Expressir::Model::Expressions::GroupReference
109
+ ref:
110
+ _class: Expressir::Model::Expressions::SimpleReference
111
+ id: SELF
112
+ entity:
113
+ _class: Expressir::Model::Expressions::SimpleReference
114
+ id: attribute_entity3
115
+ attribute:
116
+ _class: Expressir::Model::Expressions::SimpleReference
117
+ id: test
118
+ type:
119
+ _class: Expressir::Model::Types::Boolean
120
+ - _class: Expressir::Model::Entity
121
+ id: subtype_attribute_entity4
122
+ subtype_of:
123
+ - _class: Expressir::Model::Expressions::SimpleReference
124
+ id: attribute_entity4
125
+ attributes:
126
+ - _class: Expressir::Model::Attribute
127
+ kind: :EXPLICIT
128
+ supertype_attribute:
129
+ _class: Expressir::Model::Expressions::AttributeReference
130
+ ref:
131
+ _class: Expressir::Model::Expressions::GroupReference
132
+ ref:
133
+ _class: Expressir::Model::Expressions::SimpleReference
134
+ id: SELF
135
+ entity:
136
+ _class: Expressir::Model::Expressions::SimpleReference
137
+ id: attribute_entity4
138
+ attribute:
139
+ _class: Expressir::Model::Expressions::SimpleReference
140
+ id: test
141
+ type:
142
+ _class: Expressir::Model::Types::Boolean
143
+ - _class: Expressir::Model::Entity
144
+ id: subtype_missing_entity
145
+ subtype_of:
146
+ - _class: Expressir::Model::Expressions::SimpleReference
147
+ id: missing_entity
148
+ - _class: Expressir::Model::Schema
149
+ id: multiple_schema2
150
+ entities:
151
+ - _class: Expressir::Model::Entity
152
+ id: attribute_entity2
153
+ attributes:
154
+ - _class: Expressir::Model::Attribute
155
+ id: test
156
+ kind: :EXPLICIT
157
+ type:
158
+ _class: Expressir::Model::Types::Boolean
159
+ - _class: Expressir::Model::Schema
160
+ id: multiple_schema3
161
+ entities:
162
+ - _class: Expressir::Model::Entity
163
+ id: attribute_entity3
164
+ attributes:
165
+ - _class: Expressir::Model::Attribute
166
+ id: test
167
+ kind: :EXPLICIT
168
+ type:
169
+ _class: Expressir::Model::Types::Boolean
170
+ - _class: Expressir::Model::Schema
171
+ id: multiple_schema4
172
+ entities:
173
+ - _class: Expressir::Model::Entity
174
+ id: attribute_entity
175
+ attributes:
176
+ - _class: Expressir::Model::Attribute
177
+ id: test
178
+ kind: :EXPLICIT
179
+ type:
180
+ _class: Expressir::Model::Types::Boolean