expressir 1.0.0-arm64-darwin → 1.1.0-arm64-darwin

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +11 -0
  3. data/Rakefile +3 -0
  4. data/expressir.gemspec +3 -0
  5. data/lib/expressir/express/2.4/express_parser.bundle +0 -0
  6. data/lib/expressir/express/2.5/express_parser.bundle +0 -0
  7. data/lib/expressir/express/2.6/express_parser.bundle +0 -0
  8. data/lib/expressir/express/2.7/express_parser.bundle +0 -0
  9. data/lib/expressir/express/3.0/express_parser.bundle +0 -0
  10. data/lib/expressir/express/cache.rb +16 -10
  11. data/lib/expressir/express/formatter.rb +231 -180
  12. data/lib/expressir/express/hyperlink_formatter.rb +15 -1
  13. data/lib/expressir/express/model_visitor.rb +1 -0
  14. data/lib/expressir/express/parser.rb +16 -10
  15. data/lib/expressir/express/resolve_references_model_visitor.rb +7 -5
  16. data/lib/expressir/express/schema_head_formatter.rb +16 -2
  17. data/lib/expressir/express/visitor.rb +280 -254
  18. data/lib/expressir/model.rb +52 -45
  19. data/lib/expressir/model/cache.rb +6 -2
  20. data/lib/expressir/model/data_type.rb +9 -0
  21. data/lib/expressir/model/data_types/aggregate.rb +31 -0
  22. data/lib/expressir/model/data_types/array.rb +31 -0
  23. data/lib/expressir/model/data_types/bag.rb +25 -0
  24. data/lib/expressir/model/data_types/binary.rb +22 -0
  25. data/lib/expressir/model/data_types/boolean.rb +10 -0
  26. data/lib/expressir/model/data_types/enumeration.rb +25 -0
  27. data/lib/expressir/model/data_types/enumeration_item.rb +26 -0
  28. data/lib/expressir/model/data_types/generic.rb +26 -0
  29. data/lib/expressir/model/data_types/generic_entity.rb +26 -0
  30. data/lib/expressir/model/data_types/integer.rb +10 -0
  31. data/lib/expressir/model/data_types/list.rb +28 -0
  32. data/lib/expressir/model/data_types/logical.rb +10 -0
  33. data/lib/expressir/model/data_types/number.rb +10 -0
  34. data/lib/expressir/model/data_types/real.rb +19 -0
  35. data/lib/expressir/model/data_types/select.rb +28 -0
  36. data/lib/expressir/model/data_types/set.rb +25 -0
  37. data/lib/expressir/model/data_types/string.rb +22 -0
  38. data/lib/expressir/model/declaration.rb +9 -0
  39. data/lib/expressir/model/declarations/attribute.rb +47 -0
  40. data/lib/expressir/model/declarations/constant.rb +34 -0
  41. data/lib/expressir/model/declarations/entity.rb +53 -0
  42. data/lib/expressir/model/declarations/function.rb +67 -0
  43. data/lib/expressir/model/declarations/interface.rb +28 -0
  44. data/lib/expressir/model/declarations/interface_item.rb +23 -0
  45. data/lib/expressir/model/declarations/interfaced_item.rb +37 -0
  46. data/lib/expressir/model/declarations/parameter.rb +34 -0
  47. data/lib/expressir/model/declarations/procedure.rb +64 -0
  48. data/lib/expressir/model/declarations/remark_item.rb +21 -0
  49. data/lib/expressir/model/declarations/rule.rb +71 -0
  50. data/lib/expressir/model/declarations/schema.rb +117 -0
  51. data/lib/expressir/model/declarations/schema_version.rb +22 -0
  52. data/lib/expressir/model/declarations/schema_version_item.rb +22 -0
  53. data/lib/expressir/model/declarations/subtype_constraint.rb +40 -0
  54. data/lib/expressir/model/declarations/type.rb +45 -0
  55. data/lib/expressir/model/declarations/unique_rule.rb +31 -0
  56. data/lib/expressir/model/declarations/variable.rb +34 -0
  57. data/lib/expressir/model/declarations/where_rule.rb +31 -0
  58. data/lib/expressir/model/expression.rb +9 -0
  59. data/lib/expressir/model/expressions/aggregate_initializer.rb +6 -2
  60. data/lib/expressir/model/expressions/aggregate_initializer_item.rb +22 -0
  61. data/lib/expressir/model/expressions/binary_expression.rb +16 -5
  62. data/lib/expressir/model/expressions/entity_constructor.rb +8 -3
  63. data/lib/expressir/model/expressions/function_call.rb +22 -0
  64. data/lib/expressir/model/expressions/interval.rb +17 -6
  65. data/lib/expressir/model/expressions/query_expression.rb +11 -7
  66. data/lib/expressir/model/expressions/unary_expression.rb +9 -3
  67. data/lib/expressir/model/identifier.rb +26 -4
  68. data/lib/expressir/model/literal.rb +9 -0
  69. data/lib/expressir/model/literals/binary.rb +6 -2
  70. data/lib/expressir/model/literals/integer.rb +6 -2
  71. data/lib/expressir/model/literals/logical.rb +6 -2
  72. data/lib/expressir/model/literals/real.rb +6 -2
  73. data/lib/expressir/model/literals/string.rb +8 -3
  74. data/lib/expressir/model/model_element.rb +63 -37
  75. data/lib/expressir/model/reference.rb +9 -0
  76. data/lib/expressir/model/references/attribute_reference.rb +22 -0
  77. data/lib/expressir/model/references/group_reference.rb +22 -0
  78. data/lib/expressir/model/references/index_reference.rb +27 -0
  79. data/lib/expressir/model/references/simple_reference.rb +24 -0
  80. data/lib/expressir/model/repository.rb +7 -1
  81. data/lib/expressir/model/statement.rb +9 -0
  82. data/lib/expressir/model/statements/alias.rb +11 -7
  83. data/lib/expressir/model/statements/assignment.rb +8 -3
  84. data/lib/expressir/model/statements/case.rb +10 -4
  85. data/lib/expressir/model/statements/case_action.rb +7 -2
  86. data/lib/expressir/model/statements/compound.rb +6 -2
  87. data/lib/expressir/model/statements/escape.rb +3 -1
  88. data/lib/expressir/model/statements/if.rb +10 -4
  89. data/lib/expressir/model/statements/null.rb +3 -1
  90. data/lib/expressir/model/statements/procedure_call.rb +22 -0
  91. data/lib/expressir/model/statements/repeat.rb +19 -11
  92. data/lib/expressir/model/statements/return.rb +6 -2
  93. data/lib/expressir/model/statements/skip.rb +3 -1
  94. data/lib/expressir/model/supertype_expression.rb +9 -0
  95. data/lib/expressir/model/supertype_expressions/binary_supertype_expression.rb +29 -0
  96. data/lib/expressir/model/supertype_expressions/oneof_supertype_expression.rb +19 -0
  97. data/lib/expressir/version.rb +1 -1
  98. data/spec/expressir/model/model_element_spec.rb +131 -131
  99. data/spec/syntax/multiple.yaml +68 -68
  100. data/spec/syntax/remark.yaml +64 -64
  101. data/spec/syntax/single.yaml +5 -5
  102. data/spec/syntax/single_formatted.yaml +5 -5
  103. data/spec/syntax/syntax.yaml +1003 -1030
  104. metadata +97 -45
  105. data/lib/expressir/model/attribute.rb +0 -38
  106. data/lib/expressir/model/constant.rb +0 -28
  107. data/lib/expressir/model/entity.rb +0 -42
  108. data/lib/expressir/model/enumeration_item.rb +0 -22
  109. data/lib/expressir/model/expressions/aggregate_item.rb +0 -17
  110. data/lib/expressir/model/expressions/attribute_reference.rb +0 -17
  111. data/lib/expressir/model/expressions/call.rb +0 -17
  112. data/lib/expressir/model/expressions/group_reference.rb +0 -17
  113. data/lib/expressir/model/expressions/index_reference.rb +0 -19
  114. data/lib/expressir/model/expressions/simple_reference.rb +0 -19
  115. data/lib/expressir/model/function.rb +0 -57
  116. data/lib/expressir/model/interface.rb +0 -20
  117. data/lib/expressir/model/interface_item.rb +0 -15
  118. data/lib/expressir/model/interfaced_item.rb +0 -27
  119. data/lib/expressir/model/parameter.rb +0 -28
  120. data/lib/expressir/model/procedure.rb +0 -55
  121. data/lib/expressir/model/remark_item.rb +0 -15
  122. data/lib/expressir/model/rule.rb +0 -60
  123. data/lib/expressir/model/schema.rb +0 -100
  124. data/lib/expressir/model/schema_version.rb +0 -15
  125. data/lib/expressir/model/schema_version_item.rb +0 -15
  126. data/lib/expressir/model/statements/call.rb +0 -17
  127. data/lib/expressir/model/subtype_constraint.rb +0 -32
  128. data/lib/expressir/model/type.rb +0 -37
  129. data/lib/expressir/model/types/aggregate.rb +0 -28
  130. data/lib/expressir/model/types/array.rb +0 -23
  131. data/lib/expressir/model/types/bag.rb +0 -19
  132. data/lib/expressir/model/types/binary.rb +0 -17
  133. data/lib/expressir/model/types/boolean.rb +0 -8
  134. data/lib/expressir/model/types/enumeration.rb +0 -19
  135. data/lib/expressir/model/types/generic.rb +0 -24
  136. data/lib/expressir/model/types/generic_entity.rb +0 -24
  137. data/lib/expressir/model/types/integer.rb +0 -8
  138. data/lib/expressir/model/types/list.rb +0 -21
  139. data/lib/expressir/model/types/logical.rb +0 -8
  140. data/lib/expressir/model/types/number.rb +0 -8
  141. data/lib/expressir/model/types/real.rb +0 -15
  142. data/lib/expressir/model/types/select.rb +0 -21
  143. data/lib/expressir/model/types/set.rb +0 -19
  144. data/lib/expressir/model/types/string.rb +0 -17
  145. data/lib/expressir/model/unique_rule.rb +0 -26
  146. data/lib/expressir/model/variable.rb +0 -28
  147. data/lib/expressir/model/where_rule.rb +0 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 203c617ef03b1499b79c52488a5d0cbd7b96ba0f0125002ac60abde5f5df6109
