expressir 0.2.9-x64-mingw32 → 0.2.14-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/exe/format +20 -0
  3. data/expressir.gemspec +1 -0
  4. data/lib/expressir/express_exp/2.4/express_parser.so +0 -0
  5. data/lib/expressir/express_exp/2.5/express_parser.so +0 -0
  6. data/lib/expressir/express_exp/2.6/express_parser.so +0 -0
  7. data/lib/expressir/express_exp/2.7/express_parser.so +0 -0
  8. data/lib/expressir/express_exp/3.0/express_parser.so +0 -0
  9. data/lib/expressir/express_exp/formatter.rb +146 -105
  10. data/lib/expressir/express_exp/hyperlink_formatter.rb +25 -0
  11. data/lib/expressir/express_exp/parser.rb +2 -0
  12. data/lib/expressir/express_exp/schema_head_formatter.rb +14 -0
  13. data/lib/expressir/express_exp/visitor.rb +132 -82
  14. data/lib/expressir/model.rb +2 -1
  15. data/lib/expressir/model/attribute.rb +5 -1
  16. data/lib/expressir/model/constant.rb +5 -1
  17. data/lib/expressir/model/entity.rb +13 -22
  18. data/lib/expressir/model/enumeration_item.rb +5 -1
  19. data/lib/expressir/model/expressions/aggregate_initializer.rb +4 -2
  20. data/lib/expressir/model/expressions/aggregate_item.rb +3 -1
  21. data/lib/expressir/model/expressions/attribute_reference.rb +3 -1
  22. data/lib/expressir/model/expressions/binary_expression.rb +3 -1
  23. data/lib/expressir/model/expressions/call.rb +4 -2
  24. data/lib/expressir/model/expressions/entity_constructor.rb +4 -2
  25. data/lib/expressir/model/expressions/group_reference.rb +3 -1
  26. data/lib/expressir/model/expressions/index_reference.rb +3 -1
  27. data/lib/expressir/model/expressions/interval.rb +3 -1
  28. data/lib/expressir/model/expressions/query_expression.rb +5 -2
  29. data/lib/expressir/model/expressions/simple_reference.rb +3 -1
  30. data/lib/expressir/model/expressions/unary_expression.rb +3 -1
  31. data/lib/expressir/model/function.rb +28 -39
  32. data/lib/expressir/model/identifier.rb +1 -3
  33. data/lib/expressir/model/informal_proposition.rb +5 -1
  34. data/lib/expressir/model/interface.rb +4 -2
  35. data/lib/expressir/model/literals/binary.rb +3 -1
  36. data/lib/expressir/model/literals/integer.rb +3 -1
  37. data/lib/expressir/model/literals/logical.rb +3 -1
  38. data/lib/expressir/model/literals/real.rb +3 -1
  39. data/lib/expressir/model/literals/string.rb +3 -1
  40. data/lib/expressir/model/model_element.rb +140 -0
  41. data/lib/expressir/model/parameter.rb +5 -1
  42. data/lib/expressir/model/procedure.rb +29 -40
  43. data/lib/expressir/model/renamed_ref.rb +3 -1
  44. data/lib/expressir/model/repository.rb +5 -5
  45. data/lib/expressir/model/rule.rb +32 -43
  46. data/lib/expressir/model/schema.rb +48 -48
  47. data/lib/expressir/model/statements/alias.rb +6 -3
  48. data/lib/expressir/model/statements/assignment.rb +3 -1
  49. data/lib/expressir/model/statements/call.rb +4 -2
  50. data/lib/expressir/model/statements/case.rb +4 -2
  51. data/lib/expressir/model/statements/case_action.rb +4 -2
  52. data/lib/expressir/model/statements/compound.rb +4 -2
  53. data/lib/expressir/model/statements/escape.rb +1 -1
  54. data/lib/expressir/model/statements/if.rb +5 -3
  55. data/lib/expressir/model/statements/null.rb +1 -1
  56. data/lib/expressir/model/statements/repeat.rb +6 -3
  57. data/lib/expressir/model/statements/return.rb +3 -1
  58. data/lib/expressir/model/statements/skip.rb +1 -1
  59. data/lib/expressir/model/subtype_constraint.rb +5 -2
  60. data/lib/expressir/model/type.rb +10 -11
  61. data/lib/expressir/model/types/aggregate.rb +5 -1
  62. data/lib/expressir/model/types/array.rb +3 -1
  63. data/lib/expressir/model/types/bag.rb +3 -1
  64. data/lib/expressir/model/types/binary.rb +3 -1
  65. data/lib/expressir/model/types/boolean.rb +1 -1
  66. data/lib/expressir/model/types/enumeration.rb +5 -3
  67. data/lib/expressir/model/types/generic.rb +5 -1
  68. data/lib/expressir/model/types/generic_entity.rb +5 -1
  69. data/lib/expressir/model/types/integer.rb +1 -1
  70. data/lib/expressir/model/types/list.rb +3 -1
  71. data/lib/expressir/model/types/logical.rb +1 -1
  72. data/lib/expressir/model/types/number.rb +1 -1
  73. data/lib/expressir/model/types/real.rb +3 -1
  74. data/lib/expressir/model/types/select.rb +5 -3
  75. data/lib/expressir/model/types/set.rb +3 -1
  76. data/lib/expressir/model/types/string.rb +3 -1
  77. data/lib/expressir/model/unique.rb +6 -2
  78. data/lib/expressir/model/variable.rb +5 -1
  79. data/lib/expressir/model/where.rb +5 -1
  80. data/lib/expressir/version.rb +1 -1
  81. data/original/examples/syntax/hyperlink.exp +8 -0
  82. data/original/examples/syntax/hyperlink_formatted.exp +19 -0
  83. data/original/examples/syntax/remark_formatted.exp +0 -5
  84. data/original/examples/syntax/simple.exp +3 -0
  85. data/original/examples/syntax/syntax.exp +197 -189
  86. data/original/examples/syntax/syntax_formatted.exp +362 -800
  87. data/spec/expressir/express_exp/{format_remark_spec.rb → formatter/remark_spec.rb} +2 -2
  88. data/spec/expressir/express_exp/{format_syntax_spec.rb → formatter/syntax_spec.rb} +2 -2
  89. data/spec/expressir/express_exp/hyperlink_formatter_spec.rb +24 -0
  90. data/spec/expressir/express_exp/{head_source_spec.rb → parser/head_source_spec.rb} +2 -5
  91. data/spec/expressir/express_exp/{parse_multiple_spec.rb → parser/multiple_spec.rb} +6 -1
  92. data/spec/expressir/express_exp/{parse_remark_spec.rb → parser/remark_spec.rb} +5 -5
  93. data/spec/expressir/express_exp/{source_spec.rb → parser/source_spec.rb} +2 -5
  94. data/spec/expressir/express_exp/{parse_syntax_spec.rb → parser/syntax_spec.rb} +1619 -1582
  95. data/spec/expressir/express_exp/schema_head_formatter_spec.rb +36 -0
  96. data/spec/expressir/model/{find_spec.rb → model_element/find_spec.rb} +7 -2
  97. data/spec/expressir/model/model_element/hash_spec.rb +66 -0
  98. metadata +34 -12
  99. data/lib/expressir/model/scope.rb +0 -66
  100. data/spec/expressir/express_exp/ap233_spec.rb +0 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2c719db0761b1b75f5590f1191f65e63d022eb415f66fa14c4728ad5df7db158
