expressir 0.2.5 → 0.2.10

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 (96) hide show
  1. checksums.yaml +4 -4
  2. data/.cross_rubies +30 -0
  3. data/.github/workflows/rake.yml +14 -15
  4. data/.github/workflows/release.yml +24 -16
  5. data/.gitignore +3 -1
  6. data/Gemfile +0 -2
  7. data/Rakefile +2 -8
  8. data/expressir.gemspec +7 -4
  9. data/ext/express-parser/express_parser.cpp +12 -10
  10. data/ext/express-parser/extconf.rb +48 -25
  11. data/lib/expressir/express_exp/formatter.rb +74 -23
  12. data/lib/expressir/express_exp/parser.rb +20 -2
  13. data/lib/expressir/express_exp/visitor.rb +201 -96
  14. data/lib/expressir/model.rb +3 -0
  15. data/lib/expressir/model/attribute.rb +3 -1
  16. data/lib/expressir/model/constant.rb +3 -1
  17. data/lib/expressir/model/entity.rb +12 -19
  18. data/lib/expressir/model/enumeration_item.rb +3 -1
  19. data/lib/expressir/model/expressions/aggregate_initializer.rb +2 -2
  20. data/lib/expressir/model/expressions/aggregate_item.rb +1 -1
  21. data/lib/expressir/model/expressions/attribute_reference.rb +1 -1
  22. data/lib/expressir/model/expressions/binary_expression.rb +1 -1
  23. data/lib/expressir/model/expressions/call.rb +2 -2
  24. data/lib/expressir/model/expressions/entity_constructor.rb +2 -2
  25. data/lib/expressir/model/expressions/group_reference.rb +1 -1
  26. data/lib/expressir/model/expressions/index_reference.rb +1 -1
  27. data/lib/expressir/model/expressions/interval.rb +1 -1
  28. data/lib/expressir/model/expressions/query_expression.rb +5 -3
  29. data/lib/expressir/model/expressions/simple_reference.rb +1 -1
  30. data/lib/expressir/model/expressions/unary_expression.rb +1 -1
  31. data/lib/expressir/model/function.rb +32 -38
  32. data/lib/expressir/model/identifier.rb +1 -0
  33. data/lib/expressir/model/informal_proposition.rb +13 -0
  34. data/lib/expressir/model/interface.rb +2 -2
  35. data/lib/expressir/model/literals/binary.rb +1 -1
  36. data/lib/expressir/model/literals/integer.rb +1 -1
  37. data/lib/expressir/model/literals/logical.rb +1 -1
  38. data/lib/expressir/model/literals/real.rb +1 -1
  39. data/lib/expressir/model/literals/string.rb +1 -1
  40. data/lib/expressir/model/model_element.rb +67 -0
  41. data/lib/expressir/model/parameter.rb +3 -1
  42. data/lib/expressir/model/procedure.rb +33 -39
  43. data/lib/expressir/model/renamed_ref.rb +1 -1
  44. data/lib/expressir/model/repository.rb +3 -3
  45. data/lib/expressir/model/rule.rb +35 -38
  46. data/lib/expressir/model/schema.rb +35 -46
  47. data/lib/expressir/model/scope.rb +49 -3
  48. data/lib/expressir/model/statements/alias.rb +4 -2
  49. data/lib/expressir/model/statements/assignment.rb +1 -1
  50. data/lib/expressir/model/statements/call.rb +2 -2
  51. data/lib/expressir/model/statements/case.rb +2 -2
  52. data/lib/expressir/model/statements/case_action.rb +2 -2
  53. data/lib/expressir/model/statements/compound.rb +2 -2
  54. data/lib/expressir/model/statements/escape.rb +1 -1
  55. data/lib/expressir/model/statements/if.rb +3 -3
  56. data/lib/expressir/model/statements/null.rb +1 -1
  57. data/lib/expressir/model/statements/repeat.rb +4 -2
  58. data/lib/expressir/model/statements/return.rb +1 -1
  59. data/lib/expressir/model/statements/skip.rb +1 -1
  60. data/lib/expressir/model/subtype_constraint.rb +3 -1
  61. data/lib/expressir/model/type.rb +13 -3
  62. data/lib/expressir/model/types/aggregate.rb +3 -1
  63. data/lib/expressir/model/types/array.rb +1 -1
  64. data/lib/expressir/model/types/bag.rb +1 -1
  65. data/lib/expressir/model/types/binary.rb +1 -1
  66. data/lib/expressir/model/types/boolean.rb +1 -1
  67. data/lib/expressir/model/types/enumeration.rb +3 -3
  68. data/lib/expressir/model/types/generic.rb +3 -1
  69. data/lib/expressir/model/types/generic_entity.rb +3 -1
  70. data/lib/expressir/model/types/integer.rb +1 -1
  71. data/lib/expressir/model/types/list.rb +1 -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 +1 -1
  75. data/lib/expressir/model/types/select.rb +3 -3
  76. data/lib/expressir/model/types/set.rb +1 -1
  77. data/lib/expressir/model/types/string.rb +1 -1
  78. data/lib/expressir/model/unique.rb +4 -2
  79. data/lib/expressir/model/variable.rb +3 -1
  80. data/lib/expressir/model/where.rb +3 -1
  81. data/lib/expressir/version.rb +1 -1
  82. data/original/examples/syntax/remark.exp +64 -20
  83. data/original/examples/syntax/remark_formatted.exp +63 -24
  84. data/original/examples/syntax/simple.exp +3 -0
  85. data/original/examples/syntax/source.exp +16 -0
  86. data/original/examples/syntax/syntax.exp +194 -181
  87. data/original/examples/syntax/syntax_formatted.exp +354 -787
  88. data/rakelib/cross-ruby.rake +308 -0
  89. data/spec/expressir/express_exp/head_source_spec.rb +38 -0
  90. data/spec/expressir/express_exp/parse_multiple_spec.rb +32 -0
  91. data/spec/expressir/express_exp/parse_remark_spec.rb +122 -56
  92. data/spec/expressir/express_exp/parse_syntax_spec.rb +1619 -1569
  93. data/spec/expressir/express_exp/source_spec.rb +29 -0
  94. data/spec/expressir/model/model_element_spec.rb +59 -0
  95. data/spec/expressir/model/{find_spec.rb → scope_spec.rb} +20 -7
  96. metadata +45 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 567720b9ed58f631e97fe20795af2c4b99850cadb1e6fef158d8d264cde9a201