4
- data.tar.gz: fd306202ef29053bbaf052acb2e2b97ccc8bb00d45c57886279d251f2e927900
3
+ metadata.gz: 4caa2c0ff518f736c26feaa5607a109899412b48cbaee1a52e70ebc479a73cb6
4
+ data.tar.gz: 23ea8b2be6b47f496f71abf90e85e8f29b1f7912d3c1ef8b5f2fa72a02a43bf6
5
5
  SHA512:
6
- metadata.gz: ea5b1fb36a8f26c2962c67be45b97c1fd1e421404c03d6a08dbb9c34a917b08d3f546e5865eade601088137d73f03ab0750941dd80464d96e27d5fa0bc49f677
7
- data.tar.gz: 28df92411daf364ee0c2d3c1103043604628174bcc2e4ad7fe215d18b3cc88e2fb8d172654a162fc1c6101e68a46a2353bb8c80207a669e731e0d47a82647633
6
+ metadata.gz: a8078dd333cf35c5a270b88240cb69031570e978348c666fb8698bc4088e28deff85af9a70645bca51253b1fc9f945ca71d232ee07f488c743b4cb02a4fa632e
7
+ data.tar.gz: 3ea61208b7a93387693fe9ddbfaaf6aea924abb08a56ecca4fd9d450cdb44a11b10055cef1b68dae14d169d4f1cbfe5f4fd5f94116230ff35798bab0f6d426f1
data/.yardopts ADDED
@@ -0,0 +1,11 @@
1
+ # macro must be defined first, see https://stackoverflow.com/a/10344776/1823988
2
+ lib/expressir/model/model_element.rb
3
+ lib/expressir/model/data_type.rb
4
+ lib/expressir/model/declaration.rb
5
+ lib/expressir/model/expression.rb
6
+ lib/expressir/model/literal.rb
7
+ lib/expressir/model/reference.rb
8
+ lib/expressir/model/statement.rb
9
+ lib/expressir/model/supertype_expression.rb
10
+
11
+ lib/**/*.rb
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
3
  require "rake/extensiontask"