4
- data.tar.gz: 3180e6fbec4586127435b21cec78aced020a67b0d48e2a44536d8b07ff103ff7
3
+ metadata.gz: 5a68cb513f80ef0e6ced7a6493cea943d6b0e4044574102736972fa808bc8132
4
+ data.tar.gz: a6d453143c962a6a70935d4e02fe8a9c86081212e50da0d96271bd42d26c79cb
5
5
  SHA512:
6
- metadata.gz: 1d14fdcdea1dad73f8d9ed888e3601d0f58b8bc737f0f4242947fa0f92f020b14b97d0c26b60db4620791ffcbe09a72e75be0c916a311239aba0a26f47fb8ffd
7
- data.tar.gz: f757acdc03590adbaa03578aa7416252e4a71e650d7c9bde4711d9dda251638172716b5214c76453695a6abdecf0351f5fc8942fd2c7e94f81a4bbba95f94f10
6
+ metadata.gz: 3f8fc6ccdd917303d86f468c8ae4373f073468db13f83adc8a543abee8f8e5d348b223e13e679ba8d77bff622e6f92ce4aad3370123815c67332cbe172b88598
7
+ data.tar.gz: d01920fcd97378c88bb87090e52aeca6bf0c4cb5b4f6ffbfab6ddaad01049a90e87f68984a74468a3341db4068765067b55524b2d1871adfa10c0453275e143e
data/exe/format ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "expressir/express_exp/parser"
4
+ require "expressir/express_exp/hyperlink_formatter"
5
+
6
+ input_files = [
7
+ '../iso-10303-stepmod/data/resources/action_schema/action_schema_annotated.exp',
8
+ '../iso-10303-stepmod/data/resources/basic_attribute_schema/basic_attribute_schema_annotated.exp',
9
+ '../iso-10303-stepmod/data/resources/support_resource_schema/support_resource_schema_annotated.exp',
10
+ # cyclic reference
11
+ # '../iso-10303-stepmod/data/resources/product_property_definition_schema/product_property_definition_schema_annotated.exp',
12
+ # '../iso-10303-stepmod/data/resources/product_property_representation_schema/product_property_representation_schema_annotated.exp'
13
+ ]
14
+
15
+ repo = Expressir::ExpressExp::Parser.from_files(input_files)
16
+ schema = repo.schemas.find{|x| x.id == 'action_schema'}
17
+ # schema = repo.schemas.find{|x| x.id == 'product_property_definition_schema'}
18
+ result = Expressir::ExpressExp::HyperlinkFormatter.format(schema)
19
+
20
+ puts result
data/expressir.gemspec CHANGED
@@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.add_development_dependency "antlr4-native", "~> 1.1.0"
37
37
  spec.add_development_dependency "bundler", "~> 2.0"
