expressir 0.2.9 → 0.2.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/format +20 -0
- data/expressir.gemspec +1 -0
- data/lib/expressir/express_exp/formatter.rb +146 -105
- data/lib/expressir/express_exp/hyperlink_formatter.rb +25 -0
- data/lib/expressir/express_exp/parser.rb +2 -0
- data/lib/expressir/express_exp/schema_head_formatter.rb +14 -0
- data/lib/expressir/express_exp/visitor.rb +132 -82
- data/lib/expressir/model.rb +2 -1
- data/lib/expressir/model/attribute.rb +5 -1
- data/lib/expressir/model/constant.rb +5 -1
- data/lib/expressir/model/entity.rb +13 -22
- data/lib/expressir/model/enumeration_item.rb +5 -1
- data/lib/expressir/model/expressions/aggregate_initializer.rb +4 -2
- data/lib/expressir/model/expressions/aggregate_item.rb +3 -1
- data/lib/expressir/model/expressions/attribute_reference.rb +3 -1
- data/lib/expressir/model/expressions/binary_expression.rb +3 -1
- data/lib/expressir/model/expressions/call.rb +4 -2
- data/lib/expressir/model/expressions/entity_constructor.rb +4 -2
- data/lib/expressir/model/expressions/group_reference.rb +3 -1
- data/lib/expressir/model/expressions/index_reference.rb +3 -1
- data/lib/expressir/model/expressions/interval.rb +3 -1
- data/lib/expressir/model/expressions/query_expression.rb +5 -2
- data/lib/expressir/model/expressions/simple_reference.rb +3 -1
- data/lib/expressir/model/expressions/unary_expression.rb +3 -1
- data/lib/expressir/model/function.rb +28 -39
- data/lib/expressir/model/identifier.rb +1 -3
- data/lib/expressir/model/informal_proposition.rb +5 -1
- data/lib/expressir/model/interface.rb +4 -2
- data/lib/expressir/model/literals/binary.rb +3 -1
- data/lib/expressir/model/literals/integer.rb +3 -1
- data/lib/expressir/model/literals/logical.rb +3 -1
- data/lib/expressir/model/literals/real.rb +3 -1
- data/lib/expressir/model/literals/string.rb +3 -1
- data/lib/expressir/model/model_element.rb +140 -0
- data/lib/expressir/model/parameter.rb +5 -1
- data/lib/expressir/model/procedure.rb +29 -40
- data/lib/expressir/model/renamed_ref.rb +3 -1
- data/lib/expressir/model/repository.rb +5 -5
- data/lib/expressir/model/rule.rb +32 -43
- data/lib/expressir/model/schema.rb +48 -48
- data/lib/expressir/model/statements/alias.rb +6 -3
- data/lib/expressir/model/statements/assignment.rb +3 -1
- data/lib/expressir/model/statements/call.rb +4 -2
- data/lib/expressir/model/statements/case.rb +4 -2
- data/lib/expressir/model/statements/case_action.rb +4 -2
- data/lib/expressir/model/statements/compound.rb +4 -2
- data/lib/expressir/model/statements/escape.rb +1 -1
- data/lib/expressir/model/statements/if.rb +5 -3
- data/lib/expressir/model/statements/null.rb +1 -1
- data/lib/expressir/model/statements/repeat.rb +6 -3
- data/lib/expressir/model/statements/return.rb +3 -1
- data/lib/expressir/model/statements/skip.rb +1 -1
- data/lib/expressir/model/subtype_constraint.rb +5 -2
- data/lib/expressir/model/type.rb +10 -11
- data/lib/expressir/model/types/aggregate.rb +5 -1
- data/lib/expressir/model/types/array.rb +3 -1
- data/lib/expressir/model/types/bag.rb +3 -1
- data/lib/expressir/model/types/binary.rb +3 -1
- data/lib/expressir/model/types/boolean.rb +1 -1
- data/lib/expressir/model/types/enumeration.rb +5 -3
- data/lib/expressir/model/types/generic.rb +5 -1
- data/lib/expressir/model/types/generic_entity.rb +5 -1
- data/lib/expressir/model/types/integer.rb +1 -1
- data/lib/expressir/model/types/list.rb +3 -1
- data/lib/expressir/model/types/logical.rb +1 -1
- data/lib/expressir/model/types/number.rb +1 -1
- data/lib/expressir/model/types/real.rb +3 -1
- data/lib/expressir/model/types/select.rb +5 -3
- data/lib/expressir/model/types/set.rb +3 -1
- data/lib/expressir/model/types/string.rb +3 -1
- data/lib/expressir/model/unique.rb +6 -2
- data/lib/expressir/model/variable.rb +5 -1
- data/lib/expressir/model/where.rb +5 -1
- 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/remark_formatted.exp +0 -5
- data/original/examples/syntax/simple.exp +3 -0
- data/original/examples/syntax/syntax.exp +197 -189
- data/original/examples/syntax/syntax_formatted.exp +362 -800
- 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} +2 -5
- 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} +5 -5
- data/spec/expressir/express_exp/{source_spec.rb → parser/source_spec.rb} +2 -5
- data/spec/expressir/express_exp/{parse_syntax_spec.rb → parser/syntax_spec.rb} +1619 -1582
- data/spec/expressir/express_exp/schema_head_formatter_spec.rb +36 -0
- data/spec/expressir/model/{find_spec.rb → model_element/find_spec.rb} +7 -2
- data/spec/expressir/model/model_element/hash_spec.rb +66 -0
- metadata +34 -12
- data/lib/expressir/model/scope.rb +0 -66
- data/spec/expressir/express_exp/ap233_spec.rb +0 -22
@@ -1,67 +1,67 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
|
-
class Schema
|
4
|
-
|
3
|
+
class Schema < ModelElement
|
4
|
+
attr_accessor :file
|
5
|
+
|
5
6
|
include Identifier
|
6
7
|
|
8
|
+
attr_accessor :head_source
|
9
|
+
|
7
10
|
attr_accessor :version
|
8
11
|
attr_accessor :interfaces
|
9
12
|
attr_accessor :constants
|
10
|
-
attr_accessor :
|
11
|
-
|
12
|
-
attr_accessor :
|
13
|
+
attr_accessor :types
|
14
|
+
attr_accessor :entities
|
15
|
+
attr_accessor :subtype_constraints
|
16
|
+
attr_accessor :functions
|
17
|
+
attr_accessor :procedures
|
18
|
+
attr_accessor :rules
|
13
19
|
|
14
20
|
def initialize(options = {})
|
15
|
-
@
|
16
|
-
@version = options[:version]
|
17
|
-
@interfaces = options[:interfaces]
|
18
|
-
@constants = options[:constants]
|
19
|
-
@declarations = options[:declarations]
|
20
|
-
end
|
21
|
-
|
22
|
-
def use_interfaces
|
23
|
-
@interfaces.select{|x| x.kind == Expressir::Model::Interface::USE}
|
24
|
-
end
|
25
|
-
|
26
|
-
def reference_interfaces
|
27
|
-
@interfaces.select{|x| x.kind == Expressir::Model::Interface::REFERENCE}
|
28
|
-
end
|
29
|
-
|
30
|
-
def types
|
31
|
-
@declarations.select{|x| x.instance_of? Expressir::Model::Type}
|
32
|
-
end
|
21
|
+
@file = options[:file]
|
33
22
|
|
34
|
-
|
35
|
-
@
|
36
|
-
|
37
|
-
|
38
|
-
def subtype_constraints
|
39
|
-
@declarations.select{|x| x.instance_of? Expressir::Model::SubtypeConstraint}
|
40
|
-
end
|
41
|
-
|
42
|
-
def functions
|
43
|
-
@declarations.select{|x| x.instance_of? Expressir::Model::Function}
|
44
|
-
end
|
23
|
+
@id = options[:id]
|
24
|
+
@remarks = options.fetch(:remarks, [])
|
25
|
+
@source = options[:source]
|
26
|
+
@head_source = options[:head_source]
|
45
27
|
|
46
|
-
|
47
|
-
@
|
48
|
-
|
28
|
+
@version = options[:version]
|
29
|
+
@interfaces = options.fetch(:interfaces, [])
|
30
|
+
@constants = options.fetch(:constants, [])
|
31
|
+
@types = options.fetch(:types, [])
|
32
|
+
@entities = options.fetch(:entities, [])
|
33
|
+
@subtype_constraints = options.fetch(:subtype_constraints, [])
|
34
|
+
@functions = options.fetch(:functions, [])
|
35
|
+
@procedures = options.fetch(:procedures, [])
|
36
|
+
@rules = options.fetch(:rules, [])
|
49
37
|
|
50
|
-
|
51
|
-
@declarations.select{|x| x.instance_of? Expressir::Model::Rule}
|
38
|
+
super
|
52
39
|
end
|
53
40
|
|
54
|
-
def children
|
41
|
+
def children(item_ids = nil)
|
55
42
|
items = []
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
x.
|
43
|
+
unless item_ids and item_ids.length > 0
|
44
|
+
items.push(*@interfaces.flat_map do |interface|
|
45
|
+
schema = parent.schemas.find{|y| interface.schema.id == y.id}
|
46
|
+
interface_item_ids = if interface.items
|
47
|
+
# TODO: support renamed references
|
48
|
+
interface.items.select{|x| x.is_a? Model::Expressions::SimpleReference}.map{|x| x.id}
|
62
49
|
end
|
63
|
-
|
64
|
-
|
50
|
+
schema_items = schema&.children(interface_item_ids) || []
|
51
|
+
schema_items
|
52
|
+
end)
|
53
|
+
end
|
54
|
+
items.push(*@constants)
|
55
|
+
items.push(*@types)
|
56
|
+
items.push(*@types.flat_map{|x| x.type.is_a?(Expressir::Model::Types::Enumeration) ? x.type.items : []})
|
57
|
+
items.push(*@entities)
|
58
|
+
items.push(*@subtype_constraints)
|
59
|
+
items.push(*@functions)
|
60
|
+
items.push(*@procedures)
|
61
|
+
items.push(*@rules)
|
62
|
+
if item_ids and item_ids.length > 0
|
63
|
+
items = items.select{|x| item_ids.include?(x.id)}
|
64
|
+
end
|
65
65
|
items
|
66
66
|
end
|
67
67
|
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Statements
|
4
|
-
class Alias
|
5
|
-
include Scope
|
4
|
+
class Alias < ModelElement
|
6
5
|
include Identifier
|
7
6
|
|
8
7
|
attr_accessor :expression
|
@@ -10,9 +9,13 @@ module Expressir
|
|
10
9
|
|
11
10
|
def initialize(options = {})
|
12
11
|
@id = options[:id]
|
12
|
+
@remarks = options.fetch(:remarks, [])
|
13
|
+
@source = options[:source]
|
13
14
|
|
14
15
|
@expression = options[:expression]
|
15
|
-
@statements = options
|
16
|
+
@statements = options.fetch(:statements, [])
|
17
|
+
|
18
|
+
super
|
16
19
|
end
|
17
20
|
|
18
21
|
def children
|
@@ -1,13 +1,15 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Statements
|
4
|
-
class Assignment
|
4
|
+
class Assignment < ModelElement
|
5
5
|
attr_accessor :ref
|
6
6
|
attr_accessor :expression
|
7
7
|
|
8
8
|
def initialize(options = {})
|
9
9
|
@ref = options[:ref]
|
10
10
|
@expression = options[:expression]
|
11
|
+
|
12
|
+
super
|
11
13
|
end
|
12
14
|
end
|
13
15
|
end
|
@@ -1,13 +1,15 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Statements
|
4
|
-
class Call
|
4
|
+
class Call < ModelElement
|
5
5
|
attr_accessor :ref
|
6
6
|
attr_accessor :parameters
|
7
7
|
|
8
8
|
def initialize(options = {})
|
9
9
|
@ref = options[:ref]
|
10
|
-
@parameters = options
|
10
|
+
@parameters = options.fetch(:parameters, [])
|
11
|
+
|
12
|
+
super
|
11
13
|
end
|
12
14
|
end
|
13
15
|
end
|
@@ -1,15 +1,17 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Statements
|
4
|
-
class Case
|
4
|
+
class Case < ModelElement
|
5
5
|
attr_accessor :expression
|
6
6
|
attr_accessor :actions
|
7
7
|
attr_accessor :otherwise_statement
|
8
8
|
|
9
9
|
def initialize(options = {})
|
10
10
|
@expression = options[:expression]
|
11
|
-
@actions = options
|
11
|
+
@actions = options.fetch(:actions, [])
|
12
12
|
@otherwise_statement = options[:otherwise_statement]
|
13
|
+
|
14
|
+
super
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
@@ -1,13 +1,15 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Statements
|
4
|
-
class CaseAction
|
4
|
+
class CaseAction < ModelElement
|
5
5
|
attr_accessor :labels
|
6
6
|
attr_accessor :statement
|
7
7
|
|
8
8
|
def initialize(options = {})
|
9
|
-
@labels = options
|
9
|
+
@labels = options.fetch(:labels, [])
|
10
10
|
@statement = options[:statement]
|
11
|
+
|
12
|
+
super
|
11
13
|
end
|
12
14
|
end
|
13
15
|
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Statements
|
4
|
-
class Compound
|
4
|
+
class Compound < ModelElement
|
5
5
|
attr_accessor :statements
|
6
6
|
|
7
7
|
def initialize(options = {})
|
8
|
-
@statements = options
|
8
|
+
@statements = options.fetch(:statements, [])
|
9
|
+
|
10
|
+
super
|
9
11
|
end
|
10
12
|
end
|
11
13
|
end
|
@@ -1,15 +1,17 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Statements
|
4
|
-
class If
|
4
|
+
class If < ModelElement
|
5
5
|
attr_accessor :expression
|
6
6
|
attr_accessor :statements
|
7
7
|
attr_accessor :else_statements
|
8
8
|
|
9
9
|
def initialize(options = {})
|
10
10
|
@expression = options[:expression]
|
11
|
-
@statements = options
|
12
|
-
@else_statements = options
|
11
|
+
@statements = options.fetch(:statements, [])
|
12
|
+
@else_statements = options.fetch(:else_statements, [])
|
13
|
+
|
14
|
+
super
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Statements
|
4
|
-
class Repeat
|
5
|
-
include Scope
|
4
|
+
class Repeat < ModelElement
|
6
5
|
include Identifier
|
7
6
|
|
8
7
|
attr_accessor :bound1
|
@@ -14,13 +13,17 @@ module Expressir
|
|
14
13
|
|
15
14
|
def initialize(options = {})
|
16
15
|
@id = options[:id]
|
16
|
+
@remarks = options.fetch(:remarks, [])
|
17
|
+
@source = options[:source]
|
17
18
|
|
18
19
|
@bound1 = options[:bound1]
|
19
20
|
@bound2 = options[:bound2]
|
20
21
|
@increment = options[:increment]
|
21
22
|
@while_expression = options[:while_expression]
|
22
23
|
@until_expression = options[:until_expression]
|
23
|
-
@statements = options
|
24
|
+
@statements = options.fetch(:statements, [])
|
25
|
+
|
26
|
+
super
|
24
27
|
end
|
25
28
|
|
26
29
|
def children
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
|
-
class SubtypeConstraint
|
4
|
-
include Scope
|
3
|
+
class SubtypeConstraint < ModelElement
|
5
4
|
include Identifier
|
6
5
|
|
7
6
|
attr_accessor :applies_to
|
@@ -11,11 +10,15 @@ module Expressir
|
|
11
10
|
|
12
11
|
def initialize(options = {})
|
13
12
|
@id = options[:id]
|
13
|
+
@remarks = options.fetch(:remarks, [])
|
14
|
+
@source = options[:source]
|
14
15
|
|
15
16
|
@applies_to = options[:applies_to]
|
16
17
|
@abstract = options[:abstract]
|
17
18
|
@total_over = options[:total_over]
|
18
19
|
@supertype_expression = options[:supertype_expression]
|
20
|
+
|
21
|
+
super
|
19
22
|
end
|
20
23
|
|
21
24
|
def children
|
data/lib/expressir/model/type.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
|
-
class Type
|
4
|
-
include Scope
|
3
|
+
class Type < ModelElement
|
5
4
|
include Identifier
|
6
5
|
|
7
6
|
attr_accessor :type
|
@@ -10,21 +9,21 @@ module Expressir
|
|
10
9
|
|
11
10
|
def initialize(options = {})
|
12
11
|
@id = options[:id]
|
12
|
+
@remarks = options.fetch(:remarks, [])
|
13
|
+
@source = options[:source]
|
13
14
|
|
14
15
|
@type = options[:type]
|
15
|
-
@where = options
|
16
|
-
@informal_propositions = options
|
16
|
+
@where = options.fetch(:where, [])
|
17
|
+
@informal_propositions = options.fetch(:informal_propositions, [])
|
18
|
+
|
19
|
+
super
|
17
20
|
end
|
18
21
|
|
19
22
|
def children
|
20
23
|
items = []
|
21
|
-
items.push(
|
22
|
-
|
23
|
-
|
24
|
-
end
|
25
|
-
])
|
26
|
-
items.push(*@where) if @where
|
27
|
-
items.push(*@informal_propositions) if @informal_propositions
|
24
|
+
items.push(*@type.is_a?(Expressir::Model::Types::Enumeration) ? @type.items : [])
|
25
|
+
items.push(*@where)
|
26
|
+
items.push(*@informal_propositions)
|
28
27
|
items
|
29
28
|
end
|
30
29
|
end
|
@@ -1,15 +1,19 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Types
|
4
|
-
class Aggregate
|
4
|
+
class Aggregate < ModelElement
|
5
5
|
include Identifier
|
6
6
|
|
7
7
|
attr_accessor :base_type
|
8
8
|
|
9
9
|
def initialize(options = {})
|
10
10
|
@id = options[:id]
|
11
|
+
@remarks = options.fetch(:remarks, [])
|
12
|
+
@source = options[:source]
|
11
13
|
|
12
14
|
@base_type = options[:base_type]
|
15
|
+
|
16
|
+
super
|
13
17
|
end
|
14
18
|
end
|
15
19
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Types
|
4
|
-
class Array
|
4
|
+
class Array < ModelElement
|
5
5
|
attr_accessor :bound1
|
6
6
|
attr_accessor :bound2
|
7
7
|
attr_accessor :optional
|
@@ -14,6 +14,8 @@ module Expressir
|
|
14
14
|
@optional = options[:optional]
|
15
15
|
@unique = options[:unique]
|
16
16
|
@base_type = options[:base_type]
|
17
|
+
|
18
|
+
super
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Types
|
4
|
-
class Bag
|
4
|
+
class Bag < ModelElement
|
5
5
|
attr_accessor :bound1
|
6
6
|
attr_accessor :bound2
|
7
7
|
attr_accessor :base_type
|
@@ -10,6 +10,8 @@ module Expressir
|
|
10
10
|
@bound1 = options[:bound1]
|
11
11
|
@bound2 = options[:bound2]
|
12
12
|
@base_type = options[:base_type]
|
13
|
+
|
14
|
+
super
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|