4
+ require "yard"
4
5
 
5
6
  RSpec::Core::RakeTask.new(:spec)
6
7
 
@@ -9,3 +10,5 @@ task :default => :spec
9
10
  GEMSPEC = Gem::Specification.load("expressir.gemspec")
10
11
 
11
12
  Gem::PackageTask.new(GEMSPEC).define
13
+
14
+ YARD::Rake::YardocTask.new
data/expressir.gemspec CHANGED
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
32
32
 
33
33
  spec.add_runtime_dependency "thor", "~> 1.0"
34
34
  spec.add_runtime_dependency "rice", "~> 3"
35
+ spec.add_development_dependency "asciidoctor", "~> 2.0.13"
35
36
  spec.add_development_dependency "antlr4-native", "~> 1.1.0"
36
37
  spec.add_development_dependency "bundler", "~> 2.0"
37
38
  spec.add_development_dependency "pry", "~> 0.12.2"
@@ -40,4 +41,6 @@ Gem::Specification.new do |spec|
40
41
  spec.add_development_dependency "rake-compiler", "~> 1.1"
41
42
  spec.add_development_dependency "rake-compiler-dock", "~> 1.1"
42
43
  spec.add_development_dependency "rspec", "~> 3.0"
44
+ spec.add_development_dependency "yard", "~> 0.9.26"
45
+ spec.add_development_dependency "webrick", "~> 1.7.0"
43
46
  end
@@ -5,28 +5,34 @@ require 'expressir/model'
5
5
  module Expressir
6
6
  module Express
7
7
  class Cache
8
- def self.to_file(file, content, options = {})
9
- root_path = options[:root_path]
10
- test_overwrite_version = options[:test_overwrite_version] # don't use, only for tests
11
-
8
+ # Save Express model into a cache file
9
+ # @param file [String] cache file path
10
+ # @param content [Model::ModelElement] Express model
11
+ # @param root_path [String] Express repository root path, to be stripped from Express file paths to create a portable cache file
12
+ # @param test_overwrite_version [String] don't use, only for tests
13
+ # @return [nil]
14
+ def self.to_file(file, content, root_path: nil, test_overwrite_version: nil)
12
15
  version = test_overwrite_version || VERSION
13
16
 
14
- cache = Model::Cache.new({
17
+ cache = Model::Cache.new(
15
18
  version: version,
16
19
  content: content
17
- })
20
+ )
18
21
 
19
22
  hash = cache.to_hash(root_path: root_path)
20
23
  yaml = YAML.dump(hash)
21
24
  yaml_compressed = Zlib::Deflate.deflate(yaml)
22
25
 
23
26
  File.binwrite(file, yaml_compressed)
27
+ nil
24
28
  end
25
29
 
26
- def self.from_file(file, options = {})
27
- root_path = options[:root_path]
28
- test_overwrite_version = options[:test_overwrite_version] # don't use, only for tests
29
-
30
+ # Load Express model from a cache file
31
+ # @param file [String] cache file path
32
+ # @param root_path [String] Express repository root path, to be prepended to Express file paths if loading a portable cache file
33
+ # @param test_overwrite_version [String] don't use, only for tests
34
+ # @return [Model::ModelElement] Express model
35
+ def self.from_file(file, root_path: nil, test_overwrite_version: nil)
30
36
  version = test_overwrite_version || VERSION
31
37
 
32
38
  yaml_compressed = File.binread(file)
@@ -6,7 +6,6 @@ module Expressir
6
6
  INDENT_CHAR = ' '
7
7
  INDENT_WIDTH = 2
8
8
  INDENT = INDENT_CHAR * INDENT_WIDTH
9
-
10
9
  OPERATOR_PRECEDENCE = {
11
10
  Model::Expressions::BinaryExpression::EXPONENTIATION => 1,
12
11
  Model::Expressions::BinaryExpression::MULTIPLICATION => 2,
@@ -29,73 +28,112 @@ module Expressir
29
28
  Model::Expressions::BinaryExpression::INSTANCE_NOT_EQUAL => 4,
30
29
  Model::Expressions::BinaryExpression::IN => 4,
31
30
  Model::Expressions::BinaryExpression::LIKE => 4,
32
- Model::Expressions::BinaryExpression::ANDOR => 4,
31
+ }
32
+ SUPERTYPE_OPERATOR_PRECEDENCE = {
33
+ Model::SupertypeExpressions::BinarySupertypeExpression::AND => 1,
34
+ Model::SupertypeExpressions::BinarySupertypeExpression::ANDOR => 2,
33
35
  }
34
36
 
37
+ private_constant :INDENT_CHAR
38
+ private_constant :INDENT_WIDTH
39
+ private_constant :INDENT
40
+ private_constant :OPERATOR_PRECEDENCE
41
+ private_constant :SUPERTYPE_OPERATOR_PRECEDENCE
42
+
43
+ # Formats Express model into an Express code
44
+ # @param [Model::ModelElement] node
45
+ # @return [String]
35
46
  def self.format(node)
36
47
  formatter = self.new
37
48
  formatter.format(node)
38
49
  end
39
50
 
51
+ # Formats Express model into an Express code
52
+ # @param [Model::ModelElement] node
53
+ # @return [String]
40
54
  def format(node)
