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.
- checksums.yaml +4 -4
- data/.yardopts +11 -0
- data/Rakefile +3 -0
- data/expressir.gemspec +3 -0
- data/lib/expressir/express/2.4/express_parser.bundle +0 -0
- data/lib/expressir/express/2.5/express_parser.bundle +0 -0
- data/lib/expressir/express/2.6/express_parser.bundle +0 -0
- data/lib/expressir/express/2.7/express_parser.bundle +0 -0
- data/lib/expressir/express/3.0/express_parser.bundle +0 -0
- data/lib/expressir/express/cache.rb +16 -10
- data/lib/expressir/express/formatter.rb +231 -180
- data/lib/expressir/express/hyperlink_formatter.rb +15 -1
- data/lib/expressir/express/model_visitor.rb +1 -0
- data/lib/expressir/express/parser.rb +16 -10
- data/lib/expressir/express/resolve_references_model_visitor.rb +7 -5
- data/lib/expressir/express/schema_head_formatter.rb +16 -2
- data/lib/expressir/express/visitor.rb +280 -254
- data/lib/expressir/model.rb +52 -45
- data/lib/expressir/model/cache.rb +6 -2
- data/lib/expressir/model/data_type.rb +9 -0
- data/lib/expressir/model/data_types/aggregate.rb +31 -0
- data/lib/expressir/model/data_types/array.rb +31 -0
- data/lib/expressir/model/data_types/bag.rb +25 -0
- data/lib/expressir/model/data_types/binary.rb +22 -0
- data/lib/expressir/model/data_types/boolean.rb +10 -0
- data/lib/expressir/model/data_types/enumeration.rb +25 -0
- data/lib/expressir/model/data_types/enumeration_item.rb +26 -0
- data/lib/expressir/model/data_types/generic.rb +26 -0
- data/lib/expressir/model/data_types/generic_entity.rb +26 -0
- data/lib/expressir/model/data_types/integer.rb +10 -0
- data/lib/expressir/model/data_types/list.rb +28 -0
- data/lib/expressir/model/data_types/logical.rb +10 -0
- data/lib/expressir/model/data_types/number.rb +10 -0
- data/lib/expressir/model/data_types/real.rb +19 -0
- data/lib/expressir/model/data_types/select.rb +28 -0
- data/lib/expressir/model/data_types/set.rb +25 -0
- data/lib/expressir/model/data_types/string.rb +22 -0
- data/lib/expressir/model/declaration.rb +9 -0
- data/lib/expressir/model/declarations/attribute.rb +47 -0
- data/lib/expressir/model/declarations/constant.rb +34 -0
- data/lib/expressir/model/declarations/entity.rb +53 -0
- data/lib/expressir/model/declarations/function.rb +67 -0
- data/lib/expressir/model/declarations/interface.rb +28 -0
- data/lib/expressir/model/declarations/interface_item.rb +23 -0
- data/lib/expressir/model/declarations/interfaced_item.rb +37 -0
- data/lib/expressir/model/declarations/parameter.rb +34 -0
- data/lib/expressir/model/declarations/procedure.rb +64 -0
- data/lib/expressir/model/declarations/remark_item.rb +21 -0
- data/lib/expressir/model/declarations/rule.rb +71 -0
- data/lib/expressir/model/declarations/schema.rb +117 -0
- data/lib/expressir/model/declarations/schema_version.rb +22 -0
- data/lib/expressir/model/declarations/schema_version_item.rb +22 -0
- data/lib/expressir/model/declarations/subtype_constraint.rb +40 -0
- data/lib/expressir/model/declarations/type.rb +45 -0
- data/lib/expressir/model/declarations/unique_rule.rb +31 -0
- data/lib/expressir/model/declarations/variable.rb +34 -0
- data/lib/expressir/model/declarations/where_rule.rb +31 -0
- data/lib/expressir/model/expression.rb +9 -0
- data/lib/expressir/model/expressions/aggregate_initializer.rb +6 -2
- data/lib/expressir/model/expressions/aggregate_initializer_item.rb +22 -0
- data/lib/expressir/model/expressions/binary_expression.rb +16 -5
- data/lib/expressir/model/expressions/entity_constructor.rb +8 -3
- data/lib/expressir/model/expressions/function_call.rb +22 -0
- data/lib/expressir/model/expressions/interval.rb +17 -6
- data/lib/expressir/model/expressions/query_expression.rb +11 -7
- data/lib/expressir/model/expressions/unary_expression.rb +9 -3
- data/lib/expressir/model/identifier.rb +26 -4
- data/lib/expressir/model/literal.rb +9 -0
- data/lib/expressir/model/literals/binary.rb +6 -2
- data/lib/expressir/model/literals/integer.rb +6 -2
- data/lib/expressir/model/literals/logical.rb +6 -2
- data/lib/expressir/model/literals/real.rb +6 -2
- data/lib/expressir/model/literals/string.rb +8 -3
- data/lib/expressir/model/model_element.rb +63 -37
- data/lib/expressir/model/reference.rb +9 -0
- data/lib/expressir/model/references/attribute_reference.rb +22 -0
- data/lib/expressir/model/references/group_reference.rb +22 -0
- data/lib/expressir/model/references/index_reference.rb +27 -0
- data/lib/expressir/model/references/simple_reference.rb +24 -0
- data/lib/expressir/model/repository.rb +7 -1
- data/lib/expressir/model/statement.rb +9 -0
- data/lib/expressir/model/statements/alias.rb +11 -7
- data/lib/expressir/model/statements/assignment.rb +8 -3
- data/lib/expressir/model/statements/case.rb +10 -4
- data/lib/expressir/model/statements/case_action.rb +7 -2
- data/lib/expressir/model/statements/compound.rb +6 -2
- data/lib/expressir/model/statements/escape.rb +3 -1
- data/lib/expressir/model/statements/if.rb +10 -4
- data/lib/expressir/model/statements/null.rb +3 -1
- data/lib/expressir/model/statements/procedure_call.rb +22 -0
- data/lib/expressir/model/statements/repeat.rb +19 -11
- data/lib/expressir/model/statements/return.rb +6 -2
- data/lib/expressir/model/statements/skip.rb +3 -1
- data/lib/expressir/model/supertype_expression.rb +9 -0
- data/lib/expressir/model/supertype_expressions/binary_supertype_expression.rb +29 -0
- data/lib/expressir/model/supertype_expressions/oneof_supertype_expression.rb +19 -0
- data/lib/expressir/version.rb +1 -1
- data/spec/expressir/model/model_element_spec.rb +131 -131
- data/spec/syntax/multiple.yaml +68 -68
- data/spec/syntax/remark.yaml +64 -64
- data/spec/syntax/single.yaml +5 -5
- data/spec/syntax/single_formatted.yaml +5 -5
- data/spec/syntax/syntax.yaml +1003 -1030
- metadata +97 -45
- data/lib/expressir/model/attribute.rb +0 -38
- data/lib/expressir/model/constant.rb +0 -28
- data/lib/expressir/model/entity.rb +0 -42
- data/lib/expressir/model/enumeration_item.rb +0 -22
- data/lib/expressir/model/expressions/aggregate_item.rb +0 -17
- data/lib/expressir/model/expressions/attribute_reference.rb +0 -17
- data/lib/expressir/model/expressions/call.rb +0 -17
- data/lib/expressir/model/expressions/group_reference.rb +0 -17
- data/lib/expressir/model/expressions/index_reference.rb +0 -19
- data/lib/expressir/model/expressions/simple_reference.rb +0 -19
- data/lib/expressir/model/function.rb +0 -57
- data/lib/expressir/model/interface.rb +0 -20
- data/lib/expressir/model/interface_item.rb +0 -15
- data/lib/expressir/model/interfaced_item.rb +0 -27
- data/lib/expressir/model/parameter.rb +0 -28
- data/lib/expressir/model/procedure.rb +0 -55
- data/lib/expressir/model/remark_item.rb +0 -15
- data/lib/expressir/model/rule.rb +0 -60
- data/lib/expressir/model/schema.rb +0 -100
- data/lib/expressir/model/schema_version.rb +0 -15
- data/lib/expressir/model/schema_version_item.rb +0 -15
- data/lib/expressir/model/statements/call.rb +0 -17
- data/lib/expressir/model/subtype_constraint.rb +0 -32
- data/lib/expressir/model/type.rb +0 -37
- data/lib/expressir/model/types/aggregate.rb +0 -28
- data/lib/expressir/model/types/array.rb +0 -23
- data/lib/expressir/model/types/bag.rb +0 -19
- data/lib/expressir/model/types/binary.rb +0 -17
- data/lib/expressir/model/types/boolean.rb +0 -8
- data/lib/expressir/model/types/enumeration.rb +0 -19
- data/lib/expressir/model/types/generic.rb +0 -24
- data/lib/expressir/model/types/generic_entity.rb +0 -24
- data/lib/expressir/model/types/integer.rb +0 -8
- data/lib/expressir/model/types/list.rb +0 -21
- data/lib/expressir/model/types/logical.rb +0 -8
- data/lib/expressir/model/types/number.rb +0 -8
- data/lib/expressir/model/types/real.rb +0 -15
- data/lib/expressir/model/types/select.rb +0 -21
- data/lib/expressir/model/types/set.rb +0 -19
- data/lib/expressir/model/types/string.rb +0 -17
- data/lib/expressir/model/unique_rule.rb +0 -26
- data/lib/expressir/model/variable.rb +0 -28
- data/lib/expressir/model/where_rule.rb +0 -26
@@ -1,7 +1,21 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Express
|
3
|
+
# Formatter module - format references as hyperlinks
|
4
|
+
# @example Include into Formatter subclass
|
5
|
+
# formatter = Class.new(Expressir::Express::Formatter) do
|
6
|
+
# include Expressir::Express::HyperlinkFormatter
|
7
|
+
# end
|
3
8
|
module HyperlinkFormatter
|
4
|
-
|
9
|
+
# @!visibility private
|
10
|
+
def self.included(mod)
|
11
|
+
if !mod.superclass.private_method_defined? :format_references_simple_reference
|
12
|
+
raise 'Missing method'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def format_references_simple_reference(node)
|
5
19
|
return node.id unless node.base_path
|
6
20
|
|
7
21
|
# find closest node with path
|
@@ -25,16 +25,19 @@ repo = visitor.visit(parse_tree)
|
|
25
25
|
module Expressir
|
26
26
|
module Express
|
27
27
|
class Parser
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
# Parses Express file into an Express model
|
29
|
+
# @param [String] file Express file path
|
30
|
+
# @param [Boolean] skip_references skip resolving references
|
31
|
+
# @param [Boolean] include_source attach original source code to model elements
|
32
|
+
# @return [Model::Repository]
|
33
|
+
def self.from_file(file, skip_references: nil, include_source: nil)
|
31
34
|
input = File.read(file)
|
32
35
|
|
33
36
|
parser = ::ExpressParser::Parser.parse(input)
|
34
37
|
|
35
38
|
parse_tree = parser.syntax()
|
36
39
|
|
37
|
-
visitor = Visitor.new(parser.tokens,
|
40
|
+
visitor = Visitor.new(parser.tokens, include_source: include_source)
|
38
41
|
repository = visitor.visit(parse_tree)
|
39
42
|
|
40
43
|
repository.schemas.each do |schema|
|
@@ -49,19 +52,22 @@ module Expressir
|
|
49
52
|
repository
|
50
53
|
end
|
51
54
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
+
# Parses Express files into an Express model
|
56
|
+
# @param [Array<String>] files Express file paths
|
57
|
+
# @param [Boolean] skip_references skip resolving references
|
58
|
+
# @param [Boolean] include_source attach original source code to model elements
|
59
|
+
# @return [Model::Repository]
|
60
|
+
def self.from_files(files, skip_references: nil, include_source: nil)
|
55
61
|
schemas = files.each_with_index.map do |file, i|
|
56
62
|
# start = Time.now
|
57
|
-
repository = self.from_file(file,
|
63
|
+
repository = self.from_file(file, skip_references: true)
|
58
64
|
# STDERR.puts "#{i+1}/#{files.length} #{file} #{Time.now - start}"
|
59
65
|
repository.schemas
|
60
66
|
end.flatten
|
61
67
|
|
62
|
-
repository = Model::Repository.new(
|
68
|
+
repository = Model::Repository.new(
|
63
69
|
schemas: schemas
|
64
|
-
|
70
|
+
)
|
65
71
|
|
66
72
|
unless skip_references
|
67
73
|
resolve_references_model_visitor = ResolveReferencesModelVisitor.new
|
@@ -5,17 +5,19 @@ module Expressir
|
|
5
5
|
module Express
|
6
6
|
class ResolveReferencesModelVisitor < ModelVisitor
|
7
7
|
def visit(node)
|
8
|
-
if node.is_a? Model::
|
9
|
-
|
8
|
+
if node.is_a? Model::References::SimpleReference
|
9
|
+
visit_references_simple_reference(node)
|
10
10
|
end
|
11
11
|
|
12
12
|
super
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
return if node.parent.is_a? Model::Expressions::AttributeReference
|
15
|
+
private
|
17
16
|
|
18
|
-
|
17
|
+
def visit_references_simple_reference(node)
|
18
|
+
return if node.parent.is_a? Model::References::AttributeReference
|
19
|
+
|
20
|
+
if node.parent.is_a? Model::Declarations::InterfaceItem
|
19
21
|
base_item = node.find("#{node.parent.parent.schema.id}.#{node.parent.ref.id}")
|
20
22
|
else
|
21
23
|
base_item = node.find(node.id)
|
@@ -1,8 +1,22 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Express
|
3
|
+
# Formatter module - format schema as schema head only
|
4
|
+
# @example Include into Formatter subclass
|
5
|
+
# formatter = Class.new(Expressir::Express::Formatter) do
|
6
|
+
# include Expressir::Express::SchemaHeadFormatter
|
7
|
+
# end
|
3
8
|
module SchemaHeadFormatter
|
4
|
-
|
5
|
-
|
9
|
+
# @!visibility private
|
10
|
+
def self.included(mod)
|
11
|
+
if !mod.superclass.private_method_defined? :format_declarations_schema or !mod.superclass.private_method_defined? :format_declarations_schema_head
|
12
|
+
raise 'Missing method'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def format_declarations_schema(node)
|
19
|
+
format_declarations_schema_head(node)
|
6
20
|
end
|
7
21
|
end
|
8
22
|
end
|
@@ -16,7 +16,7 @@ require "set"
|
|
16
16
|
# > for example.
|
17
17
|
# - such multi-pass parsing is not implemented yet
|
18
18
|
# - xxxRef - merged to SimpleReference
|
19
|
-
# - entityConstructor, functionCall - merged to
|
19
|
+
# - entityConstructor, functionCall - merged to FunctionCall
|
20
20
|
#
|
21
21
|
# difference between generalized and instantiable types is not recognized
|
22
22
|
# see note in 8.6.2 Parameter data types
|
@@ -36,9 +36,13 @@ module Expressir
|
|
36
36
|
class Visitor < ::ExpressParser::Visitor
|
37
37
|
REMARK_CHANNEL = 2
|
38
38
|
|
39
|
-
|
39
|
+
private_constant :REMARK_CHANNEL
|
40
|
+
|
41
|
+
# @param [Array<::ExpressParser::Token>] tokens
|
42
|
+
# @param [Boolean] include_source attach original source code to model elements
|
43
|
+
def initialize(tokens, include_source: nil)
|
40
44
|
@tokens = tokens
|
41
|
-
@include_source =
|
45
|
+
@include_source = include_source
|
42
46
|
|
43
47
|
@attached_remark_tokens = ::Set.new
|
44
48
|
|
@@ -54,6 +58,8 @@ module Expressir
|
|
54
58
|
node
|
55
59
|
end
|
56
60
|
|
61
|
+
private
|
62
|
+
|
57
63
|
def visit_if(ctx, default = nil)
|
58
64
|
if ctx
|
59
65
|
visit(ctx)
|
@@ -113,9 +119,9 @@ module Expressir
|
|
113
119
|
_, _, current_path = current_path.rpartition(":") # ignore prefix
|
114
120
|
parent_node = node.find(rest)
|
115
121
|
if parent_node and parent_node.class.method_defined? :remark_items
|
116
|
-
remark_item = Model::RemarkItem.new(
|
122
|
+
remark_item = Model::Declarations::RemarkItem.new(
|
117
123
|
id: current_path
|
118
|
-
|
124
|
+
)
|
119
125
|
remark_item.parent = parent_node
|
120
126
|
|
121
127
|
# check if path can create implicit informal proposition
|
@@ -170,9 +176,9 @@ module Expressir
|
|
170
176
|
|
171
177
|
id = visit_if(ctx__attribute_id)
|
172
178
|
|
173
|
-
Model::
|
179
|
+
Model::References::SimpleReference.new(
|
174
180
|
id: id
|
175
|
-
|
181
|
+
)
|
176
182
|
end
|
177
183
|
|
178
184
|
def visit_constant_ref(ctx)
|
@@ -180,9 +186,9 @@ module Expressir
|
|
180
186
|
|
181
187
|
id = visit_if(ctx__constant_id)
|
182
188
|
|
183
|
-
Model::
|
189
|
+
Model::References::SimpleReference.new(
|
184
190
|
id: id
|
185
|
-
|
191
|
+
)
|
186
192
|
end
|
187
193
|
|
188
194
|
def visit_entity_ref(ctx)
|
@@ -190,9 +196,9 @@ module Expressir
|
|
190
196
|
|
191
197
|
id = visit_if(ctx__entity_id)
|
192
198
|
|
193
|
-
Model::
|
199
|
+
Model::References::SimpleReference.new(
|
194
200
|
id: id
|
195
|
-
|
201
|
+
)
|
196
202
|
end
|
197
203
|
|
198
204
|
def visit_enumeration_ref(ctx)
|
@@ -200,9 +206,9 @@ module Expressir
|
|
200
206
|
|
201
207
|
id = visit_if(ctx__enumeration_id)
|
202
208
|
|
203
|
-
Model::
|
209
|
+
Model::References::SimpleReference.new(
|
204
210
|
id: id
|
205
|
-
|
211
|
+
)
|
206
212
|
end
|
207
213
|
|
208
214
|
def visit_function_ref(ctx)
|
@@ -210,9 +216,9 @@ module Expressir
|
|
210
216
|
|
211
217
|
id = visit_if(ctx__function_id)
|
212
218
|
|
213
|
-
Model::
|
219
|
+
Model::References::SimpleReference.new(
|
214
220
|
id: id
|
215
|
-
|
221
|
+
)
|
216
222
|
end
|
217
223
|
|
218
224
|
def visit_parameter_ref(ctx)
|
@@ -220,9 +226,9 @@ module Expressir
|
|
220
226
|
|
221
227
|
id = visit_if(ctx__parameter_id)
|
222
228
|
|
223
|
-
Model::
|
229
|
+
Model::References::SimpleReference.new(
|
224
230
|
id: id
|
225
|
-
|
231
|
+
)
|
226
232
|
end
|
227
233
|
|
228
234
|
def visit_procedure_ref(ctx)
|
@@ -230,9 +236,9 @@ module Expressir
|
|
230
236
|
|
231
237
|
id = visit_if(ctx__procedure_id)
|
232
238
|
|
233
|
-
Model::
|
239
|
+
Model::References::SimpleReference.new(
|
234
240
|
id: id
|
235
|
-
|
241
|
+
)
|
236
242
|
end
|
237
243
|
|
238
244
|
def visit_rule_label_ref(ctx)
|
@@ -240,9 +246,9 @@ module Expressir
|
|
240
246
|
|
241
247
|
id = visit_if(ctx__rule_label_id)
|
242
248
|
|
243
|
-
Model::
|
249
|
+
Model::References::SimpleReference.new(
|
244
250
|
id: id
|
245
|
-
|
251
|
+
)
|
246
252
|
end
|
247
253
|
|
248
254
|
def visit_rule_ref(ctx)
|
@@ -250,9 +256,9 @@ module Expressir
|
|
250
256
|
|
251
257
|
id = visit_if(ctx__rule_id)
|
252
258
|
|
253
|
-
Model::
|
259
|
+
Model::References::SimpleReference.new(
|
254
260
|
id: id
|
255
|
-
|
261
|
+
)
|
256
262
|
end
|
257
263
|
|
258
264
|
def visit_schema_ref(ctx)
|
@@ -260,9 +266,9 @@ module Expressir
|
|
260
266
|
|
261
267
|
id = visit_if(ctx__schema_id)
|
262
268
|
|
263
|
-
Model::
|
269
|
+
Model::References::SimpleReference.new(
|
264
270
|
id: id
|
265
|
-
|
271
|
+
)
|
266
272
|
end
|
267
273
|
|
268
274
|
def visit_subtype_constraint_ref(ctx)
|
@@ -270,9 +276,9 @@ module Expressir
|
|
270
276
|
|
271
277
|
id = visit_if(ctx__subtype_constraint_id)
|
272
278
|
|
273
|
-
Model::
|
279
|
+
Model::References::SimpleReference.new(
|
274
280
|
id: id
|
275
|
-
|
281
|
+
)
|
276
282
|
end
|
277
283
|
|
278
284
|
def visit_type_label_ref(ctx)
|
@@ -280,9 +286,9 @@ module Expressir
|
|
280
286
|
|
281
287
|
id = visit_if(ctx__type_label_id)
|
282
288
|
|
283
|
-
Model::
|
289
|
+
Model::References::SimpleReference.new(
|
284
290
|
id: id
|
285
|
-
|
291
|
+
)
|
286
292
|
end
|
287
293
|
|
288
294
|
def visit_type_ref(ctx)
|
@@ -290,9 +296,9 @@ module Expressir
|
|
290
296
|
|
291
297
|
id = visit_if(ctx__type_id)
|
292
298
|
|
293
|
-
Model::
|
299
|
+
Model::References::SimpleReference.new(
|
294
300
|
id: id
|
295
|
-
|
301
|
+
)
|
296
302
|
end
|
297
303
|
|
298
304
|
def visit_variable_ref(ctx)
|
@@ -300,9 +306,9 @@ module Expressir
|
|
300
306
|
|
301
307
|
id = visit_if(ctx__variable_id)
|
302
308
|
|
303
|
-
Model::
|
309
|
+
Model::References::SimpleReference.new(
|
304
310
|
id: id
|
305
|
-
|
311
|
+
)
|
306
312
|
end
|
307
313
|
|
308
314
|
def visit_abstract_entity_declaration(ctx)
|
@@ -350,9 +356,9 @@ module Expressir
|
|
350
356
|
|
351
357
|
items = visit_if_map(ctx__element)
|
352
358
|
|
353
|
-
Model::Expressions::AggregateInitializer.new(
|
359
|
+
Model::Expressions::AggregateInitializer.new(
|
354
360
|
items: items
|
355
|
-
|
361
|
+
)
|
356
362
|
end
|
357
363
|
|
358
364
|
def visit_aggregate_source(ctx)
|
@@ -368,10 +374,10 @@ module Expressir
|
|
368
374
|
id = visit_if(ctx__type_label)
|
369
375
|
base_type = visit_if(ctx__parameter_type)
|
370
376
|
|
371
|
-
Model::
|
377
|
+
Model::DataTypes::Aggregate.new(
|
372
378
|
id: id,
|
373
379
|
base_type: base_type
|
374
|
-
|
380
|
+
)
|
375
381
|
end
|
376
382
|
|
377
383
|
def visit_aggregation_types(ctx)
|
@@ -397,11 +403,11 @@ module Expressir
|
|
397
403
|
expression = handle_qualified_ref(visit_if(ctx__general_ref), ctx__qualifier)
|
398
404
|
statements = visit_if_map(ctx__stmt)
|
399
405
|
|
400
|
-
Model::Statements::Alias.new(
|
406
|
+
Model::Statements::Alias.new(
|
401
407
|
id: id,
|
402
408
|
expression: expression,
|
403
409
|
statements: statements
|
404
|
-
|
410
|
+
)
|
405
411
|
end
|
406
412
|
|
407
413
|
def visit_array_type(ctx)
|
@@ -418,13 +424,13 @@ module Expressir
|
|
418
424
|
unique = ctx__UNIQUE && true
|
419
425
|
base_type = visit_if(ctx__instantiable_type)
|
420
426
|
|
421
|
-
Model::
|
427
|
+
Model::DataTypes::Array.new(
|
422
428
|
bound1: bound1,
|
423
429
|
bound2: bound2,
|
424
430
|
optional: optional,
|
425
431
|
unique: unique,
|
426
432
|
base_type: base_type
|
427
|
-
|
433
|
+
)
|
428
434
|
end
|
429
435
|
|
430
436
|
def visit_assignment_stmt(ctx)
|
@@ -435,10 +441,10 @@ module Expressir
|
|
435
441
|
ref = handle_qualified_ref(visit_if(ctx__general_ref), ctx__qualifier)
|
436
442
|
expression = visit_if(ctx__expression)
|
437
443
|
|
438
|
-
Model::Statements::Assignment.new(
|
444
|
+
Model::Statements::Assignment.new(
|
439
445
|
ref: ref,
|
440
446
|
expression: expression
|
441
|
-
|
447
|
+
)
|
442
448
|
end
|
443
449
|
|
444
450
|
def visit_attribute_decl(ctx)
|
@@ -450,10 +456,10 @@ module Expressir
|
|
450
456
|
id = visit_if(ctx__attribute_id || ctx__redeclared_attribute__attribute_id)
|
451
457
|
supertype_attribute = visit_if(ctx__redeclared_attribute__qualified_attribute)
|
452
458
|
|
453
|
-
Model::Attribute.new(
|
459
|
+
Model::Declarations::Attribute.new(
|
454
460
|
id: id,
|
455
461
|
supertype_attribute: supertype_attribute
|
456
|
-
|
462
|
+
)
|
457
463
|
end
|
458
464
|
|
459
465
|
def visit_attribute_id(ctx)
|
@@ -467,9 +473,9 @@ module Expressir
|
|
467
473
|
|
468
474
|
attribute = visit_if(ctx__attribute_ref)
|
469
475
|
|
470
|
-
Model::
|
476
|
+
Model::References::AttributeReference.new(
|
471
477
|
attribute: attribute
|
472
|
-
|
478
|
+
)
|
473
479
|
end
|
474
480
|
|
475
481
|
def visit_attribute_reference(ctx)
|
@@ -486,11 +492,11 @@ module Expressir
|
|
486
492
|
bound2 = visit_if(ctx__bound_spec__bound2)
|
487
493
|
base_type = visit_if(ctx__instantiable_type)
|
488
494
|
|
489
|
-
Model::
|
495
|
+
Model::DataTypes::Bag.new(
|
490
496
|
bound1: bound1,
|
491
497
|
bound2: bound2,
|
492
498
|
base_type: base_type
|
493
|
-
|
499
|
+
)
|
494
500
|
end
|
495
501
|
|
496
502
|
def visit_binary_type(ctx)
|
@@ -501,14 +507,14 @@ module Expressir
|
|
501
507
|
width = visit_if(ctx__width_spec__width)
|
502
508
|
fixed = ctx__width_spec__FIXED && true
|
503
509
|
|
504
|
-
Model::
|
510
|
+
Model::DataTypes::Binary.new(
|
505
511
|
width: width,
|
506
512
|
fixed: fixed
|
507
|
-
|
513
|
+
)
|
508
514
|
end
|
509
515
|
|
510
516
|
def visit_boolean_type(ctx)
|
511
|
-
Model::
|
517
|
+
Model::DataTypes::Boolean.new
|
512
518
|
end
|
513
519
|
|
514
520
|
def visit_bound1(ctx)
|
@@ -532,9 +538,9 @@ module Expressir
|
|
532
538
|
|
533
539
|
id = ctx__text
|
534
540
|
|
535
|
-
Model::
|
541
|
+
Model::References::SimpleReference.new(
|
536
542
|
id: id
|
537
|
-
|
543
|
+
)
|
538
544
|
end
|
539
545
|
|
540
546
|
def visit_built_in_function(ctx)
|
@@ -542,9 +548,9 @@ module Expressir
|
|
542
548
|
|
543
549
|
id = ctx__text
|
544
550
|
|
545
|
-
Model::
|
551
|
+
Model::References::SimpleReference.new(
|
546
552
|
id: id
|
547
|
-
|
553
|
+
)
|
548
554
|
end
|
549
555
|
|
550
556
|
def visit_built_in_procedure(ctx)
|
@@ -552,9 +558,9 @@ module Expressir
|
|
552
558
|
|
553
559
|
id = ctx__text
|
554
560
|
|
555
|
-
Model::
|
561
|
+
Model::References::SimpleReference.new(
|
556
562
|
id: id
|
557
|
-
|
563
|
+
)
|
558
564
|
end
|
559
565
|
|
560
566
|
def visit_case_action(ctx)
|
@@ -564,10 +570,10 @@ module Expressir
|
|
564
570
|
labels = visit_if_map(ctx__case_label)
|
565
571
|
statement = visit_if(ctx__stmt)
|
566
572
|
|
567
|
-
Model::Statements::CaseAction.new(
|
573
|
+
Model::Statements::CaseAction.new(
|
568
574
|
labels: labels,
|
569
575
|
statement: statement
|
570
|
-
|
576
|
+
)
|
571
577
|
end
|
572
578
|
|
573
579
|
def visit_case_label(ctx)
|
@@ -586,11 +592,11 @@ module Expressir
|
|
586
592
|
actions = visit_if_map_flatten(ctx__case_action)
|
587
593
|
otherwise_statement = visit_if(ctx__stmt)
|
588
594
|
|
589
|
-
Model::Statements::Case.new(
|
595
|
+
Model::Statements::Case.new(
|
590
596
|
expression: expression,
|
591
597
|
actions: actions,
|
592
598
|
otherwise_statement: otherwise_statement
|
593
|
-
|
599
|
+
)
|
594
600
|
end
|
595
601
|
|
596
602
|
def visit_compound_stmt(ctx)
|
@@ -598,9 +604,9 @@ module Expressir
|
|
598
604
|
|
599
605
|
statements = visit_if_map(ctx__stmt)
|
600
606
|
|
601
|
-
Model::Statements::Compound.new(
|
607
|
+
Model::Statements::Compound.new(
|
602
608
|
statements: statements
|
603
|
-
|
609
|
+
)
|
604
610
|
end
|
605
611
|
|
606
612
|
def visit_concrete_types(ctx)
|
@@ -620,11 +626,11 @@ module Expressir
|
|
620
626
|
type = visit_if(ctx__instantiable_type)
|
621
627
|
expression = visit_if(ctx__expression)
|
622
628
|
|
623
|
-
Model::Constant.new(
|
629
|
+
Model::Declarations::Constant.new(
|
624
630
|
id: id,
|
625
631
|
type: type,
|
626
632
|
expression: expression
|
627
|
-
|
633
|
+
)
|
628
634
|
end
|
629
635
|
|
630
636
|
def visit_constant_decl(ctx)
|
@@ -672,13 +678,13 @@ module Expressir
|
|
672
678
|
type = visit_if(ctx__parameter_type)
|
673
679
|
expression = visit_if(ctx__expression)
|
674
680
|
|
675
|
-
Model::Attribute.new(
|
681
|
+
Model::Declarations::Attribute.new(
|
676
682
|
id: attribute.id, # reuse
|
677
|
-
kind: Model::Attribute::DERIVED,
|
683
|
+
kind: Model::Declarations::Attribute::DERIVED,
|
678
684
|
supertype_attribute: attribute.supertype_attribute, # reuse
|
679
685
|
type: type,
|
680
686
|
expression: expression
|
681
|
-
|
687
|
+
)
|
682
688
|
end
|
683
689
|
|
684
690
|
def visit_derive_clause(ctx)
|
@@ -694,10 +700,10 @@ module Expressir
|
|
694
700
|
id = visit_if(ctx__rule_label_id)
|
695
701
|
expression = visit_if(ctx__expression)
|
696
702
|
|
697
|
-
Model::WhereRule.new(
|
703
|
+
Model::Declarations::WhereRule.new(
|
698
704
|
id: id,
|
699
705
|
expression: expression
|
700
|
-
|
706
|
+
)
|
701
707
|
end
|
702
708
|
|
703
709
|
def visit_element(ctx)
|
@@ -708,10 +714,10 @@ module Expressir
|
|
708
714
|
expression = visit_if(ctx__expression)
|
709
715
|
repetition = visit_if(ctx__repetition)
|
710
716
|
|
711
|
-
Model::Expressions::
|
717
|
+
Model::Expressions::AggregateInitializerItem.new(
|
712
718
|
expression: expression,
|
713
719
|
repetition: repetition
|
714
|
-
|
720
|
+
)
|
715
721
|
else
|
716
722
|
visit_if(ctx__expression)
|
717
723
|
end
|
@@ -725,13 +731,17 @@ module Expressir
|
|
725
731
|
ctx__entity_ref = ctx.entity_ref
|
726
732
|
ctx__expression = ctx.expression
|
727
733
|
|
728
|
-
|
734
|
+
entity = visit_if(ctx__entity_ref)
|
729
735
|
parameters = visit_if_map(ctx__expression)
|
730
736
|
|
731
|
-
Model::Expressions::
|
732
|
-
|
737
|
+
# Model::Expressions::EntityConstructor.new(
|
738
|
+
# entity: entity,
|
739
|
+
# parameters: parameters
|
740
|
+
# )
|
741
|
+
Model::Expressions::FunctionCall.new(
|
742
|
+
function: entity,
|
733
743
|
parameters: parameters
|
734
|
-
|
744
|
+
)
|
735
745
|
end
|
736
746
|
|
737
747
|
def visit_entity_decl(ctx)
|
@@ -762,7 +772,7 @@ module Expressir
|
|
762
772
|
unique_rules = visit_if(ctx__entity_body__unique_clause, [])
|
763
773
|
where_rules = visit_if(ctx__entity_body__where_clause, [])
|
764
774
|
|
765
|
-
Model::Entity.new(
|
775
|
+
Model::Declarations::Entity.new(
|
766
776
|
id: id,
|
767
777
|
abstract: abstract,
|
768
778
|
supertype_expression: supertype_expression,
|
@@ -770,7 +780,7 @@ module Expressir
|
|
770
780
|
attributes: attributes,
|
771
781
|
unique_rules: unique_rules,
|
772
782
|
where_rules: where_rules
|
773
|
-
|
783
|
+
)
|
774
784
|
end
|
775
785
|
|
776
786
|
def visit_entity_head(ctx)
|
@@ -804,9 +814,9 @@ module Expressir
|
|
804
814
|
|
805
815
|
id = visit_if(ctx__enumeration_id)
|
806
816
|
|
807
|
-
Model::EnumerationItem.new(
|
817
|
+
Model::DataTypes::EnumerationItem.new(
|
808
818
|
id: id
|
809
|
-
|
819
|
+
)
|
810
820
|
end
|
811
821
|
|
812
822
|
def visit_enumeration_reference(ctx)
|
@@ -817,10 +827,10 @@ module Expressir
|
|
817
827
|
ref = visit_if(ctx__type_ref)
|
818
828
|
attribute = visit_if(ctx__enumeration_ref)
|
819
829
|
|
820
|
-
Model::
|
830
|
+
Model::References::AttributeReference.new(
|
821
831
|
ref: ref,
|
822
832
|
attribute: attribute
|
823
|
-
|
833
|
+
)
|
824
834
|
else
|
825
835
|
visit_if(ctx__enumeration_ref)
|
826
836
|
end
|
@@ -837,11 +847,11 @@ module Expressir
|
|
837
847
|
based_on = visit_if(ctx__enumeration_extension__type_ref)
|
838
848
|
items = visit_if(ctx__enumeration_items || ctx__enumeration_extension__enumeration_items, [])
|
839
849
|
|
840
|
-
Model::
|
850
|
+
Model::DataTypes::Enumeration.new(
|
841
851
|
extensible: extensible,
|
842
852
|
based_on: based_on,
|
843
853
|
items: items
|
844
|
-
|
854
|
+
)
|
845
855
|
end
|
846
856
|
|
847
857
|
def visit_escape_stmt(ctx)
|
@@ -858,13 +868,13 @@ module Expressir
|
|
858
868
|
type = visit_if(ctx__parameter_type)
|
859
869
|
|
860
870
|
attributes.map do |attribute|
|
861
|
-
Model::Attribute.new(
|
871
|
+
Model::Declarations::Attribute.new(
|
862
872
|
id: attribute.id, # reuse
|
863
|
-
kind: Model::Attribute::EXPLICIT,
|
873
|
+
kind: Model::Declarations::Attribute::EXPLICIT,
|
864
874
|
supertype_attribute: attribute.supertype_attribute, # reuse
|
865
875
|
optional: optional,
|
866
876
|
type: type
|
867
|
-
|
877
|
+
)
|
868
878
|
end
|
869
879
|
end
|
870
880
|
|
@@ -877,11 +887,11 @@ module Expressir
|
|
877
887
|
operand1 = visit_if(ctx__simple_expression[0])
|
878
888
|
operand2 = visit_if(ctx__simple_expression[1])
|
879
889
|
|
880
|
-
Model::Expressions::BinaryExpression.new(
|
890
|
+
Model::Expressions::BinaryExpression.new(
|
881
891
|
operator: operator,
|
882
892
|
operand1: operand1,
|
883
893
|
operand2: operand2
|
884
|
-
|
894
|
+
)
|
885
895
|
else
|
886
896
|
visit_if(ctx__simple_expression[0])
|
887
897
|
end
|
@@ -895,11 +905,11 @@ module Expressir
|
|
895
905
|
operand1 = visit(ctx__simple_factor[0])
|
896
906
|
operand2 = visit(ctx__simple_factor[1])
|
897
907
|
|
898
|
-
Model::Expressions::BinaryExpression.new(
|
908
|
+
Model::Expressions::BinaryExpression.new(
|
899
909
|
operator: operator,
|
900
910
|
operand1: operand1,
|
901
911
|
operand2: operand2
|
902
|
-
|
912
|
+
)
|
903
913
|
elsif ctx__simple_factor.length == 1
|
904
914
|
visit_if(ctx__simple_factor[0])
|
905
915
|
else
|
@@ -915,10 +925,10 @@ module Expressir
|
|
915
925
|
type = visit_if(ctx__parameter_type)
|
916
926
|
|
917
927
|
ids.map do |id|
|
918
|
-
Model::Parameter.new(
|
928
|
+
Model::Declarations::Parameter.new(
|
919
929
|
id: id,
|
920
930
|
type: type
|
921
|
-
|
931
|
+
)
|
922
932
|
end
|
923
933
|
end
|
924
934
|
|
@@ -927,13 +937,13 @@ module Expressir
|
|
927
937
|
ctx__function_ref = ctx.function_ref
|
928
938
|
ctx__actual_parameter_list = ctx.actual_parameter_list
|
929
939
|
|
930
|
-
|
940
|
+
function = visit_if(ctx__built_in_function || ctx__function_ref)
|
931
941
|
parameters = visit_if(ctx__actual_parameter_list, [])
|
932
942
|
|
933
|
-
Model::Expressions::
|
934
|
-
|
943
|
+
Model::Expressions::FunctionCall.new(
|
944
|
+
function: function,
|
935
945
|
parameters: parameters
|
936
|
-
|
946
|
+
)
|
937
947
|
end
|
938
948
|
|
939
949
|
def visit_function_decl(ctx)
|
@@ -951,16 +961,16 @@ module Expressir
|
|
951
961
|
parameters = visit_if_map_flatten(ctx__function_head__formal_parameter)
|
952
962
|
return_type = visit_if(ctx__function_head__parameter_type)
|
953
963
|
declarations = visit_if_map(ctx__algorithm_head__declaration)
|
954
|
-
types = declarations.select{|x| x.is_a? Model::Type}
|
955
|
-
entities = declarations.select{|x| x.is_a? Model::Entity}
|
956
|
-
subtype_constraints = declarations.select{|x| x.is_a? Model::SubtypeConstraint}
|
957
|
-
functions = declarations.select{|x| x.is_a? Model::Function}
|
958
|
-
procedures = declarations.select{|x| x.is_a? Model::Procedure}
|
964
|
+
types = declarations.select{|x| x.is_a? Model::Declarations::Type}
|
965
|
+
entities = declarations.select{|x| x.is_a? Model::Declarations::Entity}
|
966
|
+
subtype_constraints = declarations.select{|x| x.is_a? Model::Declarations::SubtypeConstraint}
|
967
|
+
functions = declarations.select{|x| x.is_a? Model::Declarations::Function}
|
968
|
+
procedures = declarations.select{|x| x.is_a? Model::Declarations::Procedure}
|
959
969
|
constants = visit_if(ctx__algorithm_head__constant_decl, [])
|
960
970
|
variables = visit_if(ctx__algorithm_head__local_decl, [])
|
961
971
|
statements = visit_if_map(ctx__stmt)
|
962
972
|
|
963
|
-
Model::Function.new(
|
973
|
+
Model::Declarations::Function.new(
|
964
974
|
id: id,
|
965
975
|
parameters: parameters,
|
966
976
|
return_type: return_type,
|
@@ -972,7 +982,7 @@ module Expressir
|
|
972
982
|
constants: constants,
|
973
983
|
variables: variables,
|
974
984
|
statements: statements
|
975
|
-
|
985
|
+
)
|
976
986
|
end
|
977
987
|
|
978
988
|
def visit_function_head(ctx)
|
@@ -1017,13 +1027,13 @@ module Expressir
|
|
1017
1027
|
unique = ctx__UNIQUE && true
|
1018
1028
|
base_type = visit_if(ctx__parameter_type)
|
1019
1029
|
|
1020
|
-
Model::
|
1030
|
+
Model::DataTypes::Array.new(
|
1021
1031
|
bound1: bound1,
|
1022
1032
|
bound2: bound2,
|
1023
1033
|
optional: optional,
|
1024
1034
|
unique: unique,
|
1025
1035
|
base_type: base_type
|
1026
|
-
|
1036
|
+
)
|
1027
1037
|
end
|
1028
1038
|
|
1029
1039
|
def visit_general_bag_type(ctx)
|
@@ -1036,11 +1046,11 @@ module Expressir
|
|
1036
1046
|
bound2 = visit_if(ctx__bound_spec__bound2)
|
1037
1047
|
base_type = visit_if(ctx__parameter_type)
|
1038
1048
|
|
1039
|
-
Model::
|
1049
|
+
Model::DataTypes::Bag.new(
|
1040
1050
|
bound1: bound1,
|
1041
1051
|
bound2: bound2,
|
1042
1052
|
base_type: base_type
|
1043
|
-
|
1053
|
+
)
|
1044
1054
|
end
|
1045
1055
|
|
1046
1056
|
def visit_general_list_type(ctx)
|
@@ -1055,12 +1065,12 @@ module Expressir
|
|
1055
1065
|
unique = ctx__UNIQUE && true
|
1056
1066
|
base_type = visit_if(ctx__parameter_type)
|
1057
1067
|
|
1058
|
-
Model::
|
1068
|
+
Model::DataTypes::List.new(
|
1059
1069
|
bound1: bound1,
|
1060
1070
|
bound2: bound2,
|
1061
1071
|
unique: unique,
|
1062
1072
|
base_type: base_type
|
1063
|
-
|
1073
|
+
)
|
1064
1074
|
end
|
1065
1075
|
|
1066
1076
|
def visit_general_ref(ctx)
|
@@ -1080,11 +1090,11 @@ module Expressir
|
|
1080
1090
|
bound2 = visit_if(ctx__bound_spec__bound2)
|
1081
1091
|
base_type = visit_if(ctx__parameter_type)
|
1082
1092
|
|
1083
|
-
Model::
|
1093
|
+
Model::DataTypes::Set.new(
|
1084
1094
|
bound1: bound1,
|
1085
1095
|
bound2: bound2,
|
1086
1096
|
base_type: base_type
|
1087
|
-
|
1097
|
+
)
|
1088
1098
|
end
|
1089
1099
|
|
1090
1100
|
def visit_generic_entity_type(ctx)
|
@@ -1092,9 +1102,9 @@ module Expressir
|
|
1092
1102
|
|
1093
1103
|
id = visit_if(ctx__type_label)
|
1094
1104
|
|
1095
|
-
Model::
|
1105
|
+
Model::DataTypes::GenericEntity.new(
|
1096
1106
|
id: id
|
1097
|
-
|
1107
|
+
)
|
1098
1108
|
end
|
1099
1109
|
|
1100
1110
|
def visit_generic_type(ctx)
|
@@ -1102,9 +1112,9 @@ module Expressir
|
|
1102
1112
|
|
1103
1113
|
id = visit_if(ctx__type_label)
|
1104
1114
|
|
1105
|
-
Model::
|
1115
|
+
Model::DataTypes::Generic.new(
|
1106
1116
|
id: id
|
1107
|
-
|
1117
|
+
)
|
1108
1118
|
end
|
1109
1119
|
|
1110
1120
|
def visit_group_qualifier(ctx)
|
@@ -1112,9 +1122,9 @@ module Expressir
|
|
1112
1122
|
|
1113
1123
|
entity = visit_if(ctx__entity_ref)
|
1114
1124
|
|
1115
|
-
Model::
|
1125
|
+
Model::References::GroupReference.new(
|
1116
1126
|
entity: entity
|
1117
|
-
|
1127
|
+
)
|
1118
1128
|
end
|
1119
1129
|
|
1120
1130
|
def visit_group_reference(ctx)
|
@@ -1130,11 +1140,11 @@ module Expressir
|
|
1130
1140
|
statements = visit_if(ctx__if_stmt_statements, [])
|
1131
1141
|
else_statements = visit_if(ctx__if_stmt_else_statements, [])
|
1132
1142
|
|
1133
|
-
Model::Statements::If.new(
|
1143
|
+
Model::Statements::If.new(
|
1134
1144
|
expression: expression,
|
1135
1145
|
statements: statements,
|
1136
1146
|
else_statements: else_statements
|
1137
|
-
|
1147
|
+
)
|
1138
1148
|
end
|
1139
1149
|
|
1140
1150
|
def visit_if_stmt_statements(ctx)
|
@@ -1184,10 +1194,10 @@ module Expressir
|
|
1184
1194
|
index1 = visit_if(ctx__index1)
|
1185
1195
|
index2 = visit_if(ctx__index2)
|
1186
1196
|
|
1187
|
-
Model::
|
1197
|
+
Model::References::IndexReference.new(
|
1188
1198
|
index1: index1,
|
1189
1199
|
index2: index2
|
1190
|
-
|
1200
|
+
)
|
1191
1201
|
end
|
1192
1202
|
|
1193
1203
|
def visit_index_reference(ctx)
|
@@ -1202,7 +1212,7 @@ module Expressir
|
|
1202
1212
|
end
|
1203
1213
|
|
1204
1214
|
def visit_integer_type(ctx)
|
1205
|
-
Model::
|
1215
|
+
Model::DataTypes::Integer.new
|
1206
1216
|
end
|
1207
1217
|
|
1208
1218
|
def visit_interface_specification(ctx)
|
@@ -1224,13 +1234,13 @@ module Expressir
|
|
1224
1234
|
operator2 = visit_if(ctx__interval_op[1])
|
1225
1235
|
high = visit_if(ctx__interval_high)
|
1226
1236
|
|
1227
|
-
Model::Expressions::Interval.new(
|
1237
|
+
Model::Expressions::Interval.new(
|
1228
1238
|
low: low,
|
1229
1239
|
operator1: operator1,
|
1230
1240
|
item: item,
|
1231
1241
|
operator2: operator2,
|
1232
1242
|
high: high
|
1233
|
-
|
1243
|
+
)
|
1234
1244
|
end
|
1235
1245
|
|
1236
1246
|
def visit_interval_high(ctx)
|
@@ -1257,9 +1267,9 @@ module Expressir
|
|
1257
1267
|
ctx__LESS_THAN_OR_EQUAL = ctx__text == '<='
|
1258
1268
|
|
1259
1269
|
if ctx__LESS_THAN
|
1260
|
-
Model::Expressions::
|
1270
|
+
Model::Expressions::Interval::LESS_THAN
|
1261
1271
|
elsif ctx__LESS_THAN_OR_EQUAL
|
1262
|
-
Model::Expressions::
|
1272
|
+
Model::Expressions::Interval::LESS_THAN_OR_EQUAL
|
1263
1273
|
else
|
1264
1274
|
raise 'Invalid state'
|
1265
1275
|
end
|
@@ -1277,21 +1287,21 @@ module Expressir
|
|
1277
1287
|
ref = visit(ctx__entity_ref)
|
1278
1288
|
attribute_ref = visit(ctx__attribute_ref)
|
1279
1289
|
|
1280
|
-
Model::
|
1290
|
+
Model::References::AttributeReference.new(
|
1281
1291
|
ref: ref,
|
1282
1292
|
attribute: attribute_ref
|
1283
|
-
|
1293
|
+
)
|
1284
1294
|
else
|
1285
1295
|
visit(ctx__attribute_ref)
|
1286
1296
|
end
|
1287
1297
|
|
1288
|
-
Model::Attribute.new(
|
1298
|
+
Model::Declarations::Attribute.new(
|
1289
1299
|
id: attribute.id, # reuse
|
1290
|
-
kind: Model::Attribute::INVERSE,
|
1300
|
+
kind: Model::Declarations::Attribute::INVERSE,
|
1291
1301
|
supertype_attribute: attribute.supertype_attribute, # reuse
|
1292
1302
|
type: type,
|
1293
1303
|
expression: expression
|
1294
|
-
|
1304
|
+
)
|
1295
1305
|
end
|
1296
1306
|
|
1297
1307
|
def visit_inverse_attr_type(ctx)
|
@@ -1307,21 +1317,21 @@ module Expressir
|
|
1307
1317
|
bound2 = visit_if(ctx__bound_spec__bound2)
|
1308
1318
|
base_type = visit_if(ctx__entity_ref)
|
1309
1319
|
|
1310
|
-
Model::
|
1320
|
+
Model::DataTypes::Set.new(
|
1311
1321
|
bound1: bound1,
|
1312
1322
|
bound2: bound2,
|
1313
1323
|
base_type: base_type
|
1314
|
-
|
1324
|
+
)
|
1315
1325
|
elsif ctx__BAG
|
1316
1326
|
bound1 = visit_if(ctx__bound_spec__bound1)
|
1317
1327
|
bound2 = visit_if(ctx__bound_spec__bound2)
|
1318
1328
|
base_type = visit_if(ctx__entity_ref)
|
1319
1329
|
|
1320
|
-
Model::
|
1330
|
+
Model::DataTypes::Bag.new(
|
1321
1331
|
bound1: bound1,
|
1322
1332
|
bound2: bound2,
|
1323
1333
|
base_type: base_type
|
1324
|
-
|
1334
|
+
)
|
1325
1335
|
else
|
1326
1336
|
visit_if(ctx__entity_ref)
|
1327
1337
|
end
|
@@ -1345,12 +1355,12 @@ module Expressir
|
|
1345
1355
|
unique = ctx__UNIQUE && true
|
1346
1356
|
base_type = visit_if(ctx__instantiable_type)
|
1347
1357
|
|
1348
|
-
Model::
|
1358
|
+
Model::DataTypes::List.new(
|
1349
1359
|
bound1: bound1,
|
1350
1360
|
bound2: bound2,
|
1351
1361
|
unique: unique,
|
1352
1362
|
base_type: base_type
|
1353
|
-
|
1363
|
+
)
|
1354
1364
|
end
|
1355
1365
|
|
1356
1366
|
def visit_literal(ctx)
|
@@ -1391,11 +1401,11 @@ module Expressir
|
|
1391
1401
|
expression = visit_if(ctx__expression)
|
1392
1402
|
|
1393
1403
|
ids.map do |id|
|
1394
|
-
Model::Variable.new(
|
1404
|
+
Model::Declarations::Variable.new(
|
1395
1405
|
id: id,
|
1396
1406
|
type: type,
|
1397
1407
|
expression: expression
|
1398
|
-
|
1408
|
+
)
|
1399
1409
|
end
|
1400
1410
|
end
|
1401
1411
|
|
@@ -1420,13 +1430,13 @@ module Expressir
|
|
1420
1430
|
raise 'Invalid state'
|
1421
1431
|
end
|
1422
1432
|
|
1423
|
-
Model::Literals::Logical.new(
|
1433
|
+
Model::Literals::Logical.new(
|
1424
1434
|
value: value
|
1425
|
-
|
1435
|
+
)
|
1426
1436
|
end
|
1427
1437
|
|
1428
1438
|
def visit_logical_type(ctx)
|
1429
|
-
Model::
|
1439
|
+
Model::DataTypes::Logical.new
|
1430
1440
|
end
|
1431
1441
|
|
1432
1442
|
def visit_multiplication_like_op(ctx)
|
@@ -1470,10 +1480,10 @@ module Expressir
|
|
1470
1480
|
ref = visit_if(ctx__named_types)
|
1471
1481
|
id = visit_if(ctx__entity_id || ctx__type_id)
|
1472
1482
|
|
1473
|
-
Model::InterfaceItem.new(
|
1483
|
+
Model::Declarations::InterfaceItem.new(
|
1474
1484
|
ref: ref,
|
1475
1485
|
id: id
|
1476
|
-
|
1486
|
+
)
|
1477
1487
|
end
|
1478
1488
|
|
1479
1489
|
def visit_null_stmt(ctx)
|
@@ -1481,7 +1491,7 @@ module Expressir
|
|
1481
1491
|
end
|
1482
1492
|
|
1483
1493
|
def visit_number_type(ctx)
|
1484
|
-
Model::
|
1494
|
+
Model::DataTypes::Number.new
|
1485
1495
|
end
|
1486
1496
|
|
1487
1497
|
def visit_numeric_expression(ctx)
|
@@ -1493,13 +1503,11 @@ module Expressir
|
|
1493
1503
|
def visit_one_of(ctx)
|
1494
1504
|
ctx__supertype_expression = ctx.supertype_expression
|
1495
1505
|
|
1496
|
-
|
1497
|
-
parameters = visit_if_map(ctx__supertype_expression)
|
1506
|
+
operands = visit_if_map(ctx__supertype_expression)
|
1498
1507
|
|
1499
|
-
Model::
|
1500
|
-
|
1501
|
-
|
1502
|
-
})
|
1508
|
+
Model::SupertypeExpressions::OneofSupertypeExpression.new(
|
1509
|
+
operands: operands
|
1510
|
+
)
|
1503
1511
|
end
|
1504
1512
|
|
1505
1513
|
def visit_parameter(ctx)
|
@@ -1553,13 +1561,13 @@ module Expressir
|
|
1553
1561
|
ctx__procedure_ref = ctx.procedure_ref
|
1554
1562
|
ctx__actual_parameter_list = ctx.actual_parameter_list
|
1555
1563
|
|
1556
|
-
|
1564
|
+
procedure = visit_if(ctx__built_in_procedure || ctx__procedure_ref)
|
1557
1565
|
parameters = visit_if(ctx__actual_parameter_list, [])
|
1558
1566
|
|
1559
|
-
Model::Statements::
|
1560
|
-
|
1567
|
+
Model::Statements::ProcedureCall.new(
|
1568
|
+
procedure: procedure,
|
1561
1569
|
parameters: parameters
|
1562
|
-
|
1570
|
+
)
|
1563
1571
|
end
|
1564
1572
|
|
1565
1573
|
def visit_procedure_decl(ctx)
|
@@ -1575,16 +1583,16 @@ module Expressir
|
|
1575
1583
|
id = visit_if(ctx__procedure_head__procedure_id)
|
1576
1584
|
parameters = visit_if_map_flatten(ctx__procedure_head__procedure_head_parameter)
|
1577
1585
|
declarations = visit_if_map(ctx__algorithm_head__declaration)
|
1578
|
-
types = declarations.select{|x| x.is_a? Model::Type}
|
1579
|
-
entities = declarations.select{|x| x.is_a? Model::Entity}
|
1580
|
-
subtype_constraints = declarations.select{|x| x.is_a? Model::SubtypeConstraint}
|
1581
|
-
functions = declarations.select{|x| x.is_a? Model::Function}
|
1582
|
-
procedures = declarations.select{|x| x.is_a? Model::Procedure}
|
1586
|
+
types = declarations.select{|x| x.is_a? Model::Declarations::Type}
|
1587
|
+
entities = declarations.select{|x| x.is_a? Model::Declarations::Entity}
|
1588
|
+
subtype_constraints = declarations.select{|x| x.is_a? Model::Declarations::SubtypeConstraint}
|
1589
|
+
functions = declarations.select{|x| x.is_a? Model::Declarations::Function}
|
1590
|
+
procedures = declarations.select{|x| x.is_a? Model::Declarations::Procedure}
|
1583
1591
|
constants = visit_if(ctx__algorithm_head__constant_decl, [])
|
1584
1592
|
variables = visit_if(ctx__algorithm_head__local_decl, [])
|
1585
1593
|
statements = visit_if_map(ctx__stmt)
|
1586
1594
|
|
1587
|
-
Model::Procedure.new(
|
1595
|
+
Model::Declarations::Procedure.new(
|
1588
1596
|
id: id,
|
1589
1597
|
parameters: parameters,
|
1590
1598
|
types: types,
|
@@ -1595,7 +1603,7 @@ module Expressir
|
|
1595
1603
|
constants: constants,
|
1596
1604
|
variables: variables,
|
1597
1605
|
statements: statements
|
1598
|
-
|
1606
|
+
)
|
1599
1607
|
end
|
1600
1608
|
|
1601
1609
|
def visit_procedure_head(ctx)
|
@@ -1610,11 +1618,11 @@ module Expressir
|
|
1610
1618
|
|
1611
1619
|
if ctx.VAR
|
1612
1620
|
parameters.map do |parameter|
|
1613
|
-
Model::Parameter.new(
|
1621
|
+
Model::Declarations::Parameter.new(
|
1614
1622
|
id: parameter.id,
|
1615
1623
|
var: true,
|
1616
1624
|
type: parameter.type
|
1617
|
-
|
1625
|
+
)
|
1618
1626
|
end
|
1619
1627
|
else
|
1620
1628
|
parameters
|
@@ -1645,15 +1653,15 @@ module Expressir
|
|
1645
1653
|
group_reference = visit_if(ctx__group_qualifier)
|
1646
1654
|
attribute_reference = visit_if(ctx__attribute_qualifier)
|
1647
1655
|
|
1648
|
-
Model::
|
1649
|
-
ref: Model::
|
1650
|
-
ref: Model::
|
1656
|
+
Model::References::AttributeReference.new(
|
1657
|
+
ref: Model::References::GroupReference.new(
|
1658
|
+
ref: Model::References::SimpleReference.new(
|
1651
1659
|
id: id
|
1652
|
-
|
1660
|
+
),
|
1653
1661
|
entity: group_reference.entity # reuse
|
1654
|
-
|
1662
|
+
),
|
1655
1663
|
attribute: attribute_reference.attribute # reuse
|
1656
|
-
|
1664
|
+
)
|
1657
1665
|
end
|
1658
1666
|
|
1659
1667
|
def visit_qualifier(ctx)
|
@@ -1673,11 +1681,11 @@ module Expressir
|
|
1673
1681
|
aggregate_source = visit_if(ctx__aggregate_source)
|
1674
1682
|
expression = visit_if(ctx__logical_expression)
|
1675
1683
|
|
1676
|
-
Model::Expressions::QueryExpression.new(
|
1684
|
+
Model::Expressions::QueryExpression.new(
|
1677
1685
|
id: id,
|
1678
1686
|
aggregate_source: aggregate_source,
|
1679
1687
|
expression: expression
|
1680
|
-
|
1688
|
+
)
|
1681
1689
|
end
|
1682
1690
|
|
1683
1691
|
def visit_real_type(ctx)
|
@@ -1685,9 +1693,9 @@ module Expressir
|
|
1685
1693
|
|
1686
1694
|
precision = visit_if(ctx__precision_spec)
|
1687
1695
|
|
1688
|
-
Model::
|
1696
|
+
Model::DataTypes::Real.new(
|
1689
1697
|
precision: precision
|
1690
|
-
|
1698
|
+
)
|
1691
1699
|
end
|
1692
1700
|
|
1693
1701
|
def visit_redeclared_attribute(ctx)
|
@@ -1708,11 +1716,11 @@ module Expressir
|
|
1708
1716
|
schema = visit_if(ctx__schema_ref)
|
1709
1717
|
items = visit_if_map(ctx__resource_or_rename)
|
1710
1718
|
|
1711
|
-
Model::Interface.new(
|
1712
|
-
kind: Model::Interface::REFERENCE,
|
1719
|
+
Model::Declarations::Interface.new(
|
1720
|
+
kind: Model::Declarations::Interface::REFERENCE,
|
1713
1721
|
schema: schema,
|
1714
1722
|
items: items
|
1715
|
-
|
1723
|
+
)
|
1716
1724
|
end
|
1717
1725
|
|
1718
1726
|
def visit_rel_op(ctx)
|
@@ -1796,7 +1804,7 @@ module Expressir
|
|
1796
1804
|
until_expression = visit_if(ctx__repeat_control__until_control)
|
1797
1805
|
statements = visit_if_map(ctx__stmt)
|
1798
1806
|
|
1799
|
-
Model::Statements::Repeat.new(
|
1807
|
+
Model::Statements::Repeat.new(
|
1800
1808
|
id: id,
|
1801
1809
|
bound1: bound1,
|
1802
1810
|
bound2: bound2,
|
@@ -1804,7 +1812,7 @@ module Expressir
|
|
1804
1812
|
while_expression: while_expression,
|
1805
1813
|
until_expression: until_expression,
|
1806
1814
|
statements: statements
|
1807
|
-
|
1815
|
+
)
|
1808
1816
|
end
|
1809
1817
|
|
1810
1818
|
def visit_repetition(ctx)
|
@@ -1820,10 +1828,10 @@ module Expressir
|
|
1820
1828
|
ref = visit_if(ctx__resource_ref)
|
1821
1829
|
id = visit_if(ctx__rename_id)
|
1822
1830
|
|
1823
|
-
Model::InterfaceItem.new(
|
1831
|
+
Model::Declarations::InterfaceItem.new(
|
1824
1832
|
ref: ref,
|
1825
1833
|
id: id
|
1826
|
-
|
1834
|
+
)
|
1827
1835
|
end
|
1828
1836
|
|
1829
1837
|
def visit_resource_ref(ctx)
|
@@ -1841,9 +1849,9 @@ module Expressir
|
|
1841
1849
|
|
1842
1850
|
expression = visit_if(ctx__expression)
|
1843
1851
|
|
1844
|
-
Model::Statements::Return.new(
|
1852
|
+
Model::Statements::Return.new(
|
1845
1853
|
expression: expression
|
1846
|
-
|
1854
|
+
)
|
1847
1855
|
end
|
1848
1856
|
|
1849
1857
|
def visit_rule_decl(ctx)
|
@@ -1860,17 +1868,17 @@ module Expressir
|
|
1860
1868
|
id = visit_if(ctx__rule_head__rule_id)
|
1861
1869
|
applies_to = visit_if_map(ctx__rule_head__entity_ref)
|
1862
1870
|
declarations = visit_if_map(ctx__algorithm_head__declaration)
|
1863
|
-
types = declarations.select{|x| x.is_a? Model::Type}
|
1864
|
-
entities = declarations.select{|x| x.is_a? Model::Entity}
|
1865
|
-
subtype_constraints = declarations.select{|x| x.is_a? Model::SubtypeConstraint}
|
1866
|
-
functions = declarations.select{|x| x.is_a? Model::Function}
|
1867
|
-
procedures = declarations.select{|x| x.is_a? Model::Procedure}
|
1871
|
+
types = declarations.select{|x| x.is_a? Model::Declarations::Type}
|
1872
|
+
entities = declarations.select{|x| x.is_a? Model::Declarations::Entity}
|
1873
|
+
subtype_constraints = declarations.select{|x| x.is_a? Model::Declarations::SubtypeConstraint}
|
1874
|
+
functions = declarations.select{|x| x.is_a? Model::Declarations::Function}
|
1875
|
+
procedures = declarations.select{|x| x.is_a? Model::Declarations::Procedure}
|
1868
1876
|
constants = visit_if(ctx__algorithm_head__constant_decl, [])
|
1869
1877
|
variables = visit_if(ctx__algorithm_head__local_decl, [])
|
1870
1878
|
statements = visit_if_map(ctx__stmt)
|
1871
1879
|
where_rules = visit_if(ctx__where_clause, [])
|
1872
1880
|
|
1873
|
-
Model::Rule.new(
|
1881
|
+
Model::Declarations::Rule.new(
|
1874
1882
|
id: id,
|
1875
1883
|
applies_to: applies_to,
|
1876
1884
|
types: types,
|
@@ -1882,7 +1890,7 @@ module Expressir
|
|
1882
1890
|
variables: variables,
|
1883
1891
|
statements: statements,
|
1884
1892
|
where_rules: where_rules
|
1885
|
-
|
1893
|
+
)
|
1886
1894
|
end
|
1887
1895
|
|
1888
1896
|
def visit_rule_head(ctx)
|
@@ -1925,14 +1933,14 @@ module Expressir
|
|
1925
1933
|
interfaces = visit_if_map(ctx__schema_body__interface_specification)
|
1926
1934
|
constants = visit_if(ctx__schema_body__constant_decl, [])
|
1927
1935
|
declarations = visit_if_map(ctx__schema_body__schema_body_declaration)
|
1928
|
-
types = declarations.select{|x| x.is_a? Model::Type}
|
1929
|
-
entities = declarations.select{|x| x.is_a? Model::Entity}
|
1930
|
-
subtype_constraints = declarations.select{|x| x.is_a? Model::SubtypeConstraint}
|
1931
|
-
functions = declarations.select{|x| x.is_a? Model::Function}
|
1932
|
-
rules = declarations.select{|x| x.is_a? Model::Rule}
|
1933
|
-
procedures = declarations.select{|x| x.is_a? Model::Procedure}
|
1934
|
-
|
1935
|
-
Model::Schema.new(
|
1936
|
+
types = declarations.select{|x| x.is_a? Model::Declarations::Type}
|
1937
|
+
entities = declarations.select{|x| x.is_a? Model::Declarations::Entity}
|
1938
|
+
subtype_constraints = declarations.select{|x| x.is_a? Model::Declarations::SubtypeConstraint}
|
1939
|
+
functions = declarations.select{|x| x.is_a? Model::Declarations::Function}
|
1940
|
+
rules = declarations.select{|x| x.is_a? Model::Declarations::Rule}
|
1941
|
+
procedures = declarations.select{|x| x.is_a? Model::Declarations::Procedure}
|
1942
|
+
|
1943
|
+
Model::Declarations::Schema.new(
|
1936
1944
|
id: id,
|
1937
1945
|
version: version,
|
1938
1946
|
interfaces: interfaces,
|
@@ -1943,7 +1951,7 @@ module Expressir
|
|
1943
1951
|
functions: functions,
|
1944
1952
|
rules: rules,
|
1945
1953
|
procedures: procedures
|
1946
|
-
|
1954
|
+
)
|
1947
1955
|
end
|
1948
1956
|
|
1949
1957
|
def visit_schema_id(ctx)
|
@@ -1962,26 +1970,26 @@ module Expressir
|
|
1962
1970
|
parts = value.sub(/^\{/, '').sub(/\}$/, '').split(' ')
|
1963
1971
|
parts.map do |part|
|
1964
1972
|
if match = part.match(/^(.+)\((\d+)\)$/)
|
1965
|
-
Model::SchemaVersionItem.new(
|
1973
|
+
Model::Declarations::SchemaVersionItem.new(
|
1966
1974
|
name: match[1],
|
1967
1975
|
value: match[2]
|
1968
|
-
|
1976
|
+
)
|
1969
1977
|
elsif part.match(/^\d+$/)
|
1970
|
-
Model::SchemaVersionItem.new(
|
1978
|
+
Model::Declarations::SchemaVersionItem.new(
|
1971
1979
|
value: part
|
1972
|
-
|
1980
|
+
)
|
1973
1981
|
else
|
1974
|
-
Model::SchemaVersionItem.new(
|
1982
|
+
Model::Declarations::SchemaVersionItem.new(
|
1975
1983
|
name: part
|
1976
|
-
|
1984
|
+
)
|
1977
1985
|
end
|
1978
1986
|
end
|
1979
1987
|
end
|
1980
1988
|
|
1981
|
-
Model::SchemaVersion.new(
|
1989
|
+
Model::Declarations::SchemaVersion.new(
|
1982
1990
|
value: value,
|
1983
1991
|
items: items
|
1984
|
-
|
1992
|
+
)
|
1985
1993
|
end
|
1986
1994
|
|
1987
1995
|
def visit_selector(ctx)
|
@@ -2013,12 +2021,12 @@ module Expressir
|
|
2013
2021
|
based_on = visit_if(ctx__select_extension__type_ref)
|
2014
2022
|
items = visit_if(ctx__select_list || ctx__select_extension__select_list, [])
|
2015
2023
|
|
2016
|
-
Model::
|
2024
|
+
Model::DataTypes::Select.new(
|
2017
2025
|
extensible: extensible,
|
2018
2026
|
generic_entity: generic_entity,
|
2019
2027
|
based_on: based_on,
|
2020
2028
|
items: items
|
2021
|
-
|
2029
|
+
)
|
2022
2030
|
end
|
2023
2031
|
|
2024
2032
|
def visit_set_type(ctx)
|
@@ -2031,11 +2039,11 @@ module Expressir
|
|
2031
2039
|
bound2 = visit_if(ctx__bound_spec__bound2)
|
2032
2040
|
base_type = visit_if(ctx__instantiable_type)
|
2033
2041
|
|
2034
|
-
Model::
|
2042
|
+
Model::DataTypes::Set.new(
|
2035
2043
|
bound1: bound1,
|
2036
2044
|
bound2: bound2,
|
2037
2045
|
base_type: base_type
|
2038
|
-
|
2046
|
+
)
|
2039
2047
|
end
|
2040
2048
|
|
2041
2049
|
def visit_simple_expression(ctx)
|
@@ -2086,10 +2094,10 @@ module Expressir
|
|
2086
2094
|
operator = visit_if(ctx__unary_op)
|
2087
2095
|
operand = visit_if(ctx__simple_factor_expression)
|
2088
2096
|
|
2089
|
-
Model::Expressions::UnaryExpression.new(
|
2097
|
+
Model::Expressions::UnaryExpression.new(
|
2090
2098
|
operator: operator,
|
2091
2099
|
operand: operand
|
2092
|
-
|
2100
|
+
)
|
2093
2101
|
end
|
2094
2102
|
|
2095
2103
|
def visit_simple_types(ctx)
|
@@ -2145,10 +2153,10 @@ module Expressir
|
|
2145
2153
|
width = visit_if(ctx__width_spec__width)
|
2146
2154
|
fixed = ctx__width_spec__FIXED && true
|
2147
2155
|
|
2148
|
-
Model::
|
2156
|
+
Model::DataTypes::String.new(
|
2149
2157
|
width: width,
|
2150
2158
|
fixed: fixed
|
2151
|
-
|
2159
|
+
)
|
2152
2160
|
end
|
2153
2161
|
|
2154
2162
|
def visit_subsuper(ctx)
|
@@ -2180,13 +2188,13 @@ module Expressir
|
|
2180
2188
|
total_over = visit_if(ctx__subtype_constraint_body__total_over, [])
|
2181
2189
|
supertype_expression = visit_if(ctx__subtype_constraint_body__supertype_expression)
|
2182
2190
|
|
2183
|
-
Model::SubtypeConstraint.new(
|
2191
|
+
Model::Declarations::SubtypeConstraint.new(
|
2184
2192
|
id: id,
|
2185
2193
|
applies_to: applies_to,
|
2186
2194
|
abstract: abstract,
|
2187
2195
|
total_over: total_over,
|
2188
2196
|
supertype_expression: supertype_expression
|
2189
|
-
|
2197
|
+
)
|
2190
2198
|
end
|
2191
2199
|
|
2192
2200
|
def visit_subtype_constraint_head(ctx)
|
@@ -2217,9 +2225,9 @@ module Expressir
|
|
2217
2225
|
if ctx__supertype_factor.length >= 2
|
2218
2226
|
if ctx__ANDOR and ctx__ANDOR.length == ctx__supertype_factor.length - 1
|
2219
2227
|
operands = ctx__supertype_factor.map(&self.method(:visit))
|
2220
|
-
operators = ctx__ANDOR.map{Model::
|
2228
|
+
operators = ctx__ANDOR.map{Model::SupertypeExpressions::BinarySupertypeExpression::ANDOR}
|
2221
2229
|
|
2222
|
-
|
2230
|
+
handle_binary_supertype_expression(operands, operators)
|
2223
2231
|
else
|
2224
2232
|
raise 'Invalid state'
|
2225
2233
|
end
|
@@ -2239,9 +2247,9 @@ module Expressir
|
|
2239
2247
|
if ctx__supertype_term.length >= 2
|
2240
2248
|
if ctx__AND and ctx__AND.length == ctx__supertype_term.length - 1
|
2241
2249
|
operands = ctx__supertype_term.map(&self.method(:visit))
|
2242
|
-
operators = ctx__AND.map{Model::
|
2250
|
+
operators = ctx__AND.map{Model::SupertypeExpressions::BinarySupertypeExpression::AND}
|
2243
2251
|
|
2244
|
-
|
2252
|
+
handle_binary_supertype_expression(operands, operators)
|
2245
2253
|
else
|
2246
2254
|
raise 'Invalid state'
|
2247
2255
|
end
|
@@ -2272,9 +2280,9 @@ module Expressir
|
|
2272
2280
|
|
2273
2281
|
schemas = visit_if_map(ctx__schema_decl)
|
2274
2282
|
|
2275
|
-
Model::Repository.new(
|
2283
|
+
Model::Repository.new(
|
2276
2284
|
schemas: schemas
|
2277
|
-
|
2285
|
+
)
|
2278
2286
|
end
|
2279
2287
|
|
2280
2288
|
def visit_term(ctx)
|
@@ -2314,11 +2322,11 @@ module Expressir
|
|
2314
2322
|
underlying_type = visit_if(ctx__underlying_type)
|
2315
2323
|
where_rules = visit_if(ctx__where_clause, [])
|
2316
2324
|
|
2317
|
-
Model::Type.new(
|
2325
|
+
Model::Declarations::Type.new(
|
2318
2326
|
id: id,
|
2319
2327
|
underlying_type: underlying_type,
|
2320
2328
|
where_rules: where_rules
|
2321
|
-
|
2329
|
+
)
|
2322
2330
|
end
|
2323
2331
|
|
2324
2332
|
def visit_type_id(ctx)
|
@@ -2377,10 +2385,10 @@ module Expressir
|
|
2377
2385
|
id = visit_if(ctx__rule_label_id)
|
2378
2386
|
attributes = visit_if_map(ctx__referenced_attribute)
|
2379
2387
|
|
2380
|
-
Model::UniqueRule.new(
|
2388
|
+
Model::Declarations::UniqueRule.new(
|
2381
2389
|
id: id,
|
2382
2390
|
attributes: attributes
|
2383
|
-
|
2391
|
+
)
|
2384
2392
|
end
|
2385
2393
|
|
2386
2394
|
def visit_until_control(ctx)
|
@@ -2396,11 +2404,11 @@ module Expressir
|
|
2396
2404
|
schema = visit_if(ctx__schema_ref)
|
2397
2405
|
items = visit_if_map(ctx__named_type_or_rename)
|
2398
2406
|
|
2399
|
-
Model::Interface.new(
|
2400
|
-
kind: Model::Interface::USE,
|
2407
|
+
Model::Declarations::Interface.new(
|
2408
|
+
kind: Model::Declarations::Interface::USE,
|
2401
2409
|
schema: schema,
|
2402
2410
|
items: items
|
2403
|
-
|
2411
|
+
)
|
2404
2412
|
end
|
2405
2413
|
|
2406
2414
|
def visit_variable_id(ctx)
|
@@ -2431,24 +2439,42 @@ module Expressir
|
|
2431
2439
|
raise 'Invalid state'
|
2432
2440
|
end
|
2433
2441
|
|
2434
|
-
private
|
2435
|
-
|
2436
2442
|
def handle_binary_expression(operands, operators)
|
2437
2443
|
if operands.length != operators.length + 1
|
2438
2444
|
raise 'Invalid state'
|
2439
2445
|
end
|
2440
2446
|
|
2441
|
-
expression = Model::Expressions::BinaryExpression.new(
|
2447
|
+
expression = Model::Expressions::BinaryExpression.new(
|
2448
|
+
operator: operators[0],
|
2449
|
+
operand1: operands[0],
|
2450
|
+
operand2: operands[1]
|
2451
|
+
)
|
2452
|
+
operators[1..(operators.length - 1)].each_with_index do |operator, i|
|
2453
|
+
expression = Model::Expressions::BinaryExpression.new(
|
2454
|
+
operator: operator,
|
2455
|
+
operand1: expression,
|
2456
|
+
operand2: operands[i + 2]
|
2457
|
+
)
|
2458
|
+
end
|
2459
|
+
expression
|
2460
|
+
end
|
2461
|
+
|
2462
|
+
def handle_binary_supertype_expression(operands, operators)
|
2463
|
+
if operands.length != operators.length + 1
|
2464
|
+
raise 'Invalid state'
|
2465
|
+
end
|
2466
|
+
|
2467
|
+
expression = Model::SupertypeExpressions::BinarySupertypeExpression.new(
|
2442
2468
|
operator: operators[0],
|
2443
2469
|
operand1: operands[0],
|
2444
2470
|
operand2: operands[1]
|
2445
|
-
|
2471
|
+
)
|
2446
2472
|
operators[1..(operators.length - 1)].each_with_index do |operator, i|
|
2447
|
-
expression = Model::
|
2473
|
+
expression = Model::SupertypeExpressions::BinarySupertypeExpression.new(
|
2448
2474
|
operator: operator,
|
2449
2475
|
operand1: expression,
|
2450
2476
|
operand2: operands[i + 2]
|
2451
|
-
|
2477
|
+
)
|
2452
2478
|
end
|
2453
2479
|
expression
|
2454
2480
|
end
|
@@ -2462,25 +2488,25 @@ module Expressir
|
|
2462
2488
|
if ctx__attribute_qualifier
|
2463
2489
|
attribute_reference = visit_if(ctx__attribute_qualifier)
|
2464
2490
|
|
2465
|
-
Model::
|
2491
|
+
Model::References::AttributeReference.new(
|
2466
2492
|
ref: ref,
|
2467
2493
|
attribute: attribute_reference.attribute
|
2468
|
-
|
2494
|
+
)
|
2469
2495
|
elsif ctx__group_qualifier
|
2470
2496
|
group_reference = visit_if(ctx__group_qualifier)
|
2471
2497
|
|
2472
|
-
Model::
|
2498
|
+
Model::References::GroupReference.new(
|
2473
2499
|
ref: ref,
|
2474
2500
|
entity: group_reference.entity
|
2475
|
-
|
2501
|
+
)
|
2476
2502
|
elsif ctx__index_qualifier
|
2477
2503
|
index_reference = visit_if(ctx__index_qualifier)
|
2478
2504
|
|
2479
|
-
Model::
|
2505
|
+
Model::References::IndexReference.new(
|
2480
2506
|
ref: ref,
|
2481
2507
|
index1: index_reference.index1,
|
2482
2508
|
index2: index_reference.index2
|
2483
|
-
|
2509
|
+
)
|
2484
2510
|
else
|
2485
2511
|
raise 'Invalid state'
|
2486
2512
|
end
|
@@ -2492,9 +2518,9 @@ module Expressir
|
|
2492
2518
|
|
2493
2519
|
value = ctx__text[1..(ctx__text.length - 1)]
|
2494
2520
|
|
2495
|
-
Model::Literals::Binary.new(
|
2521
|
+
Model::Literals::Binary.new(
|
2496
2522
|
value: value
|
2497
|
-
|
2523
|
+
)
|
2498
2524
|
end
|
2499
2525
|
|
2500
2526
|
def handle_integer_literal(ctx)
|
@@ -2502,9 +2528,9 @@ module Expressir
|
|
2502
2528
|
|
2503
2529
|
value = ctx__text
|
2504
2530
|
|
2505
|
-
Model::Literals::Integer.new(
|
2531
|
+
Model::Literals::Integer.new(
|
2506
2532
|
value: value
|
2507
|
-
|
2533
|
+
)
|
2508
2534
|
end
|
2509
2535
|
|
2510
2536
|
def handle_real_literal(ctx)
|
@@ -2512,9 +2538,9 @@ module Expressir
|
|
2512
2538
|
|
2513
2539
|
value = ctx__text
|
2514
2540
|
|
2515
|
-
Model::Literals::Real.new(
|
2541
|
+
Model::Literals::Real.new(
|
2516
2542
|
value: value
|
2517
|
-
|
2543
|
+
)
|
2518
2544
|
end
|
2519
2545
|
|
2520
2546
|
def handle_simple_id(ctx)
|
@@ -2528,9 +2554,9 @@ module Expressir
|
|
2528
2554
|
|
2529
2555
|
value = ctx__text[1..(ctx__text.length - 2)].force_encoding('UTF-8')
|
2530
2556
|
|
2531
|
-
Model::Literals::String.new(
|
2557
|
+
Model::Literals::String.new(
|
2532
2558
|
value: value
|
2533
|
-
|
2559
|
+
)
|
2534
2560
|
end
|
2535
2561
|
|
2536
2562
|
def handle_encoded_string_literal(ctx)
|
@@ -2538,10 +2564,10 @@ module Expressir
|
|
2538
2564
|
|
2539
2565
|
value = ctx__text[1..(ctx__text.length - 2)].force_encoding('UTF-8')
|
2540
2566
|
|
2541
|
-
Model::Literals::String.new(
|
2567
|
+
Model::Literals::String.new(
|
2542
2568
|
value: value,
|
2543
2569
|
encoded: true
|
2544
|
-
|
2570
|
+
)
|
2545
2571
|
end
|
2546
2572
|
end
|
2547
2573
|
end
|