38
38
  spec.add_development_dependency "pry", "~> 0.12.2"
39
+ spec.add_development_dependency "byebug", "~> 11.1"
39
40
  spec.add_development_dependency "rake", "~> 13.0"
40
41
  spec.add_development_dependency "rake-compiler", "~> 1.1"
41
42
  spec.add_development_dependency "rake-compiler-dock", "~> 1.1"
@@ -38,129 +38,129 @@ module Expressir
38
38
  end
39
39
 
40
40
  def format(node)
41
- if node.instance_of? Model::Attribute
41
+ if node.is_a? Model::Attribute
42
42
  format_attribute(node)
43
- elsif node.instance_of? Model::Constant
43
+ elsif node.is_a? Model::Constant
44
44
  format_constant(node)
45
- elsif node.instance_of? Model::Entity
45
+ elsif node.is_a? Model::Entity
46
46
  format_entity(node)
47
- elsif node.instance_of? Model::EnumerationItem
47
+ elsif node.is_a? Model::EnumerationItem
48
48
  format_enumeration_item(node)
49
- elsif node.instance_of? Model::Function
49
+ elsif node.is_a? Model::Function
50
50
  format_function(node)
51
- elsif node.instance_of? Model::Interface
51
+ elsif node.is_a? Model::Interface
52
52
  format_interface(node)
53
- elsif node.instance_of? Model::Parameter
53
+ elsif node.is_a? Model::Parameter
54
54
  format_parameter(node)
55
- elsif node.instance_of? Model::Procedure
55
+ elsif node.is_a? Model::Procedure
56
56
  format_procedure(node)
57
- elsif node.instance_of? Model::RenamedRef
57
+ elsif node.is_a? Model::RenamedRef
58
58
  format_renamed_ref(node)
59
- elsif node.instance_of? Model::Repository
59
+ elsif node.is_a? Model::Repository
60
60
  format_repository(node)
