expressir 0.2.11-arm64-darwin → 0.2.16-arm64-darwin
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/exe/format +27 -0
- data/expressir.gemspec +1 -0
- data/lib/expressir/express_exp/2.4/express_parser.bundle +0 -0
- data/lib/expressir/express_exp/2.5/express_parser.bundle +0 -0
- data/lib/expressir/express_exp/2.6/express_parser.bundle +0 -0
- data/lib/expressir/express_exp/2.7/express_parser.bundle +0 -0
- data/lib/expressir/express_exp/3.0/express_parser.bundle +0 -0
- data/lib/expressir/express_exp/formatter.rb +90 -100
- data/lib/expressir/express_exp/hyperlink_formatter.rb +27 -0
- data/lib/expressir/express_exp/parser.rb +7 -1
- data/lib/expressir/express_exp/schema_head_formatter.rb +12 -0
- data/lib/expressir/express_exp/visitor.rb +67 -99
- data/lib/expressir/model.rb +2 -2
- data/lib/expressir/model/attribute.rb +2 -0
- data/lib/expressir/model/constant.rb +2 -0
- data/lib/expressir/model/entity.rb +3 -2
- data/lib/expressir/model/enumeration_item.rb +2 -0
- data/lib/expressir/model/expressions/aggregate_initializer.rb +2 -0
- data/lib/expressir/model/expressions/aggregate_item.rb +2 -0
- data/lib/expressir/model/expressions/attribute_reference.rb +2 -0
- data/lib/expressir/model/expressions/binary_expression.rb +2 -0
- data/lib/expressir/model/expressions/call.rb +2 -0
- data/lib/expressir/model/expressions/entity_constructor.rb +2 -0
- data/lib/expressir/model/expressions/group_reference.rb +2 -0
- data/lib/expressir/model/expressions/index_reference.rb +2 -0
- data/lib/expressir/model/expressions/interval.rb +2 -0
- data/lib/expressir/model/expressions/query_expression.rb +2 -1
- data/lib/expressir/model/expressions/simple_reference.rb +2 -0
- data/lib/expressir/model/expressions/unary_expression.rb +2 -0
- data/lib/expressir/model/function.rb +3 -8
- data/lib/expressir/model/identifier.rb +0 -1
- data/lib/expressir/model/informal_proposition.rb +2 -0
- data/lib/expressir/model/interface.rb +2 -0
- data/lib/expressir/model/{renamed_ref.rb → interface_item.rb} +4 -2
- data/lib/expressir/model/interfaced_item.rb +23 -0
- data/lib/expressir/model/literals/binary.rb +2 -0
- data/lib/expressir/model/literals/integer.rb +2 -0
- data/lib/expressir/model/literals/logical.rb +2 -0
- data/lib/expressir/model/literals/real.rb +2 -0
- data/lib/expressir/model/literals/string.rb +2 -0
- data/lib/expressir/model/model_element.rb +71 -4
- data/lib/expressir/model/parameter.rb +2 -0
- data/lib/expressir/model/procedure.rb +3 -8
- data/lib/expressir/model/repository.rb +2 -2
- data/lib/expressir/model/rule.rb +4 -9
- data/lib/expressir/model/schema.rb +45 -12
- data/lib/expressir/model/statements/alias.rb +2 -1
- data/lib/expressir/model/statements/assignment.rb +2 -0
- data/lib/expressir/model/statements/call.rb +2 -0
- data/lib/expressir/model/statements/case.rb +2 -0
- data/lib/expressir/model/statements/case_action.rb +2 -0
- data/lib/expressir/model/statements/compound.rb +2 -0
- data/lib/expressir/model/statements/if.rb +2 -0
- data/lib/expressir/model/statements/repeat.rb +2 -1
- data/lib/expressir/model/statements/return.rb +2 -0
- data/lib/expressir/model/subtype_constraint.rb +2 -1
- data/lib/expressir/model/type.rb +3 -6
- data/lib/expressir/model/types/aggregate.rb +2 -0
- data/lib/expressir/model/types/array.rb +2 -0
- data/lib/expressir/model/types/bag.rb +2 -0
- data/lib/expressir/model/types/binary.rb +2 -0
- data/lib/expressir/model/types/enumeration.rb +2 -0
- data/lib/expressir/model/types/generic.rb +2 -0
- data/lib/expressir/model/types/generic_entity.rb +2 -0
- data/lib/expressir/model/types/list.rb +2 -0
- data/lib/expressir/model/types/real.rb +2 -0
- data/lib/expressir/model/types/select.rb +2 -0
- data/lib/expressir/model/types/set.rb +2 -0
- data/lib/expressir/model/types/string.rb +2 -0
- data/lib/expressir/model/unique.rb +2 -0
- data/lib/expressir/model/variable.rb +2 -0
- data/lib/expressir/model/where.rb +2 -0
- data/lib/expressir/version.rb +1 -1
- data/original/examples/syntax/hyperlink.exp +23 -0
- data/original/examples/syntax/hyperlink_formatted.exp +51 -0
- data/original/examples/syntax/syntax.exp +18 -18
- data/original/examples/syntax/syntax_formatted.exp +32 -24
- data/spec/expressir/express_exp/{format_remark_spec.rb → formatter/remark_spec.rb} +2 -2
- data/spec/expressir/express_exp/{format_syntax_spec.rb → formatter/syntax_spec.rb} +2 -2
- data/spec/expressir/express_exp/hyperlink_formatter_spec.rb +28 -0
- data/spec/expressir/express_exp/{parse_multiple_spec.rb → parser/multiple_spec.rb} +6 -1
- data/spec/expressir/express_exp/{parse_remark_spec.rb → parser/remark_spec.rb} +2 -2
- data/spec/expressir/express_exp/{source_spec.rb → parser/source_spec.rb} +1 -1
- data/spec/expressir/express_exp/{parse_syntax_spec.rb → parser/syntax_spec.rb} +98 -60
- data/spec/expressir/express_exp/schema_head_formatter_spec.rb +40 -0
- data/spec/expressir/model/{scope_spec.rb → model_element/find_spec.rb} +7 -2
- data/spec/expressir/model/{model_element_spec.rb → model_element/hash_spec.rb} +7 -18
- metadata +33 -14
- data/lib/expressir/model/scope.rb +0 -71
- data/spec/expressir/express_exp/ap233_spec.rb +0 -22
- data/spec/expressir/express_exp/head_source_spec.rb +0 -38
@@ -0,0 +1,40 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "expressir/express_exp/parser"
|
3
|
+
require "expressir/express_exp/formatter"
|
4
|
+
require "expressir/express_exp/schema_head_formatter"
|
5
|
+
|
6
|
+
RSpec.describe Expressir::ExpressExp::SchemaHeadFormatter do
|
7
|
+
describe ".format" do
|
8
|
+
it "formats schema head" do
|
9
|
+
repo = Expressir::ExpressExp::Parser.from_file(sample_file)
|
10
|
+
|
11
|
+
class CustomFormatter < Expressir::ExpressExp::Formatter
|
12
|
+
include Expressir::ExpressExp::SchemaHeadFormatter
|
13
|
+
end
|
14
|
+
result = CustomFormatter.format(repo)
|
15
|
+
|
16
|
+
expect(result).to eq(<<~EXP.strip
|
17
|
+
SCHEMA syntax_schema 'version';
|
18
|
+
USE FROM contract_schema;
|
19
|
+
USE FROM contract_schema
|
20
|
+
(contract);
|
21
|
+
USE FROM contract_schema
|
22
|
+
(contract, contract2);
|
23
|
+
USE FROM contract_schema
|
24
|
+
(contract AS contract2);
|
25
|
+
REFERENCE FROM contract_schema;
|
26
|
+
REFERENCE FROM contract_schema
|
27
|
+
(contract);
|
28
|
+
REFERENCE FROM contract_schema
|
29
|
+
(contract, contract2);
|
30
|
+
REFERENCE FROM contract_schema
|
31
|
+
(contract AS contract2);
|
32
|
+
EXP
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def sample_file
|
38
|
+
@sample_file ||= Expressir.root_path.join("original", "examples", "syntax", "syntax.exp")
|
39
|
+
end
|
40
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require "expressir/express_exp/parser"
|
3
3
|
|
4
|
-
RSpec.describe Expressir::Model::
|
4
|
+
RSpec.describe Expressir::Model::ModelElement do
|
5
5
|
describe ".find" do
|
6
6
|
it "finds an object" do
|
7
|
-
repo = Expressir::ExpressExp::Parser.
|
7
|
+
repo = Expressir::ExpressExp::Parser.from_file(sample_file)
|
8
8
|
|
9
9
|
# universal scope
|
10
10
|
expect(repo.find('remark_schema')).to be_instance_of(Expressir::Model::Schema)
|
@@ -112,6 +112,11 @@ RSpec.describe Expressir::Model::Scope do
|
|
112
112
|
expect(rule.find('remark_variable')).to be_instance_of(Expressir::Model::Variable)
|
113
113
|
expect(rule.find('WR1')).to be_instance_of(Expressir::Model::Where)
|
114
114
|
expect(rule.find('wr:WR1')).to be_instance_of(Expressir::Model::Where)
|
115
|
+
|
116
|
+
# retry search in parent scope
|
117
|
+
expect(entity.find('remark_type')).to be_instance_of(Expressir::Model::Type)
|
118
|
+
expect(entity.find('remark_type.WR1')).to be_instance_of(Expressir::Model::Where)
|
119
|
+
expect(entity.find('remark_type.wr:WR1')).to be_instance_of(Expressir::Model::Where)
|
115
120
|
end
|
116
121
|
end
|
117
122
|
|
@@ -33,9 +33,14 @@ RSpec.describe Expressir::Model::ModelElement do
|
|
33
33
|
|
34
34
|
describe ".to_hash" do
|
35
35
|
it "exports an object to a hash" do
|
36
|
-
repo = Expressir::ExpressExp::Parser.
|
36
|
+
repo = Expressir::ExpressExp::Parser.from_file(sample_file)
|
37
37
|
|
38
|
-
|
38
|
+
class CustomFormatter < Expressir::ExpressExp::Formatter
|
39
|
+
def format_schema(node)
|
40
|
+
"Oook."
|
41
|
+
end
|
42
|
+
end
|
43
|
+
result = repo.to_hash(formatter: CustomFormatter)
|
39
44
|
|
40
45
|
expect(result).to be_instance_of(Hash)
|
41
46
|
expect(result["_class"]).to eq("Expressir::Model::Repository")
|
@@ -49,22 +54,6 @@ RSpec.describe Expressir::Model::ModelElement do
|
|
49
54
|
expect(result["schemas"].first["entities"].first).to be_instance_of(Hash)
|
50
55
|
expect(result["schemas"].first["entities"].first["_class"]).to eq("Expressir::Model::Entity")
|
51
56
|
expect(result["schemas"].first["entities"].first["id"]).to eq("empty_entity")
|
52
|
-
end
|
53
|
-
|
54
|
-
it "exports an object to a hash with a custom formatter" do
|
55
|
-
repo = Expressir::ExpressExp::Parser.from_exp(sample_file)
|
56
|
-
|
57
|
-
class CustomFormatter < Expressir::ExpressExp::Formatter
|
58
|
-
def format_schema(node)
|
59
|
-
"Oook."
|
60
|
-
end
|
61
|
-
end
|
62
|
-
result = repo.to_hash({ formatter: CustomFormatter })
|
63
|
-
|
64
|
-
expect(result).to be_instance_of(Hash)
|
65
|
-
expect(result["_class"]).to eq("Expressir::Model::Repository")
|
66
|
-
expect(result["schemas"]).to be_instance_of(Array)
|
67
|
-
expect(result["schemas"].count).to eq(1)
|
68
57
|
expect(result["schemas"].first["source"]).to eq("Oook.")
|
69
58
|
end
|
70
59
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: expressir
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.16
|
5
5
|
platform: arm64-darwin
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.12.2
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: byebug
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '11.1'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '11.1'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rake
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -160,6 +174,7 @@ files:
|
|
160
174
|
- demo.rb
|
161
175
|
- docs/development.md
|
162
176
|
- exe/expressir
|
177
|
+
- exe/format
|
163
178
|
- exe/generate-parser
|
164
179
|
- expressir.gemspec
|
165
180
|
- lib/expressir.rb
|
@@ -201,7 +216,9 @@ files:
|
|
201
216
|
- lib/expressir/express_exp/2.7/express_parser.bundle
|
202
217
|
- lib/expressir/express_exp/3.0/express_parser.bundle
|
203
218
|
- lib/expressir/express_exp/formatter.rb
|
219
|
+
- lib/expressir/express_exp/hyperlink_formatter.rb
|
204
220
|
- lib/expressir/express_exp/parser.rb
|
221
|
+
- lib/expressir/express_exp/schema_head_formatter.rb
|
205
222
|
- lib/expressir/express_exp/visitor.rb
|
206
223
|
- lib/expressir/express_parser.rb
|
207
224
|
- lib/expressir/model.rb
|
@@ -225,6 +242,8 @@ files:
|
|
225
242
|
- lib/expressir/model/identifier.rb
|
226
243
|
- lib/expressir/model/informal_proposition.rb
|
227
244
|
- lib/expressir/model/interface.rb
|
245
|
+
- lib/expressir/model/interface_item.rb
|
246
|
+
- lib/expressir/model/interfaced_item.rb
|
228
247
|
- lib/expressir/model/literals/binary.rb
|
229
248
|
- lib/expressir/model/literals/integer.rb
|
230
249
|
- lib/expressir/model/literals/logical.rb
|
@@ -233,11 +252,9 @@ files:
|
|
233
252
|
- lib/expressir/model/model_element.rb
|
234
253
|
- lib/expressir/model/parameter.rb
|
235
254
|
- lib/expressir/model/procedure.rb
|
236
|
-
- lib/expressir/model/renamed_ref.rb
|
237
255
|
- lib/expressir/model/repository.rb
|
238
256
|
- lib/expressir/model/rule.rb
|
239
257
|
- lib/expressir/model/schema.rb
|
240
|
-
- lib/expressir/model/scope.rb
|
241
258
|
- lib/expressir/model/statements/alias.rb
|
242
259
|
- lib/expressir/model/statements/assignment.rb
|
243
260
|
- lib/expressir/model/statements/call.rb
|
@@ -303,6 +320,8 @@ files:
|
|
303
320
|
- original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.owl
|
304
321
|
- original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xmi
|
305
322
|
- original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xml
|
323
|
+
- original/examples/syntax/hyperlink.exp
|
324
|
+
- original/examples/syntax/hyperlink_formatted.exp
|
306
325
|
- original/examples/syntax/remark.exp
|
307
326
|
- original/examples/syntax/remark_formatted.exp
|
308
327
|
- original/examples/syntax/simple.exp
|
@@ -320,16 +339,16 @@ files:
|
|
320
339
|
- spec/acceptance/express_to_owl_spec.rb
|
321
340
|
- spec/acceptance/version_spec.rb
|
322
341
|
- spec/expressir/express/repository_spec.rb
|
323
|
-
- spec/expressir/express_exp/
|
324
|
-
- spec/expressir/express_exp/
|
325
|
-
- spec/expressir/express_exp/
|
326
|
-
- spec/expressir/express_exp/
|
327
|
-
- spec/expressir/express_exp/
|
328
|
-
- spec/expressir/express_exp/
|
329
|
-
- spec/expressir/express_exp/
|
330
|
-
- spec/expressir/express_exp/
|
331
|
-
- spec/expressir/model/
|
332
|
-
- spec/expressir/model/
|
342
|
+
- spec/expressir/express_exp/formatter/remark_spec.rb
|
343
|
+
- spec/expressir/express_exp/formatter/syntax_spec.rb
|
344
|
+
- spec/expressir/express_exp/hyperlink_formatter_spec.rb
|
345
|
+
- spec/expressir/express_exp/parser/multiple_spec.rb
|
346
|
+
- spec/expressir/express_exp/parser/remark_spec.rb
|
347
|
+
- spec/expressir/express_exp/parser/source_spec.rb
|
348
|
+
- spec/expressir/express_exp/parser/syntax_spec.rb
|
349
|
+
- spec/expressir/express_exp/schema_head_formatter_spec.rb
|
350
|
+
- spec/expressir/model/model_element/find_spec.rb
|
351
|
+
- spec/expressir/model/model_element/hash_spec.rb
|
333
352
|
- spec/expressr_spec.rb
|
334
353
|
- spec/spec_helper.rb
|
335
354
|
- spec/support/console_helper.rb
|
@@ -1,71 +0,0 @@
|
|
1
|
-
module Expressir
|
2
|
-
module Model
|
3
|
-
module Scope
|
4
|
-
def find(path)
|
5
|
-
current_path, _, rest = path.partition(".")
|
6
|
-
|
7
|
-
# ignore prefix
|
8
|
-
_, _, current_path = current_path.rpartition(":")
|
9
|
-
|
10
|
-
current_path = current_path.downcase
|
11
|
-
child = children.find{|x| x.id and x.id.downcase == current_path}
|
12
|
-
|
13
|
-
if !rest.empty? and child.class.method_defined? :find
|
14
|
-
child.find(rest)
|
15
|
-
else
|
16
|
-
child
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def find_or_create(path)
|
21
|
-
child = find(path)
|
22
|
-
|
23
|
-
if !child
|
24
|
-
# check if path should create implicit informal proposal
|
25
|
-
# see https://github.com/lutaml/expressir/issues/50
|
26
|
-
rest, _, current_path = path.rpartition(".")
|
27
|
-
|
28
|
-
if !rest.empty?
|
29
|
-
child = find(rest)
|
30
|
-
else
|
31
|
-
child = self
|
32
|
-
end
|
33
|
-
|
34
|
-
if child.class.method_defined? :informal_propositions
|
35
|
-
# ignore prefix
|
36
|
-
_, _, current_path = current_path.rpartition(":")
|
37
|
-
|
38
|
-
# match informal proposition id
|
39
|
-
informal_proposition_id = current_path.match(/^IP\d+$/).to_a[0]
|
40
|
-
|
41
|
-
if informal_proposition_id
|
42
|
-
# create implicit informal proposition
|
43
|
-
informal_proposition = Model::InformalProposition.new({
|
44
|
-
id: informal_proposition_id
|
45
|
-
})
|
46
|
-
informal_proposition.parent = child
|
47
|
-
|
48
|
-
child.informal_propositions << informal_proposition
|
49
|
-
|
50
|
-
informal_proposition
|
51
|
-
end
|
52
|
-
end
|
53
|
-
else
|
54
|
-
child
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def attach_parent_to_children
|
59
|
-
children.each do |child_node|
|
60
|
-
if child_node.class.method_defined? :parent and !child_node.parent
|
61
|
-
child_node.parent = self
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def children
|
67
|
-
raise 'Not implemented'
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "expressir/express_exp/parser"
|
3
|
-
|
4
|
-
RSpec.describe Expressir::ExpressExp::Parser do
|
5
|
-
describe ".from_file" do
|
6
|
-
it "build an instance from a file" do
|
7
|
-
repo = Expressir::ExpressExp::Parser.from_exp(sample_file)
|
8
|
-
|
9
|
-
schemas = repo.schemas
|
10
|
-
expect(schemas.count).to eq(1)
|
11
|
-
|
12
|
-
schema = schemas.first
|
13
|
-
expect(schema.id).to eq("Ap233_systems_engineering_arm_LF")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def sample_file
|
18
|
-
@sample_file ||= Expressir.root_path.join(
|
19
|
-
"original", "examples", "ap233", "ap233e1_arm_lf_stepmod-2010-11-12.exp"
|
20
|
-
)
|
21
|
-
end
|
22
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "expressir/express_exp/parser"
|
3
|
-
|
4
|
-
RSpec.describe Expressir::ExpressExp::Parser do
|
5
|
-
describe ".head_source" do
|
6
|
-
it "contains original head source" do
|
7
|
-
input = File.read(sample_file)
|
8
|
-
repo = Expressir::ExpressExp::Parser.from_exp(sample_file)
|
9
|
-
|
10
|
-
repo.schemas[0].tap do |x|
|
11
|
-
start_index = x.source.index("SCHEMA")
|
12
|
-
stop_index = x.source.index(";") + ";".length - 1
|
13
|
-
expected_result = x.source[start_index..stop_index]
|
14
|
-
expect(x.head_source).to eq(expected_result)
|
15
|
-
end
|
16
|
-
|
17
|
-
repo.schemas[1].tap do |x|
|
18
|
-
start_index = x.source.index("SCHEMA")
|
19
|
-
stop_index = x.source.index(";") + ";".length - 1
|
20
|
-
expected_result = x.source[start_index..stop_index]
|
21
|
-
expect(x.head_source).to eq(expected_result)
|
22
|
-
end
|
23
|
-
|
24
|
-
repo.schemas[2].tap do |x|
|
25
|
-
start_index = x.source.index("SCHEMA")
|
26
|
-
stop_index = x.source.index("REFERENCE FROM contract_schema;") + "REFERENCE FROM contract_schema;".length - 1
|
27
|
-
expected_result = x.source[start_index..stop_index]
|
28
|
-
expect(x.head_source).to eq(expected_result)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def sample_file
|
34
|
-
@sample_file ||= Expressir.root_path.join(
|
35
|
-
"original", "examples", "syntax", "source.exp"
|
36
|
-
)
|
37
|
-
end
|
38
|
-
end
|