expressir 0.2.19-arm64-darwin → 0.2.27-arm64-darwin
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 -6
- 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.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/cache.rb +48 -0
- data/lib/expressir/express_exp/formatter.rb +12 -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 -3
- data/lib/expressir/express_exp/resolve_references_model_visitor.rb +29 -0
- data/lib/expressir/express_exp/visitor.rb +46 -19
- data/lib/expressir/model.rb +5 -1
- data/lib/expressir/model/attribute.rb +13 -6
- data/lib/expressir/model/cache.rb +13 -0
- data/lib/expressir/model/constant.rb +10 -3
- data/lib/expressir/model/entity.rb +16 -14
- data/lib/expressir/model/enumeration_item.rb +8 -1
- data/lib/expressir/model/expressions/aggregate_initializer.rb +2 -2
- 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 +3 -3
- data/lib/expressir/model/expressions/entity_constructor.rb +3 -3
- 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 +6 -4
- 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 +23 -21
- data/lib/expressir/model/identifier.rb +6 -3
- data/lib/expressir/model/interface.rb +4 -4
- data/lib/expressir/model/interface_item.rb +2 -2
- data/lib/expressir/model/interfaced_item.rb +10 -9
- 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 +38 -26
- data/lib/expressir/model/parameter.rb +10 -3
- data/lib/expressir/model/procedure.rb +22 -20
- data/lib/expressir/model/remark_item.rb +15 -0
- data/lib/expressir/model/repository.rb +2 -2
- data/lib/expressir/model/rule.rb +26 -24
- data/lib/expressir/model/schema.rb +24 -20
- data/lib/expressir/model/schema_version.rb +15 -0
- data/lib/expressir/model/schema_version_item.rb +15 -0
- 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 +3 -3
- data/lib/expressir/model/statements/case.rb +4 -4
- data/lib/expressir/model/statements/case_action.rb +3 -3
- data/lib/expressir/model/statements/compound.rb +2 -2
- data/lib/expressir/model/statements/if.rb +5 -5
- 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 +13 -6
- data/lib/expressir/model/type.rb +9 -7
- data/lib/expressir/model/types/aggregate.rb +9 -2
- 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 +6 -6
- data/lib/expressir/model/types/generic.rb +8 -1
- data/lib/expressir/model/types/generic_entity.rb +8 -1
- 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 +7 -7
- data/lib/expressir/model/types/set.rb +3 -3
- data/lib/expressir/model/types/string.rb +2 -2
- data/lib/expressir/model/unique.rb +10 -3
- data/lib/expressir/model/variable.rb +10 -3
- data/lib/expressir/model/where.rb +9 -2
- data/lib/expressir/version.rb +1 -1
- data/original/examples/syntax/multiple.exp +1 -1
- data/original/examples/syntax/multiple.yaml +15 -1
- 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 +23 -3
- data/original/examples/syntax/remark_formatted.exp +3 -1
- data/original/examples/syntax/single.exp +2 -1
- data/original/examples/syntax/single.yaml +9 -0
- data/original/examples/syntax/single_formatted.exp +5 -1
- data/original/examples/syntax/single_formatted.yaml +18 -1
- data/original/examples/syntax/syntax.exp +1 -1
- data/original/examples/syntax/syntax.yaml +99 -2
- data/original/examples/syntax/syntax_formatted.exp +1 -1
- data/original/examples/syntax/syntax_hyperlink_formatted.exp +902 -0
- data/original/examples/syntax/syntax_schema_head_formatted.exp +1 -1
- 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 +1 -1
- data/spec/expressir/model/model_element_spec.rb +73 -21
- metadata +12 -3
- data/lib/expressir/model/informal_proposition.rb +0 -18
@@ -0,0 +1,29 @@
|
|
1
|
+
require "expressir/express_exp/model_visitor"
|
2
|
+
require "expressir/model"
|
3
|
+
|
4
|
+
module Expressir
|
5
|
+
module ExpressExp
|
6
|
+
class ResolveReferencesModelVisitor < ModelVisitor
|
7
|
+
def visit(node)
|
8
|
+
if node.is_a? Model::Expressions::SimpleReference
|
9
|
+
visit_expressions_simple_reference(node)
|
10
|
+
end
|
11
|
+
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def visit_expressions_simple_reference(node)
|
16
|
+
return if node.parent.is_a? Model::Expressions::AttributeReference
|
17
|
+
|
18
|
+
if node.parent.is_a? Model::InterfaceItem
|
19
|
+
base_item = node.find("#{node.parent.parent.schema.id}.#{node.parent.ref.id}")
|
20
|
+
else
|
21
|
+
base_item = node.find(node.id)
|
22
|
+
end
|
23
|
+
return unless base_item
|
24
|
+
|
25
|
+
node.base_path = base_item.path
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -107,27 +107,28 @@ module Expressir
|
|
107
107
|
target_node = node.find(path)
|
108
108
|
return target_node if target_node
|
109
109
|
|
110
|
-
# check if path
|
111
|
-
# see https://github.com/lutaml/expressir/issues/
|
110
|
+
# check if path can create implicit remark item
|
111
|
+
# see https://github.com/lutaml/expressir/issues/78
|
112
112
|
rest, _, current_path = path.rpartition(".") # get last path part
|
113
113
|
_, _, current_path = current_path.rpartition(":") # ignore prefix
|
114
|
+
parent_node = node.find(rest)
|
115
|
+
if parent_node and parent_node.class.method_defined? :remark_items
|
116
|
+
remark_item = Model::RemarkItem.new({
|
117
|
+
id: current_path
|
118
|
+
})
|
119
|
+
remark_item.parent = parent_node
|
114
120
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
})
|
127
|
-
target_node.informal_propositions << informal_proposition
|
128
|
-
target_node.reset_children_by_id
|
129
|
-
informal_proposition.parent = target_node
|
130
|
-
informal_proposition
|
121
|
+
# check if path can create implicit informal proposition
|
122
|
+
# see https://github.com/lutaml/expressir/issues/50
|
123
|
+
if parent_node.class.method_defined? :informal_propositions and current_path.match(/^IP\d+$/)
|
124
|
+
parent_node.informal_propositions << remark_item
|
125
|
+
else
|
126
|
+
parent_node.remark_items << remark_item
|
127
|
+
end
|
128
|
+
parent_node.reset_children_by_id
|
129
|
+
|
130
|
+
remark_item
|
131
|
+
end
|
131
132
|
end
|
132
133
|
|
133
134
|
def attach_remarks(ctx, node)
|
@@ -1956,7 +1957,33 @@ module Expressir
|
|
1956
1957
|
def visit_schema_version_id(ctx)
|
1957
1958
|
ctx__string_literal = ctx.string_literal
|
1958
1959
|
|
1959
|
-
visit_if(ctx__string_literal)
|
1960
|
+
value = visit_if(ctx__string_literal)
|
1961
|
+
value = value.value
|
1962
|
+
|
1963
|
+
items = if value.start_with?('{') and value.end_with?('}')
|
1964
|
+
parts = value.sub(/^\{/, '').sub(/\}$/, '').split(' ')
|
1965
|
+
parts.map do |part|
|
1966
|
+
if match = part.match(/^(.+)\((\d+)\)$/)
|
1967
|
+
Model::SchemaVersionItem.new({
|
1968
|
+
name: match[1],
|
1969
|
+
value: match[2]
|
1970
|
+
})
|
1971
|
+
elsif part.match(/^\d+$/)
|
1972
|
+
Model::SchemaVersionItem.new({
|
1973
|
+
value: part
|
1974
|
+
})
|
1975
|
+
else
|
1976
|
+
Model::SchemaVersionItem.new({
|
1977
|
+
name: part
|
1978
|
+
})
|
1979
|
+
end
|
1980
|
+
end
|
1981
|
+
end
|
1982
|
+
|
1983
|
+
Model::SchemaVersion.new({
|
1984
|
+
value: value,
|
1985
|
+
items: items
|
1986
|
+
})
|
1960
1987
|
end
|
1961
1988
|
|
1962
1989
|
def visit_selector(ctx)
|
data/lib/expressir/model.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'expressir/model/model_element'
|
2
2
|
|
3
|
+
require 'expressir/model/cache'
|
4
|
+
|
3
5
|
require 'expressir/model/identifier'
|
4
6
|
|
5
7
|
require 'expressir/model/attribute'
|
@@ -7,15 +9,17 @@ require 'expressir/model/constant'
|
|
7
9
|
require 'expressir/model/entity'
|
8
10
|
require 'expressir/model/enumeration_item'
|
9
11
|
require 'expressir/model/function'
|
10
|
-
require 'expressir/model/informal_proposition'
|
11
12
|
require 'expressir/model/interface'
|
12
13
|
require 'expressir/model/interface_item'
|
13
14
|
require 'expressir/model/interfaced_item'
|
14
15
|
require 'expressir/model/parameter'
|
15
16
|
require 'expressir/model/procedure'
|
17
|
+
require 'expressir/model/remark_item'
|
16
18
|
require 'expressir/model/repository'
|
17
19
|
require 'expressir/model/rule'
|
18
20
|
require 'expressir/model/schema'
|
21
|
+
require 'expressir/model/schema_version'
|
22
|
+
require 'expressir/model/schema_version_item'
|
19
23
|
require 'expressir/model/subtype_constraint'
|
20
24
|
require 'expressir/model/type'
|
21
25
|
require 'expressir/model/unique'
|
@@ -7,15 +7,16 @@ module Expressir
|
|
7
7
|
DERIVED = :DERIVED
|
8
8
|
INVERSE = :INVERSE
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
model_attr_accessor :kind
|
11
|
+
model_attr_accessor :supertype_attribute
|
12
|
+
model_attr_accessor :optional
|
13
|
+
model_attr_accessor :type
|
14
|
+
model_attr_accessor :expression
|
15
15
|
|
16
16
|
def initialize(options = {})
|
17
17
|
@id = options[:id]
|
18
|
-
@remarks = options
|
18
|
+
@remarks = options[:remarks] || []
|
19
|
+
@remark_items = options[:remark_items] || []
|
19
20
|
@source = options[:source]
|
20
21
|
|
21
22
|
@kind = options[:kind]
|
@@ -26,6 +27,12 @@ module Expressir
|
|
26
27
|
|
27
28
|
super
|
28
29
|
end
|
30
|
+
|
31
|
+
def children
|
32
|
+
[
|
33
|
+
*remark_items
|
34
|
+
]
|
35
|
+
end
|
29
36
|
end
|
30
37
|
end
|
31
38
|
end
|
@@ -3,12 +3,13 @@ module Expressir
|
|
3
3
|
class Constant < ModelElement
|
4
4
|
include Identifier
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
model_attr_accessor :type
|
7
|
+
model_attr_accessor :expression
|
8
8
|
|
9
9
|
def initialize(options = {})
|
10
10
|
@id = options[:id]
|
11
|
-
@remarks = options
|
11
|
+
@remarks = options[:remarks] || []
|
12
|
+
@remark_items = options[: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,26 +3,27 @@ module Expressir
|
|
3
3
|
class Entity < ModelElement
|
4
4
|
include Identifier
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
model_attr_accessor :abstract
|
7
|
+
model_attr_accessor :supertype_expression
|
8
|
+
model_attr_accessor :subtype_of
|
9
|
+
model_attr_accessor :attributes
|
10
|
+
model_attr_accessor :unique
|
11
|
+
model_attr_accessor :where
|
12
|
+
model_attr_accessor :informal_propositions
|
13
13
|
|
14
14
|
def initialize(options = {})
|
15
15
|
@id = options[:id]
|
16
|
-
@remarks = options
|
16
|
+
@remarks = options[:remarks] || []
|
17
|
+
@remark_items = options[:remark_items] || []
|
17
18
|
@source = options[:source]
|
18
19
|
|
19
20
|
@abstract = options[:abstract]
|
20
21
|
@supertype_expression = options[:supertype_expression]
|
21
|
-
@subtype_of = options
|
22
|
-
@attributes = options
|
23
|
-
@unique = options
|
24
|
-
@where = options
|
25
|
-
@informal_propositions = options
|
22
|
+
@subtype_of = options[:subtype_of] || []
|
23
|
+
@attributes = options[:attributes] || []
|
24
|
+
@unique = options[:unique] || []
|
25
|
+
@where = options[:where] || []
|
26
|
+
@informal_propositions = options[:informal_propositions] || []
|
26
27
|
|
27
28
|
super
|
28
29
|
end
|
@@ -32,7 +33,8 @@ module Expressir
|
|
32
33
|
*attributes,
|
33
34
|
*unique,
|
34
35
|
*where,
|
35
|
-
*informal_propositions
|
36
|
+
*informal_propositions,
|
37
|
+
*remark_items
|
36
38
|
]
|
37
39
|
end
|
38
40
|
end
|
@@ -5,11 +5,18 @@ module Expressir
|
|
5
5
|
|
6
6
|
def initialize(options = {})
|
7
7
|
@id = options[:id]
|
8
|
-
@remarks = options
|
8
|
+
@remarks = options[:remarks] || []
|
9
|
+
@remark_items = options[:remark_items] || []
|
9
10
|
@source = options[:source]
|
10
11
|
|
11
12
|
super
|
12
13
|
end
|
14
|
+
|
15
|
+
def children
|
16
|
+
[
|
17
|
+
*remark_items
|
18
|
+
]
|
19
|
+
end
|
13
20
|
end
|
14
21
|
end
|
15
22
|
end
|
@@ -2,10 +2,10 @@ module Expressir
|
|
2
2
|
module Model
|
3
3
|
module Expressions
|
4
4
|
class AggregateInitializer < ModelElement
|
5
|
-
|
5
|
+
model_attr_accessor :items
|
6
6
|
|
7
7
|
def initialize(options = {})
|
8
|
-
@items = options
|
8
|
+
@items = options[:items] || []
|
9
9
|
|
10
10
|
super
|
11
11
|
end
|
@@ -2,8 +2,8 @@ module Expressir
|
|
2
2
|
module Model
|
3
3
|
module Expressions
|
4
4
|
class AggregateItem < ModelElement
|
5
|
-
|
6
|
-
|
5
|
+
model_attr_accessor :expression
|
6
|
+
model_attr_accessor :repetition
|
7
7
|
|
8
8
|
def initialize(options = {})
|
9
9
|
@expression = options[:expression]
|
@@ -25,9 +25,9 @@ module Expressir
|
|
25
25
|
SUBTRACTION = :SUBTRACTION
|
26
26
|
XOR = :XOR
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
model_attr_accessor :operator
|
29
|
+
model_attr_accessor :operand1
|
30
|
+
model_attr_accessor :operand2
|
31
31
|
|
32
32
|
def initialize(options = {})
|
33
33
|
@operator = options[:operator]
|
@@ -2,12 +2,12 @@ module Expressir
|
|
2
2
|
module Model
|
3
3
|
module Expressions
|
4
4
|
class Call < ModelElement
|
5
|
-
|
6
|
-
|
5
|
+
model_attr_accessor :ref
|
6
|
+
model_attr_accessor :parameters
|
7
7
|
|
8
8
|
def initialize(options = {})
|
9
9
|
@ref = options[:ref]
|
10
|
-
@parameters = options
|
10
|
+
@parameters = options[:parameters] || []
|
11
11
|
|
12
12
|
super
|
13
13
|
end
|
@@ -2,12 +2,12 @@ module Expressir
|
|
2
2
|
module Model
|
3
3
|
module Expressions
|
4
4
|
class EntityConstructor < ModelElement
|
5
|
-
|
6
|
-
|
5
|
+
model_attr_accessor :entity
|
6
|
+
model_attr_accessor :parameters
|
7
7
|
|
8
8
|
def initialize(options = {})
|
9
9
|
@entity = options[:entity]
|
10
|
-
@parameters = options
|
10
|
+
@parameters = options[:parameters] || []
|
11
11
|
|
12
12
|
super
|
13
13
|
end
|
@@ -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
|
-
@remarks = options
|
12
|
+
@remarks = options[:remarks] || []
|
13
|
+
@remark_items = options[:remark_items] || []
|
13
14
|
@source = options[:source]
|
14
15
|
|
15
16
|
@aggregate_source = options[:aggregate_source]
|
@@ -20,7 +21,8 @@ module Expressir
|
|
20
21
|
|
21
22
|
def children
|
22
23
|
[
|
23
|
-
self
|
24
|
+
self,
|
25
|
+
*remark_items
|
24
26
|
]
|
25
27
|
end
|
26
28
|
end
|