expressir 0.2.11-x64-mingw32 → 0.2.12-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/exe/format +16 -0
  3. data/expressir.gemspec +1 -0
  4. data/lib/expressir/express_exp/2.4/express_parser.so +0 -0
  5. data/lib/expressir/express_exp/2.5/express_parser.so +0 -0
  6. data/lib/expressir/express_exp/2.6/express_parser.so +0 -0
  7. data/lib/expressir/express_exp/2.7/express_parser.so +0 -0
  8. data/lib/expressir/express_exp/3.0/express_parser.so +0 -0
  9. data/lib/expressir/express_exp/formatter.rb +75 -89
  10. data/lib/expressir/express_exp/hyperlink_formatter.rb +25 -0
  11. data/lib/expressir/express_exp/schema_head_formatter.rb +14 -0
  12. data/lib/expressir/express_exp/visitor.rb +58 -58
  13. data/lib/expressir/model.rb +0 -1
  14. data/lib/expressir/model/attribute.rb +2 -0
  15. data/lib/expressir/model/constant.rb +2 -0
  16. data/lib/expressir/model/entity.rb +3 -2
  17. data/lib/expressir/model/enumeration_item.rb +2 -0
  18. data/lib/expressir/model/expressions/aggregate_initializer.rb +2 -0
  19. data/lib/expressir/model/expressions/aggregate_item.rb +2 -0
  20. data/lib/expressir/model/expressions/attribute_reference.rb +2 -0
  21. data/lib/expressir/model/expressions/binary_expression.rb +2 -0
  22. data/lib/expressir/model/expressions/call.rb +2 -0
  23. data/lib/expressir/model/expressions/entity_constructor.rb +2 -0
  24. data/lib/expressir/model/expressions/group_reference.rb +2 -0
  25. data/lib/expressir/model/expressions/index_reference.rb +2 -0
  26. data/lib/expressir/model/expressions/interval.rb +2 -0
  27. data/lib/expressir/model/expressions/query_expression.rb +2 -1
  28. data/lib/expressir/model/expressions/simple_reference.rb +2 -0
  29. data/lib/expressir/model/expressions/unary_expression.rb +2 -0
  30. data/lib/expressir/model/function.rb +3 -8
  31. data/lib/expressir/model/identifier.rb +0 -1
  32. data/lib/expressir/model/informal_proposition.rb +2 -0
  33. data/lib/expressir/model/interface.rb +2 -0
  34. data/lib/expressir/model/literals/binary.rb +2 -0
  35. data/lib/expressir/model/literals/integer.rb +2 -0
  36. data/lib/expressir/model/literals/logical.rb +2 -0
  37. data/lib/expressir/model/literals/real.rb +2 -0
  38. data/lib/expressir/model/literals/string.rb +2 -0
  39. data/lib/expressir/model/model_element.rb +71 -4
  40. data/lib/expressir/model/parameter.rb +2 -0
  41. data/lib/expressir/model/procedure.rb +3 -8
  42. data/lib/expressir/model/renamed_ref.rb +2 -0
  43. data/lib/expressir/model/repository.rb +2 -2
  44. data/lib/expressir/model/rule.rb +4 -9
  45. data/lib/expressir/model/schema.rb +5 -8
  46. data/lib/expressir/model/statements/alias.rb +2 -1
  47. data/lib/expressir/model/statements/assignment.rb +2 -0
  48. data/lib/expressir/model/statements/call.rb +2 -0
  49. data/lib/expressir/model/statements/case.rb +2 -0
  50. data/lib/expressir/model/statements/case_action.rb +2 -0
  51. data/lib/expressir/model/statements/compound.rb +2 -0
  52. data/lib/expressir/model/statements/if.rb +2 -0
  53. data/lib/expressir/model/statements/repeat.rb +2 -1
  54. data/lib/expressir/model/statements/return.rb +2 -0
  55. data/lib/expressir/model/subtype_constraint.rb +2 -1
  56. data/lib/expressir/model/type.rb +3 -6
  57. data/lib/expressir/model/types/aggregate.rb +2 -0
  58. data/lib/expressir/model/types/array.rb +2 -0
  59. data/lib/expressir/model/types/bag.rb +2 -0
  60. data/lib/expressir/model/types/binary.rb +2 -0
  61. data/lib/expressir/model/types/enumeration.rb +2 -0
  62. data/lib/expressir/model/types/generic.rb +2 -0
  63. data/lib/expressir/model/types/generic_entity.rb +2 -0
  64. data/lib/expressir/model/types/list.rb +2 -0
  65. data/lib/expressir/model/types/real.rb +2 -0
  66. data/lib/expressir/model/types/select.rb +2 -0
  67. data/lib/expressir/model/types/set.rb +2 -0
  68. data/lib/expressir/model/types/string.rb +2 -0
  69. data/lib/expressir/model/unique.rb +2 -0
  70. data/lib/expressir/model/variable.rb +2 -0
  71. data/lib/expressir/model/where.rb +2 -0
  72. data/lib/expressir/version.rb +1 -1
  73. data/original/examples/syntax/hyperlink.exp +8 -0
  74. data/original/examples/syntax/hyperlink_formatted.exp +19 -0
  75. data/original/examples/syntax/syntax.exp +18 -18
  76. data/original/examples/syntax/syntax_formatted.exp +32 -24
  77. data/spec/expressir/express_exp/{format_remark_spec.rb → formatter/remark_spec.rb} +2 -2
  78. data/spec/expressir/express_exp/{format_syntax_spec.rb → formatter/syntax_spec.rb} +2 -2
  79. data/spec/expressir/express_exp/hyperlink_formatter_spec.rb +24 -0
  80. data/spec/expressir/express_exp/{head_source_spec.rb → parser/head_source_spec.rb} +1 -1
  81. data/spec/expressir/express_exp/{parse_multiple_spec.rb → parser/multiple_spec.rb} +1 -1
  82. data/spec/expressir/express_exp/{parse_remark_spec.rb → parser/remark_spec.rb} +2 -2
  83. data/spec/expressir/express_exp/{source_spec.rb → parser/source_spec.rb} +1 -1
  84. data/spec/expressir/express_exp/{parse_syntax_spec.rb → parser/syntax_spec.rb} +76 -44
  85. data/spec/expressir/express_exp/schema_head_formatter_spec.rb +36 -0
  86. data/spec/expressir/model/{scope_spec.rb → model_element/find_spec.rb} +7 -2
  87. data/spec/expressir/model/{model_element_spec.rb → model_element/hash_spec.rb} +7 -18
  88. metadata +32 -13
  89. data/lib/expressir/model/scope.rb +0 -71
  90. data/spec/expressir/express_exp/ap233_spec.rb +0 -22
