expressir 0.2.18-x86-linux → 0.2.26-x86-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +7 -1
- data/.github/workflows/release.yml +31 -3
- data/README.adoc +3 -3
- data/exe/format +2 -49
- data/exe/format-test +81 -0
- 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 +2 -2
- data/lib/expressir/express_exp/hyperlink_formatter.rb +10 -15
- data/lib/expressir/express_exp/model_visitor.rb +23 -0
- data/lib/expressir/express_exp/parser.rb +14 -6
- data/lib/expressir/express_exp/resolve_references_model_visitor.rb +29 -0
- data/lib/expressir/express_exp/visitor.rb +19 -18
- 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 +10 -8
- 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 +5 -3
- data/lib/expressir/model/expressions/simple_reference.rb +5 -1
- data/lib/expressir/model/expressions/unary_expression.rb +2 -2
- data/lib/expressir/model/function.rb +13 -11
- 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 +9 -8
- 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 +47 -26
- data/lib/expressir/model/parameter.rb +9 -2
- data/lib/expressir/model/procedure.rb +12 -10
- data/lib/expressir/model/{informal_proposition.rb → remark_item.rb} +3 -6
- data/lib/expressir/model/repository.rb +1 -1
- data/lib/expressir/model/rule.rb +14 -12
- data/lib/expressir/model/schema.rb +15 -11
- data/lib/expressir/model/statements/alias.rb +5 -3
- 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 +9 -7
- data/lib/expressir/model/statements/return.rb +1 -1
- data/lib/expressir/model/subtype_constraint.rb +11 -4
- data/lib/expressir/model/type.rb +6 -4
- 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/multiple.exp +1 -1
- data/original/examples/syntax/multiple.yaml +19 -5
- data/original/examples/syntax/multiple_formatted.exp +1 -1
- data/original/examples/syntax/multiple_hyperlink_formatted.exp +4 -4
- data/original/examples/syntax/multiple_schema_head_hyperlink_formatted.exp +1 -1
- data/original/examples/syntax/remark.exp +12 -10
- data/original/examples/syntax/remark.yaml +24 -4
- data/original/examples/syntax/remark_formatted.exp +3 -1
- data/original/examples/syntax/single.exp +1 -0
- data/original/examples/syntax/single.yaml +7 -1
- data/original/examples/syntax/single_formatted.exp +4 -0
- data/original/examples/syntax/single_formatted.yaml +15 -1
- data/original/examples/syntax/syntax.yaml +82 -1
- data/original/examples/syntax/syntax_hyperlink_formatted.exp +902 -0
- data/spec/expressir/express_exp/cache_spec.rb +64 -0
- data/spec/expressir/express_exp/formatter_spec.rb +16 -0
- data/spec/expressir/express_exp/parser_spec.rb +10 -33
- data/spec/expressir/model/model_element_spec.rb +82 -44
- metadata +10 -4
- data/original/examples/syntax/single_root_path.yaml +0 -9
@@ -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,25 +1,26 @@
|
|
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
|
-
|
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
|
-
|
13
|
+
@remark_items = options.fetch(:remark_items, [])
|
15
14
|
|
16
15
|
@base_item = options[:base_item]
|
17
16
|
|
18
17
|
super
|
19
18
|
end
|
20
19
|
|
21
|
-
def
|
22
|
-
|
20
|
+
def children
|
21
|
+
[
|
22
|
+
*remark_items
|
23
|
+
]
|
23
24
|
end
|
24
25
|
end
|
25
26
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
1
3
|
module Expressir
|
2
4
|
module Model
|
3
5
|
class ModelElement
|
4
6
|
CLASS_KEY = '_class'
|
5
7
|
FILE_KEY = 'file'
|
6
|
-
PARENT_KEY = 'parent'
|
7
|
-
CHILDREN_BY_ID_KEY = 'children_by_id'
|
8
8
|
SOURCE_KEY = 'source'
|
9
9
|
|
10
10
|
attr_accessor :parent
|
@@ -13,18 +13,14 @@ module Expressir
|
|
13
13
|
attach_parent_to_children
|
14
14
|
end
|
15
15
|
|
16
|
-
def model_instance_variables
|
17
|
-
skip_variables = [FILE_KEY, PARENT_KEY, CHILDREN_BY_ID_KEY].map{|x| "@#{x}".to_sym}
|
18
|
-
instance_variables.select{|x| !skip_variables.include?(x)}
|
19
|
-
end
|
20
|
-
|
21
16
|
def path
|
22
|
-
|
17
|
+
# this creates an implicit scope
|
18
|
+
return if is_a? Statements::Alias or is_a? Statements::Repeat or is_a? Expressions::QueryExpression
|
23
19
|
|
24
20
|
current_node = self
|
25
21
|
path_parts = []
|
26
22
|
loop do
|
27
|
-
if current_node.class.method_defined? :id
|
23
|
+
if current_node.class.method_defined? :id and !(current_node.is_a? Expressions::SimpleReference)
|
28
24
|
path_parts << current_node.id
|
29
25
|
end
|
30
26
|
|
@@ -32,12 +28,14 @@ module Expressir
|
|
32
28
|
break unless current_node
|
33
29
|
end
|
34
30
|
|
31
|
+
return if path_parts.empty?
|
32
|
+
|
35
33
|
path_parts.reverse.join(".")
|
36
34
|
end
|
37
35
|
|
38
36
|
def attach_parent_to_children
|
39
|
-
|
40
|
-
value =
|
37
|
+
self.class.model_attrs.each do |variable|
|
38
|
+
value = self.send(variable)
|
41
39
|
|
42
40
|
if value.is_a? Array
|
43
41
|
value.each do |value|
|
@@ -76,6 +74,10 @@ module Expressir
|
|
76
74
|
break unless current_scope
|
77
75
|
end
|
78
76
|
|
77
|
+
if target_node.is_a? Model::InterfacedItem
|
78
|
+
target_node = target_node.base_item
|
79
|
+
end
|
80
|
+
|
79
81
|
target_node
|
80
82
|
end
|
81
83
|
|
@@ -98,18 +100,14 @@ module Expressir
|
|
98
100
|
|
99
101
|
hash = {}
|
100
102
|
hash[CLASS_KEY] = self.class.name
|
101
|
-
if self.is_a? Schema and file
|
102
|
-
hash[FILE_KEY] = root_path ? File.expand_path("#{root_path}/#{file}") : file
|
103
|
-
end
|
104
103
|
|
105
|
-
|
106
|
-
|
107
|
-
value = instance_variable_get(variable)
|
104
|
+
self.class.model_attrs.each do |variable|
|
105
|
+
value = self.send(variable)
|
108
106
|
empty = value.nil? || (value.is_a?(Array) && value.count == 0)
|
109
107
|
|
110
108
|
# skip empty values
|
111
109
|
if !empty or include_empty
|
112
|
-
|
110
|
+
hash[variable.to_s] = if value.is_a? Array
|
113
111
|
value.map do |value|
|
114
112
|
if value.is_a? ModelElement
|
115
113
|
value.to_hash(options)
|
@@ -125,6 +123,10 @@ module Expressir
|
|
125
123
|
end
|
126
124
|
end
|
127
125
|
|
126
|
+
if self.is_a? Schema and file
|
127
|
+
hash[FILE_KEY] = root_path ? Pathname.new(file).relative_path_from(root_path).to_s : file
|
128
|
+
end
|
129
|
+
|
128
130
|
if self.class.method_defined? :source and formatter
|
129
131
|
hash[SOURCE_KEY] = formatter.format(self)
|
130
132
|
end
|
@@ -132,30 +134,49 @@ module Expressir
|
|
132
134
|
hash
|
133
135
|
end
|
134
136
|
|
135
|
-
def self.from_hash(hash)
|
136
|
-
|
137
|
-
|
138
|
-
|
137
|
+
def self.from_hash(hash, options = {})
|
138
|
+
root_path = options[:root_path]
|
139
|
+
|
140
|
+
node_class = Object.const_get(hash[CLASS_KEY])
|
141
|
+
node_options = {}
|
142
|
+
|
143
|
+
node_class.model_attrs.each do |variable|
|
144
|
+
value = hash[variable.to_s]
|
139
145
|
|
140
|
-
|
146
|
+
node_options[variable] = if value.is_a? Array
|
141
147
|
value.map do |value|
|
142
148
|
if value.is_a? Hash
|
143
|
-
self.from_hash(value)
|
149
|
+
self.from_hash(value, options)
|
144
150
|
else
|
145
151
|
value
|
146
152
|
end
|
147
153
|
end
|
148
154
|
elsif value.is_a? Hash
|
149
|
-
self.from_hash(value)
|
155
|
+
self.from_hash(value, options)
|
150
156
|
else
|
151
157
|
value
|
152
158
|
end
|
153
159
|
end
|
154
160
|
|
155
|
-
|
161
|
+
if node_class == Schema and hash[FILE_KEY]
|
162
|
+
node_options[FILE_KEY.to_sym] = root_path ? File.expand_path("#{root_path}/#{hash[FILE_KEY]}") : hash[FILE_KEY]
|
163
|
+
end
|
164
|
+
|
165
|
+
node = node_class.new(node_options)
|
156
166
|
|
157
167
|
node
|
158
168
|
end
|
169
|
+
|
170
|
+
def self.model_attrs
|
171
|
+
@model_attrs ||= []
|
172
|
+
end
|
173
|
+
|
174
|
+
def self.model_attr_accessor(*vars)
|
175
|
+
@model_attrs ||= []
|
176
|
+
@model_attrs.concat(vars)
|
177
|
+
|
178
|
+
attr_accessor *vars
|
179
|
+
end
|
159
180
|
end
|
160
181
|
end
|
161
182
|
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
|
@@ -3,19 +3,20 @@ module Expressir
|
|
3
3
|
class Procedure < ModelElement
|
4
4
|
include Identifier
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
4
|
-
|
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
|
data/lib/expressir/model/rule.rb
CHANGED
@@ -3,21 +3,22 @@ module Expressir
|
|
3
3
|
class Rule < ModelElement
|
4
4
|
include Identifier
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
4
|
+
model_attr_accessor :file
|
5
5
|
|
6
6
|
include Identifier
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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]
|
@@ -45,6 +46,8 @@ module Expressir
|
|
45
46
|
end
|
46
47
|
|
47
48
|
def interfaced_items
|
49
|
+
return [] unless parent
|
50
|
+
|
48
51
|
interfaces.flat_map do |interface|
|
49
52
|
schema = parent.children_by_id[interface.schema.id.downcase]
|
50
53
|
if schema
|
@@ -81,7 +84,8 @@ module Expressir
|
|
81
84
|
*subtype_constraints,
|
82
85
|
*functions,
|
83
86
|
*rules,
|
84
|
-
*procedures
|
87
|
+
*procedures,
|
88
|
+
*remark_items
|
85
89
|
]
|
86
90
|
end
|
87
91
|
|