expressir 0.2.11 → 0.2.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/format +16 -0
- data/expressir.gemspec +1 -0
- data/lib/expressir/express_exp/formatter.rb +75 -89
- data/lib/expressir/express_exp/hyperlink_formatter.rb +25 -0
- data/lib/expressir/express_exp/schema_head_formatter.rb +14 -0
- data/lib/expressir/express_exp/visitor.rb +58 -58
- data/lib/expressir/model.rb +0 -1
- 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/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/renamed_ref.rb +2 -0
- data/lib/expressir/model/repository.rb +2 -2
- data/lib/expressir/model/rule.rb +4 -9
- data/lib/expressir/model/schema.rb +5 -8
- 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 +8 -0
- data/original/examples/syntax/hyperlink_formatted.exp +19 -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 +24 -0
- data/spec/expressir/express_exp/{head_source_spec.rb → parser/head_source_spec.rb} +1 -1
- data/spec/expressir/express_exp/{parse_multiple_spec.rb → parser/multiple_spec.rb} +1 -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} +76 -44
- data/spec/expressir/express_exp/schema_head_formatter_spec.rb +36 -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 +32 -13
- data/lib/expressir/model/scope.rb +0 -71
- data/spec/expressir/express_exp/ap233_spec.rb +0 -22
data/lib/expressir/model/rule.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
class Rule < ModelElement
|
4
|
-
include Scope
|
5
4
|
include Identifier
|
6
5
|
|
7
6
|
attr_accessor :applies_to
|
@@ -21,7 +20,7 @@ module Expressir
|
|
21
20
|
@remarks = options.fetch(:remarks, [])
|
22
21
|
@source = options[:source]
|
23
22
|
|
24
|
-
@applies_to = options
|
23
|
+
@applies_to = options.fetch(:applies_to, [])
|
25
24
|
@types = options.fetch(:types, [])
|
26
25
|
@entities = options.fetch(:entities, [])
|
27
26
|
@subtype_constraints = options.fetch(:subtype_constraints, [])
|
@@ -32,18 +31,14 @@ module Expressir
|
|
32
31
|
@statements = options.fetch(:statements, [])
|
33
32
|
@where = options.fetch(:where, [])
|
34
33
|
@informal_propositions = options.fetch(:informal_propositions, [])
|
34
|
+
|
35
|
+
super
|
35
36
|
end
|
36
37
|
|
37
38
|
def children
|
38
39
|
items = []
|
39
40
|
items.push(*@types)
|
40
|
-
items.push(*@types.flat_map
|
41
|
-
if x.type.instance_of? Expressir::Model::Types::Enumeration
|
42
|
-
x.type.items
|
43
|
-
else
|
44
|
-
[]
|
45
|
-
end
|
46
|
-
end)
|
41
|
+
items.push(*@types.flat_map{|x| x.type.is_a?(Expressir::Model::Types::Enumeration) ? x.type.items : []})
|
47
42
|
items.push(*@entities)
|
48
43
|
items.push(*@subtype_constraints)
|
49
44
|
items.push(*@functions)
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
class Schema < ModelElement
|
4
|
-
include Scope
|
5
4
|
include Identifier
|
6
5
|
|
7
6
|
attr_accessor :head_source
|
@@ -31,19 +30,17 @@ module Expressir
|
|
31
30
|
@functions = options.fetch(:functions, [])
|
32
31
|
@procedures = options.fetch(:procedures, [])
|
33
32
|
@rules = options.fetch(:rules, [])
|
33
|
+
|
34
|
+
super
|
34
35
|
end
|
35
36
|
|
36
37
|
def children
|
37
38
|
items = []
|
39
|
+
# TODO: select interface items
|
40
|
+
items.push(*@interfaces.flat_map{|x| parent.schemas.find{|y| x.schema.id == y.id}&.children || []})
|
38
41
|
items.push(*@constants)
|
39
42
|
items.push(*@types)
|
40
|
-
items.push(*@types.flat_map
|
41
|
-
if x.type.instance_of? Expressir::Model::Types::Enumeration
|
42
|
-
x.type.items
|
43
|
-
else
|
44
|
-
[]
|
45
|
-
end
|
46
|
-
end)
|
43
|
+
items.push(*@types.flat_map{|x| x.type.is_a?(Expressir::Model::Types::Enumeration) ? x.type.items : []})
|
47
44
|
items.push(*@entities)
|
48
45
|
items.push(*@subtype_constraints)
|
49
46
|
items.push(*@functions)
|
@@ -2,7 +2,6 @@ module Expressir
|
|
2
2
|
module Model
|
3
3
|
module Statements
|
4
4
|
class Alias < ModelElement
|
5
|
-
include Scope
|
6
5
|
include Identifier
|
7
6
|
|
8
7
|
attr_accessor :expression
|
@@ -15,6 +14,8 @@ module Expressir
|
|
15
14
|
|
16
15
|
@expression = options[:expression]
|
17
16
|
@statements = options.fetch(:statements, [])
|
17
|
+
|
18
|
+
super
|
18
19
|
end
|
19
20
|
|
20
21
|
def children
|
@@ -2,7 +2,6 @@ module Expressir
|
|
2
2
|
module Model
|
3
3
|
module Statements
|
4
4
|
class Repeat < ModelElement
|
5
|
-
include Scope
|
6
5
|
include Identifier
|
7
6
|
|
8
7
|
attr_accessor :bound1
|
@@ -23,6 +22,8 @@ module Expressir
|
|
23
22
|
@while_expression = options[:while_expression]
|
24
23
|
@until_expression = options[:until_expression]
|
25
24
|
@statements = options.fetch(:statements, [])
|
25
|
+
|
26
|
+
super
|
26
27
|
end
|
27
28
|
|
28
29
|
def children
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
class SubtypeConstraint < ModelElement
|
4
|
-
include Scope
|
5
4
|
include Identifier
|
6
5
|
|
7
6
|
attr_accessor :applies_to
|
@@ -18,6 +17,8 @@ module Expressir
|
|
18
17
|
@abstract = options[:abstract]
|
19
18
|
@total_over = options[:total_over]
|
20
19
|
@supertype_expression = options[:supertype_expression]
|
20
|
+
|
21
|
+
super
|
21
22
|
end
|
22
23
|
|
23
24
|
def children
|
data/lib/expressir/model/type.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
class Type < ModelElement
|
4
|
-
include Scope
|
5
4
|
include Identifier
|
6
5
|
|
7
6
|
attr_accessor :type
|
@@ -16,15 +15,13 @@ module Expressir
|
|
16
15
|
@type = options[:type]
|
17
16
|
@where = options.fetch(:where, [])
|
18
17
|
@informal_propositions = options.fetch(:informal_propositions, [])
|
18
|
+
|
19
|
+
super
|
19
20
|
end
|
20
21
|
|
21
22
|
def children
|
22
23
|
items = []
|
23
|
-
items.push(
|
24
|
-
*if @type.instance_of? Expressir::Model::Types::Enumeration
|
25
|
-
@type.items
|
26
|
-
end
|
27
|
-
])
|
24
|
+
items.push(*@type.is_a?(Expressir::Model::Types::Enumeration) ? @type.items : [])
|
28
25
|
items.push(*@where)
|
29
26
|
items.push(*@informal_propositions)
|
30
27
|
items
|
data/lib/expressir/version.rb
CHANGED
@@ -0,0 +1,8 @@
|
|
1
|
+
SCHEMA hyperlink_schema;
|
2
|
+
ENTITY test; END_ENTITY;
|
3
|
+
ENTITY empty_entity; END_ENTITY;
|
4
|
+
ENTITY attribute_entity; test : BOOLEAN; END_ENTITY;
|
5
|
+
ENTITY subtype_empty_entity SUBTYPE OF (empty_entity); END_ENTITY;
|
6
|
+
ENTITY subtype_attribute_entity SUBTYPE OF (attribute_entity); SELF\attribute_entity.test : BOOLEAN; END_ENTITY;
|
7
|
+
ENTITY subtype_missing_entity SUBTYPE OF (missing_entity); END_ENTITY;
|
8
|
+
END_SCHEMA;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
SCHEMA hyperlink_schema;
|
2
|
+
ENTITY test;
|
3
|
+
END_ENTITY;
|
4
|
+
ENTITY empty_entity;
|
5
|
+
END_ENTITY;
|
6
|
+
ENTITY attribute_entity;
|
7
|
+
test : BOOLEAN;
|
8
|
+
END_ENTITY;
|
9
|
+
ENTITY subtype_empty_entity
|
10
|
+
SUBTYPE OF ({{{<<express:hyperlink_schema.empty_entity,empty_entity>>}}});
|
11
|
+
END_ENTITY;
|
12
|
+
ENTITY subtype_attribute_entity
|
13
|
+
SUBTYPE OF ({{{<<express:hyperlink_schema.attribute_entity,attribute_entity>>}}});
|
14
|
+
SELF\{{{<<express:hyperlink_schema.attribute_entity,attribute_entity>>}}}.test : BOOLEAN;
|
15
|
+
END_ENTITY;
|
16
|
+
ENTITY subtype_missing_entity
|
17
|
+
SUBTYPE OF (missing_entity);
|
18
|
+
END_ENTITY;
|
19
|
+
END_SCHEMA;
|
@@ -31,23 +31,23 @@ ENTITY attribute_entity; test : BOOLEAN; END_ENTITY;
|
|
31
31
|
ENTITY attribute_optional_entity; test : OPTIONAL BOOLEAN; END_ENTITY;
|
32
32
|
ENTITY attribute_multiple_entity; test : BOOLEAN; test2 : BOOLEAN; END_ENTITY;
|
33
33
|
ENTITY attribute_multiple_shorthand_entity; test, test2 : BOOLEAN; END_ENTITY;
|
34
|
-
ENTITY attribute_redeclared_entity; SELF\attribute_entity.test : BOOLEAN; END_ENTITY;
|
35
|
-
ENTITY attribute_redeclared_renamed_entity; SELF\attribute_entity.test RENAMED test2 : BOOLEAN; END_ENTITY;
|
34
|
+
ENTITY attribute_redeclared_entity SUBTYPE OF (attribute_entity); SELF\attribute_entity.test : BOOLEAN; END_ENTITY;
|
35
|
+
ENTITY attribute_redeclared_renamed_entity SUBTYPE OF (attribute_entity); SELF\attribute_entity.test RENAMED test2 : BOOLEAN; END_ENTITY;
|
36
36
|
ENTITY derived_attribute_entity; DERIVE test : BOOLEAN := TRUE; END_ENTITY;
|
37
|
-
ENTITY derived_attribute_redeclared_entity; DERIVE SELF\attribute_entity.test : BOOLEAN := TRUE; END_ENTITY;
|
38
|
-
ENTITY derived_attribute_redeclared_renamed_entity; DERIVE SELF\attribute_entity.test RENAMED test2 : BOOLEAN := TRUE; END_ENTITY;
|
37
|
+
ENTITY derived_attribute_redeclared_entity SUBTYPE OF (attribute_entity); DERIVE SELF\attribute_entity.test : BOOLEAN := TRUE; END_ENTITY;
|
38
|
+
ENTITY derived_attribute_redeclared_renamed_entity SUBTYPE OF (attribute_entity); DERIVE SELF\attribute_entity.test RENAMED test2 : BOOLEAN := TRUE; END_ENTITY;
|
39
39
|
ENTITY inverse_attribute_entity; INVERSE test : attribute_entity FOR test; END_ENTITY;
|
40
40
|
ENTITY inverse_attribute_entity_entity; INVERSE test : attribute_entity FOR attribute_entity.test; END_ENTITY;
|
41
41
|
ENTITY inverse_attribute_set_entity; INVERSE test : SET OF attribute_entity FOR test; END_ENTITY;
|
42
42
|
ENTITY inverse_attribute_set_bound_entity; INVERSE test : SET [1:9] OF attribute_entity FOR test; END_ENTITY;
|
43
43
|
ENTITY inverse_attribute_bag_entity; INVERSE test : BAG OF attribute_entity FOR test; END_ENTITY;
|
44
44
|
ENTITY inverse_attribute_bag_bound_entity; INVERSE test : BAG [1:9] OF attribute_entity FOR test; END_ENTITY;
|
45
|
-
ENTITY inverse_attribute_redeclared_entity; INVERSE SELF\attribute_entity.test : attribute_entity FOR test; END_ENTITY;
|
46
|
-
ENTITY inverse_attribute_redeclared_renamed_entity; INVERSE SELF\attribute_entity.test RENAMED test2 : attribute_entity FOR test; END_ENTITY;
|
45
|
+
ENTITY inverse_attribute_redeclared_entity SUBTYPE OF (attribute_entity); INVERSE SELF\attribute_entity.test : attribute_entity FOR test; END_ENTITY;
|
46
|
+
ENTITY inverse_attribute_redeclared_renamed_entity SUBTYPE OF (attribute_entity); INVERSE SELF\attribute_entity.test RENAMED test2 : attribute_entity FOR test; END_ENTITY;
|
47
47
|
ENTITY unique_entity; test : BOOLEAN; UNIQUE test; END_ENTITY;
|
48
48
|
ENTITY unique_label_entity; test : BOOLEAN; UNIQUE UR1 : test; END_ENTITY;
|
49
|
-
ENTITY
|
50
|
-
ENTITY
|
49
|
+
ENTITY unique_redeclared_entity SUBTYPE OF (attribute_entity); UNIQUE SELF\attribute_entity.test; END_ENTITY;
|
50
|
+
ENTITY unique_label_redeclared_entity SUBTYPE OF (attribute_entity); UNIQUE UR1 : SELF\attribute_entity.test; END_ENTITY;
|
51
51
|
ENTITY where_entity; WHERE TRUE; END_ENTITY;
|
52
52
|
ENTITY where_label_entity; WHERE WR1 : TRUE; END_ENTITY;
|
53
53
|
|
@@ -122,15 +122,15 @@ RULE where_label_rule FOR (empty_entity); WHERE WR1 : TRUE; END_RULE;
|
|
122
122
|
PROCEDURE statements;
|
123
123
|
-- statements
|
124
124
|
PROCEDURE alias_simple_reference_statement; ALIAS test FOR test; ; END_ALIAS; END_PROCEDURE;
|
125
|
-
PROCEDURE
|
126
|
-
PROCEDURE alias_group_reference_statement; ALIAS test FOR test\test; ; END_ALIAS; END_PROCEDURE;
|
125
|
+
PROCEDURE alias_group_reference_statement; ALIAS test FOR test\test2; ; END_ALIAS; END_PROCEDURE;
|
127
126
|
PROCEDURE alias_index_reference_statement; ALIAS test FOR test[1]; ; END_ALIAS; END_PROCEDURE;
|
128
127
|
PROCEDURE alias_index2_reference_statement; ALIAS test FOR test[1:9]; ; END_ALIAS; END_PROCEDURE;
|
128
|
+
PROCEDURE alias_attribute_reference_statement; ALIAS test FOR test.test2; ; END_ALIAS; END_PROCEDURE;
|
129
129
|
PROCEDURE assignment_simple_reference_statement; test := TRUE; END_PROCEDURE;
|
130
|
-
PROCEDURE
|
131
|
-
PROCEDURE assignment_group_reference_statement; test\test := TRUE; END_PROCEDURE;
|
130
|
+
PROCEDURE assignment_group_reference_statement; test\test2 := TRUE; END_PROCEDURE;
|
132
131
|
PROCEDURE assignment_index_reference_statement; test[1] := TRUE; END_PROCEDURE;
|
133
132
|
PROCEDURE assignment_index2_reference_statement; test[1:9] := TRUE; END_PROCEDURE;
|
133
|
+
PROCEDURE assignment_attribute_reference_statement; test.test2 := TRUE; END_PROCEDURE;
|
134
134
|
PROCEDURE case_statement; CASE test OF TRUE : ; END_CASE; END_PROCEDURE;
|
135
135
|
PROCEDURE case_multiple_statement; CASE test OF TRUE : ; TRUE : ; END_CASE; END_PROCEDURE;
|
136
136
|
PROCEDURE case_multiple_shorthand_statement; CASE test OF TRUE, TRUE : ; END_CASE; END_PROCEDURE;
|
@@ -290,7 +290,7 @@ PROCEDURE expressions;
|
|
290
290
|
and_or_expression : BOOLEAN := TRUE AND FALSE OR TRUE;
|
291
291
|
parenthesis_or_and_expression : BOOLEAN := (TRUE OR FALSE) AND TRUE;
|
292
292
|
and_parenthesis_or_expression : BOOLEAN := TRUE AND (FALSE OR TRUE);
|
293
|
-
combine_expression : BOOLEAN := test ||
|
293
|
+
combine_expression : BOOLEAN := test || test2;
|
294
294
|
in_expression : BOOLEAN := TRUE IN [TRUE];
|
295
295
|
like_expression : BOOLEAN := 'xxx' LIKE 'xxx';
|
296
296
|
|
@@ -304,11 +304,11 @@ PROCEDURE expressions;
|
|
304
304
|
call_expression : BOOLEAN := parameter_function(TRUE);
|
305
305
|
|
306
306
|
-- reference expressions
|
307
|
-
simple_reference_expression : BOOLEAN :=
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
307
|
+
simple_reference_expression : BOOLEAN := test;
|
308
|
+
group_reference_expression : BOOLEAN := test\test2;
|
309
|
+
index_reference_expression : BOOLEAN := test[1];
|
310
|
+
index2_reference_expression : BOOLEAN := test[1:9];
|
311
|
+
attribute_reference_expression : BOOLEAN := test.test2;
|
312
312
|
|
313
313
|
-- interval expressions
|
314
314
|
lt_lt_interval_expression : BOOLEAN := {1 < 5 < 9};
|