expressir 0.2.9-arm64-darwin → 0.2.10-arm64-darwin

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.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/lib/expressir/express_exp/2.4/express_parser.bundle +0 -0
  3. data/lib/expressir/express_exp/2.5/express_parser.bundle +0 -0
  4. data/lib/expressir/express_exp/2.6/express_parser.bundle +0 -0
  5. data/lib/expressir/express_exp/2.7/express_parser.bundle +0 -0
  6. data/lib/expressir/express_exp/formatter.rb +71 -16
  7. data/lib/expressir/express_exp/visitor.rb +95 -41
  8. data/lib/expressir/model.rb +2 -0
  9. data/lib/expressir/model/attribute.rb +3 -1
  10. data/lib/expressir/model/constant.rb +3 -1
  11. data/lib/expressir/model/entity.rb +11 -21
  12. data/lib/expressir/model/enumeration_item.rb +3 -1
  13. data/lib/expressir/model/expressions/aggregate_initializer.rb +2 -2
  14. data/lib/expressir/model/expressions/aggregate_item.rb +1 -1
  15. data/lib/expressir/model/expressions/attribute_reference.rb +1 -1
  16. data/lib/expressir/model/expressions/binary_expression.rb +1 -1
  17. data/lib/expressir/model/expressions/call.rb +2 -2
  18. data/lib/expressir/model/expressions/entity_constructor.rb +2 -2
  19. data/lib/expressir/model/expressions/group_reference.rb +1 -1
  20. data/lib/expressir/model/expressions/index_reference.rb +1 -1
  21. data/lib/expressir/model/expressions/interval.rb +1 -1
  22. data/lib/expressir/model/expressions/query_expression.rb +3 -1
  23. data/lib/expressir/model/expressions/simple_reference.rb +1 -1
  24. data/lib/expressir/model/expressions/unary_expression.rb +1 -1
  25. data/lib/expressir/model/function.rb +32 -38
  26. data/lib/expressir/model/identifier.rb +1 -2
  27. data/lib/expressir/model/informal_proposition.rb +3 -1
  28. data/lib/expressir/model/interface.rb +2 -2
  29. data/lib/expressir/model/literals/binary.rb +1 -1
  30. data/lib/expressir/model/literals/integer.rb +1 -1
  31. data/lib/expressir/model/literals/logical.rb +1 -1
  32. data/lib/expressir/model/literals/real.rb +1 -1
  33. data/lib/expressir/model/literals/string.rb +1 -1
  34. data/lib/expressir/model/model_element.rb +67 -0
  35. data/lib/expressir/model/parameter.rb +3 -1
  36. data/lib/expressir/model/procedure.rb +33 -39
  37. data/lib/expressir/model/renamed_ref.rb +1 -1
  38. data/lib/expressir/model/repository.rb +3 -3
  39. data/lib/expressir/model/rule.rb +34 -40
  40. data/lib/expressir/model/schema.rb +35 -48
  41. data/lib/expressir/model/scope.rb +0 -3
  42. data/lib/expressir/model/statements/alias.rb +4 -2
  43. data/lib/expressir/model/statements/assignment.rb +1 -1
  44. data/lib/expressir/model/statements/call.rb +2 -2
  45. data/lib/expressir/model/statements/case.rb +2 -2
  46. data/lib/expressir/model/statements/case_action.rb +2 -2
  47. data/lib/expressir/model/statements/compound.rb +2 -2
  48. data/lib/expressir/model/statements/escape.rb +1 -1
  49. data/lib/expressir/model/statements/if.rb +3 -3
  50. data/lib/expressir/model/statements/null.rb +1 -1
  51. data/lib/expressir/model/statements/repeat.rb +4 -2
  52. data/lib/expressir/model/statements/return.rb +1 -1
  53. data/lib/expressir/model/statements/skip.rb +1 -1
  54. data/lib/expressir/model/subtype_constraint.rb +3 -1
  55. data/lib/expressir/model/type.rb +7 -5
  56. data/lib/expressir/model/types/aggregate.rb +3 -1
  57. data/lib/expressir/model/types/array.rb +1 -1
  58. data/lib/expressir/model/types/bag.rb +1 -1
  59. data/lib/expressir/model/types/binary.rb +1 -1
  60. data/lib/expressir/model/types/boolean.rb +1 -1
  61. data/lib/expressir/model/types/enumeration.rb +3 -3
  62. data/lib/expressir/model/types/generic.rb +3 -1
  63. data/lib/expressir/model/types/generic_entity.rb +3 -1
  64. data/lib/expressir/model/types/integer.rb +1 -1
  65. data/lib/expressir/model/types/list.rb +1 -1
  66. data/lib/expressir/model/types/logical.rb +1 -1
  67. data/lib/expressir/model/types/number.rb +1 -1
  68. data/lib/expressir/model/types/real.rb +1 -1
  69. data/lib/expressir/model/types/select.rb +3 -3
  70. data/lib/expressir/model/types/set.rb +1 -1
  71. data/lib/expressir/model/types/string.rb +1 -1
  72. data/lib/expressir/model/unique.rb +4 -2
  73. data/lib/expressir/model/variable.rb +3 -1
  74. data/lib/expressir/model/where.rb +3 -1
  75. data/lib/expressir/version.rb +1 -1
  76. data/original/examples/syntax/remark_formatted.exp +0 -5
  77. data/original/examples/syntax/simple.exp +3 -0
  78. data/original/examples/syntax/syntax.exp +189 -181
  79. data/original/examples/syntax/syntax_formatted.exp +346 -792
  80. data/spec/expressir/express_exp/head_source_spec.rb +1 -4
  81. data/spec/expressir/express_exp/parse_remark_spec.rb +3 -3
  82. data/spec/expressir/express_exp/parse_syntax_spec.rb +1583 -1578
  83. data/spec/expressir/express_exp/source_spec.rb +1 -4
  84. data/spec/expressir/model/model_element_spec.rb +59 -0
  85. data/spec/expressir/model/{find_spec.rb → scope_spec.rb} +1 -1
  86. metadata +6 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2553e66dcb3b2d0a8bede24995f3818cccacf9b1ff3813581848757ff070eac0