4
- data.tar.gz: a9ecc46df11220f963c69235c1b27aa7d97bad00b5b961f16bc1548feed2e2a7
3
+ metadata.gz: b7ba84b2e2bb6810108340208cb5d2e72047af1576990acfeb73c4f077eb8ba2
4
+ data.tar.gz: e92db63b885211b20df63adb3f91e6bb299af7ce745aa4c6f9557e7deb583257
5
5
  SHA512:
6
- metadata.gz: 278e45df08db09c8e84d5c61173315e80a68bdadd1c729940f42e07a684255b15cf1ab82edd6d241304f896e5a06e71a00008d8975f20e7e513b314db69c1afc
7
- data.tar.gz: 642fdc300642949ab9d6eeb9d3142ac0972383930b56909f3aafada88164527fb74440b94eb61504e584e2b80452c2defbc9d5fab8445bba8bd7f58d58c0fb00
6
+ metadata.gz: 5ded502bc8563615f49af32175de1127b41aa019f0efe42699ba953da542bc5df04d3639196c6355f55d1b12c94b496eb8bfe03e1e41a179df69bfd97270dc5a
7
+ data.tar.gz: 99015fc2a30fe12f69ccd861ffd49e54593666e6892176f0076c90f215df282bb77c83ddf7bf197915366bdab162757a1834851dd4118426de9fb38735c69855
data/.cross_rubies ADDED
@@ -0,0 +1,30 @@
1
+ 3.0.0:i686-w64-mingw32
2
+ 3.0.0:x86_64-w64-mingw32
3
+ 3.0.0:i686-linux-gnu
4
+ 3.0.0:x86_64-linux-gnu
5
+ 3.0.0:x86_64-darwin
6
+ 3.0.0:arm64-darwin
7
+ 2.7.0:i686-w64-mingw32
8
+ 2.7.0:x86_64-w64-mingw32
9
+ 2.7.0:i686-linux-gnu
10
+ 2.7.0:x86_64-linux-gnu
11
+ 2.7.0:x86_64-darwin
12
+ 2.7.0:arm64-darwin
13
+ 2.6.0:i686-w64-mingw32
14
+ 2.6.0:x86_64-w64-mingw32
15
+ 2.6.0:i686-linux-gnu
16
+ 2.6.0:x86_64-linux-gnu
17
+ 2.6.0:x86_64-darwin
18
+ 2.6.0:arm64-darwin
19
+ 2.5.0:i686-w64-mingw32
20
+ 2.5.0:x86_64-w64-mingw32
21
+ 2.5.0:i686-linux-gnu
22
+ 2.5.0:x86_64-linux-gnu
23
+ 2.5.0:x86_64-darwin
24
+ 2.5.0:arm64-darwin
25
+ 2.4.0:i686-w64-mingw32
26
+ 2.4.0:x86_64-w64-mingw32
27
+ 2.4.0:i686-linux-gnu
28
+ 2.4.0:x86_64-linux-gnu
29
+ 2.4.0:x86_64-darwin
30
+ 2.4.0:arm64-darwin
@@ -3,8 +3,6 @@ name: rake
3
3
  on:
4
4
  push:
5
5
  branches: [ master ]
6
- tags:
7
- - '*'
8
6
  pull_request:
9
7
 
10
8
  jobs:
@@ -18,28 +16,29 @@ jobs:
18
16
  ruby: [ '2.7', '2.6', '2.5', '2.4' ]
19
17
  os: [ ubuntu-latest, windows-latest, macos-latest ]
20
18
  experimental: [ false ]
19
+ include:
20
+ - ruby: '3.0'
21
+ os: 'ubuntu-latest'
22
+ experimental: true
23
+ - ruby: '3.0'
24
+ os: 'windows-latest'
25
+ experimental: true
26
+ - ruby: '3.0'
27
+ os: 'macos-latest'
28
+ experimental: true
21
29
 
22
30
  steps:
23
31
  - uses: actions/checkout@v2
24
32
  with:
25
33
  submodules: recursive
26
34
 
27
- - uses: ruby/setup-ruby@v1
28
- with:
29
- ruby-version: ${{ matrix.ruby }}
30
-
31
- - uses: actions/cache@v2
32
- with:
33
- path: vendor/bundle
34
- key: bundle-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}
35
- restore-keys: bundle-${{ matrix.os }}-${{ matrix.ruby }}
36
-
37
35
  - if: matrix.os == 'macos-latest'
38
36
  run: brew install autoconf automake libtool
39
37
 
40
- - run: bundle config set path 'vendor/bundle'
41
-
42
- - run: bundle install --jobs 4 --retry 3
38
+ - uses: ruby/setup-ruby@v1
39
+ with:
40
+ ruby-version: ${{ matrix.ruby }}
41
+ bundler-cache: true
43
42
 
44
43
  - run: bundle exec rake compile
45
44
 
@@ -7,11 +7,11 @@ on:
7
7
 
8
8
  jobs:
9
9
  pack:
10
- runs-on: ${{ matrix.os }}
10
+ runs-on: ubuntu-18.04
11
11
  strategy:
12
12
  fail-fast: false
13
13
  matrix:
14
- os: [ ubuntu-latest, windows-latest, macos-latest ]
14
+ host: [ linux, windows, darwin ]
15
15
  steps:
16
16
  - uses: actions/checkout@v2
17
17
  with:
@@ -19,39 +19,48 @@ jobs:
19
19
 