61
- elsif node.instance_of? Model::Rule
61
+ elsif node.is_a? Model::Rule
62
62
  format_rule(node)
63
- elsif node.instance_of? Model::Schema
63
+ elsif node.is_a? Model::Schema
64
64
  format_schema(node)
65
- elsif node.instance_of? Model::SubtypeConstraint
65
+ elsif node.is_a? Model::SubtypeConstraint
66
66
  format_subtype_constraint(node)
67
- elsif node.instance_of? Model::Type
67
+ elsif node.is_a? Model::Type
68
68
  format_type(node)
69
- elsif node.instance_of? Model::Unique
69
+ elsif node.is_a? Model::Unique
70
70
  format_unique(node)
71
- elsif node.instance_of? Model::Variable
71
+ elsif node.is_a? Model::Variable
72
72
  format_variable(node)
73
- elsif node.instance_of? Model::Where
73
+ elsif node.is_a? Model::Where
74
74
  format_where(node)
75
- elsif node.instance_of? Model::Expressions::AggregateInitializer
75
+ elsif node.is_a? Model::Expressions::AggregateInitializer
76
76
  format_expressions_aggregate_initializer(node)
77
- elsif node.instance_of? Model::Expressions::AggregateItem
77
+ elsif node.is_a? Model::Expressions::AggregateItem
78
78
  format_expressions_aggregate_item(node)
79
- elsif node.instance_of? Model::Expressions::AttributeReference
79
+ elsif node.is_a? Model::Expressions::AttributeReference
80
80
  format_expressions_attribute_reference(node)
81
- elsif node.instance_of? Model::Expressions::BinaryExpression
81
+ elsif node.is_a? Model::Expressions::BinaryExpression
82
82
  format_expressions_binary_expression(node)
83
- elsif node.instance_of? Model::Expressions::Call
83
+ elsif node.is_a? Model::Expressions::Call
84
84
  format_expressions_call(node)
85
- elsif node.instance_of? Model::Expressions::EntityConstructor
85
+ elsif node.is_a? Model::Expressions::EntityConstructor
86
86
  format_expressions_entity_constructor(node)
87
- elsif node.instance_of? Model::Expressions::GroupReference
87
+ elsif node.is_a? Model::Expressions::GroupReference
88
88
  format_expressions_group_reference(node)
89
- elsif node.instance_of? Model::Expressions::IndexReference
89
+ elsif node.is_a? Model::Expressions::IndexReference
90
90
  format_expressions_index_reference(node)
91
- elsif node.instance_of? Model::Expressions::Interval
91
+ elsif node.is_a? Model::Expressions::Interval
92
92
  format_expressions_interval(node)
93
- elsif node.instance_of? Model::Expressions::QueryExpression
93
+ elsif node.is_a? Model::Expressions::QueryExpression
94
94
  format_expressions_query_expression(node)
95
- elsif node.instance_of? Model::Expressions::SimpleReference
95
+ elsif node.is_a? Model::Expressions::SimpleReference
96
96
  format_expressions_simple_reference(node)
97
- elsif node.instance_of? Model::Expressions::UnaryExpression
97
+ elsif node.is_a? Model::Expressions::UnaryExpression
98
98
  format_expressions_unary_expression(node)
99
- elsif node.instance_of? Model::Literals::Binary
99
+ elsif node.is_a? Model::Literals::Binary
100
100
  format_literals_binary(node)
101
- elsif node.instance_of? Model::Literals::Integer
101
+ elsif node.is_a? Model::Literals::Integer
102
102
  format_literals_integer(node)
103
- elsif node.instance_of? Model::Literals::Logical
103
+ elsif node.is_a? Model::Literals::Logical
104
104
  format_literals_logical(node)
105
- elsif node.instance_of? Model::Literals::Real
105
+ elsif node.is_a? Model::Literals::Real
106
106
  format_literals_real(node)
107
- elsif node.instance_of? Model::Literals::String
107
+ elsif node.is_a? Model::Literals::String
108
108
  format_literals_string(node)