4
- data.tar.gz: 6f0171678bca72673824591469eb268d3cf1492bbfc126361b68613c6bbaea6e
3
+ metadata.gz: b6b9fd133266e935daa1a46dd8ed3405f59dd8ef07f0cdb1c111469a30e653c9
4
+ data.tar.gz: 492f03f70f9ca4860d49d905094475cffe343ec8d5734f0a104c512a82be4432
5
5
  SHA512:
6
- metadata.gz: f9f7dc75588fe18b31603ac622b847e1cb6531fb0e9f2d913be472438c4897d61ac1757bf7a7fa3d57fc51756134b34de13e22d722487dcfd3c651d951260630
7
- data.tar.gz: 5c8176868357761c894d8d29bbd55ad40f966ca643627c4a25e54ecc46c64c726e28f1bcd98f2e3895c045cba905623c1176525f90e79700281bb5f148719ec5
6
+ metadata.gz: 25bc06b8f1901b3130a6f3d3b0bda8e38d5e5c3b881019d40f0b53dcf701d9ac4451fba2621e89aa9e547e0eaa507f4ca2888944f3652323e9d7785489dd8890
7
+ data.tar.gz: bb6804d766279028844b929c1d3f8cdf6404c84bacf53d1c7b37b24eca23868991cdfd9ddec980ddf8905f51e78ead7e25e393be236e78ce45819c6af38c4cbb
@@ -233,6 +233,10 @@ module Expressir
233
233
  end
234
234
 
235
235
  def format_entity(node)