20
20
  - uses: ruby/setup-ruby@v1
21
21
  with:
22
- ruby-version: '2.4'
23
-
24
- - if: matrix.os == 'macos-latest'
25
- run: brew install autoconf automake libtool
22
+ ruby-version: '2.6'
26
23
 
27
24
  - run: bundle install --jobs 4 --retry 3
28
25
 
29
- - run: bundle exec rake native gem
26
+ - run: gem build expressir.gemspec
27
+
28
+ - if: matrix.host == 'linux'
29
+ uses: actions/upload-artifact@v2
30
+ with:
31
+ name: pkg-ruby
32
+ path: expressir-*.gem
30
33
 
31
- - run: bundle exec rake
34
+ - run: bundle exec rake gem:${{ matrix.host }}
32
35
 
33
36
  - uses: actions/upload-artifact@v2
34
37
  with:
35
- name: pkg-${{ matrix.os }}
38
+ name: pkg-${{ matrix.host }}
36
39
  path: pkg/*.gem
37
40
 
41
+
38
42
  release:
39
43
  runs-on: ubuntu-18.04
40
44
  needs: pack
41
45
  steps:
42
46
  - uses: actions/download-artifact@v2
43
47
  with:
44
- name: pkg-ubuntu-latest
48
+ name: pkg-ruby
49
+ path: pkg
50
+
51
+ - uses: actions/download-artifact@v2
52
+ with:
53
+ name: pkg-linux
45
54
  path: pkg
46
55
 
47
56
  - uses: actions/download-artifact@v2
48
57
  with:
49
- name: pkg-windows-latest
58
+ name: pkg-windows
50
59
  path: pkg
51
60
 
52
61
  - uses: actions/download-artifact@v2
53
62
  with:
54
- name: pkg-macos-latest
63
+ name: pkg-darwin
55
64
  path: pkg
56
65
 
57
66
  - uses: ruby/setup-ruby@v1
@@ -62,14 +71,13 @@ jobs:
62
71
 
63
72
  - name: Publish to rubygems.org
64
73
  env:
65
- RUBYGEMS_API_KEY: ${{secrets.LUTAML_CI_RUBYGEMS_API_KEY}}
74
+ RUBYGEMS_API_KEY: ${{ secrets.LUTAML_CI_RUBYGEMS_API_KEY }}
66
75
  run: |
67
76
  mkdir -p ~/.gem
68
- cat <<'EOF' > ~/.gem/credentials
77
+ cat > ~/.gem/credentials << EOF
69
78
  ---
70
79
  :rubygems_api_key: ${RUBYGEMS_API_KEY}
71
80
  EOF
72
81
  chmod 0600 ~/.gem/credentials
73
- gem -v
74
82
  gem signin
75
- for gem in pkg/*.gem; do gem push $gem -V -k rubygems ; done
83
+ for gem in pkg/*.gem; do gem push $gem -V; done
data/.gitignore CHANGED
@@ -8,8 +8,10 @@
8
8
  /tmp/
9
9
  /Gemfile.lock
10
10
  /.idea
11
- /lib/express_parser.bundle
11
+ /lib/expressir/express_exp/express_parser.bundle
12
12
  /original/examples/syntax/*-pretty.exp
13
13
 
14
14
  # rspec failure tracking
15
15
  .rspec_status
16
+
17
+ /ext/express-parser/rice-embed
data/Gemfile CHANGED
@@ -2,5 +2,3 @@ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in reeper.gemspec
4
4
  gemspec
5
-
6
- gem "rake-compiler", git: "https://github.com/larskanis/rake-compiler", branch: "fix-native-version"
data/Rakefile CHANGED
@@ -6,12 +6,6 @@ RSpec::Core::RakeTask.new(:spec)
6
6
 
7
7
  task :default => :spec
8
8
 
9
- spec = Gem::Specification.load("expressir.gemspec")
9
+ GEMSPEC = Gem::Specification.load("expressir.gemspec")
10
10
 
11
- # add your default gem packing task
12
- Gem::PackageTask.new(spec) do |pkg|
13
- end
14
-
15
- ext = Rake::ExtensionTask.new("express_parser", spec) do |ext|
16
- ext.ext_dir = "ext/express-parser"
17
- end
11
+ Gem::PackageTask.new(GEMSPEC).define
data/expressir.gemspec CHANGED
@@ -17,6 +17,8 @@ Gem::Specification.new do |spec|
17
17
  spec.metadata["source_code_uri"] = spec.homepage
18
18
  spec.metadata["changelog_uri"] = "https://github.com/lutaml/expressir/releases"
19
19
 
20
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
21
+
20
22
  spec.files = `git ls-files`.split("\n")\
21
23
  + Dir.glob('ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/**/*')