109
- elsif node.instance_of? Model::Statements::Alias
109
+ elsif node.is_a? Model::Statements::Alias
110
110
  format_statements_alias(node)
111
- elsif node.instance_of? Model::Statements::Assignment
111
+ elsif node.is_a? Model::Statements::Assignment
112
112
  format_statements_assignment(node)
113
- elsif node.instance_of? Model::Statements::Call
113
+ elsif node.is_a? Model::Statements::Call
114
114
  format_statements_call(node)
115
- elsif node.instance_of? Model::Statements::Case
115
+ elsif node.is_a? Model::Statements::Case
116
116
  format_statements_case(node)
117
- elsif node.instance_of? Model::Statements::CaseAction
117
+ elsif node.is_a? Model::Statements::CaseAction
118
118
  format_statements_case_action(node)
119
- elsif node.instance_of? Model::Statements::Compound
119
+ elsif node.is_a? Model::Statements::Compound
120
120
  format_statements_compound(node)
121
- elsif node.instance_of? Model::Statements::Escape
121
+ elsif node.is_a? Model::Statements::Escape
122
122
  format_statements_escape(node)
123
- elsif node.instance_of? Model::Statements::If
123
+ elsif node.is_a? Model::Statements::If
124
124
  format_statements_if(node)
125
- elsif node.instance_of? Model::Statements::Null
125
+ elsif node.is_a? Model::Statements::Null
126
126
  format_statements_null(node)
127
- elsif node.instance_of? Model::Statements::Repeat
127
+ elsif node.is_a? Model::Statements::Repeat
128
128
  format_statements_repeat(node)
129
- elsif node.instance_of? Model::Statements::Return
129
+ elsif node.is_a? Model::Statements::Return
130
130
  format_statements_return(node)
131
- elsif node.instance_of? Model::Statements::Skip
131
+ elsif node.is_a? Model::Statements::Skip
132
132
  format_statements_skip(node)
133
- elsif node.instance_of? Model::Types::Aggregate
133
+ elsif node.is_a? Model::Types::Aggregate
134
134
  format_types_aggregate(node)
135
- elsif node.instance_of? Model::Types::Array
135
+ elsif node.is_a? Model::Types::Array
136
136
  format_types_array(node)
137
- elsif node.instance_of? Model::Types::Bag
137
+ elsif node.is_a? Model::Types::Bag
138
138
  format_types_bag(node)
139
- elsif node.instance_of? Model::Types::Binary
139
+ elsif node.is_a? Model::Types::Binary
140
140
  format_types_binary(node)
141
- elsif node.instance_of? Model::Types::Boolean
141
+ elsif node.is_a? Model::Types::Boolean
142
142
  format_types_boolean(node)
143
- elsif node.instance_of? Model::Types::Enumeration
143
+ elsif node.is_a? Model::Types::Enumeration
144
144
  format_types_enumeration(node)
145
- elsif node.instance_of? Model::Types::GenericEntity
145
+ elsif node.is_a? Model::Types::GenericEntity
146
146
  format_types_generic_entity(node)
147
- elsif node.instance_of? Model::Types::Generic
147
+ elsif node.is_a? Model::Types::Generic
148
148
  format_types_generic(node)
149
- elsif node.instance_of? Model::Types::Integer
149
+ elsif node.is_a? Model::Types::Integer
150
150
  format_types_integer(node)
151
- elsif node.instance_of? Model::Types::List
151
+ elsif node.is_a? Model::Types::List
152
152
  format_types_list(node)
153
- elsif node.instance_of? Model::Types::Logical
153
+ elsif node.is_a? Model::Types::Logical
154
154
  format_types_logical(node)
155
- elsif node.instance_of? Model::Types::Number
155
+ elsif node.is_a? Model::Types::Number
156
156
  format_types_number(node)
157
- elsif node.instance_of? Model::Types::Real
157
+ elsif node.is_a? Model::Types::Real
158
158
  format_types_real(node)
159
- elsif node.instance_of? Model::Types::Select
159
+ elsif node.is_a? Model::Types::Select
160
160
  format_types_select(node)
