expressir 0.2.24 → 1.1.0
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/.gitignore +2 -2
- data/.yardopts +11 -0
- data/Rakefile +3 -0
- data/demo.rb +5 -5
- data/exe/format +10 -73
- data/exe/format-test +81 -0
- data/expressir.gemspec +3 -1
- data/ext/express-parser/extconf.rb +1 -1
- data/lib/expressir.rb +0 -1
- data/lib/expressir/cli.rb +0 -6
- data/lib/expressir/express/cache.rb +51 -0
- data/lib/expressir/{express_exp → express}/formatter.rb +306 -239
- data/lib/expressir/express/hyperlink_formatter.rb +36 -0
- data/lib/expressir/express/model_visitor.rb +24 -0
- data/lib/expressir/express/parser.rb +81 -0
- data/lib/expressir/express/resolve_references_model_visitor.rb +31 -0
- data/lib/expressir/express/schema_head_formatter.rb +23 -0
- data/lib/expressir/{express_exp → express}/visitor.rb +318 -270
- data/lib/expressir/model.rb +52 -43
- data/lib/expressir/model/cache.rb +6 -2
- data/lib/expressir/model/data_type.rb +9 -0
- data/lib/expressir/model/data_types/aggregate.rb +31 -0
- data/lib/expressir/model/data_types/array.rb +31 -0
- data/lib/expressir/model/data_types/bag.rb +25 -0
- data/lib/expressir/model/data_types/binary.rb +22 -0
- data/lib/expressir/model/data_types/boolean.rb +10 -0
- data/lib/expressir/model/data_types/enumeration.rb +25 -0
- data/lib/expressir/model/data_types/enumeration_item.rb +26 -0
- data/lib/expressir/model/data_types/generic.rb +26 -0
- data/lib/expressir/model/data_types/generic_entity.rb +26 -0
- data/lib/expressir/model/data_types/integer.rb +10 -0
- data/lib/expressir/model/data_types/list.rb +28 -0
- data/lib/expressir/model/data_types/logical.rb +10 -0
- data/lib/expressir/model/data_types/number.rb +10 -0
- data/lib/expressir/model/data_types/real.rb +19 -0
- data/lib/expressir/model/data_types/select.rb +28 -0
- data/lib/expressir/model/data_types/set.rb +25 -0
- data/lib/expressir/model/data_types/string.rb +22 -0
- data/lib/expressir/model/declaration.rb +9 -0
- data/lib/expressir/model/declarations/attribute.rb +47 -0
- data/lib/expressir/model/declarations/constant.rb +34 -0
- data/lib/expressir/model/declarations/entity.rb +53 -0
- data/lib/expressir/model/declarations/function.rb +67 -0
- data/lib/expressir/model/declarations/interface.rb +28 -0
- data/lib/expressir/model/declarations/interface_item.rb +23 -0
- data/lib/expressir/model/declarations/interfaced_item.rb +37 -0
- data/lib/expressir/model/declarations/parameter.rb +34 -0
- data/lib/expressir/model/declarations/procedure.rb +64 -0
- data/lib/expressir/model/declarations/remark_item.rb +21 -0
- data/lib/expressir/model/declarations/rule.rb +71 -0
- data/lib/expressir/model/declarations/schema.rb +117 -0
- data/lib/expressir/model/declarations/schema_version.rb +22 -0
- data/lib/expressir/model/declarations/schema_version_item.rb +22 -0
- data/lib/expressir/model/declarations/subtype_constraint.rb +40 -0
- data/lib/expressir/model/declarations/type.rb +45 -0
- data/lib/expressir/model/declarations/unique_rule.rb +31 -0
- data/lib/expressir/model/declarations/variable.rb +34 -0
- data/lib/expressir/model/declarations/where_rule.rb +31 -0
- data/lib/expressir/model/expression.rb +9 -0
- data/lib/expressir/model/expressions/aggregate_initializer.rb +7 -3
- data/lib/expressir/model/expressions/aggregate_initializer_item.rb +22 -0
- data/lib/expressir/model/expressions/binary_expression.rb +16 -5
- data/lib/expressir/model/expressions/entity_constructor.rb +9 -4
- data/lib/expressir/model/expressions/function_call.rb +22 -0
- data/lib/expressir/model/expressions/interval.rb +17 -6
- data/lib/expressir/model/expressions/query_expression.rb +11 -7
- data/lib/expressir/model/expressions/unary_expression.rb +9 -3
- data/lib/expressir/model/identifier.rb +26 -4
- data/lib/expressir/model/literal.rb +9 -0
- data/lib/expressir/model/literals/binary.rb +6 -2
- data/lib/expressir/model/literals/integer.rb +6 -2
- data/lib/expressir/model/literals/logical.rb +6 -2
- data/lib/expressir/model/literals/real.rb +6 -2
- data/lib/expressir/model/literals/string.rb +8 -3
- data/lib/expressir/model/model_element.rb +70 -37
- data/lib/expressir/model/reference.rb +9 -0
- data/lib/expressir/model/references/attribute_reference.rb +22 -0
- data/lib/expressir/model/references/group_reference.rb +22 -0
- data/lib/expressir/model/references/index_reference.rb +27 -0
- data/lib/expressir/model/references/simple_reference.rb +24 -0
- data/lib/expressir/model/repository.rb +8 -2
- data/lib/expressir/model/statement.rb +9 -0
- data/lib/expressir/model/statements/alias.rb +12 -8
- data/lib/expressir/model/statements/assignment.rb +8 -3
- data/lib/expressir/model/statements/case.rb +11 -5
- data/lib/expressir/model/statements/case_action.rb +8 -3
- data/lib/expressir/model/statements/compound.rb +7 -3
- data/lib/expressir/model/statements/escape.rb +3 -1
- data/lib/expressir/model/statements/if.rb +12 -6
- data/lib/expressir/model/statements/null.rb +3 -1
- data/lib/expressir/model/statements/procedure_call.rb +22 -0
- data/lib/expressir/model/statements/repeat.rb +20 -12
- data/lib/expressir/model/statements/return.rb +6 -2
- data/lib/expressir/model/statements/skip.rb +3 -1
- data/lib/expressir/model/supertype_expression.rb +9 -0
- data/lib/expressir/model/supertype_expressions/binary_supertype_expression.rb +29 -0
- data/lib/expressir/model/supertype_expressions/oneof_supertype_expression.rb +19 -0
- data/lib/expressir/version.rb +1 -1
- data/rakelib/cross-ruby.rake +1 -1
- data/spec/expressir/{express_exp → express}/cache_spec.rb +9 -9
- data/spec/expressir/express/formatter_spec.rb +127 -0
- data/spec/expressir/{express_exp → express}/parser_spec.rb +24 -24
- data/spec/expressir/model/model_element_spec.rb +181 -129
- data/{original/examples → spec}/syntax/multiple.exp +1 -1
- data/spec/syntax/multiple.yaml +198 -0
- data/{original/examples → spec}/syntax/multiple_formatted.exp +1 -1
- data/{original/examples → spec}/syntax/multiple_hyperlink_formatted.exp +4 -4
- data/{original/examples → spec}/syntax/multiple_schema_head_hyperlink_formatted.exp +1 -1
- data/{original/examples → spec}/syntax/remark.exp +0 -0
- data/{original/examples → spec}/syntax/remark.yaml +87 -73
- data/{original/examples → spec}/syntax/remark_formatted.exp +0 -0
- data/spec/syntax/single.exp +4 -0
- data/spec/syntax/single.yaml +18 -0
- data/spec/syntax/single_formatted.exp +10 -0
- data/spec/syntax/single_formatted.yaml +36 -0
- data/{original/examples → spec}/syntax/syntax.exp +11 -11
- data/{original/examples → spec}/syntax/syntax.yaml +1181 -1111
- data/{original/examples → spec}/syntax/syntax_formatted.exp +11 -11
- data/spec/syntax/syntax_hyperlink_formatted.exp +902 -0
- data/{original/examples → spec}/syntax/syntax_schema_head_formatted.exp +1 -1
- metadata +123 -113
- data/lib/expressir/express.rb +0 -11
- data/lib/expressir/express/aggregate_dimension.rb +0 -38
- data/lib/expressir/express/attribute.rb +0 -15
- data/lib/expressir/express/comment.rb +0 -7
- data/lib/expressir/express/defined_type.rb +0 -36
- data/lib/expressir/express/derived.rb +0 -65
- data/lib/expressir/express/derived_aggregate.rb +0 -43
- data/lib/expressir/express/entity.rb +0 -137
- data/lib/expressir/express/explicit.rb +0 -70
- data/lib/expressir/express/explicit_aggregate.rb +0 -46
- data/lib/expressir/express/explicit_or_derived.rb +0 -16
- data/lib/expressir/express/global_rule.rb +0 -44
- data/lib/expressir/express/interface_specification.rb +0 -51
- data/lib/expressir/express/interfaced_item.rb +0 -38
- data/lib/expressir/express/inverse.rb +0 -46
- data/lib/expressir/express/inverse_aggregate.rb +0 -37
- data/lib/expressir/express/model_element.rb +0 -7
- data/lib/expressir/express/named_type.rb +0 -19
- data/lib/expressir/express/remark.rb +0 -8
- data/lib/expressir/express/repository.rb +0 -306
- data/lib/expressir/express/schema_definition.rb +0 -96
- data/lib/expressir/express/subtype_constraint.rb +0 -14
- data/lib/expressir/express/type.rb +0 -26
- data/lib/expressir/express/type_aggregate.rb +0 -42
- data/lib/expressir/express/type_enum.rb +0 -29
- data/lib/expressir/express/type_parser.rb +0 -45
- data/lib/expressir/express/type_select.rb +0 -82
- data/lib/expressir/express/unique_rule.rb +0 -35
- data/lib/expressir/express/where_rule.rb +0 -32
- data/lib/expressir/express_exp/cache.rb +0 -48
- data/lib/expressir/express_exp/hyperlink_formatter.rb +0 -27
- data/lib/expressir/express_exp/parser.rb +0 -64
- data/lib/expressir/express_exp/schema_head_formatter.rb +0 -9
- data/lib/expressir/express_parser.rb +0 -30
- data/lib/expressir/model/attribute.rb +0 -38
- data/lib/expressir/model/constant.rb +0 -28
- data/lib/expressir/model/entity.rb +0 -42
- data/lib/expressir/model/enumeration_item.rb +0 -22
- data/lib/expressir/model/expressions/aggregate_item.rb +0 -17
- data/lib/expressir/model/expressions/attribute_reference.rb +0 -17
- data/lib/expressir/model/expressions/call.rb +0 -17
- data/lib/expressir/model/expressions/group_reference.rb +0 -17
- data/lib/expressir/model/expressions/index_reference.rb +0 -19
- data/lib/expressir/model/expressions/simple_reference.rb +0 -15
- data/lib/expressir/model/function.rb +0 -57
- data/lib/expressir/model/interface.rb +0 -20
- data/lib/expressir/model/interface_item.rb +0 -15
- data/lib/expressir/model/interfaced_item.rb +0 -31
- data/lib/expressir/model/parameter.rb +0 -28
- data/lib/expressir/model/procedure.rb +0 -55
- data/lib/expressir/model/remark_item.rb +0 -15
- data/lib/expressir/model/rule.rb +0 -60
- data/lib/expressir/model/schema.rb +0 -98
- data/lib/expressir/model/statements/call.rb +0 -17
- data/lib/expressir/model/subtype_constraint.rb +0 -32
- data/lib/expressir/model/type.rb +0 -37
- data/lib/expressir/model/types/aggregate.rb +0 -28
- data/lib/expressir/model/types/array.rb +0 -23
- data/lib/expressir/model/types/bag.rb +0 -19
- data/lib/expressir/model/types/binary.rb +0 -17
- data/lib/expressir/model/types/boolean.rb +0 -8
- data/lib/expressir/model/types/enumeration.rb +0 -21
- data/lib/expressir/model/types/generic.rb +0 -24
- data/lib/expressir/model/types/generic_entity.rb +0 -24
- data/lib/expressir/model/types/integer.rb +0 -8
- data/lib/expressir/model/types/list.rb +0 -21
- data/lib/expressir/model/types/logical.rb +0 -8
- data/lib/expressir/model/types/number.rb +0 -8
- data/lib/expressir/model/types/real.rb +0 -15
- data/lib/expressir/model/types/select.rb +0 -23
- data/lib/expressir/model/types/set.rb +0 -19
- data/lib/expressir/model/types/string.rb +0 -17
- data/lib/expressir/model/unique.rb +0 -26
- data/lib/expressir/model/variable.rb +0 -28
- data/lib/expressir/model/where.rb +0 -26
- data/lib/expressir/parser.rb +0 -6
- data/lib/expressir/parser/owl_parser.rb +0 -8
- data/original/examples/syntax/multiple.yaml +0 -184
- data/original/examples/syntax/single.exp +0 -3
- data/original/examples/syntax/single.yaml +0 -9
- data/original/examples/syntax/single_formatted.exp +0 -6
- data/original/examples/syntax/single_formatted.yaml +0 -19
- data/spec/acceptance/express_to_owl_spec.rb +0 -18
- data/spec/expressir/express/repository_spec.rb +0 -25
- data/spec/expressir/express_exp/formatter_spec.rb +0 -111
@@ -0,0 +1,34 @@
|
|
1
|
+
module Expressir
|
2
|
+
module Model
|
3
|
+
module Declarations
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 9.5.4 Local variables
|
6
|
+
class Variable < Declaration
|
7
|
+
include Identifier
|
8
|
+
|
9
|
+
model_attr_accessor :type, 'DataType'
|
10
|
+
model_attr_accessor :expression, 'Expression'
|
11
|
+
|
12
|
+
# @param [Hash] options
|
13
|
+
# @option (see Identifier#initialize_identifier)
|
14
|
+
# @option options [DataType] :type
|
15
|
+
# @option options [Expression] :expression
|
16
|
+
def initialize(options = {})
|
17
|
+
initialize_identifier(options)
|
18
|
+
|
19
|
+
@type = options[:type]
|
20
|
+
@expression = options[:expression]
|
21
|
+
|
22
|
+
super
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [Array<Declaration>]
|
26
|
+
def children
|
27
|
+
[
|
28
|
+
*remark_items
|
29
|
+
]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Expressir
|
2
|
+
module Model
|
3
|
+
module Declarations
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 9.2.2.2 Domain rules (WHERE clause)
|
6
|
+
class WhereRule < Declaration
|
7
|
+
include Identifier
|
8
|
+
|
9
|
+
model_attr_accessor :expression, 'Expression'
|
10
|
+
|
11
|
+
# @param [Hash] options
|
12
|
+
# @option (see Identifier#initialize_identifier)
|
13
|
+
# @option options [Expression] :expression
|
14
|
+
def initialize(options = {})
|
15
|
+
initialize_identifier(options)
|
16
|
+
|
17
|
+
@expression = options[:expression]
|
18
|
+
|
19
|
+
super
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Array<Declaration>]
|
23
|
+
def children
|
24
|
+
[
|
25
|
+
*remark_items
|
26
|
+
]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,11 +1,15 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Expressions
|
4
|
-
|
5
|
-
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 12.9 Aggregate initializer
|
6
|
+
class AggregateInitializer < Expression
|
7
|
+
model_attr_accessor :items, 'Array<AggregateInitializerItem>'
|
6
8
|
|
9
|
+
# @param [Hash] options
|
10
|
+
# @option options [Array<AggregateInitializerItem>] :items
|
7
11
|
def initialize(options = {})
|
8
|
-
@items = options
|
12
|
+
@items = options[:items] || []
|
9
13
|
|
10
14
|
super
|
11
15
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Expressir
|
2
|
+
module Model
|
3
|
+
module Expressions
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 12.9 Aggregate initializer
|
6
|
+
class AggregateInitializerItem < Expression
|
7
|
+
model_attr_accessor :expression, 'Expression'
|
8
|
+
model_attr_accessor :repetition, 'Expression'
|
9
|
+
|
10
|
+
# @param [Hash] options
|
11
|
+
# @option options [Expression] :expression
|
12
|
+
# @option options [Expression] :repetition
|
13
|
+
def initialize(options = {})
|
14
|
+
@expression = options[:expression]
|
15
|
+
@repetition = options[:repetition]
|
16
|
+
|
17
|
+
super
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,10 +1,17 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Expressions
|
4
|
-
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 12.1 Arithmetic operators
|
6
|
+
# - section 12.2 Relational operators
|
7
|
+
# - section 12.3 Binary operators
|
8
|
+
# - section 12.4 Logical operators
|
9
|
+
# - section 12.5 String operators
|
10
|
+
# - section 12.6 Aggregate operators
|
11
|
+
# - section 12.10 Complex entity instance construction operator
|
12
|
+
class BinaryExpression < Expression
|
5
13
|
ADDITION = :ADDITION
|
6
14
|
AND = :AND
|
7
|
-
ANDOR = :ANDOR
|
8
15
|
COMBINE = :COMBINE
|
9
16
|
EQUAL = :EQUAL
|
10
17
|
EXPONENTIATION = :EXPONENTIATION
|
@@ -25,10 +32,14 @@ module Expressir
|
|
25
32
|
SUBTRACTION = :SUBTRACTION
|
26
33
|
XOR = :XOR
|
27
34
|
|
28
|
-
model_attr_accessor :operator
|
29
|
-
model_attr_accessor :operand1
|
30
|
-
model_attr_accessor :operand2
|
35
|
+
model_attr_accessor :operator, ':ADDITION, :AND, :COMBINE, :EQUAL, :EXPONENTIATION, :GREATER_THAN, :GREATER_THAN_OR_EQUAL, :IN, :INSTANCE_EQUAL, :INSTANCE_NOT_EQUAL, :INTEGER_DIVISION, :LESS_THAN, :LESS_THAN_OR_EQUAL, :LIKE, :MODULO, :MULTIPLICATION, :NOT_EQUAL, :OR, :REAL_DIVISION, :SUBTRACTION, :XOR'
|
36
|
+
model_attr_accessor :operand1, 'Expression'
|
37
|
+
model_attr_accessor :operand2, 'Expression'
|
31
38
|
|
39
|
+
# @param [Hash] options
|
40
|
+
# @option options [:ADDITION, :AND, :COMBINE, :EQUAL, :EXPONENTIATION, :GREATER_THAN, :GREATER_THAN_OR_EQUAL, :IN, :INSTANCE_EQUAL, :INSTANCE_NOT_EQUAL, :INTEGER_DIVISION, :LESS_THAN, :LESS_THAN_OR_EQUAL, :LIKE, :MODULO, :MULTIPLICATION, :NOT_EQUAL, :OR, :REAL_DIVISION, :SUBTRACTION, :XOR] :operator
|
41
|
+
# @option options [Expression] :operand1
|
42
|
+
# @option options [Expression] :operand2
|
32
43
|
def initialize(options = {})
|
33
44
|
@operator = options[:operator]
|
34
45
|
@operand1 = options[:operand1]
|
@@ -1,13 +1,18 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Expressions
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 9.2.6 Implicit declarations
|
6
|
+
class EntityConstructor < Expression
|
7
|
+
model_attr_accessor :entity, 'Reference'
|
8
|
+
model_attr_accessor :parameters, 'Array<Expression>'
|
7
9
|
|
10
|
+
# @param [Hash] options
|
11
|
+
# @option options [Reference] :entity
|
12
|
+
# @option options [Array<Expression>] :parameters
|
8
13
|
def initialize(options = {})
|
9
14
|
@entity = options[:entity]
|
10
|
-
@parameters = options
|
15
|
+
@parameters = options[:parameters] || []
|
11
16
|
|
12
17
|
super
|
13
18
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Expressir
|
2
|
+
module Model
|
3
|
+
module Expressions
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 12.8 Function call
|
6
|
+
class FunctionCall < Expression
|
7
|
+
model_attr_accessor :function, 'Reference'
|
8
|
+
model_attr_accessor :parameters, 'Array<Expression>'
|
9
|
+
|
10
|
+
# @param [Hash] options
|
11
|
+
# @option options [Reference] :function
|
12
|
+
# @option options [Array<Expression>] :parameters
|
13
|
+
def initialize(options = {})
|
14
|
+
@function = options[:function]
|
15
|
+
@parameters = options[:parameters] || []
|
16
|
+
|
17
|
+
super
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,13 +1,24 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Expressions
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
model_attr_accessor :high
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 12.2.4 Interval expressions
|
6
|
+
class Interval < Expression
|
7
|
+
LESS_THAN = :LESS_THAN
|
8
|
+
LESS_THAN_OR_EQUAL = :LESS_THAN_OR_EQUAL
|
10
9
|
|
10
|
+
model_attr_accessor :low, 'Expression'
|
11
|
+
model_attr_accessor :operator1, ':LESS_THAN, :LESS_THAN_OR_EQUAL'
|
12
|
+
model_attr_accessor :item, 'Reference'
|
13
|
+
model_attr_accessor :operator2, ':LESS_THAN, :LESS_THAN_OR_EQUAL'
|
14
|
+
model_attr_accessor :high, 'Expression'
|
15
|
+
|
16
|
+
# @param [Hash] options
|
17
|
+
# @option options [Expression] :low
|
18
|
+
# @option options [:LESS_THAN, :LESS_THAN_OR_EQUAL] :operator1
|
19
|
+
# @option options [Reference] :item
|
20
|
+
# @option options [:LESS_THAN, :LESS_THAN_OR_EQUAL] :operator2
|
21
|
+
# @option options [Expression] :high
|
11
22
|
def initialize(options = {})
|
12
23
|
@low = options[:low]
|
13
24
|
@operator1 = options[:operator1]
|
@@ -1,17 +1,20 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Expressions
|
4
|
-
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 12.6.7 Query expression
|
6
|
+
class QueryExpression < Expression
|
5
7
|
include Identifier
|
6
8
|
|
7
|
-
model_attr_accessor :aggregate_source
|
8
|
-
model_attr_accessor :expression
|
9
|
+
model_attr_accessor :aggregate_source, 'Reference'
|
10
|
+
model_attr_accessor :expression, 'Expression'
|
9
11
|
|
12
|
+
# @param [Hash] options
|
13
|
+
# @option (see Identifier#initialize_identifier)
|
14
|
+
# @option options [Reference] :aggregace_source
|
15
|
+
# @option options [Expression] :expression
|
10
16
|
def initialize(options = {})
|
11
|
-
|
12
|
-
@remarks = options.fetch(:remarks, [])
|
13
|
-
@remark_items = options.fetch(:remark_items, [])
|
14
|
-
@source = options[:source]
|
17
|
+
initialize_identifier(options)
|
15
18
|
|
16
19
|
@aggregate_source = options[:aggregate_source]
|
17
20
|
@expression = options[:expression]
|
@@ -19,6 +22,7 @@ module Expressir
|
|
19
22
|
super
|
20
23
|
end
|
21
24
|
|
25
|
+
# @return [Array<Declaration>]
|
22
26
|
def children
|
23
27
|
[
|
24
28
|
self,
|
@@ -1,14 +1,20 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Expressions
|
4
|
-
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 12.1 Arithmetic operators
|
6
|
+
# - section 12.4.1 NOT operator
|
7
|
+
class UnaryExpression < Expression
|
5
8
|
MINUS = :MINUS
|
6
9
|
NOT = :NOT
|
7
10
|
PLUS = :PLUS
|
8
11
|
|
9
|
-
model_attr_accessor :operator
|
10
|
-
model_attr_accessor :operand
|
12
|
+
model_attr_accessor :operator, ':MINUS, :NOT, :PLUS'
|
13
|
+
model_attr_accessor :operand, 'Expression'
|
11
14
|
|
15
|
+
# @param [Hash] options
|
16
|
+
# @option options [:MINUS, :NOT, :PLUS] :operator
|
17
|
+
# @option options [Expression] :operand
|
12
18
|
def initialize(options = {})
|
13
19
|
@operator = options[:operator]
|
14
20
|
@operand = options[:operand]
|
@@ -1,11 +1,33 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Identifier
|
4
|
+
# @!attribute id
|
5
|
+
# @return [::String]
|
6
|
+
# @!attribute remarks
|
7
|
+
# @return [::Array<::String>]
|
8
|
+
# @!attribute remark_items
|
9
|
+
# @return [::Array<RemarkItem>]
|
10
|
+
# @!attribute source
|
11
|
+
# @return [::String]
|
12
|
+
# @!visibility private
|
4
13
|
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
|
14
|
+
mod.model_attr_accessor :id, '::String'
|
15
|
+
mod.model_attr_accessor :remarks, '::Array<::String>'
|
16
|
+
mod.model_attr_accessor :remark_items, '::Array<RemarkItem>'
|
17
|
+
mod.model_attr_accessor :source, '::String'
|
18
|
+
end
|
19
|
+
|
20
|
+
# @param [Hash] options
|
21
|
+
# @option options [::String] :id
|
22
|
+
# @option options [::Array<::String>] :remarks
|
23
|
+
# @option options [::Array<RemarkItem>] :remark_items
|
24
|
+
# @option options [::String] :source
|
25
|
+
# @!visibility private
|
26
|
+
def initialize_identifier(options = {})
|
27
|
+
@id = options[:id]
|
28
|
+
@remarks = options[:remarks] || []
|
29
|
+
@remark_items = options[:remark_items] || []
|
30
|
+
@source = options[:source]
|
9
31
|
end
|
10
32
|
end
|
11
33
|
end
|
@@ -1,9 +1,13 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Literals
|
4
|
-
|
5
|
-
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 7.5.1 Binary literal
|
6
|
+
class Binary < Literal
|
7
|
+
model_attr_accessor :value, '::String'
|
6
8
|
|
9
|
+
# @param [Hash] options
|
10
|
+
# @option options [::String] :value
|
7
11
|
def initialize(options = {})
|
8
12
|
@value = options[:value]
|
9
13
|
|
@@ -1,9 +1,13 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Literals
|
4
|
-
|
5
|
-
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 7.5.2 Integer literal
|
6
|
+
class Integer < Literal
|
7
|
+
model_attr_accessor :value, '::String'
|
6
8
|
|
9
|
+
# @param [Hash] options
|
10
|
+
# @option options [::String] :value
|
7
11
|
def initialize(options = {})
|
8
12
|
@value = options[:value]
|
9
13
|
|
@@ -1,13 +1,17 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Literals
|
4
|
-
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 7.5.5 Logical literal
|
6
|
+
class Logical < Literal
|
5
7
|
TRUE = :TRUE
|
6
8
|
FALSE = :FALSE
|
7
9
|
UNKNOWN = :UNKNOWN
|
8
10
|
|
9
|
-
model_attr_accessor :value
|
11
|
+
model_attr_accessor :value, ':TRUE, :FALSE, :UNKNOWN'
|
10
12
|
|
13
|
+
# @param [Hash] options
|
14
|
+
# @option options [:TRUE, :FALSE, :UNKNOWN] :value
|
11
15
|
def initialize(options = {})
|
12
16
|
@value = options[:value]
|
13
17
|
|
@@ -1,9 +1,13 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Literals
|
4
|
-
|
5
|
-
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 7.5.3 Real literal
|
6
|
+
class Real < Literal
|
7
|
+
model_attr_accessor :value, '::String'
|
6
8
|
|
9
|
+
# @param [Hash] options
|
10
|
+
# @option options [::String] :value
|
7
11
|
def initialize(options = {})
|
8
12
|
@value = options[:value]
|
9
13
|
|
@@ -1,10 +1,15 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Literals
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 7.5.4 String literal
|
6
|
+
class String < Literal
|
7
|
+
model_attr_accessor :value, '::String'
|
8
|
+
model_attr_accessor :encoded, '::Boolean'
|
7
9
|
|
10
|
+
# @param [Hash] options
|
11
|
+
# @option options [::String] :value
|
12
|
+
# @option options [::Boolean] :encoded
|
8
13
|
def initialize(options = {})
|
9
14
|
@value = options[:value]
|
10
15
|
@encoded = options[:encoded]
|
@@ -2,24 +2,33 @@ require 'pathname'
|
|
2
2
|
|
3
3
|
module Expressir
|
4
4
|
module Model
|
5
|
+
# Base model element
|
5
6
|
class ModelElement
|
6
7
|
CLASS_KEY = '_class'
|
7
8
|
FILE_KEY = 'file'
|
8
9
|
SOURCE_KEY = 'source'
|
9
10
|
|
11
|
+
private_constant :CLASS_KEY
|
12
|
+
private_constant :FILE_KEY
|
13
|
+
private_constant :SOURCE_KEY
|
14
|
+
|
15
|
+
# @return [ModelElement]
|
10
16
|
attr_accessor :parent
|
11
17
|
|
18
|
+
# @param [Hash] options
|
12
19
|
def initialize(options = {})
|
13
20
|
attach_parent_to_children
|
14
21
|
end
|
15
22
|
|
23
|
+
# @return [String]
|
16
24
|
def path
|
17
|
-
|
25
|
+
# this creates an implicit scope
|
26
|
+
return if is_a? Statements::Alias or is_a? Statements::Repeat or is_a? Expressions::QueryExpression
|
18
27
|
|
19
28
|
current_node = self
|
20
29
|
path_parts = []
|
21
30
|
loop do
|
22
|
-
if current_node.class.method_defined? :id
|
31
|
+
if current_node.class.method_defined? :id and !(current_node.is_a? References::SimpleReference)
|
23
32
|
path_parts << current_node.id
|
24
33
|
end
|
25
34
|
|
@@ -27,25 +36,13 @@ module Expressir
|
|
27
36
|
break unless current_node
|
28
37
|
end
|
29
38
|
|
30
|
-
path_parts.
|
31
|
-
end
|
39
|
+
return if path_parts.empty?
|
32
40
|
|
33
|
-
|
34
|
-
self.class.model_attrs.each do |variable|
|
35
|
-
value = self.send(variable)
|
36
|
-
|
37
|
-
if value.is_a? Array
|
38
|
-
value.each do |value|
|
39
|
-
if value.is_a? ModelElement
|
40
|
-
value.parent = self
|
41
|
-
end
|
42
|
-
end
|
43
|
-
elsif value.is_a? ModelElement
|
44
|
-
value.parent = self
|
45
|
-
end
|
46
|
-
end
|
41
|
+
path_parts.reverse.join(".")
|
47
42
|
end
|
48
43
|
|
44
|
+
# @param [String] path
|
45
|
+
# @return [ModelElement]
|
49
46
|
def find(path)
|
50
47
|
return self if path.empty?
|
51
48
|
|
@@ -71,26 +68,34 @@ module Expressir
|
|
71
68
|
break unless current_scope
|
72
69
|
end
|
73
70
|
|
71
|
+
if target_node.is_a? Model::Declarations::InterfacedItem
|
72
|
+
target_node = target_node.base_item
|
73
|
+
end
|
74
|
+
|
74
75
|
target_node
|
75
76
|
end
|
76
77
|
|
78
|
+
# @return [Array<Declaration>]
|
77
79
|
def children
|
78
80
|
[]
|
79
81
|
end
|
80
82
|
|
83
|
+
# @return [Hash<String, Declaration>]
|
81
84
|
def children_by_id
|
82
85
|
@children_by_id ||= children.select{|x| x.id}.map{|x| [x.id.downcase, x]}.to_h
|
83
86
|
end
|
84
87
|
|
88
|
+
# @return [nil]
|
85
89
|
def reset_children_by_id
|
86
90
|
@children_by_id = nil
|
91
|
+
nil
|
87
92
|
end
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
93
|
+
|
94
|
+
# @param [String] root_path
|
95
|
+
# @param [Express::Formatter] formatter
|
96
|
+
# @param [Boolean] include_empty
|
97
|
+
# @return [Hash]
|
98
|
+
def to_hash(root_path: nil, formatter: nil, include_empty: nil)
|
94
99
|
hash = {}
|
95
100
|
hash[CLASS_KEY] = self.class.name
|
96
101
|
|
@@ -103,20 +108,20 @@ module Expressir
|
|
103
108
|
hash[variable.to_s] = if value.is_a? Array
|
104
109
|
value.map do |value|
|
105
110
|
if value.is_a? ModelElement
|
106
|
-
value.to_hash(
|
111
|
+
value.to_hash(root_path: root_path, formatter: formatter, include_empty: include_empty)
|
107
112
|
else
|
108
113
|
value
|
109
114
|
end
|
110
115
|
end
|
111
116
|
elsif value.is_a? ModelElement
|
112
|
-
value.to_hash(
|
117
|
+
value.to_hash(root_path: root_path, formatter: formatter, include_empty: include_empty)
|
113
118
|
else
|
114
119
|
value
|
115
120
|
end
|
116
121
|
end
|
117
122
|
end
|
118
123
|
|
119
|
-
if self.is_a? Schema and file
|
124
|
+
if self.is_a? Declarations::Schema and file
|
120
125
|
hash[FILE_KEY] = root_path ? Pathname.new(file).relative_path_from(root_path).to_s : file
|
121
126
|
end
|
122
127
|
|
@@ -126,10 +131,11 @@ module Expressir
|
|
126
131
|
|
127
132
|
hash
|
128
133
|
end
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
134
|
+
|
135
|
+
# @param [Hash] hash
|
136
|
+
# @param [String] root_path
|
137
|
+
# @return [ModelElement]
|
138
|
+
def self.from_hash(hash, root_path: nil)
|
133
139
|
node_class = Object.const_get(hash[CLASS_KEY])
|
134
140
|
node_options = {}
|
135
141
|
|
@@ -139,19 +145,19 @@ module Expressir
|
|
139
145
|
node_options[variable] = if value.is_a? Array
|
140
146
|
value.map do |value|
|
141
147
|
if value.is_a? Hash
|
142
|
-
self.from_hash(value,
|
148
|
+
self.from_hash(value, root_path: root_path)
|
143
149
|
else
|
144
150
|
value
|
145
151
|
end
|
146
152
|
end
|
147
153
|
elsif value.is_a? Hash
|
148
|
-
self.from_hash(value,
|
154
|
+
self.from_hash(value, root_path: root_path)
|
149
155
|
else
|
150
156
|
value
|
151
157
|
end
|
152
158
|
end
|
153
159
|
|
154
|
-
if node_class == Schema and hash[FILE_KEY]
|
160
|
+
if node_class == Declarations::Schema and hash[FILE_KEY]
|
155
161
|
node_options[FILE_KEY.to_sym] = root_path ? File.expand_path("#{root_path}/#{hash[FILE_KEY]}") : hash[FILE_KEY]
|
156
162
|
end
|
157
163
|
|
@@ -160,15 +166,42 @@ module Expressir
|
|
160
166
|
node
|
161
167
|
end
|
162
168
|
|
169
|
+
# @return [Array<Symbol>]
|
163
170
|
def self.model_attrs
|
164
171
|
@model_attrs ||= []
|
165
172
|
end
|
166
173
|
|
167
|
-
|
174
|
+
# Define a new model attribute
|
175
|
+
# @param attr_name [Symbol] attribute name
|
176
|
+
# @param attr_type [Symbol] attribute type
|
177
|
+
# @!macro [attach] model_attr_accessor
|
178
|
+
# @!attribute $1
|
179
|
+
# @return [$2]
|
180
|
+
def self.model_attr_accessor(attr_name, attr_type = nil)
|
168
181
|
@model_attrs ||= []
|
169
|
-
@model_attrs
|
182
|
+
@model_attrs << attr_name
|
183
|
+
|
184
|
+
attr_accessor attr_name
|
185
|
+
end
|
186
|
+
|
187
|
+
private
|
188
|
+
|
189
|
+
# @return [nil]
|
190
|
+
def attach_parent_to_children
|
191
|
+
self.class.model_attrs.each do |variable|
|
192
|
+
value = self.send(variable)
|
170
193
|
|
171
|
-
|
194
|
+
if value.is_a? Array
|
195
|
+
value.each do |value|
|
196
|
+
if value.is_a? ModelElement
|
197
|
+
value.parent = self
|
198
|
+
end
|
199
|
+
end
|
200
|
+
elsif value.is_a? ModelElement
|
201
|
+
value.parent = self
|
202
|
+
end
|
203
|
+
end
|
204
|
+
nil
|
172
205
|
end
|
173
206
|
end
|
174
207
|
end
|