expressir 0.2.26-x86_64-linux → 1.2.0-x86_64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +50 -5
- data/.github/workflows/release.yml +8 -0
- data/.gitignore +2 -2
- data/.hound.yml +3 -0
- data/.rubocop.yml +6 -506
- data/.yardopts +11 -0
- data/Rakefile +3 -0
- data/demo.rb +5 -5
- data/exe/format +8 -8
- data/exe/format-test +11 -11
- data/expressir.gemspec +4 -2
- data/lib/expressir/cli.rb +0 -6
- data/lib/expressir/express/2.4/express_parser.so +0 -0
- data/lib/expressir/express/2.5/express_parser.so +0 -0
- data/lib/expressir/express/2.6/express_parser.so +0 -0
- data/lib/expressir/express/2.7/express_parser.so +0 -0
- data/lib/expressir/{express_exp → express}/3.0/express_parser.so +0 -0
- data/lib/expressir/express/cache.rb +51 -0
- data/lib/expressir/{express_exp → express}/formatter.rb +304 -237
- data/lib/expressir/{express_exp → express}/hyperlink_formatter.rb +16 -2
- data/lib/expressir/{express_exp → express}/model_visitor.rb +2 -1
- data/lib/expressir/{express_exp → express}/parser.rb +19 -13
- data/lib/expressir/{express_exp → express}/resolve_references_model_visitor.rb +9 -7
- data/lib/expressir/express/schema_head_formatter.rb +23 -0
- data/lib/expressir/{express_exp → express}/visitor.rb +318 -270
- 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 +7 -3
- 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 +9 -4
- 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 +6 -2
- data/lib/expressir/model/statement.rb +9 -0
- data/lib/expressir/model/statements/alias.rb +12 -8
- data/lib/expressir/model/statements/assignment.rb +8 -3
- data/lib/expressir/model/statements/case.rb +11 -5
- data/lib/expressir/model/statements/case_action.rb +8 -3
- data/lib/expressir/model/statements/compound.rb +7 -3
- data/lib/expressir/model/statements/escape.rb +3 -1
- data/lib/expressir/model/statements/if.rb +12 -6
- 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 +20 -12
- 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/model.rb +52 -43
- data/lib/expressir/version.rb +1 -1
- data/lib/expressir.rb +0 -1
- data/rakelib/cross-ruby.rake +1 -1
- data/spec/expressir/{express_exp → express}/cache_spec.rb +9 -9
- data/spec/expressir/express/formatter_spec.rb +127 -0
- data/spec/expressir/{express_exp → express}/parser_spec.rb +23 -23
- data/spec/expressir/model/model_element_spec.rb +153 -153
- data/{original/examples → spec}/syntax/multiple.exp +0 -0
- data/spec/syntax/multiple.yaml +198 -0
- data/{original/examples → spec}/syntax/multiple_formatted.exp +0 -0
- data/{original/examples → spec}/syntax/multiple_hyperlink_formatted.exp +0 -0
- data/{original/examples → spec}/syntax/multiple_schema_head_hyperlink_formatted.exp +0 -0
- data/{original/examples → spec}/syntax/remark.exp +0 -0
- data/{original/examples → spec}/syntax/remark.yaml +73 -73
- data/{original/examples → spec}/syntax/remark_formatted.exp +0 -0
- data/{original/examples → spec}/syntax/single.exp +1 -1
- data/spec/syntax/single.yaml +18 -0
- data/{original/examples → spec}/syntax/single_formatted.exp +1 -1
- data/{original/examples → spec}/syntax/single_formatted.yaml +9 -6
- data/{original/examples → spec}/syntax/syntax.exp +11 -11
- data/{original/examples → spec}/syntax/syntax.yaml +1100 -1111
- data/{original/examples → spec}/syntax/syntax_formatted.exp +11 -11
- data/{original/examples → spec}/syntax/syntax_hyperlink_formatted.exp +11 -11
- data/{original/examples → spec}/syntax/syntax_schema_head_formatted.exp +1 -1
- metadata +128 -121
- data/lib/expressir/express/aggregate_dimension.rb +0 -38
- data/lib/expressir/express/attribute.rb +0 -15
- data/lib/expressir/express/comment.rb +0 -7
- data/lib/expressir/express/defined_type.rb +0 -36
- data/lib/expressir/express/derived.rb +0 -65
- data/lib/expressir/express/derived_aggregate.rb +0 -43
- data/lib/expressir/express/entity.rb +0 -137
- data/lib/expressir/express/explicit.rb +0 -70
- data/lib/expressir/express/explicit_aggregate.rb +0 -46
- data/lib/expressir/express/explicit_or_derived.rb +0 -16
- data/lib/expressir/express/global_rule.rb +0 -44
- data/lib/expressir/express/interface_specification.rb +0 -51
- data/lib/expressir/express/interfaced_item.rb +0 -38
- data/lib/expressir/express/inverse.rb +0 -46
- data/lib/expressir/express/inverse_aggregate.rb +0 -37
- data/lib/expressir/express/model_element.rb +0 -7
- data/lib/expressir/express/named_type.rb +0 -19
- data/lib/expressir/express/remark.rb +0 -8
- data/lib/expressir/express/repository.rb +0 -306
- data/lib/expressir/express/schema_definition.rb +0 -96
- data/lib/expressir/express/subtype_constraint.rb +0 -14
- data/lib/expressir/express/type.rb +0 -26
- data/lib/expressir/express/type_aggregate.rb +0 -42
- data/lib/expressir/express/type_enum.rb +0 -29
- data/lib/expressir/express/type_parser.rb +0 -45
- data/lib/expressir/express/type_select.rb +0 -82
- data/lib/expressir/express/unique_rule.rb +0 -35
- data/lib/expressir/express/where_rule.rb +0 -32
- data/lib/expressir/express.rb +0 -11
- data/lib/expressir/express_exp/2.4/express_parser.so +0 -0
- data/lib/expressir/express_exp/2.5/express_parser.so +0 -0
- data/lib/expressir/express_exp/2.6/express_parser.so +0 -0
- data/lib/expressir/express_exp/2.7/express_parser.so +0 -0
- data/lib/expressir/express_exp/cache.rb +0 -48
- data/lib/expressir/express_exp/schema_head_formatter.rb +0 -9
- data/lib/expressir/express_parser.rb +0 -30
- 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/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 -21
- 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 -23
- data/lib/expressir/model/types/set.rb +0 -19
- data/lib/expressir/model/types/string.rb +0 -17
- data/lib/expressir/model/unique.rb +0 -26
- data/lib/expressir/model/variable.rb +0 -28
- data/lib/expressir/model/where.rb +0 -26
- data/lib/expressir/parser/owl_parser.rb +0 -8
- data/lib/expressir/parser.rb +0 -6
- data/original/examples/syntax/multiple.yaml +0 -198
- data/original/examples/syntax/single.yaml +0 -15
- data/spec/acceptance/express_to_owl_spec.rb +0 -18
- data/spec/expressir/express/repository_spec.rb +0 -25
- data/spec/expressir/express_exp/formatter_spec.rb +0 -127
@@ -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
|
@@ -32,13 +32,17 @@ require "set"
|
|
32
32
|
# - e.g. see visit_schema_decl
|
33
33
|
|
34
34
|
module Expressir
|
35
|
-
module
|
35
|
+
module Express
|
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::
|
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)
|
@@ -759,18 +769,18 @@ module Expressir
|
|
759
769
|
*visit_if(ctx__entity_body__derive_clause),
|
760
770
|
*visit_if(ctx__entity_body__inverse_clause)
|
761
771
|
]
|
762
|
-
|
763
|
-
|
772
|
+
unique_rules = visit_if(ctx__entity_body__unique_clause, [])
|
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,
|
769
779
|
subtype_of: subtype_of,
|
770
780
|
attributes: attributes,
|
771
|
-
|
772
|
-
|
773
|
-
|
781
|
+
unique_rules: unique_rules,
|
782
|
+
where_rules: where_rules
|
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
|
@@ -834,16 +844,14 @@ module Expressir
|
|
834
844
|
ctx__enumeration_extension__enumeration_items = ctx__enumeration_extension&.enumeration_items
|
835
845
|
|
836
846
|
extensible = ctx__EXTENSIBLE && true
|
837
|
-
|
838
|
-
|
839
|
-
extension_items = visit_if(ctx__enumeration_extension__enumeration_items, [])
|
847
|
+
based_on = visit_if(ctx__enumeration_extension__type_ref)
|
848
|
+
items = visit_if(ctx__enumeration_items || ctx__enumeration_extension__enumeration_items, [])
|
840
849
|
|
841
|
-
Model::
|
850
|
+
Model::DataTypes::Enumeration.new(
|
842
851
|
extensible: extensible,
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
})
|
852
|
+
based_on: based_on,
|
853
|
+
items: items
|
854
|
+
)
|
847
855
|
end
|
848
856
|
|
849
857
|
def visit_escape_stmt(ctx)
|
@@ -860,13 +868,13 @@ module Expressir
|
|
860
868
|
type = visit_if(ctx__parameter_type)
|
861
869
|
|
862
870
|
attributes.map do |attribute|
|
863
|
-
Model::Attribute.new(
|
871
|
+
Model::Declarations::Attribute.new(
|
864
872
|
id: attribute.id, # reuse
|
865
|
-
kind: Model::Attribute::EXPLICIT,
|
873
|
+
kind: Model::Declarations::Attribute::EXPLICIT,
|
866
874
|
supertype_attribute: attribute.supertype_attribute, # reuse
|
867
875
|
optional: optional,
|
868
876
|
type: type
|
869
|
-
|
877
|
+
)
|
870
878
|
end
|
871
879
|
end
|
872
880
|
|
@@ -879,11 +887,11 @@ module Expressir
|
|
879
887
|
operand1 = visit_if(ctx__simple_expression[0])
|
880
888
|
operand2 = visit_if(ctx__simple_expression[1])
|
881
889
|
|
882
|
-
Model::Expressions::BinaryExpression.new(
|
890
|
+
Model::Expressions::BinaryExpression.new(
|
883
891
|
operator: operator,
|
884
892
|
operand1: operand1,
|
885
893
|
operand2: operand2
|
886
|
-
|
894
|
+
)
|
887
895
|
else
|
888
896
|
visit_if(ctx__simple_expression[0])
|
889
897
|
end
|
@@ -897,11 +905,11 @@ module Expressir
|
|
897
905
|
operand1 = visit(ctx__simple_factor[0])
|
898
906
|
operand2 = visit(ctx__simple_factor[1])
|
899
907
|
|
900
|
-
Model::Expressions::BinaryExpression.new(
|
908
|
+
Model::Expressions::BinaryExpression.new(
|
901
909
|
operator: operator,
|
902
910
|
operand1: operand1,
|
903
911
|
operand2: operand2
|
904
|
-
|
912
|
+
)
|
905
913
|
elsif ctx__simple_factor.length == 1
|
906
914
|
visit_if(ctx__simple_factor[0])
|
907
915
|
else
|
@@ -917,10 +925,10 @@ module Expressir
|
|
917
925
|
type = visit_if(ctx__parameter_type)
|
918
926
|
|
919
927
|
ids.map do |id|
|
920
|
-
Model::Parameter.new(
|
928
|
+
Model::Declarations::Parameter.new(
|
921
929
|
id: id,
|
922
930
|
type: type
|
923
|
-
|
931
|
+
)
|
924
932
|
end
|
925
933
|
end
|
926
934
|
|
@@ -929,13 +937,13 @@ module Expressir
|
|
929
937
|
ctx__function_ref = ctx.function_ref
|
930
938
|
ctx__actual_parameter_list = ctx.actual_parameter_list
|
931
939
|
|
932
|
-
|
940
|
+
function = visit_if(ctx__built_in_function || ctx__function_ref)
|
933
941
|
parameters = visit_if(ctx__actual_parameter_list, [])
|
934
942
|
|
935
|
-
Model::Expressions::
|
936
|
-
|
943
|
+
Model::Expressions::FunctionCall.new(
|
944
|
+
function: function,
|
937
945
|
parameters: parameters
|
938
|
-
|
946
|
+
)
|
939
947
|
end
|
940
948
|
|
941
949
|
def visit_function_decl(ctx)
|
@@ -953,16 +961,16 @@ module Expressir
|
|
953
961
|
parameters = visit_if_map_flatten(ctx__function_head__formal_parameter)
|
954
962
|
return_type = visit_if(ctx__function_head__parameter_type)
|
955
963
|
declarations = visit_if_map(ctx__algorithm_head__declaration)
|
956
|
-
types = declarations.select{|x| x.is_a? Model::Type}
|
957
|
-
entities = declarations.select{|x| x.is_a? Model::Entity}
|
958
|
-
subtype_constraints = declarations.select{|x| x.is_a? Model::SubtypeConstraint}
|
959
|
-
functions = declarations.select{|x| x.is_a? Model::Function}
|
960
|
-
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}
|
961
969
|
constants = visit_if(ctx__algorithm_head__constant_decl, [])
|
962
970
|
variables = visit_if(ctx__algorithm_head__local_decl, [])
|
963
971
|
statements = visit_if_map(ctx__stmt)
|
964
972
|
|
965
|
-
Model::Function.new(
|
973
|
+
Model::Declarations::Function.new(
|
966
974
|
id: id,
|
967
975
|
parameters: parameters,
|
968
976
|
return_type: return_type,
|
@@ -974,7 +982,7 @@ module Expressir
|
|
974
982
|
constants: constants,
|
975
983
|
variables: variables,
|
976
984
|
statements: statements
|
977
|
-
|
985
|
+
)
|
978
986
|
end
|
979
987
|
|
980
988
|
def visit_function_head(ctx)
|
@@ -1019,13 +1027,13 @@ module Expressir
|
|
1019
1027
|
unique = ctx__UNIQUE && true
|
1020
1028
|
base_type = visit_if(ctx__parameter_type)
|
1021
1029
|
|
1022
|
-
Model::
|
1030
|
+
Model::DataTypes::Array.new(
|
1023
1031
|
bound1: bound1,
|
1024
1032
|
bound2: bound2,
|
1025
1033
|
optional: optional,
|
1026
1034
|
unique: unique,
|
1027
1035
|
base_type: base_type
|
1028
|
-
|
1036
|
+
)
|
1029
1037
|
end
|
1030
1038
|
|
1031
1039
|
def visit_general_bag_type(ctx)
|
@@ -1038,11 +1046,11 @@ module Expressir
|
|
1038
1046
|
bound2 = visit_if(ctx__bound_spec__bound2)
|
1039
1047
|
base_type = visit_if(ctx__parameter_type)
|
1040
1048
|
|
1041
|
-
Model::
|
1049
|
+
Model::DataTypes::Bag.new(
|
1042
1050
|
bound1: bound1,
|
1043
1051
|
bound2: bound2,
|
1044
1052
|
base_type: base_type
|
1045
|
-
|
1053
|
+
)
|
1046
1054
|
end
|
1047
1055
|
|
1048
1056
|
def visit_general_list_type(ctx)
|
@@ -1057,12 +1065,12 @@ module Expressir
|
|
1057
1065
|
unique = ctx__UNIQUE && true
|
1058
1066
|
base_type = visit_if(ctx__parameter_type)
|
1059
1067
|
|
1060
|
-
Model::
|
1068
|
+
Model::DataTypes::List.new(
|
1061
1069
|
bound1: bound1,
|
1062
1070
|
bound2: bound2,
|
1063
1071
|
unique: unique,
|
1064
1072
|
base_type: base_type
|
1065
|
-
|
1073
|
+
)
|
1066
1074
|
end
|
1067
1075
|
|
1068
1076
|
def visit_general_ref(ctx)
|
@@ -1082,11 +1090,11 @@ module Expressir
|
|
1082
1090
|
bound2 = visit_if(ctx__bound_spec__bound2)
|
1083
1091
|
base_type = visit_if(ctx__parameter_type)
|
1084
1092
|
|
1085
|
-
Model::
|
1093
|
+
Model::DataTypes::Set.new(
|
1086
1094
|
bound1: bound1,
|
1087
1095
|
bound2: bound2,
|
1088
1096
|
base_type: base_type
|
1089
|
-
|
1097
|
+
)
|
1090
1098
|
end
|
1091
1099
|
|
1092
1100
|
def visit_generic_entity_type(ctx)
|
@@ -1094,9 +1102,9 @@ module Expressir
|
|
1094
1102
|
|
1095
1103
|
id = visit_if(ctx__type_label)
|
1096
1104
|
|
1097
|
-
Model::
|
1105
|
+
Model::DataTypes::GenericEntity.new(
|
1098
1106
|
id: id
|
1099
|
-
|
1107
|
+
)
|
1100
1108
|
end
|
1101
1109
|
|
1102
1110
|
def visit_generic_type(ctx)
|
@@ -1104,9 +1112,9 @@ module Expressir
|
|
1104
1112
|
|
1105
1113
|
id = visit_if(ctx__type_label)
|
1106
1114
|
|
1107
|
-
Model::
|
1115
|
+
Model::DataTypes::Generic.new(
|
1108
1116
|
id: id
|
1109
|
-
|
1117
|
+
)
|
1110
1118
|
end
|
1111
1119
|
|
1112
1120
|
def visit_group_qualifier(ctx)
|
@@ -1114,9 +1122,9 @@ module Expressir
|
|
1114
1122
|
|
1115
1123
|
entity = visit_if(ctx__entity_ref)
|
1116
1124
|
|
1117
|
-
Model::
|
1125
|
+
Model::References::GroupReference.new(
|
1118
1126
|
entity: entity
|
1119
|
-
|
1127
|
+
)
|
1120
1128
|
end
|
1121
1129
|
|
1122
1130
|
def visit_group_reference(ctx)
|
@@ -1132,11 +1140,11 @@ module Expressir
|
|
1132
1140
|
statements = visit_if(ctx__if_stmt_statements, [])
|
1133
1141
|
else_statements = visit_if(ctx__if_stmt_else_statements, [])
|
1134
1142
|
|
1135
|
-
Model::Statements::If.new(
|
1143
|
+
Model::Statements::If.new(
|
1136
1144
|
expression: expression,
|
1137
1145
|
statements: statements,
|
1138
1146
|
else_statements: else_statements
|
1139
|
-
|
1147
|
+
)
|
1140
1148
|
end
|
1141
1149
|
|
1142
1150
|
def visit_if_stmt_statements(ctx)
|
@@ -1186,10 +1194,10 @@ module Expressir
|
|
1186
1194
|
index1 = visit_if(ctx__index1)
|
1187
1195
|
index2 = visit_if(ctx__index2)
|
1188
1196
|
|
1189
|
-
Model::
|
1197
|
+
Model::References::IndexReference.new(
|
1190
1198
|
index1: index1,
|
1191
1199
|
index2: index2
|
1192
|
-
|
1200
|
+
)
|
1193
1201
|
end
|
1194
1202
|
|
1195
1203
|
def visit_index_reference(ctx)
|
@@ -1204,7 +1212,7 @@ module Expressir
|
|
1204
1212
|
end
|
1205
1213
|
|
1206
1214
|
def visit_integer_type(ctx)
|
1207
|
-
Model::
|
1215
|
+
Model::DataTypes::Integer.new
|
1208
1216
|
end
|
1209
1217
|
|
1210
1218
|
def visit_interface_specification(ctx)
|
@@ -1226,13 +1234,13 @@ module Expressir
|
|
1226
1234
|
operator2 = visit_if(ctx__interval_op[1])
|
1227
1235
|
high = visit_if(ctx__interval_high)
|
1228
1236
|
|
1229
|
-
Model::Expressions::Interval.new(
|
1237
|
+
Model::Expressions::Interval.new(
|
1230
1238
|
low: low,
|
1231
1239
|
operator1: operator1,
|
1232
1240
|
item: item,
|
1233
1241
|
operator2: operator2,
|
1234
1242
|
high: high
|
1235
|
-
|
1243
|
+
)
|
1236
1244
|
end
|
1237
1245
|
|
1238
1246
|
def visit_interval_high(ctx)
|
@@ -1259,9 +1267,9 @@ module Expressir
|
|
1259
1267
|
ctx__LESS_THAN_OR_EQUAL = ctx__text == '<='
|
1260
1268
|
|
1261
1269
|
if ctx__LESS_THAN
|
1262
|
-
Model::Expressions::
|
1270
|
+
Model::Expressions::Interval::LESS_THAN
|
1263
1271
|
elsif ctx__LESS_THAN_OR_EQUAL
|
1264
|
-
Model::Expressions::
|
1272
|
+
Model::Expressions::Interval::LESS_THAN_OR_EQUAL
|
1265
1273
|
else
|
1266
1274
|
raise 'Invalid state'
|
1267
1275
|
end
|
@@ -1279,21 +1287,21 @@ module Expressir
|
|
1279
1287
|
ref = visit(ctx__entity_ref)
|
1280
1288
|
attribute_ref = visit(ctx__attribute_ref)
|
1281
1289
|
|
1282
|
-
Model::
|
1290
|
+
Model::References::AttributeReference.new(
|
1283
1291
|
ref: ref,
|
1284
1292
|
attribute: attribute_ref
|
1285
|
-
|
1293
|
+
)
|
1286
1294
|
else
|
1287
1295
|
visit(ctx__attribute_ref)
|
1288
1296
|
end
|
1289
1297
|
|
1290
|
-
Model::Attribute.new(
|
1298
|
+
Model::Declarations::Attribute.new(
|
1291
1299
|
id: attribute.id, # reuse
|
1292
|
-
kind: Model::Attribute::INVERSE,
|
1300
|
+
kind: Model::Declarations::Attribute::INVERSE,
|
1293
1301
|
supertype_attribute: attribute.supertype_attribute, # reuse
|
1294
1302
|
type: type,
|
1295
1303
|
expression: expression
|
1296
|
-
|
1304
|
+
)
|
1297
1305
|
end
|
1298
1306
|
|
1299
1307
|
def visit_inverse_attr_type(ctx)
|
@@ -1309,21 +1317,21 @@ module Expressir
|
|
1309
1317
|
bound2 = visit_if(ctx__bound_spec__bound2)
|
1310
1318
|
base_type = visit_if(ctx__entity_ref)
|
1311
1319
|
|
1312
|
-
Model::
|
1320
|
+
Model::DataTypes::Set.new(
|
1313
1321
|
bound1: bound1,
|
1314
1322
|
bound2: bound2,
|
1315
1323
|
base_type: base_type
|
1316
|
-
|
1324
|
+
)
|
1317
1325
|
elsif ctx__BAG
|
1318
1326
|
bound1 = visit_if(ctx__bound_spec__bound1)
|
1319
1327
|
bound2 = visit_if(ctx__bound_spec__bound2)
|
1320
1328
|
base_type = visit_if(ctx__entity_ref)
|
1321
1329
|
|
1322
|
-
Model::
|
1330
|
+
Model::DataTypes::Bag.new(
|
1323
1331
|
bound1: bound1,
|
1324
1332
|
bound2: bound2,
|
1325
1333
|
base_type: base_type
|
1326
|
-
|
1334
|
+
)
|
1327
1335
|
else
|
1328
1336
|
visit_if(ctx__entity_ref)
|
1329
1337
|
end
|
@@ -1347,12 +1355,12 @@ module Expressir
|
|
1347
1355
|
unique = ctx__UNIQUE && true
|
1348
1356
|
base_type = visit_if(ctx__instantiable_type)
|
1349
1357
|
|
1350
|
-
Model::
|
1358
|
+
Model::DataTypes::List.new(
|
1351
1359
|
bound1: bound1,
|
1352
1360
|
bound2: bound2,
|
1353
1361
|
unique: unique,
|
1354
1362
|
base_type: base_type
|
1355
|
-
|
1363
|
+
)
|
1356
1364
|
end
|
1357
1365
|
|
1358
1366
|
def visit_literal(ctx)
|
@@ -1393,11 +1401,11 @@ module Expressir
|
|
1393
1401
|
expression = visit_if(ctx__expression)
|
1394
1402
|
|
1395
1403
|
ids.map do |id|
|
1396
|
-
Model::Variable.new(
|
1404
|
+
Model::Declarations::Variable.new(
|
1397
1405
|
id: id,
|
1398
1406
|
type: type,
|
1399
1407
|
expression: expression
|
1400
|
-
|
1408
|
+
)
|
1401
1409
|
end
|
1402
1410
|
end
|
1403
1411
|
|
@@ -1422,13 +1430,13 @@ module Expressir
|
|
1422
1430
|
raise 'Invalid state'
|
1423
1431
|
end
|
1424
1432
|
|
1425
|
-
Model::Literals::Logical.new(
|
1433
|
+
Model::Literals::Logical.new(
|
1426
1434
|
value: value
|
1427
|
-
|
1435
|
+
)
|
1428
1436
|
end
|
1429
1437
|
|
1430
1438
|
def visit_logical_type(ctx)
|
1431
|
-
Model::
|
1439
|
+
Model::DataTypes::Logical.new
|
1432
1440
|
end
|
1433
1441
|
|
1434
1442
|
def visit_multiplication_like_op(ctx)
|
@@ -1472,10 +1480,10 @@ module Expressir
|
|
1472
1480
|
ref = visit_if(ctx__named_types)
|
1473
1481
|
id = visit_if(ctx__entity_id || ctx__type_id)
|
1474
1482
|
|
1475
|
-
Model::InterfaceItem.new(
|
1483
|
+
Model::Declarations::InterfaceItem.new(
|
1476
1484
|
ref: ref,
|
1477
1485
|
id: id
|
1478
|
-
|
1486
|
+
)
|
1479
1487
|
end
|
1480
1488
|
|
1481
1489
|
def visit_null_stmt(ctx)
|
@@ -1483,7 +1491,7 @@ module Expressir
|
|
1483
1491
|
end
|
1484
1492
|
|
1485
1493
|
def visit_number_type(ctx)
|
1486
|
-
Model::
|
1494
|
+
Model::DataTypes::Number.new
|
1487
1495
|
end
|
1488
1496
|
|
1489
1497
|
def visit_numeric_expression(ctx)
|
@@ -1495,13 +1503,11 @@ module Expressir
|
|
1495
1503
|
def visit_one_of(ctx)
|
1496
1504
|
ctx__supertype_expression = ctx.supertype_expression
|
1497
1505
|
|
1498
|
-
|
1499
|
-
parameters = visit_if_map(ctx__supertype_expression)
|
1506
|
+
operands = visit_if_map(ctx__supertype_expression)
|
1500
1507
|
|
1501
|
-
Model::
|
1502
|
-
|
1503
|
-
|
1504
|
-
})
|
1508
|
+
Model::SupertypeExpressions::OneofSupertypeExpression.new(
|
1509
|
+
operands: operands
|
1510
|
+
)
|
1505
1511
|
end
|
1506
1512
|
|
1507
1513
|
def visit_parameter(ctx)
|
@@ -1555,13 +1561,13 @@ module Expressir
|
|
1555
1561
|
ctx__procedure_ref = ctx.procedure_ref
|
1556
1562
|
ctx__actual_parameter_list = ctx.actual_parameter_list
|
1557
1563
|
|
1558
|
-
|
1564
|
+
procedure = visit_if(ctx__built_in_procedure || ctx__procedure_ref)
|
1559
1565
|
parameters = visit_if(ctx__actual_parameter_list, [])
|
1560
1566
|
|
1561
|
-
Model::Statements::
|
1562
|
-
|
1567
|
+
Model::Statements::ProcedureCall.new(
|
1568
|
+
procedure: procedure,
|
1563
1569
|
parameters: parameters
|
1564
|
-
|
1570
|
+
)
|
1565
1571
|
end
|
1566
1572
|
|
1567
1573
|
def visit_procedure_decl(ctx)
|
@@ -1577,16 +1583,16 @@ module Expressir
|
|
1577
1583
|
id = visit_if(ctx__procedure_head__procedure_id)
|
1578
1584
|
parameters = visit_if_map_flatten(ctx__procedure_head__procedure_head_parameter)
|
1579
1585
|
declarations = visit_if_map(ctx__algorithm_head__declaration)
|
1580
|
-
types = declarations.select{|x| x.is_a? Model::Type}
|
1581
|
-
entities = declarations.select{|x| x.is_a? Model::Entity}
|
1582
|
-
subtype_constraints = declarations.select{|x| x.is_a? Model::SubtypeConstraint}
|
1583
|
-
functions = declarations.select{|x| x.is_a? Model::Function}
|
1584
|
-
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}
|
1585
1591
|
constants = visit_if(ctx__algorithm_head__constant_decl, [])
|
1586
1592
|
variables = visit_if(ctx__algorithm_head__local_decl, [])
|
1587
1593
|
statements = visit_if_map(ctx__stmt)
|
1588
1594
|
|
1589
|
-
Model::Procedure.new(
|
1595
|
+
Model::Declarations::Procedure.new(
|
1590
1596
|
id: id,
|
1591
1597
|
parameters: parameters,
|
1592
1598
|
types: types,
|
@@ -1597,7 +1603,7 @@ module Expressir
|
|
1597
1603
|
constants: constants,
|
1598
1604
|
variables: variables,
|
1599
1605
|
statements: statements
|
1600
|
-
|
1606
|
+
)
|
1601
1607
|
end
|
1602
1608
|
|
1603
1609
|
def visit_procedure_head(ctx)
|
@@ -1612,11 +1618,11 @@ module Expressir
|
|
1612
1618
|
|
1613
1619
|
if ctx.VAR
|
1614
1620
|
parameters.map do |parameter|
|
1615
|
-
Model::Parameter.new(
|
1621
|
+
Model::Declarations::Parameter.new(
|
1616
1622
|
id: parameter.id,
|
1617
1623
|
var: true,
|
1618
1624
|
type: parameter.type
|
1619
|
-
|
1625
|
+
)
|
1620
1626
|
end
|
1621
1627
|
else
|
1622
1628
|
parameters
|
@@ -1647,15 +1653,15 @@ module Expressir
|
|
1647
1653
|
group_reference = visit_if(ctx__group_qualifier)
|
1648
1654
|
attribute_reference = visit_if(ctx__attribute_qualifier)
|
1649
1655
|
|
1650
|
-
Model::
|
1651
|
-
ref: Model::
|
1652
|
-
ref: Model::
|
1656
|
+
Model::References::AttributeReference.new(
|
1657
|
+
ref: Model::References::GroupReference.new(
|
1658
|
+
ref: Model::References::SimpleReference.new(
|
1653
1659
|
id: id
|
1654
|
-
|
1660
|
+
),
|
1655
1661
|
entity: group_reference.entity # reuse
|
1656
|
-
|
1662
|
+
),
|
1657
1663
|
attribute: attribute_reference.attribute # reuse
|
1658
|
-
|
1664
|
+
)
|
1659
1665
|
end
|
1660
1666
|
|
1661
1667
|
def visit_qualifier(ctx)
|
@@ -1675,11 +1681,11 @@ module Expressir
|
|
1675
1681
|
aggregate_source = visit_if(ctx__aggregate_source)
|
1676
1682
|
expression = visit_if(ctx__logical_expression)
|
1677
1683
|
|
1678
|
-
Model::Expressions::QueryExpression.new(
|
1684
|
+
Model::Expressions::QueryExpression.new(
|
1679
1685
|
id: id,
|
1680
1686
|
aggregate_source: aggregate_source,
|
1681
1687
|
expression: expression
|
1682
|
-
|
1688
|
+
)
|
1683
1689
|
end
|
1684
1690
|
|
1685
1691
|
def visit_real_type(ctx)
|
@@ -1687,9 +1693,9 @@ module Expressir
|
|
1687
1693
|
|
1688
1694
|
precision = visit_if(ctx__precision_spec)
|
1689
1695
|
|
1690
|
-
Model::
|
1696
|
+
Model::DataTypes::Real.new(
|
1691
1697
|
precision: precision
|
1692
|
-
|
1698
|
+
)
|
1693
1699
|
end
|
1694
1700
|
|
1695
1701
|
def visit_redeclared_attribute(ctx)
|
@@ -1710,11 +1716,11 @@ module Expressir
|
|
1710
1716
|
schema = visit_if(ctx__schema_ref)
|
1711
1717
|
items = visit_if_map(ctx__resource_or_rename)
|
1712
1718
|
|
1713
|
-
Model::Interface.new(
|
1714
|
-
kind: Model::Interface::REFERENCE,
|
1719
|
+
Model::Declarations::Interface.new(
|
1720
|
+
kind: Model::Declarations::Interface::REFERENCE,
|
1715
1721
|
schema: schema,
|
1716
1722
|
items: items
|
1717
|
-
|
1723
|
+
)
|
1718
1724
|
end
|
1719
1725
|
|
1720
1726
|
def visit_rel_op(ctx)
|
@@ -1798,7 +1804,7 @@ module Expressir
|
|
1798
1804
|
until_expression = visit_if(ctx__repeat_control__until_control)
|
1799
1805
|
statements = visit_if_map(ctx__stmt)
|
1800
1806
|
|
1801
|
-
Model::Statements::Repeat.new(
|
1807
|
+
Model::Statements::Repeat.new(
|
1802
1808
|
id: id,
|
1803
1809
|
bound1: bound1,
|
1804
1810
|
bound2: bound2,
|
@@ -1806,7 +1812,7 @@ module Expressir
|
|
1806
1812
|
while_expression: while_expression,
|
1807
1813
|
until_expression: until_expression,
|
1808
1814
|
statements: statements
|
1809
|
-
|
1815
|
+
)
|
1810
1816
|
end
|
1811
1817
|
|
1812
1818
|
def visit_repetition(ctx)
|
@@ -1822,10 +1828,10 @@ module Expressir
|
|
1822
1828
|
ref = visit_if(ctx__resource_ref)
|
1823
1829
|
id = visit_if(ctx__rename_id)
|
1824
1830
|
|
1825
|
-
Model::InterfaceItem.new(
|
1831
|
+
Model::Declarations::InterfaceItem.new(
|
1826
1832
|
ref: ref,
|
1827
1833
|
id: id
|
1828
|
-
|
1834
|
+
)
|
1829
1835
|
end
|
1830
1836
|
|
1831
1837
|
def visit_resource_ref(ctx)
|
@@ -1843,9 +1849,9 @@ module Expressir
|
|
1843
1849
|
|
1844
1850
|
expression = visit_if(ctx__expression)
|
1845
1851
|
|
1846
|
-
Model::Statements::Return.new(
|
1852
|
+
Model::Statements::Return.new(
|
1847
1853
|
expression: expression
|
1848
|
-
|
1854
|
+
)
|
1849
1855
|
end
|
1850
1856
|
|
1851
1857
|
def visit_rule_decl(ctx)
|
@@ -1862,17 +1868,17 @@ module Expressir
|
|
1862
1868
|
id = visit_if(ctx__rule_head__rule_id)
|
1863
1869
|
applies_to = visit_if_map(ctx__rule_head__entity_ref)
|
1864
1870
|
declarations = visit_if_map(ctx__algorithm_head__declaration)
|
1865
|
-
types = declarations.select{|x| x.is_a? Model::Type}
|
1866
|
-
entities = declarations.select{|x| x.is_a? Model::Entity}
|
1867
|
-
subtype_constraints = declarations.select{|x| x.is_a? Model::SubtypeConstraint}
|
1868
|
-
functions = declarations.select{|x| x.is_a? Model::Function}
|
1869
|
-
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}
|
1870
1876
|
constants = visit_if(ctx__algorithm_head__constant_decl, [])
|
1871
1877
|
variables = visit_if(ctx__algorithm_head__local_decl, [])
|
1872
1878
|
statements = visit_if_map(ctx__stmt)
|
1873
|
-
|
1879
|
+
where_rules = visit_if(ctx__where_clause, [])
|
1874
1880
|
|
1875
|
-
Model::Rule.new(
|
1881
|
+
Model::Declarations::Rule.new(
|
1876
1882
|
id: id,
|
1877
1883
|
applies_to: applies_to,
|
1878
1884
|
types: types,
|
@@ -1883,8 +1889,8 @@ module Expressir
|
|
1883
1889
|
constants: constants,
|
1884
1890
|
variables: variables,
|
1885
1891
|
statements: statements,
|
1886
|
-
|
1887
|
-
|
1892
|
+
where_rules: where_rules
|
1893
|
+
)
|
1888
1894
|
end
|
1889
1895
|
|
1890
1896
|
def visit_rule_head(ctx)
|
@@ -1927,14 +1933,14 @@ module Expressir
|
|
1927
1933
|
interfaces = visit_if_map(ctx__schema_body__interface_specification)
|
1928
1934
|
constants = visit_if(ctx__schema_body__constant_decl, [])
|
1929
1935
|
declarations = visit_if_map(ctx__schema_body__schema_body_declaration)
|
1930
|
-
types = declarations.select{|x| x.is_a? Model::Type}
|
1931
|
-
entities = declarations.select{|x| x.is_a? Model::Entity}
|
1932
|
-
subtype_constraints = declarations.select{|x| x.is_a? Model::SubtypeConstraint}
|
1933
|
-
functions = declarations.select{|x| x.is_a? Model::Function}
|
1934
|
-
rules = declarations.select{|x| x.is_a? Model::Rule}
|
1935
|
-
procedures = declarations.select{|x| x.is_a? Model::Procedure}
|
1936
|
-
|
1937
|
-
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(
|
1938
1944
|
id: id,
|
1939
1945
|
version: version,
|
1940
1946
|
interfaces: interfaces,
|
@@ -1945,7 +1951,7 @@ module Expressir
|
|
1945
1951
|
functions: functions,
|
1946
1952
|
rules: rules,
|
1947
1953
|
procedures: procedures
|
1948
|
-
|
1954
|
+
)
|
1949
1955
|
end
|
1950
1956
|
|
1951
1957
|
def visit_schema_id(ctx)
|
@@ -1957,7 +1963,33 @@ module Expressir
|
|
1957
1963
|
def visit_schema_version_id(ctx)
|
1958
1964
|
ctx__string_literal = ctx.string_literal
|
1959
1965
|
|
1960
|
-
visit_if(ctx__string_literal)
|
1966
|
+
value = visit_if(ctx__string_literal)
|
1967
|
+
value = value.value
|
1968
|
+
|
1969
|
+
items = if value.start_with?('{') and value.end_with?('}')
|
1970
|
+
parts = value.sub(/^\{/, '').sub(/\}$/, '').split(' ')
|
1971
|
+
parts.map do |part|
|
1972
|
+
if match = part.match(/^(.+)\((\d+)\)$/)
|
1973
|
+
Model::Declarations::SchemaVersionItem.new(
|
1974
|
+
name: match[1],
|
1975
|
+
value: match[2]
|
1976
|
+
)
|
1977
|
+
elsif part.match(/^\d+$/)
|
1978
|
+
Model::Declarations::SchemaVersionItem.new(
|
1979
|
+
value: part
|
1980
|
+
)
|
1981
|
+
else
|
1982
|
+
Model::Declarations::SchemaVersionItem.new(
|
1983
|
+
name: part
|
1984
|
+
)
|
1985
|
+
end
|
1986
|
+
end
|
1987
|
+
end
|
1988
|
+
|
1989
|
+
Model::Declarations::SchemaVersion.new(
|
1990
|
+
value: value,
|
1991
|
+
items: items
|
1992
|
+
)
|
1961
1993
|
end
|
1962
1994
|
|
1963
1995
|
def visit_selector(ctx)
|
@@ -1986,17 +2018,15 @@ module Expressir
|
|
1986
2018
|
|
1987
2019
|
extensible = ctx__EXTENSIBLE && true
|
1988
2020
|
generic_entity = ctx__GENERIC_ENTITY && true
|
1989
|
-
|
1990
|
-
|
1991
|
-
extension_items = visit_if(ctx__select_extension__select_list, [])
|
2021
|
+
based_on = visit_if(ctx__select_extension__type_ref)
|
2022
|
+
items = visit_if(ctx__select_list || ctx__select_extension__select_list, [])
|
1992
2023
|
|
1993
|
-
Model::
|
2024
|
+
Model::DataTypes::Select.new(
|
1994
2025
|
extensible: extensible,
|
1995
2026
|
generic_entity: generic_entity,
|
1996
|
-
|
1997
|
-
|
1998
|
-
|
1999
|
-
})
|
2027
|
+
based_on: based_on,
|
2028
|
+
items: items
|
2029
|
+
)
|
2000
2030
|
end
|
2001
2031
|
|
2002
2032
|
def visit_set_type(ctx)
|
@@ -2009,11 +2039,11 @@ module Expressir
|
|
2009
2039
|
bound2 = visit_if(ctx__bound_spec__bound2)
|
2010
2040
|
base_type = visit_if(ctx__instantiable_type)
|
2011
2041
|
|
2012
|
-
Model::
|
2042
|
+
Model::DataTypes::Set.new(
|
2013
2043
|
bound1: bound1,
|
2014
2044
|
bound2: bound2,
|
2015
2045
|
base_type: base_type
|
2016
|
-
|
2046
|
+
)
|
2017
2047
|
end
|
2018
2048
|
|
2019
2049
|
def visit_simple_expression(ctx)
|
@@ -2064,10 +2094,10 @@ module Expressir
|
|
2064
2094
|
operator = visit_if(ctx__unary_op)
|
2065
2095
|
operand = visit_if(ctx__simple_factor_expression)
|
2066
2096
|
|
2067
|
-
Model::Expressions::UnaryExpression.new(
|
2097
|
+
Model::Expressions::UnaryExpression.new(
|
2068
2098
|
operator: operator,
|
2069
2099
|
operand: operand
|
2070
|
-
|
2100
|
+
)
|
2071
2101
|
end
|
2072
2102
|
|
2073
2103
|
def visit_simple_types(ctx)
|
@@ -2123,10 +2153,10 @@ module Expressir
|
|
2123
2153
|
width = visit_if(ctx__width_spec__width)
|
2124
2154
|
fixed = ctx__width_spec__FIXED && true
|
2125
2155
|
|
2126
|
-
Model::
|
2156
|
+
Model::DataTypes::String.new(
|
2127
2157
|
width: width,
|
2128
2158
|
fixed: fixed
|
2129
|
-
|
2159
|
+
)
|
2130
2160
|
end
|
2131
2161
|
|
2132
2162
|
def visit_subsuper(ctx)
|
@@ -2158,13 +2188,13 @@ module Expressir
|
|
2158
2188
|
total_over = visit_if(ctx__subtype_constraint_body__total_over, [])
|
2159
2189
|
supertype_expression = visit_if(ctx__subtype_constraint_body__supertype_expression)
|
2160
2190
|
|
2161
|
-
Model::SubtypeConstraint.new(
|
2191
|
+
Model::Declarations::SubtypeConstraint.new(
|
2162
2192
|
id: id,
|
2163
2193
|
applies_to: applies_to,
|
2164
2194
|
abstract: abstract,
|
2165
2195
|
total_over: total_over,
|
2166
2196
|
supertype_expression: supertype_expression
|
2167
|
-
|
2197
|
+
)
|
2168
2198
|
end
|
2169
2199
|
|
2170
2200
|
def visit_subtype_constraint_head(ctx)
|
@@ -2195,9 +2225,9 @@ module Expressir
|
|
2195
2225
|
if ctx__supertype_factor.length >= 2
|
2196
2226
|
if ctx__ANDOR and ctx__ANDOR.length == ctx__supertype_factor.length - 1
|
2197
2227
|
operands = ctx__supertype_factor.map(&self.method(:visit))
|
2198
|
-
operators = ctx__ANDOR.map{Model::
|
2228
|
+
operators = ctx__ANDOR.map{Model::SupertypeExpressions::BinarySupertypeExpression::ANDOR}
|
2199
2229
|
|
2200
|
-
|
2230
|
+
handle_binary_supertype_expression(operands, operators)
|
2201
2231
|
else
|
2202
2232
|
raise 'Invalid state'
|
2203
2233
|
end
|
@@ -2217,9 +2247,9 @@ module Expressir
|
|
2217
2247
|
if ctx__supertype_term.length >= 2
|
2218
2248
|
if ctx__AND and ctx__AND.length == ctx__supertype_term.length - 1
|
2219
2249
|
operands = ctx__supertype_term.map(&self.method(:visit))
|
2220
|
-
operators = ctx__AND.map{Model::
|
2250
|
+
operators = ctx__AND.map{Model::SupertypeExpressions::BinarySupertypeExpression::AND}
|
2221
2251
|
|
2222
|
-
|
2252
|
+
handle_binary_supertype_expression(operands, operators)
|
2223
2253
|
else
|
2224
2254
|
raise 'Invalid state'
|
2225
2255
|
end
|
@@ -2250,9 +2280,9 @@ module Expressir
|
|
2250
2280
|
|
2251
2281
|
schemas = visit_if_map(ctx__schema_decl)
|
2252
2282
|
|
2253
|
-
Model::Repository.new(
|
2283
|
+
Model::Repository.new(
|
2254
2284
|
schemas: schemas
|
2255
|
-
|
2285
|
+
)
|
2256
2286
|
end
|
2257
2287
|
|
2258
2288
|
def visit_term(ctx)
|
@@ -2289,14 +2319,14 @@ module Expressir
|
|
2289
2319
|
ctx__where_clause = ctx.where_clause
|
2290
2320
|
|
2291
2321
|
id = visit_if(ctx__type_id)
|
2292
|
-
|
2293
|
-
|
2322
|
+
underlying_type = visit_if(ctx__underlying_type)
|
2323
|
+
where_rules = visit_if(ctx__where_clause, [])
|
2294
2324
|
|
2295
|
-
Model::Type.new(
|
2325
|
+
Model::Declarations::Type.new(
|
2296
2326
|
id: id,
|
2297
|
-
|
2298
|
-
|
2299
|
-
|
2327
|
+
underlying_type: underlying_type,
|
2328
|
+
where_rules: where_rules
|
2329
|
+
)
|
2300
2330
|
end
|
2301
2331
|
|
2302
2332
|
def visit_type_id(ctx)
|
@@ -2355,10 +2385,10 @@ module Expressir
|
|
2355
2385
|
id = visit_if(ctx__rule_label_id)
|
2356
2386
|
attributes = visit_if_map(ctx__referenced_attribute)
|
2357
2387
|
|
2358
|
-
Model::
|
2388
|
+
Model::Declarations::UniqueRule.new(
|
2359
2389
|
id: id,
|
2360
2390
|
attributes: attributes
|
2361
|
-
|
2391
|
+
)
|
2362
2392
|
end
|
2363
2393
|
|
2364
2394
|
def visit_until_control(ctx)
|
@@ -2374,11 +2404,11 @@ module Expressir
|
|
2374
2404
|
schema = visit_if(ctx__schema_ref)
|
2375
2405
|
items = visit_if_map(ctx__named_type_or_rename)
|
2376
2406
|
|
2377
|
-
Model::Interface.new(
|
2378
|
-
kind: Model::Interface::USE,
|
2407
|
+
Model::Declarations::Interface.new(
|
2408
|
+
kind: Model::Declarations::Interface::USE,
|
2379
2409
|
schema: schema,
|
2380
2410
|
items: items
|
2381
|
-
|
2411
|
+
)
|
2382
2412
|
end
|
2383
2413
|
|
2384
2414
|
def visit_variable_id(ctx)
|
@@ -2409,24 +2439,42 @@ module Expressir
|
|
2409
2439
|
raise 'Invalid state'
|
2410
2440
|
end
|
2411
2441
|
|
2412
|
-
private
|
2413
|
-
|
2414
2442
|
def handle_binary_expression(operands, operators)
|
2415
2443
|
if operands.length != operators.length + 1
|
2416
2444
|
raise 'Invalid state'
|
2417
2445
|
end
|
2418
2446
|
|
2419
|
-
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(
|
2420
2468
|
operator: operators[0],
|
2421
2469
|
operand1: operands[0],
|
2422
2470
|
operand2: operands[1]
|
2423
|
-
|
2471
|
+
)
|
2424
2472
|
operators[1..(operators.length - 1)].each_with_index do |operator, i|
|
2425
|
-
expression = Model::
|
2473
|
+
expression = Model::SupertypeExpressions::BinarySupertypeExpression.new(
|
2426
2474
|
operator: operator,
|
2427
2475
|
operand1: expression,
|
2428
2476
|
operand2: operands[i + 2]
|
2429
|
-
|
2477
|
+
)
|
2430
2478
|
end
|
2431
2479
|
expression
|
2432
2480
|
end
|
@@ -2440,25 +2488,25 @@ module Expressir
|
|
2440
2488
|
if ctx__attribute_qualifier
|
2441
2489
|
attribute_reference = visit_if(ctx__attribute_qualifier)
|
2442
2490
|
|
2443
|
-
Model::
|
2491
|
+
Model::References::AttributeReference.new(
|
2444
2492
|
ref: ref,
|
2445
2493
|
attribute: attribute_reference.attribute
|
2446
|
-
|
2494
|
+
)
|
2447
2495
|
elsif ctx__group_qualifier
|
2448
2496
|
group_reference = visit_if(ctx__group_qualifier)
|
2449
2497
|
|
2450
|
-
Model::
|
2498
|
+
Model::References::GroupReference.new(
|
2451
2499
|
ref: ref,
|
2452
2500
|
entity: group_reference.entity
|
2453
|
-
|
2501
|
+
)
|
2454
2502
|
elsif ctx__index_qualifier
|
2455
2503
|
index_reference = visit_if(ctx__index_qualifier)
|
2456
2504
|
|
2457
|
-
Model::
|
2505
|
+
Model::References::IndexReference.new(
|
2458
2506
|
ref: ref,
|
2459
2507
|
index1: index_reference.index1,
|
2460
2508
|
index2: index_reference.index2
|
2461
|
-
|
2509
|
+
)
|
2462
2510
|
else
|
2463
2511
|
raise 'Invalid state'
|
2464
2512
|
end
|
@@ -2470,9 +2518,9 @@ module Expressir
|
|
2470
2518
|
|
2471
2519
|
value = ctx__text[1..(ctx__text.length - 1)]
|
2472
2520
|
|
2473
|
-
Model::Literals::Binary.new(
|
2521
|
+
Model::Literals::Binary.new(
|
2474
2522
|
value: value
|
2475
|
-
|
2523
|
+
)
|
2476
2524
|
end
|
2477
2525
|
|
2478
2526
|
def handle_integer_literal(ctx)
|
@@ -2480,9 +2528,9 @@ module Expressir
|
|
2480
2528
|
|
2481
2529
|
value = ctx__text
|
2482
2530
|
|
2483
|
-
Model::Literals::Integer.new(
|
2531
|
+
Model::Literals::Integer.new(
|
2484
2532
|
value: value
|
2485
|
-
|
2533
|
+
)
|
2486
2534
|
end
|
2487
2535
|
|
2488
2536
|
def handle_real_literal(ctx)
|
@@ -2490,9 +2538,9 @@ module Expressir
|
|
2490
2538
|
|
2491
2539
|
value = ctx__text
|
2492
2540
|
|
2493
|
-
Model::Literals::Real.new(
|
2541
|
+
Model::Literals::Real.new(
|
2494
2542
|
value: value
|
2495
|
-
|
2543
|
+
)
|
2496
2544
|
end
|
2497
2545
|
|
2498
2546
|
def handle_simple_id(ctx)
|
@@ -2506,9 +2554,9 @@ module Expressir
|
|
2506
2554
|
|
2507
2555
|
value = ctx__text[1..(ctx__text.length - 2)].force_encoding('UTF-8')
|
2508
2556
|
|
2509
|
-
Model::Literals::String.new(
|
2557
|
+
Model::Literals::String.new(
|
2510
2558
|
value: value
|
2511
|
-
|
2559
|
+
)
|
2512
2560
|
end
|
2513
2561
|
|
2514
2562
|
def handle_encoded_string_literal(ctx)
|
@@ -2516,10 +2564,10 @@ module Expressir
|
|
2516
2564
|
|
2517
2565
|
value = ctx__text[1..(ctx__text.length - 2)].force_encoding('UTF-8')
|
2518
2566
|
|
2519
|
-
Model::Literals::String.new(
|
2567
|
+
Model::Literals::String.new(
|
2520
2568
|
value: value,
|
2521
2569
|
encoded: true
|
2522
|
-
|
2570
|
+
)
|
2523
2571
|
end
|
2524
2572
|
end
|
2525
2573
|
end
|