236
+ explicit_attributes = node.attributes.select{|x| x.kind == Model::Attribute::EXPLICIT}
237
+ derived_attributes = node.attributes.select{|x| x.kind == Model::Attribute::DERIVED}
238
+ inverse_attributes = node.attributes.select{|x| x.kind == Model::Attribute::INVERSE}
239
+
236
240
  [
237
241
  [
238
242
  'ENTITY',
@@ -290,19 +294,19 @@ module Expressir
290
294
  end,
291
295
  ';'
292
296
  ].join(''),
293
- *if node.explicit_attributes and node.explicit_attributes.length > 0
294
- indent(node.explicit_attributes.map{|x| format(x)}.join("\n"))
297
+ *if explicit_attributes and explicit_attributes.length > 0
298
+ indent(explicit_attributes.map{|x| format(x)}.join("\n"))
295
299
  end,
296
- *if node.derived_attributes and node.derived_attributes.length > 0
300
+ *if derived_attributes and derived_attributes.length > 0
297
301
  indent([
298
302
  'DERIVE',
299
- indent(node.derived_attributes.map{|x| format(x)}.join("\n")),
303
+ indent(derived_attributes.map{|x| format(x)}.join("\n")),
300
304
  ].join("\n"))
301
305
  end,
302
- *if node.inverse_attributes and node.inverse_attributes.length > 0
306
+ *if inverse_attributes and inverse_attributes.length > 0
303
307
  indent([
304
308
  'INVERSE',
305
- indent(node.inverse_attributes.map{|x| format(x)}.join("\n")),
309
+ indent(inverse_attributes.map{|x| format(x)}.join("\n")),
306
310
  ].join("\n"))
307
311
  end,
308
312
  *if node.unique and node.unique.length > 0
@@ -347,8 +351,20 @@ module Expressir
347
351
  format(node.return_type),
348
352
  ';'
349
353
  ].join(''),
350
- *if node.declarations and node.declarations.length > 0
351
- indent(node.declarations.map{|x| format(x)}.join("\n"))
354
+ *if node.types and node.types.length > 0
355
+ indent(node.types.map{|x| format(x)}.join("\n"))
356
+ end,
357
+ *if node.entities and node.entities.length > 0
358
+ indent(node.entities.map{|x| format(x)}.join("\n"))
359
+ end,
360
+ *if node.subtype_constraints and node.subtype_constraints.length > 0
361
+ indent(node.subtype_constraints.map{|x| format(x)}.join("\n"))
362
+ end,
363
+ *if node.functions and node.functions.length > 0
364
+ indent(node.functions.map{|x| format(x)}.join("\n"))
365
+ end,
366
+ *if node.procedures and node.procedures.length > 0
367
+ indent(node.procedures.map{|x| format(x)}.join("\n"))
352
368
  end,
353
369
  *if node.constants and node.constants.length > 0
