expressir 0.2.11-x86-mingw32 → 0.2.12-x86-mingw32
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/2.4/express_parser.so +0 -0
- data/lib/expressir/express_exp/2.5/express_parser.so +0 -0
- data/lib/expressir/express_exp/2.6/express_parser.so +0 -0
- data/lib/expressir/express_exp/2.7/express_parser.so +0 -0
- data/lib/expressir/express_exp/3.0/express_parser.so +0 -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.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
class Entity < ModelElement
|
4
|
-
include Scope
|
5
4
|
include Identifier
|
6
5
|
|
7
6
|
attr_accessor :abstract
|
@@ -19,11 +18,13 @@ module Expressir
|
|
19
18
|
|
20
19
|
@abstract = options[:abstract]
|
21
20
|
@supertype_expression = options[:supertype_expression]
|
22
|
-
@subtype_of = options
|
21
|
+
@subtype_of = options.fetch(:subtype_of, [])
|
23
22
|
@attributes = options.fetch(:attributes, [])
|
24
23
|
@unique = options.fetch(:unique, [])
|
25
24
|
@where = options.fetch(:where, [])
|
26
25
|
@informal_propositions = options.fetch(:informal_propositions, [])
|
26
|
+
|
27
|
+
super
|
27
28
|
end
|
28
29
|
|
29
30
|
def children
|
@@ -2,7 +2,6 @@ module Expressir
|
|
2
2
|
module Model
|
3
3
|
module Expressions
|
4
4
|
class QueryExpression < ModelElement
|
5
|
-
include Scope
|
6
5
|
include Identifier
|
7
6
|
|
8
7
|
attr_accessor :aggregate_source
|
@@ -15,6 +14,8 @@ module Expressir
|
|
15
14
|
|
16
15
|
@aggregate_source = options[:aggregate_source]
|
17
16
|
@expression = options[:expression]
|
17
|
+
|
18
|
+
super
|
18
19
|
end
|
19
20
|
|
20
21
|
def children
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
class Function < ModelElement
|
4
|
-
include Scope
|
5
4
|
include Identifier
|
6
5
|
|
7
6
|
attr_accessor :parameters
|
@@ -30,19 +29,15 @@ module Expressir
|
|
30
29
|
@constants = options.fetch(:constants, [])
|
31
30
|
@variables = options.fetch(:variables, [])
|
32
31
|
@statements = options.fetch(:statements, [])
|
32
|
+
|
33
|
+
super
|
33
34
|
end
|
34
35
|
|
35
36
|
def children
|
36
37
|
items = []
|
37
38
|
items.push(*@parameters)
|
38
39
|
items.push(*@types)
|
39
|
-
items.push(*@types.flat_map
|
40
|
-
if x.type.instance_of? Expressir::Model::Types::Enumeration
|
41
|
-
x.type.items
|
42
|
-
else
|
43
|
-
[]
|
44
|
-
end
|
45
|
-
end)
|
40
|
+
items.push(*@types.flat_map{|x| x.type.is_a?(Expressir::Model::Types::Enumeration) ? x.type.items : []})
|
46
41
|
items.push(*@entities)
|
47
42
|
items.push(*@subtype_constraints)
|
48
43
|
items.push(*@functions)
|
@@ -4,6 +4,77 @@ module Expressir
|
|
4
4
|
CLASS_KEY = '_class'
|
5
5
|
SOURCE_KEY = 'source'
|
6
6
|
|
7
|
+
attr_accessor :parent
|
8
|
+
|
9
|
+
def initialize(options = {})
|
10
|
+
attach_parent_to_children
|
11
|
+
end
|
12
|
+
|
13
|
+
def path
|
14
|
+
return id if is_a? Statements::Alias or is_a? Statements::Repeat or is_a? Expressions::QueryExpression
|
15
|
+
|
16
|
+
current_node = self
|
17
|
+
path_parts = []
|
18
|
+
loop do
|
19
|
+
if current_node.class.method_defined? :id
|
20
|
+
path_parts << current_node.id
|
21
|
+
end
|
22
|
+
|
23
|
+
current_node = current_node.parent
|
24
|
+
break unless current_node
|
25
|
+
end
|
26
|
+
|
27
|
+
path_parts.reverse.join(".")
|
28
|
+
end
|
29
|
+
|
30
|
+
def attach_parent_to_children
|
31
|
+
instance_variables.select{|x| x != :@parent}.each do |variable|
|
32
|
+
value = instance_variable_get(variable)
|
33
|
+
|
34
|
+
if value.is_a? Array
|
35
|
+
value.each do |value|
|
36
|
+
if value.is_a? ModelElement
|
37
|
+
value.parent = self
|
38
|
+
end
|
39
|
+
end
|
40
|
+
elsif value.is_a? ModelElement
|
41
|
+
value.parent = self
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def find(path)
|
47
|
+
return self if path.empty?
|
48
|
+
|
49
|
+
path_parts = path.downcase.split(/\./).map do |current_path|
|
50
|
+
_, _, current_path = current_path.rpartition(":") # ignore prefix
|
51
|
+
current_path
|
52
|
+
end
|
53
|
+
|
54
|
+
current_scope = self
|
55
|
+
target_node = nil
|
56
|
+
loop do
|
57
|
+
# find in current scope
|
58
|
+
current_node = current_scope
|
59
|
+
path_parts.each do |current_path|
|
60
|
+
current_node = current_node.children.find{|x| x.id and x.id.downcase == current_path}
|
61
|
+
break unless current_node
|
62
|
+
end
|
63
|
+
target_node = current_node
|
64
|
+
break if target_node
|
65
|
+
|
66
|
+
# retry search in parent scope
|
67
|
+
current_scope = current_scope.parent
|
68
|
+
break unless current_scope
|
69
|
+
end
|
70
|
+
|
71
|
+
target_node
|
72
|
+
end
|
73
|
+
|
74
|
+
def children
|
75
|
+
[]
|
76
|
+
end
|
77
|
+
|
7
78
|
def to_hash(options = {})
|
8
79
|
skip_empty = options[:skip_empty]
|
9
80
|
formatter = options[:formatter]
|
@@ -62,10 +133,6 @@ module Expressir
|
|
62
133
|
|
63
134
|
node = Object.const_get(node_class).new(node_options)
|
64
135
|
|
65
|
-
if node.class.method_defined? :attach_parent_to_children
|
66
|
-
node.attach_parent_to_children
|
67
|
-
end
|
68
|
-
|
69
136
|
node
|
70
137
|
end
|
71
138
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
class Procedure < ModelElement
|
4
|
-
include Scope
|
5
4
|
include Identifier
|
6
5
|
|
7
6
|
attr_accessor :parameters
|
@@ -28,19 +27,15 @@ module Expressir
|
|
28
27
|
@constants = options.fetch(:constants, [])
|
29
28
|
@variables = options.fetch(:variables, [])
|
30
29
|
@statements = options.fetch(:statements, [])
|
30
|
+
|
31
|
+
super
|
31
32
|
end
|
32
33
|
|
33
34
|
def children
|
34
35
|
items = []
|
35
36
|
items.push(*@parameters)
|
36
37
|
items.push(*@types)
|
37
|
-
items.push(*@types.flat_map
|
38
|
-
if x.type.instance_of? Expressir::Model::Types::Enumeration
|
39
|
-
x.type.items
|
40
|
-
else
|
41
|
-
[]
|
42
|
-
end
|
43
|
-
end)
|
38
|
+
items.push(*@types.flat_map{|x| x.type.is_a?(Expressir::Model::Types::Enumeration) ? x.type.items : []})
|
44
39
|
items.push(*@entities)
|
45
40
|
items.push(*@subtype_constraints)
|
46
41
|
items.push(*@functions)
|