@@ -1,6 +1,5 @@
1
1
  require 'expressir/model/model_element'
2
2
 
3
- require 'expressir/model/scope'
4
3
  require 'expressir/model/identifier'
5
4
 
6
5
  require 'expressir/model/attribute'
@@ -23,6 +23,8 @@ module Expressir
23
23
  @optional = options[:optional]
24
24
  @type = options[:type]
25
25
  @expression = options[:expression]
26
+
27
+ super
26
28
  end
27
29
  end
28
30
  end
@@ -13,6 +13,8 @@ module Expressir
13
13
 
14
14
  @type = options[:type]
15
15
  @expression = options[:expression]
16
+
17
+ super
16
18
  end
17
19
  end
18
20
  end
@@ -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[:subtype_of]
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
@@ -7,6 +7,8 @@ module Expressir
7
7
  @id = options[:id]
8
8
  @remarks = options.fetch(:remarks, [])
9
9
  @source = options[:source]
10
+
11
+ super
10
12
  end
11
13
  end
12
14
  end
@@ -6,6 +6,8 @@ module Expressir
6
6
 
7
7
  def initialize(options = {})
8
8
  @items = options.fetch(:items, [])
9
+
10
+ super
9
11
  end
10
12
  end
11
13
  end
@@ -8,6 +8,8 @@ module Expressir
8
8
  def initialize(options = {})
9
9
  @expression = options[:expression]
10
10
  @repetition = options[:repetition]
11
+
12
+ super
11
13
  end
12
14
  end
13
15
  end
@@ -8,6 +8,8 @@ module Expressir
8
8
  def initialize(options = {})
9
9
  @ref = options[:ref]
10
10
  @attribute = options[:attribute]
11
+
12
+ super
11
13
  end
12
14
  end
13
15
  end
@@ -33,6 +33,8 @@ module Expressir
33
33
  @operator = options[:operator]
34
34
  @operand1 = options[:operand1]
35
35
  @operand2 = options[:operand2]
36
+
37
+ super
36
38
  end
37
39
  end
38
40
  end
@@ -8,6 +8,8 @@ module Expressir
8
8
  def initialize(options = {})
9
9
  @ref = options[:ref]