161
- elsif node.instance_of? Model::Types::Set
161
+ elsif node.is_a? Model::Types::Set
162
162
  format_types_set(node)
163
- elsif node.instance_of? Model::Types::String
163
+ elsif node.is_a? Model::Types::String
164
164
  format_types_string(node)
165
165
  else
166
166
  puts node.class
@@ -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([
@@ -481,8 +509,7 @@ module Expressir
481
509
  [
482
510
  *if node.schemas and node.schemas.length > 0
483
511
  node.schemas.map{|node| format(node)}
484
- end,
485
- *format_scope_remarks(node)
512
+ end
486
513
  ].join("\n")
487
514
  end
488
515
 
@@ -500,8 +527,20 @@ module Expressir
500
527
  ')',
501
528
  ';'
502
529
  ].join(''),
503
- *if node.declarations and node.declarations.length > 0
504
- indent(node.declarations.map{|x| format(x)}.join("\n"))
530
+ *if node.types and node.types.length > 0
531
+ indent(node.types.map{|x| format(x)}.join("\n"))
532
+ end,
533
+ *if node.entities and node.entities.length > 0
534
+ indent(node.entities.map{|x| format(x)}.join("\n"))
535
+ end,
536
+ *if node.subtype_constraints and node.subtype_constraints.length > 0
537
+ indent(node.subtype_constraints.map{|x| format(x)}.join("\n"))
538
+ end,
539
+ *if node.functions and node.functions.length > 0
540
+ indent(node.functions.map{|x| format(x)}.join("\n"))
541
+ end,
542
+ *if node.procedures and node.procedures.length > 0
543
+ indent(node.procedures.map{|x| format(x)}.join("\n"))
505
544
  end,
506
545
  *if node.constants and node.constants.length > 0
507
546
  indent([
@@ -566,13 +605,29 @@ module Expressir
566
605
  ].join('')
567
606
  ].join("\n")
568
607
  end,
569
- *if node.declarations and node.declarations.length > 0
570
- node.declarations.map{|x| format(x)}.join("\n\n")
608
+ *if node.types and node.types.length > 0
609
+ node.types.map{|x| format(x)}.join("\n")
610
+ end,
611
+ *if node.entities and node.entities.length > 0
612
+ node.entities.map{|x| format(x)}.join("\n")
613
+ end,
614
+ *if node.subtype_constraints and node.subtype_constraints.length > 0
615
+ node.subtype_constraints.map{|x| format(x)}.join("\n")
616
+ end,
617
+ *if node.functions and node.functions.length > 0
618
+ node.functions.map{|x| format(x)}.join("\n")
619
+ end,
620
+ *if node.procedures and node.procedures.length > 0
621
+ node.procedures.map{|x| format(x)}.join("\n")
622
+ end,
623
+ *if node.rules and node.rules.length > 0
624
+ node.rules.map{|x| format(x)}.join("\n")
571
625
  end,
572
626
  [
573
627
  'END_SCHEMA',
574
628
  ';'
575
- ].join('')
629
+ ].join(''),
630
+ *format_scope_remarks(node)
576
631
  ].join("\n")
577
632
  end
578
633
 
@@ -718,11 +773,11 @@ module Expressir
718
773
 
719
774
  def format_expressions_binary_expression(node)