41
- if node.is_a? Model::Attribute
42
- format_attribute(node)
43
- elsif node.is_a? Model::Constant
44
- format_constant(node)
45
- elsif node.is_a? Model::Entity
46
- format_entity(node)
47
- elsif node.is_a? Model::EnumerationItem
48
- format_enumeration_item(node)
49
- elsif node.is_a? Model::Function
50
- format_function(node)
51
- elsif node.is_a? Model::Interface
52
- format_interface(node)
53
- elsif node.is_a? Model::InterfaceItem
54
- format_interface_item(node)
55
- elsif node.is_a? Model::Parameter
56
- format_parameter(node)
57
- elsif node.is_a? Model::Procedure
58
- format_procedure(node)
59
- elsif node.is_a? Model::Repository
55
+ if node.is_a? Model::Repository
60
56
  format_repository(node)
61
- elsif node.is_a? Model::Rule
62
- format_rule(node)
63
- elsif node.is_a? Model::Schema
64
- format_schema(node)
65
- elsif node.is_a? Model::SchemaVersion
66
- format_schema_version(node)
67
- elsif node.is_a? Model::SubtypeConstraint
68
- format_subtype_constraint(node)
69
- elsif node.is_a? Model::Type
70
- format_type(node)
71
- elsif node.is_a? Model::UniqueRule
72
- format_unique_rule(node)
73
- elsif node.is_a? Model::Variable
74
- format_variable(node)
75
- elsif node.is_a? Model::WhereRule
76
- format_where_rule(node)
57
+ elsif node.is_a? Model::Declarations::Attribute
58
+ format_declarations_attribute(node)
59
+ elsif node.is_a? Model::Declarations::Constant
60
+ format_declarations_constant(node)
61
+ elsif node.is_a? Model::Declarations::Entity
62
+ format_declarations_entity(node)
63
+ elsif node.is_a? Model::Declarations::Function
64
+ format_declarations_function(node)
65
+ elsif node.is_a? Model::Declarations::Interface
66
+ format_declarations_interface(node)
67
+ elsif node.is_a? Model::Declarations::InterfaceItem
68
+ format_declarations_interface_item(node)
69
+ elsif node.is_a? Model::Declarations::Parameter
70
+ format_declarations_parameter(node)
71
+ elsif node.is_a? Model::Declarations::Procedure
72
+ format_declarations_procedure(node)
73
+ elsif node.is_a? Model::Declarations::Rule
74
+ format_declarations_rule(node)
75
+ elsif node.is_a? Model::Declarations::Schema
76
+ format_declarations_schema(node)
77
+ elsif node.is_a? Model::Declarations::SchemaVersion
78
+ format_declarations_schema_version(node)
79
+ elsif node.is_a? Model::Declarations::SubtypeConstraint
80
+ format_declarations_subtype_constraint(node)
81
+ elsif node.is_a? Model::Declarations::Type
82
+ format_declarations_type(node)
83
+ elsif node.is_a? Model::Declarations::UniqueRule
84
+ format_declarations_unique_rule(node)
85
+ elsif node.is_a? Model::Declarations::Variable
86
+ format_declarations_variable(node)
87
+ elsif node.is_a? Model::Declarations::WhereRule
88
+ format_declarations_where_rule(node)
89
+ elsif node.is_a? Model::DataTypes::Aggregate
90
+ format_data_types_aggregate(node)
91
+ elsif node.is_a? Model::DataTypes::Array
92
+ format_data_types_array(node)
93
+ elsif node.is_a? Model::DataTypes::Bag
94
+ format_data_types_bag(node)
95
+ elsif node.is_a? Model::DataTypes::Binary
96
+ format_data_types_binary(node)
97
+ elsif node.is_a? Model::DataTypes::Boolean
98
+ format_data_types_boolean(node)
99
+ elsif node.is_a? Model::DataTypes::Enumeration
100
+ format_data_types_enumeration(node)
101
+ elsif node.is_a? Model::DataTypes::EnumerationItem
102
+ format_data_types_enumeration_item(node)
103
+ elsif node.is_a? Model::DataTypes::GenericEntity
104
+ format_data_types_generic_entity(node)
105
+ elsif node.is_a? Model::DataTypes::Generic
106
+ format_data_types_generic(node)
107
+ elsif node.is_a? Model::DataTypes::Integer
108
+ format_data_types_integer(node)
109
+ elsif node.is_a? Model::DataTypes::List
110
+ format_data_types_list(node)
111
+ elsif node.is_a? Model::DataTypes::Logical
112
+ format_data_types_logical(node)
113
+ elsif node.is_a? Model::DataTypes::Number
114
+ format_data_types_number(node)
115
+ elsif node.is_a? Model::DataTypes::Real
116
+ format_data_types_real(node)
117
+ elsif node.is_a? Model::DataTypes::Select
118
+ format_data_types_select(node)
119
+ elsif node.is_a? Model::DataTypes::Set
120
+ format_data_types_set(node)
121
+ elsif node.is_a? Model::DataTypes::String
122
+ format_data_types_string(node)
77
123
  elsif node.is_a? Model::Expressions::AggregateInitializer
78
124
  format_expressions_aggregate_initializer(node)
79
- elsif node.is_a? Model::Expressions::AggregateItem
80
- format_expressions_aggregate_item(node)
81
- elsif node.is_a? Model::Expressions::AttributeReference
82
- format_expressions_attribute_reference(node)
125
+ elsif node.is_a? Model::Expressions::AggregateInitializerItem
126
+ format_expressions_aggregate_initializer_item(node)
83
127
  elsif node.is_a? Model::Expressions::BinaryExpression
84
128
  format_expressions_binary_expression(node)
85
- elsif node.is_a? Model::Expressions::Call
86
- format_expressions_call(node)
87
129
  elsif node.is_a? Model::Expressions::EntityConstructor
88
130
  format_expressions_entity_constructor(node)