22
24
 
@@ -28,13 +30,14 @@ Gem::Specification.new do |spec|
28
30
 
29
31
  spec.extensions = File.join(*%w(ext express-parser extconf.rb))
30
32
 
33
+ spec.add_runtime_dependency "nokogiri", "~> 1.10"
31
34
  spec.add_runtime_dependency "thor", "~> 1.0"
32
- spec.add_runtime_dependency "rice", "~> 2.2.0"
35
+ spec.add_runtime_dependency "rice", "~> 3"
33
36
  spec.add_development_dependency "antlr4-native", "~> 1.1.0"
34
- spec.add_development_dependency "nokogiri", "~> 1.10"
35
37
  spec.add_development_dependency "bundler", "~> 2.0"
36
38
  spec.add_development_dependency "pry", "~> 0.12.2"
37
- spec.add_development_dependency "rake", "~> 10.0"
38
- spec.add_development_dependency "rake-compiler", "~> 1.1.1"
39
+ spec.add_development_dependency "rake", "~> 13.0"
40
+ spec.add_development_dependency "rake-compiler", "~> 1.1"
41
+ spec.add_development_dependency "rake-compiler-dock", "~> 1.1"
39
42
  spec.add_development_dependency "rspec", "~> 3.0"
40
43
  end
@@ -1,24 +1,26 @@
1
1
  #include <iostream>
2
2
 
3
- #include "antlr4-runtime.h"
3
+ #include <antlr4-runtime.h>
4
4
 
5
- #include "ExpressParser.h"
6
- #include "ExpressBaseVisitor.h"
7
- #include "ExpressLexer.h"
5
+ #include "antlrgen/ExpressParser.h"
6
+ #include "antlrgen/ExpressBaseVisitor.h"
7
+ #include "antlrgen/ExpressLexer.h"
8
8
 
9
- #include "rice/Array.hpp"
10
- #include "rice/Class.hpp"
11
- #include "rice/Constructor.hpp"
12
- #include "rice/Director.hpp"
9
+ #include <rice/Array.hpp>
10
+ #include <rice/Class.hpp>
11
+ #include <rice/Constructor.hpp>
12
+ #include <rice/Director.hpp>
13
13
 
14
14
  #ifdef _WIN32
15
- #undef FALSE
16
- #undef TRUE
17
15
  #undef OPTIONAL
18
16
  #undef IN
19
17
  #undef OUT
20
18
  #endif
21
19
 
20
+ // ruby-3.0
21
+ #undef FALSE
22
+ #undef TRUE
23
+
22
24
  using namespace std;
23
25
  using namespace Rice;
24
26
  using namespace antlr4;
@@ -1,34 +1,57 @@
1
- require 'mkmf-rice'
1
+ require 'rubygems'
2
+ require 'mkmf'
2
3
 
3
4
  extension_name = 'express_parser'
