expressir 0.2.9-x86-linux → 0.2.10-x86-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/expressir/express_exp/formatter.rb +71 -16
- data/lib/expressir/express_exp/visitor.rb +95 -41
- data/lib/expressir/model.rb +2 -0
- data/lib/expressir/model/attribute.rb +3 -1
- data/lib/expressir/model/constant.rb +3 -1
- data/lib/expressir/model/entity.rb +11 -21
- data/lib/expressir/model/enumeration_item.rb +3 -1
- data/lib/expressir/model/expressions/aggregate_initializer.rb +2 -2
- data/lib/expressir/model/expressions/aggregate_item.rb +1 -1
- data/lib/expressir/model/expressions/attribute_reference.rb +1 -1
- data/lib/expressir/model/expressions/binary_expression.rb +1 -1
- data/lib/expressir/model/expressions/call.rb +2 -2
- data/lib/expressir/model/expressions/entity_constructor.rb +2 -2
- data/lib/expressir/model/expressions/group_reference.rb +1 -1
- data/lib/expressir/model/expressions/index_reference.rb +1 -1
- data/lib/expressir/model/expressions/interval.rb +1 -1
- data/lib/expressir/model/expressions/query_expression.rb +3 -1
- data/lib/expressir/model/expressions/simple_reference.rb +1 -1
- data/lib/expressir/model/expressions/unary_expression.rb +1 -1
- data/lib/expressir/model/function.rb +32 -38
- data/lib/expressir/model/identifier.rb +1 -2
- data/lib/expressir/model/informal_proposition.rb +3 -1
- data/lib/expressir/model/interface.rb +2 -2
- 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 +1 -1
- data/lib/expressir/model/model_element.rb +67 -0
- data/lib/expressir/model/parameter.rb +3 -1
- data/lib/expressir/model/procedure.rb +33 -39
- data/lib/expressir/model/renamed_ref.rb +1 -1
- data/lib/expressir/model/repository.rb +3 -3
- data/lib/expressir/model/rule.rb +34 -40
- data/lib/expressir/model/schema.rb +35 -48
- data/lib/expressir/model/scope.rb +0 -3
- data/lib/expressir/model/statements/alias.rb +4 -2
- data/lib/expressir/model/statements/assignment.rb +1 -1
- data/lib/expressir/model/statements/call.rb +2 -2
- data/lib/expressir/model/statements/case.rb +2 -2
- data/lib/expressir/model/statements/case_action.rb +2 -2
- data/lib/expressir/model/statements/compound.rb +2 -2
- data/lib/expressir/model/statements/escape.rb +1 -1
- data/lib/expressir/model/statements/if.rb +3 -3
- data/lib/expressir/model/statements/null.rb +1 -1
- data/lib/expressir/model/statements/repeat.rb +4 -2
- data/lib/expressir/model/statements/return.rb +1 -1
- data/lib/expressir/model/statements/skip.rb +1 -1
- data/lib/expressir/model/subtype_constraint.rb +3 -1
- data/lib/expressir/model/type.rb +7 -5
- data/lib/expressir/model/types/aggregate.rb +3 -1
- data/lib/expressir/model/types/array.rb +1 -1
- data/lib/expressir/model/types/bag.rb +1 -1
- data/lib/expressir/model/types/binary.rb +1 -1
- data/lib/expressir/model/types/boolean.rb +1 -1
- data/lib/expressir/model/types/enumeration.rb +3 -3
- data/lib/expressir/model/types/generic.rb +3 -1
- data/lib/expressir/model/types/generic_entity.rb +3 -1
- data/lib/expressir/model/types/integer.rb +1 -1
- data/lib/expressir/model/types/list.rb +1 -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 +1 -1
- data/lib/expressir/model/types/select.rb +3 -3
- data/lib/expressir/model/types/set.rb +1 -1
- data/lib/expressir/model/types/string.rb +1 -1
- data/lib/expressir/model/unique.rb +4 -2
- data/lib/expressir/model/variable.rb +3 -1
- data/lib/expressir/model/where.rb +3 -1
- data/lib/expressir/version.rb +1 -1
- data/original/examples/syntax/remark_formatted.exp +0 -5
- data/original/examples/syntax/simple.exp +3 -0
- data/original/examples/syntax/syntax.exp +189 -181
- data/original/examples/syntax/syntax_formatted.exp +346 -792
- data/spec/expressir/express_exp/head_source_spec.rb +1 -4
- data/spec/expressir/express_exp/parse_remark_spec.rb +3 -3
- data/spec/expressir/express_exp/parse_syntax_spec.rb +1583 -1578
- data/spec/expressir/express_exp/source_spec.rb +1 -4
- data/spec/expressir/model/model_element_spec.rb +59 -0
- data/spec/expressir/model/{find_spec.rb → scope_spec.rb} +1 -1
- metadata +6 -3
@@ -0,0 +1,67 @@
|
|
1
|
+
module Expressir
|
2
|
+
module Model
|
3
|
+
class ModelElement
|
4
|
+
CLASS_KEY = '_class'
|
5
|
+
|
6
|
+
def to_hash(options = {})
|
7
|
+
skip_empty = options[:skip_empty]
|
8
|
+
|
9
|
+
instance_variables.select{|x| x != :@parent}.each_with_object({ CLASS_KEY => self.class.name }) do |variable, result|
|
10
|
+
key = variable.to_s.sub(/^@/, '')
|
11
|
+
value = instance_variable_get(variable)
|
12
|
+
|
13
|
+
# skip default values (nil, empty array)
|
14
|
+
if !skip_empty or !(value.nil? or (value.is_a? Array and value.count == 0))
|
15
|
+
result[key] = if value.is_a? Array
|
16
|
+
value.map do |value|
|
17
|
+
if value.is_a? ModelElement
|
18
|
+
value.to_hash(options)
|
19
|
+
else
|
20
|
+
value
|
21
|
+
end
|
22
|
+
end
|
23
|
+
elsif value.is_a? ModelElement
|
24
|
+
value.to_hash(options)
|
25
|
+
else
|
26
|
+
value
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.from_hash(hash)
|
33
|
+
node_class = hash[CLASS_KEY]
|
34
|
+
node_options = hash.select{|x| x != CLASS_KEY}.each_with_object({}) do |(variable, value), result|
|
35
|
+
key = variable.to_sym
|
36
|
+
|
37
|
+
result[key] = if value.is_a? Array
|
38
|
+
value.map do |value|
|
39
|
+
if value.is_a? Hash
|
40
|
+
self.from_hash(value)
|
41
|
+
else
|
42
|
+
value
|
43
|
+
end
|
44
|
+
end
|
45
|
+
elsif value.is_a? Hash
|
46
|
+
self.from_hash(value)
|
47
|
+
else
|
48
|
+
value
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
node = Object.const_get(node_class).new(node_options)
|
53
|
+
|
54
|
+
# attach parent
|
55
|
+
if node.class.method_defined? :children
|
56
|
+
node.children.each do |child_node|
|
57
|
+
if child_node.class.method_defined? :parent and !child_node.parent
|
58
|
+
child_node.parent = node
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
node
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
|
-
class Parameter
|
3
|
+
class Parameter < ModelElement
|
4
4
|
include Identifier
|
5
5
|
|
6
6
|
attr_accessor :var
|
@@ -8,6 +8,8 @@ module Expressir
|
|
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
|
@var = options[:var]
|
13
15
|
@type = options[:type]
|
@@ -1,58 +1,52 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
|
-
class Procedure
|
3
|
+
class Procedure < ModelElement
|
4
4
|
include Scope
|
5
5
|
include Identifier
|
6
6
|
|
7
7
|
attr_accessor :parameters
|
8
|
-
attr_accessor :
|
8
|
+
attr_accessor :types
|
9
|
+
attr_accessor :entities
|
10
|
+
attr_accessor :subtype_constraints
|
11
|
+
attr_accessor :functions
|
12
|
+
attr_accessor :procedures
|
9
13
|
attr_accessor :constants
|
10
14
|
attr_accessor :variables
|
11
15
|
attr_accessor :statements
|
12
16
|
|
13
17
|
def initialize(options = {})
|
14
18
|
@id = options[:id]
|
15
|
-
|
16
|
-
@
|
17
|
-
|
18
|
-
@
|
19
|
-
@
|
20
|
-
@
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
@
|
25
|
-
|
26
|
-
|
27
|
-
def entities
|
28
|
-
@declarations.select{|x| x.instance_of? Expressir::Model::Entity}
|
29
|
-
end
|
30
|
-
|
31
|
-
def subtype_constraints
|
32
|
-
@declarations.select{|x| x.instance_of? Expressir::Model::SubtypeConstraint}
|
33
|
-
end
|
34
|
-
|
35
|
-
def functions
|
36
|
-
@declarations.select{|x| x.instance_of? Expressir::Model::Function}
|
37
|
-
end
|
38
|
-
|
39
|
-
def procedures
|
40
|
-
@declarations.select{|x| x.instance_of? Expressir::Model::Procedure}
|
19
|
+
@remarks = options.fetch(:remarks, [])
|
20
|
+
@source = options[:source]
|
21
|
+
|
22
|
+
@parameters = options.fetch(:parameters, [])
|
23
|
+
@types = options.fetch(:types, [])
|
24
|
+
@entities = options.fetch(:entities, [])
|
25
|
+
@subtype_constraints = options.fetch(:subtype_constraints, [])
|
26
|
+
@functions = options.fetch(:functions, [])
|
27
|
+
@procedures = options.fetch(:procedures, [])
|
28
|
+
@constants = options.fetch(:constants, [])
|
29
|
+
@variables = options.fetch(:variables, [])
|
30
|
+
@statements = options.fetch(:statements, [])
|
41
31
|
end
|
42
32
|
|
43
33
|
def children
|
44
34
|
items = []
|
45
|
-
items.push(*@parameters)
|
46
|
-
items.push(*@
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
end)
|
54
|
-
items.push(*@
|
55
|
-
items.push(*@
|
35
|
+
items.push(*@parameters)
|
36
|
+
items.push(*@types)
|
37
|
+
items.push(*@types.flat_map do |x|
|
38
|
+
if x.type.instance_of? Expressir::Model::Types::Enumeration
|
39
|
+
x.type.items
|
40
|
+
else
|
41
|
+
[]
|
42
|
+
end
|
43
|
+
end)
|
44
|
+
items.push(*@entities)
|
45
|
+
items.push(*@subtype_constraints)
|
46
|
+
items.push(*@functions)
|
47
|
+
items.push(*@procedures)
|
48
|
+
items.push(*@constants)
|
49
|
+
items.push(*@variables)
|
56
50
|
items
|
57
51
|
end
|
58
52
|
end
|
@@ -1,17 +1,17 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
|
-
class Repository
|
3
|
+
class Repository < ModelElement
|
4
4
|
include Scope
|
5
5
|
|
6
6
|
attr_accessor :schemas
|
7
7
|
|
8
8
|
def initialize(options = {})
|
9
|
-
@schemas = options
|
9
|
+
@schemas = options.fetch(:schemas, [])
|
10
10
|
end
|
11
11
|
|
12
12
|
def children
|
13
13
|
items = []
|
14
|
-
items.push(*@schemas)
|
14
|
+
items.push(*@schemas)
|
15
15
|
items
|
16
16
|
end
|
17
17
|
end
|
data/lib/expressir/model/rule.rb
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
|
-
class Rule
|
3
|
+
class Rule < ModelElement
|
4
4
|
include Scope
|
5
5
|
include Identifier
|
6
6
|
|
7
7
|
attr_accessor :applies_to
|
8
|
-
attr_accessor :
|
8
|
+
attr_accessor :types
|
9
|
+
attr_accessor :entities
|
10
|
+
attr_accessor :subtype_constraints
|
11
|
+
attr_accessor :functions
|
12
|
+
attr_accessor :procedures
|
9
13
|
attr_accessor :constants
|
10
14
|
attr_accessor :variables
|
11
15
|
attr_accessor :statements
|
@@ -14,50 +18,40 @@ module Expressir
|
|
14
18
|
|
15
19
|
def initialize(options = {})
|
16
20
|
@id = options[:id]
|
21
|
+
@remarks = options.fetch(:remarks, [])
|
22
|
+
@source = options[:source]
|
17
23
|
|
18
24
|
@applies_to = options[:applies_to]
|
19
|
-
@
|
20
|
-
@
|
21
|
-
@
|
22
|
-
@
|
23
|
-
@
|
24
|
-
@
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
@
|
29
|
-
end
|
30
|
-
|
31
|
-
def entities
|
32
|
-
@declarations.select{|x| x.instance_of? Expressir::Model::Entity}
|
33
|
-
end
|
34
|
-
|
35
|
-
def subtype_constraints
|
36
|
-
@declarations.select{|x| x.instance_of? Expressir::Model::SubtypeConstraint}
|
37
|
-
end
|
38
|
-
|
39
|
-
def functions
|
40
|
-
@declarations.select{|x| x.instance_of? Expressir::Model::Function}
|
41
|
-
end
|
42
|
-
|
43
|
-
def procedures
|
44
|
-
@declarations.select{|x| x.instance_of? Expressir::Model::Procedure}
|
25
|
+
@types = options.fetch(:types, [])
|
26
|
+
@entities = options.fetch(:entities, [])
|
27
|
+
@subtype_constraints = options.fetch(:subtype_constraints, [])
|
28
|
+
@functions = options.fetch(:functions, [])
|
29
|
+
@procedures = options.fetch(:procedures, [])
|
30
|
+
@constants = options.fetch(:constants, [])
|
31
|
+
@variables = options.fetch(:variables, [])
|
32
|
+
@statements = options.fetch(:statements, [])
|
33
|
+
@where = options.fetch(:where, [])
|
34
|
+
@informal_propositions = options.fetch(:informal_propositions, [])
|
45
35
|
end
|
46
36
|
|
47
37
|
def children
|
48
38
|
items = []
|
49
|
-
items.push(*@
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end)
|
57
|
-
items.push(*@
|
58
|
-
items.push(*@
|
59
|
-
items.push(*@
|
60
|
-
items.push(*@
|
39
|
+
items.push(*@types)
|
40
|
+
items.push(*@types.flat_map do |x|
|
41
|
+
if x.type.instance_of? Expressir::Model::Types::Enumeration
|
42
|
+
x.type.items
|
43
|
+
else
|
44
|
+
[]
|
45
|
+
end
|
46
|
+
end)
|
47
|
+
items.push(*@entities)
|
48
|
+
items.push(*@subtype_constraints)
|
49
|
+
items.push(*@functions)
|
50
|
+
items.push(*@procedures)
|
51
|
+
items.push(*@constants)
|
52
|
+
items.push(*@variables)
|
53
|
+
items.push(*@where)
|
54
|
+
items.push(*@informal_propositions)
|
61
55
|
items
|
62
56
|
end
|
63
57
|
end
|
@@ -1,67 +1,54 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
|
-
class Schema
|
3
|
+
class Schema < ModelElement
|
4
4
|
include Scope
|
5
5
|
include Identifier
|
6
6
|
|
7
|
+
attr_accessor :head_source
|
8
|
+
|
7
9
|
attr_accessor :version
|
8
10
|
attr_accessor :interfaces
|
9
11
|
attr_accessor :constants
|
10
|
-
attr_accessor :
|
11
|
-
|
12
|
-
attr_accessor :
|
12
|
+
attr_accessor :types
|
13
|
+
attr_accessor :entities
|
14
|
+
attr_accessor :subtype_constraints
|
15
|
+
attr_accessor :functions
|
16
|
+
attr_accessor :procedures
|
17
|
+
attr_accessor :rules
|
13
18
|
|
14
19
|
def initialize(options = {})
|
15
20
|
@id = options[:id]
|
16
|
-
@
|
17
|
-
@
|
18
|
-
@
|
19
|
-
@declarations = options[:declarations]
|
20
|
-
end
|
21
|
+
@remarks = options.fetch(:remarks, [])
|
22
|
+
@source = options[:source]
|
23
|
+
@head_source = options[:head_source]
|
21
24
|
|
22
|
-
|
23
|
-
@interfaces
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
@
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
@declarations.select{|x| x.instance_of? Expressir::Model::Type}
|
32
|
-
end
|
33
|
-
|
34
|
-
def entities
|
35
|
-
@declarations.select{|x| x.instance_of? Expressir::Model::Entity}
|
36
|
-
end
|
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
|
45
|
-
|
46
|
-
def procedures
|
47
|
-
@declarations.select{|x| x.instance_of? Expressir::Model::Procedure}
|
48
|
-
end
|
49
|
-
|
50
|
-
def rules
|
51
|
-
@declarations.select{|x| x.instance_of? Expressir::Model::Rule}
|
25
|
+
@version = options[:version]
|
26
|
+
@interfaces = options.fetch(:interfaces, [])
|
27
|
+
@constants = options.fetch(:constants, [])
|
28
|
+
@types = options.fetch(:types, [])
|
29
|
+
@entities = options.fetch(:entities, [])
|
30
|
+
@subtype_constraints = options.fetch(:subtype_constraints, [])
|
31
|
+
@functions = options.fetch(:functions, [])
|
32
|
+
@procedures = options.fetch(:procedures, [])
|
33
|
+
@rules = options.fetch(:rules, [])
|
52
34
|
end
|
53
35
|
|
54
36
|
def children
|
55
37
|
items = []
|
56
|
-
items.push(*@constants)
|
57
|
-
items.push(*@
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
end)
|
38
|
+
items.push(*@constants)
|
39
|
+
items.push(*@types)
|
40
|
+
items.push(*@types.flat_map do |x|
|
41
|
+
if x.type.instance_of? Expressir::Model::Types::Enumeration
|
42
|
+
x.type.items
|
43
|
+
else
|
44
|
+
[]
|
45
|
+
end
|
46
|
+
end)
|
47
|
+
items.push(*@entities)
|
48
|
+
items.push(*@subtype_constraints)
|
49
|
+
items.push(*@functions)
|
50
|
+
items.push(*@procedures)
|
51
|
+
items.push(*@rules)
|
65
52
|
items
|
66
53
|
end
|
67
54
|
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Scope
|
4
|
-
attr_accessor :source
|
5
|
-
|
6
4
|
def find(path)
|
7
5
|
current_path, _, rest = path.partition(".")
|
8
6
|
|
@@ -47,7 +45,6 @@ module Expressir
|
|
47
45
|
})
|
48
46
|
informal_proposition.parent = child
|
49
47
|
|
50
|
-
child.informal_propositions ||= []
|
51
48
|
child.informal_propositions << informal_proposition
|
52
49
|
|
53
50
|
informal_proposition
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Statements
|
4
|
-
class Alias
|
4
|
+
class Alias < ModelElement
|
5
5
|
include Scope
|
6
6
|
include Identifier
|
7
7
|
|
@@ -10,9 +10,11 @@ module Expressir
|
|
10
10
|
|
11
11
|
def initialize(options = {})
|
12
12
|
@id = options[:id]
|
13
|
+
@remarks = options.fetch(:remarks, [])
|
14
|
+
@source = options[:source]
|
13
15
|
|
14
16
|
@expression = options[:expression]
|
15
|
-
@statements = options
|
17
|
+
@statements = options.fetch(:statements, [])
|
16
18
|
end
|
17
19
|
|
18
20
|
def children
|