89
- elsif node.is_a? Model::Expressions::GroupReference
90
- format_expressions_group_reference(node)
91
- elsif node.is_a? Model::Expressions::IndexReference
92
- format_expressions_index_reference(node)
131
+ elsif node.is_a? Model::Expressions::FunctionCall
132
+ format_expressions_function_call(node)
93
133
  elsif node.is_a? Model::Expressions::Interval
94
134
  format_expressions_interval(node)
95
135
  elsif node.is_a? Model::Expressions::QueryExpression
96
136
  format_expressions_query_expression(node)
97
- elsif node.is_a? Model::Expressions::SimpleReference
98
- format_expressions_simple_reference(node)
99
137
  elsif node.is_a? Model::Expressions::UnaryExpression
100
138
  format_expressions_unary_expression(node)
101
139
  elsif node.is_a? Model::Literals::Binary
@@ -108,12 +146,18 @@ module Expressir
108
146
  format_literals_real(node)
109
147
  elsif node.is_a? Model::Literals::String
110
148
  format_literals_string(node)
149
+ elsif node.is_a? Model::References::AttributeReference
150
+ format_references_attribute_reference(node)
151
+ elsif node.is_a? Model::References::GroupReference
152
+ format_references_group_reference(node)
153
+ elsif node.is_a? Model::References::IndexReference
154
+ format_references_index_reference(node)
155
+ elsif node.is_a? Model::References::SimpleReference
156
+ format_references_simple_reference(node)
111
157
  elsif node.is_a? Model::Statements::Alias
112
158
  format_statements_alias(node)
113
159
  elsif node.is_a? Model::Statements::Assignment
114
160
  format_statements_assignment(node)
115
- elsif node.is_a? Model::Statements::Call
116
- format_statements_call(node)
117
161
  elsif node.is_a? Model::Statements::Case
118
162
  format_statements_case(node)
119
163
  elsif node.is_a? Model::Statements::CaseAction
@@ -126,44 +170,18 @@ module Expressir
126
170
  format_statements_if(node)
127
171
  elsif node.is_a? Model::Statements::Null
128
172
  format_statements_null(node)
173
+ elsif node.is_a? Model::Statements::ProcedureCall
174
+ format_statements_procedure_call(node)
129
175
  elsif node.is_a? Model::Statements::Repeat
130
176
  format_statements_repeat(node)
131
177
  elsif node.is_a? Model::Statements::Return
132
178
  format_statements_return(node)
133
179
  elsif node.is_a? Model::Statements::Skip
134
180
  format_statements_skip(node)
135
- elsif node.is_a? Model::Types::Aggregate
136
- format_types_aggregate(node)
137
- elsif node.is_a? Model::Types::Array
138
- format_types_array(node)
139
- elsif node.is_a? Model::Types::Bag
140
- format_types_bag(node)
141
- elsif node.is_a? Model::Types::Binary
142
- format_types_binary(node)
143
- elsif node.is_a? Model::Types::Boolean
144
- format_types_boolean(node)
145
- elsif node.is_a? Model::Types::Enumeration
146
- format_types_enumeration(node)
147
- elsif node.is_a? Model::Types::GenericEntity
148
- format_types_generic_entity(node)
149
- elsif node.is_a? Model::Types::Generic
150
- format_types_generic(node)
151
- elsif node.is_a? Model::Types::Integer
152
- format_types_integer(node)
153
- elsif node.is_a? Model::Types::List
154
- format_types_list(node)
155
- elsif node.is_a? Model::Types::Logical
156
- format_types_logical(node)
157
- elsif node.is_a? Model::Types::Number
158
- format_types_number(node)
159
- elsif node.is_a? Model::Types::Real
160
- format_types_real(node)
161
- elsif node.is_a? Model::Types::Select
162
- format_types_select(node)
163
- elsif node.is_a? Model::Types::Set
164
- format_types_set(node)
165
- elsif node.is_a? Model::Types::String
166
- format_types_string(node)
181
+ elsif node.is_a? Model::SupertypeExpressions::BinarySupertypeExpression
182
+ format_supertype_expressions_binary_supertype_expression(node)
183
+ elsif node.is_a? Model::SupertypeExpressions::OneofSupertypeExpression
184
+ format_supertype_expressions_oneof_supertype_expression(node)
167
185
  else
168
186
  STDERR.puts "#{node.class.name} format not implemented"
169
187
  ''
@@ -172,7 +190,11 @@ module Expressir
172
190
 
173
191
  private
174
192
 