4
- dir_config(extension_name)
5
-
6
- have_library('stdc++')
7
-
8
- $CFLAGS << ' -std=c++14 -DANTLR4CPP_STATIC'
9
-
10
- include_paths = [
11
- '.',
12
- 'antlrgen',
13
- 'antlr4-upstream/runtime/Cpp/runtime/src',
14
- 'antlr4-upstream/runtime/Cpp/runtime/src/atn',
15
- 'antlr4-upstream/runtime/Cpp/runtime/src/dfa',
16
- 'antlr4-upstream/runtime/Cpp/runtime/src/misc',
17
- 'antlr4-upstream/runtime/Cpp/runtime/src/support',
18
- 'antlr4-upstream/runtime/Cpp/runtime/src/tree',
19
- 'antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern',
20
- 'antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath'
5
+ cross_build = enable_config("cross-build")
6
+
7
+ antlr4_src = 'antlr4-upstream/runtime/Cpp/runtime/src'
8
+ src_paths = [
9
+ ".",
10
+ "antlrgen",
11
+ "#{antlr4_src}",
12
+ "#{antlr4_src}/atn",
13
+ "#{antlr4_src}/dfa",
14
+ "#{antlr4_src}/misc",
15
+ "#{antlr4_src}/support",
16
+ "#{antlr4_src}/tree",
17
+ "#{antlr4_src}/tree/pattern",
18
+ "#{antlr4_src}/tree/xpath",
21
19
  ]
22
20
 
23
- $srcs = []
21
+ if cross_build
22
+ rice_subdir = "rice-embed"
23
+ rice_root = Gem.loaded_specs["rice"].full_gem_path
24
+ rice_src = File.join(rice_root, "rice")
25
+ rice_embed = File.join(__dir__, rice_subdir)
26
+ unless File.exists?(rice_embed)
27
+ FileUtils.mkdir_p(rice_embed)
28
+ FileUtils.cp_r(Dir.glob(rice_src), rice_embed)
29
+ File.delete(*Dir.glob("#{rice_embed}/**/*.o"))
30
+ File.delete(*Dir.glob("#{rice_embed}/**/Makefile"))
31
+ end
24
32
 
25
- include_paths.each do |include_path|
26
- $INCFLAGS << " -I#{__dir__}/#{include_path}"
27
- $VPATH << "#{__dir__}/#{include_path}"
33
+ src_paths.push("#{rice_subdir}/rice", "#{rice_subdir}/rice/detail")
28
34
 
29
- Dir.glob("#{__dir__}/#{include_path}/*.cpp").each do |path|
30
- $srcs << path
35
+ $INCFLAGS << " -I#{__dir__}/#{rice_subdir}"
36
+
37
+ if RbConfig::CONFIG['target_os'] =~ /mingw32|mswin/
38
+ # workaround for 'w64-mingw32-as: express_parser.o: too many sections'
39
+ $CXXFLAGS << " -O3 -Wa,-mbig-obj"
31
40
  end
41
+ else
42
+ require 'mkmf-rice'
43
+
44
+ dir_config(extension_name)
45
+ end
46
+
47
+ $CPPFLAGS << " -std=c++14 -DANTLR4CPP_STATIC -DHAVE_CXX11"
48
+ $INCFLAGS << " -I#{__dir__}/#{antlr4_src}"
49
+ $srcs = []
50
+
51
+ src_paths.each do |src_path|
52
+ abs_src_path = File.join(__dir__, src_path)
53
+ $VPATH << abs_src_path
54
+ $srcs.push(*Dir["#{abs_src_path}/*.cpp"])
32
55
  end
33
56
 
34
- create_makefile(extension_name)
57
+ create_makefile "expressir/express_exp/#{extension_name}"
@@ -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([
@@ -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',
@@ -832,7 +887,7 @@ module Expressir
832
887
  ' ',
833
888
  '<*',
834
889
  ' ',
835
- format(node.source),
890
+ format(node.aggregate_source),
836
891
  ' ',
837
892
  '|',
838
893
  ' ',
@@ -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',
@@ -1437,11 +1492,7 @@ module Expressir
1437
1492
  [
1438
1493
  *format_remarks(node),
1439
1494
  *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
1495
+ node.children.select{|x| x.parent == node}.flat_map{|x| format_scope_remarks(x)}
1445
1496
  end
1446
1497
  ]
1447
1498
  end