720
775
  [
721
- *if node.operand1.instance_of? Model::Expressions::BinaryExpression and OPERATOR_PRECEDENCE[node.operand1.operator] > OPERATOR_PRECEDENCE[node.operator]
776
+ *if node.operand1.is_a? Model::Expressions::BinaryExpression and OPERATOR_PRECEDENCE[node.operand1.operator] > OPERATOR_PRECEDENCE[node.operator]
722
777
  '('
723
778
  end,
724
779
  format(node.operand1),
725
- *if node.operand1.instance_of? Model::Expressions::BinaryExpression and OPERATOR_PRECEDENCE[node.operand1.operator] > OPERATOR_PRECEDENCE[node.operator]
780
+ *if node.operand1.is_a? Model::Expressions::BinaryExpression and OPERATOR_PRECEDENCE[node.operand1.operator] > OPERATOR_PRECEDENCE[node.operator]
726
781
  ')'
727
782
  end,
728
783
  ' ',
@@ -751,11 +806,11 @@ module Expressir
751
806
  when Model::Expressions::BinaryExpression::XOR then 'XOR'
752
807
  end,
753
808
  ' ',
754
- *if node.operand2.instance_of? Model::Expressions::BinaryExpression and OPERATOR_PRECEDENCE[node.operand2.operator] > OPERATOR_PRECEDENCE[node.operator]
809
+ *if node.operand2.is_a? Model::Expressions::BinaryExpression and OPERATOR_PRECEDENCE[node.operand2.operator] > OPERATOR_PRECEDENCE[node.operator]
755
810
  '('
756
811
  end,
757
812
  format(node.operand2),
758
- *if node.operand2.instance_of? Model::Expressions::BinaryExpression and OPERATOR_PRECEDENCE[node.operand2.operator] > OPERATOR_PRECEDENCE[node.operator]
813
+ *if node.operand2.is_a? Model::Expressions::BinaryExpression and OPERATOR_PRECEDENCE[node.operand2.operator] > OPERATOR_PRECEDENCE[node.operator]
759
814
  ')'
760
815
  end,
761
816
  ].join('')
@@ -856,11 +911,11 @@ module Expressir
856
911
  if node.operator == Model::Expressions::UnaryExpression::NOT
857
912
  ' '
858
913
  end,
859
- *if node.operand.instance_of? Model::Expressions::BinaryExpression
914
+ *if node.operand.is_a? Model::Expressions::BinaryExpression
860
915
  '('
861
916
  end,
862
917
  format(node.operand),
863
- *if node.operand.instance_of? Model::Expressions::BinaryExpression
918
+ *if node.operand.is_a? Model::Expressions::BinaryExpression
864
919
  ')'
865
920
  end
866
921
  ].join('')
@@ -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',
@@ -1387,25 +1442,13 @@ module Expressir
1387
1442
  str.split("\n").map{|x| "#{INDENT}#{x}"}.join("\n")
1388
1443
  end
1389
1444
 
1390
- def format_remark_ref(node)
1391
- [
1392
- *if node.class.method_defined? :parent and node.parent.class.method_defined? :id and node.parent != node
1393
- [
1394
- format_remark_ref(node.parent),
1395
- '.'
1396
- ].join('')
1397
- end,
1398
- node.id,
1399
- ].join('')
1400
- end
1401
-
1402
1445
  def format_remark(node, remark)
1403
1446
  if remark.include?("\n")
1404
1447
  [
1405
1448
  [
1406
1449
  '(*',
1407
1450
  '"',
1408
- format_remark_ref(node),
1451
+ node.path,
1409
1452
  '"',
1410
1453
  ].join(''),
1411
1454
  remark,
@@ -1415,7 +1458,7 @@ module Expressir
1415
1458
  [
1416
1459
  '--',
1417
1460
  '"',
1418
- format_remark_ref(node),
1461
+ node.path,
1419
1462
  '"',
1420
1463
  ' ',
1421
1464
  remark
@@ -1424,7 +1467,7 @@ module Expressir
1424
1467
  end
1425
1468
 
1426
1469
  def format_remarks(node)
1427
- if node.class.method_defined? :remarks and node.remarks and node.remarks.length > 0
1470
+ if node.class.method_defined? :remarks
1428
1471
  node.remarks.map do |remark|
1429
1472
  format_remark(node, remark)
1430
1473
  end
@@ -1436,9 +1479,7 @@ module Expressir
1436
1479
  def format_scope_remarks(node)
1437
1480
  [
1438
1481
  *format_remarks(node),
1439
- *if node.class.method_defined? :children
1440
- node.children.select{|x| x.parent == node}.flat_map{|x| format_scope_remarks(x)}
1441
- end
1482
+ *node.children.select{|x| !x.is_a? Model::EnumerationItem or node.is_a? Model::Type}.flat_map{|x| format_scope_remarks(x)}
1442
1483
  ]
1443
1484
  end
1444
1485
  end