175
- def format_attribute(node)
193
+ def format_repository(node)
194
+ node.schemas.map{|x| format(x)}.join("\n\n")
195
+ end
196
+
197
+ def format_declarations_attribute(node)
176
198
  [
177
199
  *if node.supertype_attribute
178
200
  [
@@ -201,14 +223,14 @@ module Expressir
201
223
  end,
202
224
  ' ',
203
225
  format(node.type),
204
- *if node.kind == Model::Attribute::DERIVED
226
+ *if node.kind == Model::Declarations::Attribute::DERIVED
205
227
  [
206
228
  ' ',
207
229
  ':=',
208
230
  ' ',
209
231
  format(node.expression)
210
232
  ].join('')
211
- elsif node.kind == Model::Attribute::INVERSE
233
+ elsif node.kind == Model::Declarations::Attribute::INVERSE
212
234
  [
213
235
  ' ',
214
236
  'FOR',
@@ -220,7 +242,7 @@ module Expressir
220
242
  ].join('')
221
243
  end
222
244
 
223
- def format_constant(node)
245
+ def format_declarations_constant(node)
224
246
  [
225
247
  node.id,
226
248
  ' ',
@@ -235,10 +257,10 @@ module Expressir
235
257
  ].join('')
236
258
  end
237
259
 
238
- def format_entity(node)
239
- explicit_attributes = node.attributes.select{|x| x.kind == Model::Attribute::EXPLICIT}
240
- derived_attributes = node.attributes.select{|x| x.kind == Model::Attribute::DERIVED}
241
- inverse_attributes = node.attributes.select{|x| x.kind == Model::Attribute::INVERSE}
260
+ def format_declarations_entity(node)
261
+ explicit_attributes = node.attributes.select{|x| x.kind == Model::Declarations::Attribute::EXPLICIT}
262
+ derived_attributes = node.attributes.select{|x| x.kind == Model::Declarations::Attribute::DERIVED}
263
+ inverse_attributes = node.attributes.select{|x| x.kind == Model::Declarations::Attribute::INVERSE}
242
264
 
243
265
  [
244
266
  [
@@ -335,11 +357,7 @@ module Expressir
335
357
  ].join("\n")
336
358
  end
337
359
 
338
- def format_enumeration_item(node)
339
- node.id
340
- end
341
-
342
- def format_function(node)
360
+ def format_declarations_function(node)
343
361
  [
344
362
  [
345
363
  'FUNCTION',
@@ -404,11 +422,11 @@ module Expressir
404
422
  ].join("\n")
405
423
  end
406
424
 
407
- def format_interface(node)
425
+ def format_declarations_interface(node)
408
426
  [
409
427
  case node.kind
410
- when Model::Interface::USE then 'USE'
411
- when Model::Interface::REFERENCE then 'REFERENCE'
428
+ when Model::Declarations::Interface::USE then 'USE'
429
+ when Model::Declarations::Interface::REFERENCE then 'REFERENCE'
412
430
  end,
413
431
  ' ',
414
432
  'FROM',
@@ -429,7 +447,7 @@ module Expressir
429
447
  ].join('')
430
448
  end
431
449
 
432
- def format_interface_item(node)
450
+ def format_declarations_interface_item(node)
433
451
  [
434
452
  format(node.ref),
435
453
  *if node.id
@@ -443,7 +461,7 @@ module Expressir
443
461
  ].join('')
444
462
  end
445
463
 
446
- def format_parameter(node)
464
+ def format_declarations_parameter(node)
447
465
  [
448
466
  *if node.var
449
467
  [
@@ -459,7 +477,7 @@ module Expressir
459
477
  ].join('')
460
478
  end
461
479
 
462
- def format_procedure(node)
480
+ def format_declarations_procedure(node)
463
481
  [
464
482
  [
465
483
  'PROCEDURE',
@@ -520,11 +538,7 @@ module Expressir
520
538
  ].join("\n")
521
539
  end
522
540
 
523
- def format_repository(node)
524
- node.schemas.map{|node| format(node)}.join("\n\n")
525
- end
526
-
527
- def format_rule(node)
541
+ def format_declarations_rule(node)
528
542
  [
529
543
  [
530
544
  'RULE',
@@ -589,7 +603,7 @@ module Expressir
589
603
  ].join("\n")
590
604
  end
591
605
 
592
- def format_schema_head(node)
606
+ def format_declarations_schema_head(node)
593
607
  [
594
608
  [
595
609
  'SCHEMA',
@@ -612,7 +626,7 @@ module Expressir
612
626
  ].join("\n")
613
627
  end
614
628
 
615
- def format_schema(node)
629
+ def format_declarations_schema(node)
616
630
  schema_declarations = [
617
631
  *if node.constants.length > 0
618
632
  [
@@ -645,7 +659,7 @@ module Expressir
645
659
  ]
646
660
 
647
661
  [
648
- format_schema_head(node),
662
+ format_declarations_schema_head(node),
649
663
  *if schema_declarations.length > 0
650
664
  [
651
665
  '',
@@ -661,7 +675,7 @@ module Expressir
661
675
  ].join("\n")
662
676
  end
663
677
 
664
- def format_schema_version(node)
678
+ def format_declarations_schema_version(node)
665
679
  [
666
680
  "'",
667
681
  node.value,
@@ -669,7 +683,7 @@ module Expressir
669
683
  ].join('')
670
684
  end
671
685
 
672
- def format_subtype_constraint(node)
686
+ def format_declarations_subtype_constraint(node)
673
687
  [
674
688
  [
675
689
  'SUBTYPE_CONSTRAINT',
@@ -711,7 +725,7 @@ module Expressir
711
725
  ].join("\n")
712
726
  end
713
727
 
714
- def format_type(node)
728
+ def format_declarations_type(node)
715
729
  [
716
730
  [
717
731
  'TYPE',
@@ -736,7 +750,7 @@ module Expressir
736
750
  ].join("\n")
737
751
  end
738
752
 
739
- def format_unique_rule(node)
753
+ def format_declarations_unique_rule(node)
740
754
  [
741
755
  *if node.id
742
756
  [
@@ -750,7 +764,7 @@ module Expressir
750
764
  ].join('')
751
765
  end
752
766
 
753
- def format_variable(node)
767
+ def format_declarations_variable(node)
754
768
  [
755
769
  node.id,
756
770
  ' ',
@@ -769,7 +783,7 @@ module Expressir
769
783
  ].join('')
770
784
  end
771
785
 
772
- def format_where_rule(node)
786
+ def format_declarations_where_rule(node)
773
787
  [
774
788
  *if node.id
775
789
  [
@@ -791,7 +805,7 @@ module Expressir
791
805
  ].join('')
792
806
  end
793
807
 
794
- def format_expressions_aggregate_item(node)
808
+ def format_expressions_aggregate_initializer_item(node)
795
809
  [
796
810
  format(node.expression),
797
811
  ':',
@@ -799,14 +813,6 @@ module Expressir
799
813
  ].join('')
800
814
  end
801
815
 
802
- def format_expressions_attribute_reference(node)
803
- [
804
- format(node.ref),
805
- '.',
806
- format(node.attribute)
807
- ].join('')
808
- end
809
-
810
816
  def format_expressions_binary_expression(node)
811
817
  [
812
818
  *if node.operand1.is_a? Model::Expressions::BinaryExpression and OPERATOR_PRECEDENCE[node.operand1.operator] > OPERATOR_PRECEDENCE[node.operator]
@@ -820,7 +826,6 @@ module Expressir
820
826
  case node.operator
821
827
  when Model::Expressions::BinaryExpression::ADDITION then '+'
822
828
  when Model::Expressions::BinaryExpression::AND then 'AND'
823
- when Model::Expressions::BinaryExpression::ANDOR then 'ANDOR'
824
829
  when Model::Expressions::BinaryExpression::COMBINE then '||'
825
830
  when Model::Expressions::BinaryExpression::EQUAL then '='
826
831
  when Model::Expressions::BinaryExpression::EXPONENTIATION then '**'
@@ -852,62 +857,39 @@ module Expressir
852
857
  ].join('')
853
858
  end
854
859
 
855
- def format_expressions_call(node)
860
+ def format_expressions_entity_constructor(node)
856
861
  [
857
- format(node.ref),
862
+ format(node.entity),
858
863
  '(',
859
864
  node.parameters.map{|x| format(x)}.join(', '),
860
865
  ')'
861
866
  ].join('')
862
867
  end
863
868
 
864
- def format_expressions_entity_constructor(node)
869
+ def format_expressions_function_call(node)
865
870
  [
866
- format(node.entity),
871
+ format(node.function),
867
872
  '(',
868
873
  node.parameters.map{|x| format(x)}.join(', '),
869
874
  ')'
870
875
  ].join('')
871
876
  end
872
877
 
873
- def format_expressions_group_reference(node)
874
- [
875
- format(node.ref),
876
- '\\',
877
- format(node.entity)
878
- ].join('')
879
- end
880
-
881
- def format_expressions_index_reference(node)
882
- [
883
- format(node.ref),
884
- '[',
885
- format(node.index1),
886
- *if node.index2
887
- [
888
- ':',
889
- format(node.index2)
890
- ].join('')
891
- end,
892
- ']'
893
- ].join('')
894
- end
895
-
896
878
  def format_expressions_interval(node)
897
879
  [
898
880
  '{',
899
881
  format(node.low),
900
882
  ' ',
901
883
  case node.operator1
902
- when Model::Expressions::BinaryExpression::LESS_THAN then '<'
903
- when Model::Expressions::BinaryExpression::LESS_THAN_OR_EQUAL then '<='
884
+ when Model::Expressions::Interval::LESS_THAN then '<'
885
+ when Model::Expressions::Interval::LESS_THAN_OR_EQUAL then '<='
904
886
  end,
905
887
  ' ',
906
888
  format(node.item),
907
889
  ' ',
908
890
  case node.operator2
909
- when Model::Expressions::BinaryExpression::LESS_THAN then '<'
910
- when Model::Expressions::BinaryExpression::LESS_THAN_OR_EQUAL then '<='
891
+ when Model::Expressions::Interval::LESS_THAN then '<'
892
+ when Model::Expressions::Interval::LESS_THAN_OR_EQUAL then '<='
911
893
  end,
912
894
  ' ',
913
895
  format(node.high),
@@ -933,10 +915,6 @@ module Expressir
933
915
  ].join('')
934
916
  end
935
917
 
936
- def format_expressions_simple_reference(node)
937
- node.id
938
- end
939
-
940
918
  def format_expressions_unary_expression(node)
941
919
  [
942
920
  case node.operator
@@ -996,6 +974,41 @@ module Expressir
996
974
  end
997
975
  end
998
976
 
977
+ def format_references_attribute_reference(node)
978
+ [
979
+ format(node.ref),
980
+ '.',
981
+ format(node.attribute)
982
+ ].join('')
983
+ end
984
+
985
+ def format_references_group_reference(node)
986
+ [
987
+ format(node.ref),
988
+ '\\',
989
+ format(node.entity)
990
+ ].join('')
991
+ end
992
+
993
+ def format_references_index_reference(node)
994
+ [
995
+ format(node.ref),
996
+ '[',
997
+ format(node.index1),
998
+ *if node.index2
999
+ [
1000
+ ':',
1001
+ format(node.index2)
1002
+ ].join('')
1003
+ end,
1004
+ ']'
1005
+ ].join('')
1006
+ end
1007
+
1008
+ def format_references_simple_reference(node)
1009
+ node.id
1010
+ end
1011
+
999
1012
  def format_statements_alias(node)
1000
1013
  [
1001
1014
  [
@@ -1030,9 +1043,9 @@ module Expressir
1030
1043
  ].join('')
1031
1044
  end
1032
1045
 
1033
- def format_statements_call(node)
1046
+ def format_statements_procedure_call(node)
1034
1047
  [
1035
- format(node.ref),
1048
+ format(node.procedure),
1036
1049
  *if node.parameters.length > 0
1037
1050
  [
1038
1051
  '(',
@@ -1210,11 +1223,45 @@ module Expressir
1210
1223
  ].join('')
1211
1224
  end
1212
1225
 
1213
- def format_types_aggregate(node)
1226
+ def format_supertype_expressions_binary_supertype_expression(node)
1227
+ [
1228
+ *if node.operand1.is_a? Model::SupertypeExpressions::BinarySupertypeExpression and SUPERTYPE_OPERATOR_PRECEDENCE[node.operand1.operator] > SUPERTYPE_OPERATOR_PRECEDENCE[node.operator]
1229
+ '('
1230
+ end,
1231
+ format(node.operand1),
1232
+ *if node.operand1.is_a? Model::SupertypeExpressions::BinarySupertypeExpression and SUPERTYPE_OPERATOR_PRECEDENCE[node.operand1.operator] > SUPERTYPE_OPERATOR_PRECEDENCE[node.operator]
1233
+ ')'
1234
+ end,
1235
+ ' ',
1236
+ case node.operator
1237
+ when Model::SupertypeExpressions::BinarySupertypeExpression::AND then 'AND'
1238
+ when Model::SupertypeExpressions::BinarySupertypeExpression::ANDOR then 'ANDOR'
1239
+ end,
1240
+ ' ',
1241
+ *if node.operand2.is_a? Model::SupertypeExpressions::BinarySupertypeExpression and SUPERTYPE_OPERATOR_PRECEDENCE[node.operand2.operator] > SUPERTYPE_OPERATOR_PRECEDENCE[node.operator]
1242
+ '('
1243
+ end,
1244
+ format(node.operand2),
1245
+ *if node.operand2.is_a? Model::SupertypeExpressions::BinarySupertypeExpression and SUPERTYPE_OPERATOR_PRECEDENCE[node.operand2.operator] > SUPERTYPE_OPERATOR_PRECEDENCE[node.operator]
1246
+ ')'
1247
+ end,
1248
+ ].join('')
1249
+ end
1250
+
1251
+ def format_supertype_expressions_oneof_supertype_expression(node)
1252
+ [
1253
+ 'ONEOF',
1254
+ '(',
1255
+ node.operands.map{|x| format(x)}.join(', '),
1256
+ ')'
1257
+ ].join('')
1258
+ end
1259
+
1260
+ def format_data_types_aggregate(node)
1214
1261
  'AGGREGATE'
1215
1262
  end
1216
1263
 
1217
- def format_types_array(node)
1264
+ def format_data_types_array(node)
1218
1265
  [
1219
1266
  'ARRAY',
1220
1267
  *if node.bound1 and node.bound2
@@ -1246,7 +1293,7 @@ module Expressir
1246
1293
  ].join('')
1247
1294
  end
1248
1295
 
1249
- def format_types_bag(node)
1296
+ def format_data_types_bag(node)
1250
1297
  [
1251
1298
  'BAG',
1252
1299
  *if node.bound1 and node.bound2
@@ -1266,7 +1313,7 @@ module Expressir
1266
1313
  ].join('')
1267
1314
  end
1268
1315
 
1269
- def format_types_binary(node)
1316
+ def format_data_types_binary(node)
1270
1317
  [
1271
1318
  'BINARY',
1272
1319
  *if node.width
@@ -1286,11 +1333,11 @@ module Expressir
1286
1333
  ].join('')
1287
1334
  end
1288
1335
 
1289
- def format_types_boolean(node)
1336
+ def format_data_types_boolean(node)
1290
1337
  'BOOLEAN'
1291
1338
  end
1292
1339
 
1293
- def format_types_enumeration(node)
1340
+ def format_data_types_enumeration(node)
1294
1341
  [
1295
1342
  *if node.extensible
1296
1343
  [
@@ -1339,7 +1386,11 @@ module Expressir
1339
1386
  ].join('')
1340
1387
  end
1341
1388
 
1342
- def format_types_generic_entity(node)
1389
+ def format_data_types_enumeration_item(node)
1390
+ node.id
1391
+ end
1392
+
1393
+ def format_data_types_generic_entity(node)
1343
1394
  [
1344
1395
  'GENERIC_ENTITY',
1345
1396
  *if node.id
@@ -1351,7 +1402,7 @@ module Expressir
1351
1402
  ].join('')
1352
1403
  end
1353
1404
 
1354
- def format_types_generic(node)
1405
+ def format_data_types_generic(node)
1355
1406
  [
1356
1407
  'GENERIC',
1357
1408
  *if node.id
@@ -1363,11 +1414,11 @@ module Expressir
1363
1414
  ].join('')
1364
1415
  end
1365
1416
 
1366
- def format_types_integer(node)
1417
+ def format_data_types_integer(node)
1367
1418
  'INTEGER'
1368
1419
  end
1369
1420
 
1370
- def format_types_list(node)
1421
+ def format_data_types_list(node)
1371
1422
  [
1372
1423
  'LIST',
1373
1424
  *if node.bound1 and node.bound2
@@ -1393,15 +1444,15 @@ module Expressir
1393
1444
  ].join('')
1394
1445
  end
1395
1446
 
1396
- def format_types_logical(node)
1447
+ def format_data_types_logical(node)
1397
1448
  'LOGICAL'
1398
1449
  end
1399
1450
 
1400
- def format_types_number(node)
1451
+ def format_data_types_number(node)
1401
1452
  'NUMBER'
1402
1453
  end
1403
1454
 
1404
- def format_types_real(node)
1455
+ def format_data_types_real(node)
1405
1456
  [
1406
1457
  'REAL',
1407
1458
  *if node.precision
@@ -1415,7 +1466,7 @@ module Expressir
1415
1466
  ].join('')
1416
1467
  end
1417
1468
 
1418
- def format_types_select(node)
1469
+ def format_data_types_select(node)
1419
1470
  [
1420
1471
  *if node.extensible
1421
1472
  [
@@ -1468,7 +1519,7 @@ module Expressir
1468
1519
  ].join('')
1469
1520
  end
1470
1521
 
1471
- def format_types_set(node)
1522
+ def format_data_types_set(node)
1472
1523
  [
1473
1524
  'SET',
1474
1525
  *if node.bound1 and node.bound2
@@ -1488,7 +1539,7 @@ module Expressir
1488
1539
  ].join('')
1489
1540
  end
1490
1541
 
1491
- def format_types_string(node)
1542
+ def format_data_types_string(node)
1492
1543
  [
1493
1544
  'STRING',
1494
1545
  *if node.width
@@ -1549,7 +1600,7 @@ module Expressir
1549
1600
  def format_scope_remarks(node)
1550
1601
  [
1551
1602
  *format_remarks(node),
1552
- *node.children.select{|x| !x.is_a? Model::EnumerationItem or node.is_a? Model::Type}.flat_map{|x| format_scope_remarks(x)}
1603
+ *node.children.select{|x| !x.is_a? Model::DataTypes::EnumerationItem or node.is_a? Model::Declarations::Type}.flat_map{|x| format_scope_remarks(x)}
1553
1604
  ]
1554
1605
  end
1555
1606
  end