expressir 0.2.8-x64-mingw32 → 0.2.13-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release.yml +1 -7
  3. data/exe/format +20 -0
  4. data/expressir.gemspec +3 -2
  5. data/lib/expressir/express_exp/2.4/express_parser.so +0 -0
  6. data/lib/expressir/express_exp/2.5/express_parser.so +0 -0
  7. data/lib/expressir/express_exp/2.6/express_parser.so +0 -0
  8. data/lib/expressir/express_exp/2.7/express_parser.so +0 -0
  9. data/lib/expressir/express_exp/3.0/express_parser.so +0 -0
  10. data/lib/expressir/express_exp/formatter.rb +147 -110
  11. data/lib/expressir/express_exp/hyperlink_formatter.rb +25 -0
  12. data/lib/expressir/express_exp/parser.rb +14 -1
  13. data/lib/expressir/express_exp/schema_head_formatter.rb +14 -0
  14. data/lib/expressir/express_exp/visitor.rb +197 -111
  15. data/lib/expressir/model.rb +3 -1
  16. data/lib/expressir/model/attribute.rb +5 -1
  17. data/lib/expressir/model/constant.rb +5 -1
  18. data/lib/expressir/model/entity.rb +14 -20
  19. data/lib/expressir/model/enumeration_item.rb +5 -1
  20. data/lib/expressir/model/expressions/aggregate_initializer.rb +4 -2
  21. data/lib/expressir/model/expressions/aggregate_item.rb +3 -1
  22. data/lib/expressir/model/expressions/attribute_reference.rb +3 -1
  23. data/lib/expressir/model/expressions/binary_expression.rb +3 -1
  24. data/lib/expressir/model/expressions/call.rb +4 -2
  25. data/lib/expressir/model/expressions/entity_constructor.rb +4 -2
  26. data/lib/expressir/model/expressions/group_reference.rb +3 -1
  27. data/lib/expressir/model/expressions/index_reference.rb +3 -1
  28. data/lib/expressir/model/expressions/interval.rb +3 -1
  29. data/lib/expressir/model/expressions/query_expression.rb +5 -2
  30. data/lib/expressir/model/expressions/simple_reference.rb +3 -1
  31. data/lib/expressir/model/expressions/unary_expression.rb +3 -1
  32. data/lib/expressir/model/function.rb +28 -39
  33. data/lib/expressir/model/identifier.rb +1 -3
  34. data/lib/expressir/model/informal_proposition.rb +15 -0
  35. data/lib/expressir/model/interface.rb +4 -2
  36. data/lib/expressir/model/literals/binary.rb +3 -1
  37. data/lib/expressir/model/literals/integer.rb +3 -1
  38. data/lib/expressir/model/literals/logical.rb +3 -1
  39. data/lib/expressir/model/literals/real.rb +3 -1
  40. data/lib/expressir/model/literals/string.rb +3 -1
  41. data/lib/expressir/model/model_element.rb +140 -0
  42. data/lib/expressir/model/parameter.rb +5 -1
  43. data/lib/expressir/model/procedure.rb +29 -40
  44. data/lib/expressir/model/renamed_ref.rb +3 -1
  45. data/lib/expressir/model/repository.rb +5 -5
  46. data/lib/expressir/model/rule.rb +33 -41
  47. data/lib/expressir/model/schema.rb +44 -46
  48. data/lib/expressir/model/statements/alias.rb +6 -3
  49. data/lib/expressir/model/statements/assignment.rb +3 -1
  50. data/lib/expressir/model/statements/call.rb +4 -2
  51. data/lib/expressir/model/statements/case.rb +4 -2
  52. data/lib/expressir/model/statements/case_action.rb +4 -2
  53. data/lib/expressir/model/statements/compound.rb +4 -2
  54. data/lib/expressir/model/statements/escape.rb +1 -1
  55. data/lib/expressir/model/statements/if.rb +5 -3
  56. data/lib/expressir/model/statements/null.rb +1 -1
  57. data/lib/expressir/model/statements/repeat.rb +6 -3
  58. data/lib/expressir/model/statements/return.rb +3 -1
  59. data/lib/expressir/model/statements/skip.rb +1 -1
  60. data/lib/expressir/model/subtype_constraint.rb +5 -2
  61. data/lib/expressir/model/type.rb +11 -4
  62. data/lib/expressir/model/types/aggregate.rb +5 -1
  63. data/lib/expressir/model/types/array.rb +3 -1
  64. data/lib/expressir/model/types/bag.rb +3 -1
  65. data/lib/expressir/model/types/binary.rb +3 -1
  66. data/lib/expressir/model/types/boolean.rb +1 -1
  67. data/lib/expressir/model/types/enumeration.rb +5 -3
  68. data/lib/expressir/model/types/generic.rb +5 -1
  69. data/lib/expressir/model/types/generic_entity.rb +5 -1
  70. data/lib/expressir/model/types/integer.rb +1 -1
  71. data/lib/expressir/model/types/list.rb +3 -1
  72. data/lib/expressir/model/types/logical.rb +1 -1
  73. data/lib/expressir/model/types/number.rb +1 -1
  74. data/lib/expressir/model/types/real.rb +3 -1
  75. data/lib/expressir/model/types/select.rb +5 -3
  76. data/lib/expressir/model/types/set.rb +3 -1
  77. data/lib/expressir/model/types/string.rb +3 -1
  78. data/lib/expressir/model/unique.rb +6 -2
  79. data/lib/expressir/model/variable.rb +5 -1
  80. data/lib/expressir/model/where.rb +5 -1
  81. data/lib/expressir/version.rb +1 -1
  82. data/original/examples/syntax/hyperlink.exp +8 -0
  83. data/original/examples/syntax/hyperlink_formatted.exp +19 -0
  84. data/original/examples/syntax/remark.exp +63 -20
  85. data/original/examples/syntax/remark_formatted.exp +62 -24
  86. data/original/examples/syntax/simple.exp +3 -0
  87. data/original/examples/syntax/source.exp +16 -0
  88. data/original/examples/syntax/syntax.exp +201 -190
  89. data/original/examples/syntax/syntax_formatted.exp +370 -799
  90. data/spec/expressir/express_exp/{format_remark_spec.rb → formatter/remark_spec.rb} +2 -2
  91. data/spec/expressir/express_exp/{format_syntax_spec.rb → formatter/syntax_spec.rb} +2 -2
  92. data/spec/expressir/express_exp/hyperlink_formatter_spec.rb +24 -0
  93. data/spec/expressir/express_exp/parser/head_source_spec.rb +38 -0
  94. data/spec/expressir/express_exp/parser/multiple_spec.rb +32 -0
  95. data/spec/expressir/express_exp/{parse_remark_spec.rb → parser/remark_spec.rb} +120 -55
  96. data/spec/expressir/express_exp/{source_spec.rb → parser/source_spec.rb} +3 -6
  97. data/spec/expressir/express_exp/parser/syntax_spec.rb +3080 -0
  98. data/spec/expressir/express_exp/schema_head_formatter_spec.rb +36 -0
  99. data/spec/expressir/model/{find_spec.rb → model_element/find_spec.rb} +26 -8
  100. data/spec/expressir/model/model_element/hash_spec.rb +66 -0
  101. metadata +38 -13
  102. data/lib/expressir/model/scope.rb +0 -32
  103. data/spec/expressir/express_exp/ap233_spec.rb +0 -22
  104. data/spec/expressir/express_exp/find_spec.rb +0 -28
  105. data/spec/expressir/express_exp/parse_syntax_spec.rb +0 -3003
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a9693930dd06c19eededab31261d9d3de41261b28d8c80edd3e0f8a3a8059da
4
- data.tar.gz: d144183e37f61c02b1444436a025291aa5678a9bc9c6675b4872466c0f6075b2
3
+ metadata.gz: 893b08150342d7e5e7d8ec1f0edd111c916355ef2b619e5b99d6faac4e5cd967
4
+ data.tar.gz: 20fec0d8ca1b42dce5dd650c50514bc8d6b1e3985278fd3a37613d51534fc0ae
5
5
  SHA512:
6
- metadata.gz: d40a36cdf2d7712353ba266468bd324e8fe68132fe51231707467a24e848ca5ce029088ba513ccd37531251219bee3e666dfafb01d2323c650d6930b8c1654a1
7
- data.tar.gz: 8e384fed328cb582918a42c12b418db5ecc12ca9dfe9d61ed6f1af8326fee85c1cf8bbce7d2fe6a744a15c63fa5c1afdc45781f24e6d6d4efbc6e1bc28e25435
6
+ metadata.gz: 51dbf159b960e3d973b27239be90a2321598b0557c1c50bff4b74e305564fd8a06fc34efc534382524085102ede330e5961b5ec4a198fea721bf1ec4f9fbec36
7
+ data.tar.gz: 40ae0df6545e9fd98271507696074d5d43339c62feefead2a21590ce7a60eb950037f0efb25deb8cad74f73f29b268fc44a73482fab597a076055a77ad264f8e
@@ -74,16 +74,10 @@ jobs:
74
74
  RUBYGEMS_API_KEY: ${{ secrets.LUTAML_CI_RUBYGEMS_API_KEY }}
75
75
  run: |
76
76
  mkdir -p ~/.gem
77
- echo "---"
78
77
  cat > ~/.gem/credentials << EOF
79
78
  ---
80
79
  :rubygems_api_key: ${RUBYGEMS_API_KEY}
81
80
  EOF
82
- echo "---"
83
81
  chmod 0600 ~/.gem/credentials
84
- echo "---"
85
- ls -la ~/.gem
86
- echo "---"
87
- gem signin --debug
88
- echo "---"
82
+ gem signin
89
83
  for gem in pkg/*.gem; do gem push $gem -V; done
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
@@ -32,11 +32,12 @@ Gem::Specification.new do |spec|
32
32
 
33
33
  spec.add_runtime_dependency "nokogiri", "~> 1.10"
34
34
  spec.add_runtime_dependency "thor", "~> 1.0"
35
- spec.add_runtime_dependency "rice", "~> 2.2.0"
35
+ spec.add_runtime_dependency "rice", "~> 3"
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 "rake", "~> 10.0"
39
+ spec.add_development_dependency "byebug", "~> 11.1"
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"
42
43
  spec.add_development_dependency "rspec", "~> 3.0"
@@ -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([
@@ -395,7 +411,7 @@ module Expressir
395
411
  "\n",
396
412
  INDENT,
397
413
  '(',
398
- node.items.map{|x| format(x)},
414
+ node.items.map{|x| format(x)}.join(', '),
399
415
  ')'
400
416
  ].join('')
401
417
  end,
@@ -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,13 +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.flat_map do |x|
1441
- if x != node
1442
- format_scope_remarks(x)
1443
- end
1444
- end
1445
- end
1482
+ *node.children.select{|x| !x.is_a? Model::EnumerationItem or node.is_a? Model::Type}.flat_map{|x| format_scope_remarks(x)}
1446
1483
  ]
1447
1484
  end
1448
1485
  end