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.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +5 -0
- data/.github/workflows/release.yml +31 -3
- data/README.adoc +3 -3
- data/exe/format +66 -12
- data/lib/expressir/express_exp/2.4/express_parser.so +0 -0
- data/lib/expressir/express_exp/2.5/express_parser.so +0 -0
- data/lib/expressir/express_exp/2.6/express_parser.so +0 -0
- data/lib/expressir/express_exp/2.7/express_parser.so +0 -0
- data/lib/expressir/express_exp/3.0/express_parser.so +0 -0
- data/lib/expressir/express_exp/cache.rb +48 -0
- data/lib/expressir/express_exp/formatter.rb +185 -135
- data/lib/expressir/express_exp/parser.rb +33 -29
- data/lib/expressir/express_exp/schema_head_formatter.rb +1 -4
- data/lib/expressir/express_exp/visitor.rb +29 -23
- data/lib/expressir/model.rb +3 -1
- data/lib/expressir/model/attribute.rb +12 -5
- data/lib/expressir/model/cache.rb +13 -0
- data/lib/expressir/model/constant.rb +9 -2
- data/lib/expressir/model/entity.rb +15 -13
- data/lib/expressir/model/enumeration_item.rb +7 -0
- data/lib/expressir/model/expressions/aggregate_initializer.rb +1 -1
- data/lib/expressir/model/expressions/aggregate_item.rb +2 -2
- data/lib/expressir/model/expressions/attribute_reference.rb +2 -2
- data/lib/expressir/model/expressions/binary_expression.rb +3 -3
- data/lib/expressir/model/expressions/call.rb +2 -2
- data/lib/expressir/model/expressions/entity_constructor.rb +2 -2
- data/lib/expressir/model/expressions/group_reference.rb +2 -2
- data/lib/expressir/model/expressions/index_reference.rb +3 -3
- data/lib/expressir/model/expressions/interval.rb +5 -5
- data/lib/expressir/model/expressions/query_expression.rb +7 -5
- data/lib/expressir/model/expressions/simple_reference.rb +1 -1
- data/lib/expressir/model/expressions/unary_expression.rb +2 -2
- data/lib/expressir/model/function.rb +27 -21
- data/lib/expressir/model/identifier.rb +6 -3
- data/lib/expressir/model/interface.rb +3 -3
- data/lib/expressir/model/interface_item.rb +2 -2
- data/lib/expressir/model/interfaced_item.rb +11 -3
- data/lib/expressir/model/literals/binary.rb +1 -1
- data/lib/expressir/model/literals/integer.rb +1 -1
- data/lib/expressir/model/literals/logical.rb +1 -1
- data/lib/expressir/model/literals/real.rb +1 -1
- data/lib/expressir/model/literals/string.rb +2 -2
- data/lib/expressir/model/model_element.rb +54 -19
- data/lib/expressir/model/parameter.rb +9 -2
- data/lib/expressir/model/procedure.rb +26 -20
- data/lib/expressir/model/{informal_proposition.rb → remark_item.rb} +3 -3
- data/lib/expressir/model/repository.rb +4 -4
- data/lib/expressir/model/rule.rb +29 -23
- data/lib/expressir/model/schema.rb +63 -54
- data/lib/expressir/model/statements/alias.rb +7 -5
- data/lib/expressir/model/statements/assignment.rb +2 -2
- data/lib/expressir/model/statements/call.rb +2 -2
- data/lib/expressir/model/statements/case.rb +3 -3
- data/lib/expressir/model/statements/case_action.rb +2 -2
- data/lib/expressir/model/statements/compound.rb +1 -1
- data/lib/expressir/model/statements/if.rb +3 -3
- data/lib/expressir/model/statements/repeat.rb +11 -9
- data/lib/expressir/model/statements/return.rb +1 -1
- data/lib/expressir/model/subtype_constraint.rb +9 -7
- data/lib/expressir/model/type.rb +14 -8
- data/lib/expressir/model/types/aggregate.rb +8 -1
- data/lib/expressir/model/types/array.rb +5 -5
- data/lib/expressir/model/types/bag.rb +3 -3
- data/lib/expressir/model/types/binary.rb +2 -2
- data/lib/expressir/model/types/enumeration.rb +4 -4
- data/lib/expressir/model/types/generic.rb +7 -0
- data/lib/expressir/model/types/generic_entity.rb +7 -0
- data/lib/expressir/model/types/list.rb +4 -4
- data/lib/expressir/model/types/real.rb +1 -1
- data/lib/expressir/model/types/select.rb +5 -5
- data/lib/expressir/model/types/set.rb +3 -3
- data/lib/expressir/model/types/string.rb +2 -2
- data/lib/expressir/model/unique.rb +8 -1
- data/lib/expressir/model/variable.rb +9 -2
- data/lib/expressir/model/where.rb +8 -1
- data/lib/expressir/version.rb +1 -1
- data/original/examples/syntax/{hyperlink.exp → multiple.exp} +8 -8
- data/original/examples/syntax/multiple.yaml +184 -0
- data/original/examples/syntax/multiple_formatted.exp +71 -0
- data/original/examples/syntax/multiple_hyperlink_formatted.exp +71 -0
- data/original/examples/syntax/multiple_schema_head_hyperlink_formatted.exp +13 -0
- data/original/examples/syntax/remark.exp +52 -50
- data/original/examples/syntax/remark.yaml +452 -0
- data/original/examples/syntax/remark_formatted.exp +64 -50
- data/original/examples/syntax/{simple.exp → single.exp} +1 -1
- data/original/examples/syntax/single.yaml +9 -0
- data/original/examples/syntax/single_formatted.exp +6 -0
- data/original/examples/syntax/single_formatted.yaml +19 -0
- data/original/examples/syntax/syntax.exp +29 -19
- data/original/examples/syntax/syntax.yaml +3439 -0
- data/original/examples/syntax/syntax_formatted.exp +271 -131
- data/original/examples/syntax/syntax_schema_head_formatted.exp +18 -0
- data/spec/expressir/express_exp/cache_spec.rb +64 -0
- data/spec/expressir/express_exp/formatter_spec.rb +111 -0
- data/spec/expressir/express_exp/parser_spec.rb +98 -0
- data/spec/expressir/model/{model_element/find_spec.rb → model_element_spec.rb} +96 -10
- metadata +21 -17
- data/original/examples/syntax/hyperlink_formatted.exp +0 -51
- data/original/examples/syntax/source.exp +0 -16
- data/spec/expressir/express_exp/formatter/remark_spec.rb +0 -28
- data/spec/expressir/express_exp/formatter/syntax_spec.rb +0 -28
- data/spec/expressir/express_exp/hyperlink_formatter_spec.rb +0 -28
- data/spec/expressir/express_exp/parser/multiple_spec.rb +0 -37
- data/spec/expressir/express_exp/parser/remark_spec.rb +0 -411
- data/spec/expressir/express_exp/parser/source_spec.rb +0 -29
- data/spec/expressir/express_exp/parser/syntax_spec.rb +0 -3086
- data/spec/expressir/express_exp/schema_head_formatter_spec.rb +0 -40
- data/spec/expressir/model/model_element/hash_spec.rb +0 -66
@@ -2,9 +2,9 @@ module Expressir
|
|
2
2
|
module Model
|
3
3
|
module Expressions
|
4
4
|
class IndexReference < ModelElement
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
model_attr_accessor :ref
|
6
|
+
model_attr_accessor :index1
|
7
|
+
model_attr_accessor :index2
|
8
8
|
|
9
9
|
def initialize(options = {})
|
10
10
|
@ref = options[:ref]
|
@@ -2,11 +2,11 @@ module Expressir
|
|
2
2
|
module Model
|
3
3
|
module Expressions
|
4
4
|
class Interval < ModelElement
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
model_attr_accessor :low
|
6
|
+
model_attr_accessor :operator1
|
7
|
+
model_attr_accessor :item
|
8
|
+
model_attr_accessor :operator2
|
9
|
+
model_attr_accessor :high
|
10
10
|
|
11
11
|
def initialize(options = {})
|
12
12
|
@low = options[:low]
|
@@ -4,12 +4,13 @@ module Expressir
|
|
4
4
|
class QueryExpression < ModelElement
|
5
5
|
include Identifier
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
model_attr_accessor :aggregate_source
|
8
|
+
model_attr_accessor :expression
|
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
|
@aggregate_source = options[:aggregate_source]
|
@@ -19,9 +20,10 @@ module Expressir
|
|
19
20
|
end
|
20
21
|
|
21
22
|
def children
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
[
|
24
|
+
self,
|
25
|
+
*remark_items
|
26
|
+
]
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
@@ -3,20 +3,21 @@ module Expressir
|
|
3
3
|
class Function < ModelElement
|
4
4
|
include Identifier
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
6
|
+
model_attr_accessor :parameters
|
7
|
+
model_attr_accessor :return_type
|
8
|
+
model_attr_accessor :types
|
9
|
+
model_attr_accessor :entities
|
10
|
+
model_attr_accessor :subtype_constraints
|
11
|
+
model_attr_accessor :functions
|
12
|
+
model_attr_accessor :procedures
|
13
|
+
model_attr_accessor :constants
|
14
|
+
model_attr_accessor :variables
|
15
|
+
model_attr_accessor :statements
|
16
16
|
|
17
17
|
def initialize(options = {})
|
18
18
|
@id = options[:id]
|
19
19
|
@remarks = options.fetch(:remarks, [])
|
20
|
+
@remark_items = options.fetch(:remark_items, [])
|
20
21
|
@source = options[:source]
|
21
22
|
|
22
23
|
@parameters = options.fetch(:parameters, [])
|
@@ -33,18 +34,23 @@ module Expressir
|
|
33
34
|
super
|
34
35
|
end
|
35
36
|
|
37
|
+
def enumeration_items
|
38
|
+
types.flat_map{|x| x.enumeration_items}
|
39
|
+
end
|
40
|
+
|
36
41
|
def children
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
42
|
+
[
|
43
|
+
*parameters,
|
44
|
+
*types,
|
45
|
+
*enumeration_items,
|
46
|
+
*entities,
|
47
|
+
*subtype_constraints,
|
48
|
+
*functions,
|
49
|
+
*procedures,
|
50
|
+
*constants,
|
51
|
+
*variables,
|
52
|
+
*remark_items
|
53
|
+
]
|
48
54
|
end
|
49
55
|
end
|
50
56
|
end
|
@@ -1,9 +1,12 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Identifier
|
4
|
-
|
5
|
-
|
6
|
-
|
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
|
-
|
8
|
-
|
9
|
-
|
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,14 +1,16 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
class InterfacedItem < ModelElement
|
4
|
-
|
4
|
+
model_attr_accessor :id
|
5
|
+
model_attr_accessor :remarks
|
6
|
+
model_attr_accessor :remark_items
|
5
7
|
|
6
|
-
|
8
|
+
model_attr_accessor :base_item
|
7
9
|
|
8
10
|
def initialize(options = {})
|
9
11
|
@id = options[:id]
|
10
12
|
@remarks = options.fetch(:remarks, [])
|
11
|
-
@
|
13
|
+
@remark_items = options.fetch(:remark_items, [])
|
12
14
|
|
13
15
|
@base_item = options[:base_item]
|
14
16
|
|
@@ -18,6 +20,12 @@ module Expressir
|
|
18
20
|
def path
|
19
21
|
base_item.path
|
20
22
|
end
|
23
|
+
|
24
|
+
def children
|
25
|
+
[
|
26
|
+
*remark_items
|
27
|
+
]
|
28
|
+
end
|
21
29
|
end
|
22
30
|
end
|
23
31
|
end
|
@@ -1,7 +1,10 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
1
3
|
module Expressir
|
2
4
|
module Model
|
3
5
|
class ModelElement
|
4
6
|
CLASS_KEY = '_class'
|
7
|
+
FILE_KEY = 'file'
|
5
8
|
SOURCE_KEY = 'source'
|
6
9
|
|
7
10
|
attr_accessor :parent
|
@@ -28,8 +31,8 @@ module Expressir
|
|
28
31
|
end
|
29
32
|
|
30
33
|
def attach_parent_to_children
|
31
|
-
|
32
|
-
value =
|
34
|
+
self.class.model_attrs.each do |variable|
|
35
|
+
value = self.send(variable)
|
33
36
|
|
34
37
|
if value.is_a? Array
|
35
38
|
value.each do |value|
|
@@ -57,7 +60,7 @@ module Expressir
|
|
57
60
|
# find in current scope
|
58
61
|
current_node = current_scope
|
59
62
|
path_parts.each do |current_path|
|
60
|
-
current_node = current_node.
|
63
|
+
current_node = current_node.children_by_id[current_path]
|
61
64
|
break unless current_node
|
62
65
|
end
|
63
66
|
target_node = current_node
|
@@ -75,20 +78,29 @@ module Expressir
|
|
75
78
|
[]
|
76
79
|
end
|
77
80
|
|
81
|
+
def children_by_id
|
82
|
+
@children_by_id ||= children.select{|x| x.id}.map{|x| [x.id.downcase, x]}.to_h
|
83
|
+
end
|
84
|
+
|
85
|
+
def reset_children_by_id
|
86
|
+
@children_by_id = nil
|
87
|
+
end
|
88
|
+
|
78
89
|
def to_hash(options = {})
|
79
|
-
|
90
|
+
root_path = options[:root_path]
|
80
91
|
formatter = options[:formatter]
|
92
|
+
include_empty = options[:include_empty] || !options[:skip_empty] # TODO: remove skip_empty
|
81
93
|
|
82
94
|
hash = {}
|
83
95
|
hash[CLASS_KEY] = self.class.name
|
84
96
|
|
85
|
-
|
86
|
-
|
87
|
-
|
97
|
+
self.class.model_attrs.each do |variable|
|
98
|
+
value = self.send(variable)
|
99
|
+
empty = value.nil? || (value.is_a?(Array) && value.count == 0)
|
88
100
|
|
89
|
-
# skip empty values
|
90
|
-
if !
|
91
|
-
|
101
|
+
# skip empty values
|
102
|
+
if !empty or include_empty
|
103
|
+
hash[variable.to_s] = if value.is_a? Array
|
92
104
|
value.map do |value|
|
93
105
|
if value.is_a? ModelElement
|
94
106
|
value.to_hash(options)
|
@@ -104,37 +116,60 @@ module Expressir
|
|
104
116
|
end
|
105
117
|
end
|
106
118
|
|
107
|
-
if
|
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
|
+
|
123
|
+
if self.class.method_defined? :source and formatter
|
108
124
|
hash[SOURCE_KEY] = formatter.format(self)
|
109
125
|
end
|
110
126
|
|
111
127
|
hash
|
112
128
|
end
|
113
129
|
|
114
|
-
def self.from_hash(hash)
|
115
|
-
|
116
|
-
|
117
|
-
|
130
|
+
def self.from_hash(hash, options = {})
|
131
|
+
root_path = options[:root_path]
|
132
|
+
|
133
|
+
node_class = Object.const_get(hash[CLASS_KEY])
|
134
|
+
node_options = {}
|
118
135
|
|
119
|
-
|
136
|
+
node_class.model_attrs.each do |variable|
|
137
|
+
value = hash[variable.to_s]
|
138
|
+
|
139
|
+
node_options[variable] = if value.is_a? Array
|
120
140
|
value.map do |value|
|
121
141
|
if value.is_a? Hash
|
122
|
-
self.from_hash(value)
|
142
|
+
self.from_hash(value, options)
|
123
143
|
else
|
124
144
|
value
|
125
145
|
end
|
126
146
|
end
|
127
147
|
elsif value.is_a? Hash
|
128
|
-
self.from_hash(value)
|
148
|
+
self.from_hash(value, options)
|
129
149
|
else
|
130
150
|
value
|
131
151
|
end
|
132
152
|
end
|
133
153
|
|
134
|
-
|
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)
|
135
159
|
|
136
160
|
node
|
137
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
|
138
173
|
end
|
139
174
|
end
|
140
175
|
end
|
@@ -3,12 +3,13 @@ module Expressir
|
|
3
3
|
class Parameter < ModelElement
|
4
4
|
include Identifier
|
5
5
|
|
6
|
-
|
7
|
-
|
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
|