10
10
  @parameters = options.fetch(:parameters, [])
11
+
12
+ super
11
13
  end
12
14
  end
13
15
  end
@@ -8,6 +8,8 @@ module Expressir
8
8
  def initialize(options = {})
9
9
  @entity = options[:entity]
10
10
  @parameters = options.fetch(:parameters, [])
11
+
12
+ super
11
13
  end
12
14
  end
13
15
  end
@@ -8,6 +8,8 @@ module Expressir
8
8
  def initialize(options = {})
9
9
  @ref = options[:ref]
10
10
  @entity = options[:entity]
11
+
12
+ super
11
13
  end
12
14
  end
13
15
  end
@@ -10,6 +10,8 @@ module Expressir
10
10
  @ref = options[:ref]
11
11
  @index1 = options[:index1]
12
12
  @index2 = options[:index2]
13
+
14
+ super
13
15
  end
14
16
  end
15
17
  end
@@ -14,6 +14,8 @@ module Expressir
14
14
  @item = options[:item]
15
15
  @operator2 = options[:operator2]
16
16
  @high = options[:high]
17
+
18
+ super
17
19
  end
18
20
  end
19
21
  end
@@ -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
@@ -6,6 +6,8 @@ module Expressir
6
6
 
7
7
  def initialize(options = {})
8
8
  @id = options[:id]
9
+
10
+ super
9
11
  end
10
12
  end
11
13
  end
@@ -12,6 +12,8 @@ module Expressir
12
12
  def initialize(options = {})
13
13
  @operator = options[:operator]
14
14
  @operand = options[:operand]
15
+
16
+ super
15
17
  end
16
18
  end
17
19
  end
@@ -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 do |x|
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)
@@ -2,7 +2,6 @@ module Expressir
2
2
  module Model
3
3
  module Identifier
4
4
  attr_accessor :id
5
- attr_accessor :parent
6
5
  attr_accessor :remarks
7
6
  attr_accessor :source
8
7
  end
@@ -7,6 +7,8 @@ module Expressir
7
7
  @id = options[:id]
8
8
  @remarks = options.fetch(:remarks, [])
9
9
  @source = options[:source]
10
+
11
+ super
10
12
  end
11
13
  end
12
14
  end
@@ -12,6 +12,8 @@ module Expressir
12
12
  @kind = options[:kind]
13
13
  @schema = options[:schema]
14
14
  @items = options.fetch(:items, [])
15
+
16
+ super
15
17
  end
16
18
  end
17
19
  end
@@ -6,6 +6,8 @@ module Expressir
6
6
 
7
7
  def initialize(options = {})
8
8
  @value = options[:value]
9
+
10
+ super
9
11
  end
10
12
  end
11
13
  end
@@ -6,6 +6,8 @@ module Expressir
6
6
 
7
7
  def initialize(options = {})
8
8
  @value = options[:value]
9
+
10
+ super
9
11
  end
10
12
  end
11
13
  end
@@ -10,6 +10,8 @@ module Expressir
10
10
 
11
11
  def initialize(options = {})
12
12
  @value = options[:value]
13
+
14
+ super
13
15
  end
14
16
  end
15
17
  end
@@ -6,6 +6,8 @@ module Expressir
6
6
 
7
7
  def initialize(options = {})
8
8
  @value = options[:value]
9
+
10
+ super
9
11
  end
10
12
  end
11
13
  end
@@ -8,6 +8,8 @@ module Expressir
8
8
  def initialize(options = {})
9
9
  @value = options[:value]
10
10
  @encoded = options[:encoded]
11
+
12
+ super
11
13
  end
12
14
  end
13
15
  end
@@ -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
@@ -13,6 +13,8 @@ module Expressir
13
13
 
14
14
  @var = options[:var]
15
15
  @type = options[:type]
16
+
17
+ super
16
18
  end
17
19
  end
18
20
  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 do |x|
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)
@@ -7,6 +7,8 @@ module Expressir
7
7
  def initialize(options = {})
8
8
  @ref = options[:ref]
9
9
  @id = options[:id]
10
+
11
+ super
10
12
  end
11
13
  end
12
14
  end
@@ -1,12 +1,12 @@
1
1
  module Expressir
2
2
  module Model
3
3
  class Repository < ModelElement
4
- include Scope
5
-
6
4
  attr_accessor :schemas
7
5
 
8
6
  def initialize(options = {})
9
7
  @schemas = options.fetch(:schemas, [])
8
+
9
+ super
10
10
  end
11
11
 
12
12
  def children