354
370
  indent([
@@ -434,8 +450,20 @@ module Expressir
434
450
  end,
435
451
  ';'
436
452
  ].join(''),
437
- *if node.declarations and node.declarations.length > 0
438
- indent(node.declarations.map{|x| format(x)}.join("\n"))
453
+ *if node.types and node.types.length > 0
454
+ indent(node.types.map{|x| format(x)}.join("\n"))
455
+ end,
456
+ *if node.entities and node.entities.length > 0
457
+ indent(node.entities.map{|x| format(x)}.join("\n"))
458
+ end,
459
+ *if node.subtype_constraints and node.subtype_constraints.length > 0
460
+ indent(node.subtype_constraints.map{|x| format(x)}.join("\n"))
461
+ end,
462
+ *if node.functions and node.functions.length > 0
463
+ indent(node.functions.map{|x| format(x)}.join("\n"))
464
+ end,
465
+ *if node.procedures and node.procedures.length > 0
466
+ indent(node.procedures.map{|x| format(x)}.join("\n"))
439
467
  end,
440
468
  *if node.constants and node.constants.length > 0
441
469
  indent([
@@ -500,8 +528,20 @@ module Expressir
500
528
  ')',
501
529
  ';'
502
530
  ].join(''),
503
- *if node.declarations and node.declarations.length > 0
504
- indent(node.declarations.map{|x| format(x)}.join("\n"))
531
+ *if node.types and node.types.length > 0
532
+ indent(node.types.map{|x| format(x)}.join("\n"))
533
+ end,
534
+ *if node.entities and node.entities.length > 0
535
+ indent(node.entities.map{|x| format(x)}.join("\n"))
536
+ end,
537
+ *if node.subtype_constraints and node.subtype_constraints.length > 0
538
+ indent(node.subtype_constraints.map{|x| format(x)}.join("\n"))
539
+ end,
540
+ *if node.functions and node.functions.length > 0
541
+ indent(node.functions.map{|x| format(x)}.join("\n"))
542
+ end,
543
+ *if node.procedures and node.procedures.length > 0
544
+ indent(node.procedures.map{|x| format(x)}.join("\n"))
505
545
  end,
506
546
  *if node.constants and node.constants.length > 0
507
547
  indent([
@@ -566,8 +606,23 @@ module Expressir
566
606
  ].join('')
567
607
  ].join("\n")
568
608
  end,
569
- *if node.declarations and node.declarations.length > 0
570
- node.declarations.map{|x| format(x)}.join("\n\n")
609
+ *if node.types and node.types.length > 0
610
+ node.types.map{|x| format(x)}.join("\n")
611
+ end,
612
+ *if node.entities and node.entities.length > 0
613
+ node.entities.map{|x| format(x)}.join("\n")
614
+ end,
615
+ *if node.subtype_constraints and node.subtype_constraints.length > 0
616
+ node.subtype_constraints.map{|x| format(x)}.join("\n")
617
+ end,
618
+ *if node.functions and node.functions.length > 0
619
+ node.functions.map{|x| format(x)}.join("\n")
620
+ end,
621
+ *if node.procedures and node.procedures.length > 0
622
+ node.procedures.map{|x| format(x)}.join("\n")
623
+ end,
624
+ *if node.rules and node.rules.length > 0
625
+ node.rules.map{|x| format(x)}.join("\n")
571
626
  end,
572
627
  [
573
628
  'END_SCHEMA',
@@ -1226,7 +1281,7 @@ module Expressir
1226
1281
  format(node.extension_type)
1227
1282
  ].join('')
1228
1283
  end,
1229
- *if node.extension_items
1284
+ *if node.extension_items and node.extension_items.length > 0
1230
1285
  [
1231
1286
  ' ',
1232
1287
  'WITH',
@@ -1330,7 +1385,7 @@ module Expressir
1330
1385
  format(node.extension_type)
1331
1386
  ].join('')
1332
1387
  end,
1333
- *if node.extension_items
1388
+ *if node.extension_items and node.extension_items.length > 0
1334
1389
  [
1335
1390
  ' ',
1336
1391
  'WITH',
@@ -26,6 +26,10 @@ require "set"
26
26
  #
27
27
  # static shorthands are unwrapped
28
28
  # - entity attributes, function/procedure parameters, local variables
29
+ #
30
+ # all access to ctx members must happen before calling other visitor code
31
+ # - prevents segfault in ANTLR4 C++ runtime, not sure why they are caused
32
+ # - e.g. see visit_schema_decl
29
33
 
30
34
  module Expressir
31
35
  module ExpressExp
@@ -47,16 +51,28 @@ module Expressir
47
51
  result
48
52
  end
49
53
 
50
- def visit_if(ctx)
51
- visit(ctx) if ctx
54
+ def visit_if(ctx, default = nil)
55
+ if ctx
56
+ visit(ctx)
57
+ else
58
+ default
59
+ end
52
60
  end
53
61
 
54
62
  def visit_if_map(ctx)
55
- ctx.map{|ctx2| visit(ctx2)} if ctx
63
+ if ctx
64
+ ctx.map{|ctx2| visit(ctx2)}
65
+ else
66
+ []
67
+ end
56
68
  end
57
69
 
58
70
  def visit_if_map_flatten(ctx)
59
- ctx.map{|ctx2| visit(ctx2)}.flatten if ctx
71
+ if ctx
72
+ ctx.map{|ctx2| visit(ctx2)}.flatten
73
+ else
74
+ []
75
+ end
60
76
  end
61
77
 
62
78
  def get_tokens_source(tokens)
@@ -416,8 +432,8 @@ module Expressir
416
432
 
417
433
  bound1 = visit_if(ctx__bound_spec__bound1)
418
434
  bound2 = visit_if(ctx__bound_spec__bound2)
419
- optional = !!ctx__OPTIONAL
420
- unique = !!ctx__UNIQUE
435
+ optional = ctx__OPTIONAL && true
436
+ unique = ctx__UNIQUE && true
421
437
  base_type = visit_if(ctx__instantiable_type)
422
438
 
423
439
  Model::Types::Array.new({
@@ -501,7 +517,7 @@ module Expressir
501
517
  ctx__width_spec__FIXED = ctx__width_spec&.FIXED
502
518
 
503
519
  width = visit_if(ctx__width_spec__width)
504
- fixed = !!ctx__width_spec__FIXED
520
+ fixed = ctx__width_spec__FIXED && true
505
521
 
506
522
  Model::Types::Binary.new({
507
523
  width: width,
@@ -753,7 +769,7 @@ module Expressir
753
769
  ctx__entity_body__where_clause = ctx__entity_body&.where_clause
754
770
 
755
771
  id = visit_if(ctx__entity_head__entity_id)
756
- abstract = !!(ctx__entity_head__subsuper__supertype_constraint__abstract_entity_declaration || ctx__entity_head__subsuper__supertype_constraint__abstract_supertype_declaration)
772
+ abstract = (ctx__entity_head__subsuper__supertype_constraint__abstract_entity_declaration || ctx__entity_head__subsuper__supertype_constraint__abstract_supertype_declaration) && true
757
773
  supertype_expression = visit_if(ctx__entity_head__subsuper__supertype_constraint__abstract_supertype_declaration || ctx__entity_head__subsuper__supertype_constraint__supertype_rule)
758
774
  subtype_of = visit_if(ctx__entity_head__subsuper__subtype_declaration)
759
775
  attributes = [
@@ -761,8 +777,8 @@ module Expressir
761
777
  *visit_if(ctx__entity_body__derive_clause),
762
778
  *visit_if(ctx__entity_body__inverse_clause)
763
779
  ]
764
- unique = visit_if(ctx__entity_body__unique_clause)
765
- where = visit_if(ctx__entity_body__where_clause)
780
+ unique = visit_if(ctx__entity_body__unique_clause, [])
781
+ where = visit_if(ctx__entity_body__where_clause, [])
766
782
 
767
783
  Model::Entity.new({
768
784
  id: id,
@@ -835,10 +851,10 @@ module Expressir
835
851
  ctx__enumeration_extension__type_ref = ctx__enumeration_extension&.type_ref
836
852
  ctx__enumeration_extension__enumeration_items = ctx__enumeration_extension&.enumeration_items
837
853
 
838
- extensible = !!ctx__EXTENSIBLE
839
- items = visit_if(ctx__enumeration_items)
854
+ extensible = ctx__EXTENSIBLE && true
855
+ items = visit_if(ctx__enumeration_items, [])
840
856
  extension_type = visit_if(ctx__enumeration_extension__type_ref)
841
- extension_items = visit_if(ctx__enumeration_extension__enumeration_items)
857
+ extension_items = visit_if(ctx__enumeration_extension__enumeration_items, [])
842
858
 
843
859
  Model::Types::Enumeration.new({
844
860
  extensible: extensible,
@@ -858,7 +874,7 @@ module Expressir
858
874
  ctx__parameter_type = ctx.parameter_type
859
875
 
860
876
  attributes = visit_if_map(ctx__attribute_decl)
861
- optional = !!ctx__OPTIONAL
877
+ optional = ctx__OPTIONAL && true
862
878
  type = visit_if(ctx__parameter_type)
863
879
 
864
880
  attributes.map do |attribute|
@@ -932,7 +948,7 @@ module Expressir
932
948
  ctx__actual_parameter_list = ctx.actual_parameter_list
933
949
 
934
950
  ref = visit_if(ctx__built_in_function || ctx__function_ref)
935
- parameters = visit_if(ctx__actual_parameter_list)
951
+ parameters = visit_if(ctx__actual_parameter_list, [])
936
952
 
937
953
  Model::Expressions::Call.new({
938
954
  ref: ref,
@@ -955,15 +971,24 @@ module Expressir
955
971
  parameters = visit_if_map_flatten(ctx__function_head__formal_parameter)
956
972
  return_type = visit_if(ctx__function_head__parameter_type)
957
973
  declarations = visit_if_map(ctx__algorithm_head__declaration)
958
- constants = visit_if(ctx__algorithm_head__constant_decl)
959
- variables = visit_if(ctx__algorithm_head__local_decl)
974
+ types = declarations.select{|x| x.instance_of? Model::Type}
975
+ entities = declarations.select{|x| x.instance_of? Model::Entity}
976
+ subtype_constraints = declarations.select{|x| x.instance_of? Model::SubtypeConstraint}
977
+ functions = declarations.select{|x| x.instance_of? Model::Function}
978
+ procedures = declarations.select{|x| x.instance_of? Model::Procedure}
979
+ constants = visit_if(ctx__algorithm_head__constant_decl, [])
980
+ variables = visit_if(ctx__algorithm_head__local_decl, [])
960
981
  statements = visit_if_map(ctx__stmt)
961
982
 
962
983
  Model::Function.new({
963
984
  id: id,
964
985
  parameters: parameters,
965
986
  return_type: return_type,
966
- declarations: declarations,
987
+ types: types,
988
+ entities: entities,
989
+ subtype_constraints: subtype_constraints,
990
+ functions: functions,
991
+ procedures: procedures,
967
992
  constants: constants,
968
993
  variables: variables,
969
994
  statements: statements
@@ -1008,8 +1033,8 @@ module Expressir
1008
1033
 
1009
1034
  bound1 = visit_if(ctx__bound_spec__bound1)
1010
1035
  bound2 = visit_if(ctx__bound_spec__bound2)
1011
- optional = !!ctx__OPTIONAL
1012
- unique = !!ctx__UNIQUE
1036
+ optional = ctx__OPTIONAL && true
1037
+ unique = ctx__UNIQUE && true
1013
1038
  base_type = visit_if(ctx__parameter_type)
1014
1039
 
1015
1040
  Model::Types::Array.new({
@@ -1047,7 +1072,7 @@ module Expressir
1047
1072
 
1048
1073
  bound1 = visit_if(ctx__bound_spec__bound1)
1049
1074
  bound2 = visit_if(ctx__bound_spec__bound2)
1050
- unique = !!ctx__UNIQUE
1075
+ unique = ctx__UNIQUE && true
1051
1076
  base_type = visit_if(ctx__parameter_type)
1052
1077
 
1053
1078
  Model::Types::List.new({
@@ -1122,8 +1147,8 @@ module Expressir
1122
1147
  ctx__if_stmt_else_statements = ctx.if_stmt_else_statements
1123
1148
 
1124
1149
  expression = visit_if(ctx__logical_expression)
1125
- statements = visit_if(ctx__if_stmt_statements)
1126
- else_statements = visit_if(ctx__if_stmt_else_statements)
1150
+ statements = visit_if(ctx__if_stmt_statements, [])
1151
+ else_statements = visit_if(ctx__if_stmt_else_statements, [])
1127
1152
 
1128
1153
  Model::Statements::If.new({
1129
1154
  expression: expression,
@@ -1337,7 +1362,7 @@ module Expressir
1337
1362
 
1338
1363
  bound1 = visit_if(ctx__bound_spec__bound1)
1339
1364
  bound2 = visit_if(ctx__bound_spec__bound2)
1340
- unique = !!ctx__UNIQUE
1365
+ unique = ctx__UNIQUE && true
1341
1366
  base_type = visit_if(ctx__instantiable_type)
1342
1367
 
1343
1368
  Model::Types::List.new({
@@ -1553,7 +1578,7 @@ module Expressir
1553
1578
  ctx__actual_parameter_list = ctx.actual_parameter_list
1554
1579
 
1555
1580
  ref = visit_if(ctx__built_in_procedure || ctx__procedure_ref)
1556
- parameters = visit_if(ctx__actual_parameter_list)
1581
+ parameters = visit_if(ctx__actual_parameter_list, [])
1557
1582
 
1558
1583
  Model::Statements::Call.new({
1559
1584
  ref: ref,
@@ -1574,14 +1599,23 @@ module Expressir
1574
1599
  id = visit_if(ctx__procedure_head__procedure_id)
1575
1600
  parameters = visit_if_map_flatten(ctx__procedure_head__procedure_head_parameter)
1576
1601
  declarations = visit_if_map(ctx__algorithm_head__declaration)
1577
- constants = visit_if(ctx__algorithm_head__constant_decl)
1578
- variables = visit_if(ctx__algorithm_head__local_decl)
1602
+ types = declarations.select{|x| x.instance_of? Model::Type}
1603
+ entities = declarations.select{|x| x.instance_of? Model::Entity}
1604
+ subtype_constraints = declarations.select{|x| x.instance_of? Model::SubtypeConstraint}
1605
+ functions = declarations.select{|x| x.instance_of? Model::Function}
1606
+ procedures = declarations.select{|x| x.instance_of? Model::Procedure}
1607
+ constants = visit_if(ctx__algorithm_head__constant_decl, [])
1608
+ variables = visit_if(ctx__algorithm_head__local_decl, [])
1579
1609
  statements = visit_if_map(ctx__stmt)
1580
1610
 
1581
1611
  Model::Procedure.new({
1582
1612
  id: id,
1583
1613
  parameters: parameters,
1584
- declarations: declarations,
1614
+ types: types,
1615
+ entities: entities,
1616
+ subtype_constraints: subtype_constraints,
1617
+ functions: functions,
1618
+ procedures: procedures,
1585
1619
  constants: constants,
1586
1620
  variables: variables,
1587
1621
  statements: statements
@@ -1858,15 +1892,24 @@ module Expressir
1858
1892
  id = visit_if(ctx__rule_head__rule_id)
1859
1893
  applies_to = visit_if_map(ctx__rule_head__entity_ref)
1860
1894
  declarations = visit_if_map(ctx__algorithm_head__declaration)
1861
- constants = visit_if(ctx__algorithm_head__constant_decl)
1862
- variables = visit_if(ctx__algorithm_head__local_decl)
1895
+ types = declarations.select{|x| x.instance_of? Model::Type}
1896
+ entities = declarations.select{|x| x.instance_of? Model::Entity}
1897
+ subtype_constraints = declarations.select{|x| x.instance_of? Model::SubtypeConstraint}
1898
+ functions = declarations.select{|x| x.instance_of? Model::Function}
1899
+ procedures = declarations.select{|x| x.instance_of? Model::Procedure}
1900
+ constants = visit_if(ctx__algorithm_head__constant_decl, [])
1901
+ variables = visit_if(ctx__algorithm_head__local_decl, [])
1863
1902
  statements = visit_if_map(ctx__stmt)
1864
- where = visit_if(ctx__where_clause)
1903
+ where = visit_if(ctx__where_clause, [])
1865
1904
 
1866
1905
  Model::Rule.new({
1867
1906
  id: id,
1868
1907
  applies_to: applies_to,
1869
- declarations: declarations,
1908
+ types: types,
1909
+ entities: entities,
1910
+ subtype_constraints: subtype_constraints,
1911
+ functions: functions,
1912
+ procedures: procedures,
1870
1913
  constants: constants,
1871
1914
  variables: variables,
1872
1915
  statements: statements,
@@ -1912,15 +1955,26 @@ module Expressir
1912
1955
  id = visit_if(ctx__schema_id)
1913
1956
  version = visit_if(ctx__schema_version_id)
1914
1957
  interfaces = visit_if_map(ctx__schema_body__interface_specification)
1915
- constants = visit_if(ctx__schema_body__constant_decl)
1958
+ constants = visit_if(ctx__schema_body__constant_decl, [])
1916
1959
  declarations = visit_if_map(ctx__schema_body__schema_body_declaration)
1960
+ types = declarations.select{|x| x.instance_of? Model::Type}
1961
+ entities = declarations.select{|x| x.instance_of? Model::Entity}
1962
+ subtype_constraints = declarations.select{|x| x.instance_of? Model::SubtypeConstraint}
1963
+ functions = declarations.select{|x| x.instance_of? Model::Function}
1964
+ procedures = declarations.select{|x| x.instance_of? Model::Procedure}
1965
+ rules = declarations.select{|x| x.instance_of? Model::Rule}
1917
1966
 
1918
1967
  Model::Schema.new({
1919
1968
  id: id,
1920
1969
  version: version,
1921
1970
  interfaces: interfaces,
1922
1971
  constants: constants,
1923
- declarations: declarations
1972
+ types: types,
1973
+ entities: entities,
1974
+ subtype_constraints: subtype_constraints,
1975
+ functions: functions,
1976
+ procedures: procedures,
1977
+ rules: rules
1924
1978
  })
1925
1979
  end
1926
1980
 
@@ -1960,11 +2014,11 @@ module Expressir
1960
2014
  ctx__select_extension__type_ref = ctx.select_extension&.type_ref
1961
2015
  ctx__select_extension__select_list = ctx__select_extension&.select_list
1962
2016
 
1963
- extensible = !!ctx__EXTENSIBLE
1964
- generic_entity = !!ctx__GENERIC_ENTITY
1965
- items = visit_if(ctx__select_list)
2017
+ extensible = ctx__EXTENSIBLE && true
2018
+ generic_entity = ctx__GENERIC_ENTITY && true
2019
+ items = visit_if(ctx__select_list, [])
1966
2020
  extension_type = visit_if(ctx__select_extension__type_ref)
1967
- extension_items = visit_if(ctx__select_extension__select_list)
2021
+ extension_items = visit_if(ctx__select_extension__select_list, [])
1968
2022
 
1969
2023
  Model::Types::Select.new({
1970
2024
  extensible: extensible,
@@ -2097,7 +2151,7 @@ module Expressir
2097
2151
  ctx__width_spec__FIXED = ctx__width_spec&.FIXED
2098
2152
 
2099
2153
  width = visit_if(ctx__width_spec__width)
2100
- fixed = !!ctx__width_spec__FIXED
2154
+ fixed = ctx__width_spec__FIXED && true
2101
2155
 
2102
2156
  Model::Types::String.new({
2103
2157
  width: width,
@@ -2130,7 +2184,7 @@ module Expressir
2130
2184
 
2131
2185
  id = visit_if(ctx__subtype_constraint_head__subtype_constraint_id)
2132
2186
  applies_to = visit_if(ctx__subtype_constraint_head__entity_ref)
2133
- abstract = !!ctx__subtype_constraint_body__abstract_supertype
2187
+ abstract = ctx__subtype_constraint_body__abstract_supertype && true
2134
2188
  total_over = visit_if(ctx__subtype_constraint_body__total_over)
2135
2189
  supertype_expression = visit_if(ctx__subtype_constraint_body__supertype_expression)
2136
2190
 
@@ -2266,7 +2320,7 @@ module Expressir
2266
2320
 
2267
2321
  id = visit_if(ctx__type_id)
2268
2322
  type = visit_if(ctx__underlying_type)
2269
- where = visit_if(ctx__where_clause)
2323
+ where = visit_if(ctx__where_clause, [])
2270
2324
 
2271
2325
  Model::Type.new({
2272
2326
  id: id,