expressir 0.2.21-x86-mingw32 → 1.0.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +7 -6
  3. data/.github/workflows/release.yml +22 -6
  4. data/.gitignore +2 -2
  5. data/demo.rb +5 -5
  6. data/exe/format +10 -73
  7. data/exe/format-test +81 -0
  8. data/expressir.gemspec +0 -1
  9. data/lib/expressir.rb +0 -1
  10. data/lib/expressir/cli.rb +0 -6
  11. data/lib/expressir/express/2.4/express_parser.so +0 -0
  12. data/lib/expressir/express/2.5/express_parser.so +0 -0
  13. data/lib/expressir/express/2.6/express_parser.so +0 -0
  14. data/lib/expressir/express/2.7/express_parser.so +0 -0
  15. data/lib/expressir/express/3.0/express_parser.so +0 -0
  16. data/lib/expressir/{express_exp → express}/cache.rb +3 -6
  17. data/lib/expressir/{express_exp → express}/formatter.rb +84 -68
  18. data/lib/expressir/express/hyperlink_formatter.rb +22 -0
  19. data/lib/expressir/express/model_visitor.rb +23 -0
  20. data/lib/expressir/{express_exp → express}/parser.rb +16 -5
  21. data/lib/expressir/express/resolve_references_model_visitor.rb +29 -0
  22. data/lib/expressir/{express_exp → express}/schema_head_formatter.rb +1 -1
  23. data/lib/expressir/{express_exp → express}/visitor.rb +67 -44
  24. data/lib/expressir/model.rb +5 -3
  25. data/lib/expressir/model/attribute.rb +13 -6
  26. data/lib/expressir/model/cache.rb +2 -2
  27. data/lib/expressir/model/constant.rb +10 -3
  28. data/lib/expressir/model/entity.rb +18 -16
  29. data/lib/expressir/model/enumeration_item.rb +8 -1
  30. data/lib/expressir/model/expressions/aggregate_initializer.rb +2 -2
  31. data/lib/expressir/model/expressions/aggregate_item.rb +2 -2
  32. data/lib/expressir/model/expressions/attribute_reference.rb +2 -2
  33. data/lib/expressir/model/expressions/binary_expression.rb +3 -3
  34. data/lib/expressir/model/expressions/call.rb +3 -3
  35. data/lib/expressir/model/expressions/entity_constructor.rb +3 -3
  36. data/lib/expressir/model/expressions/group_reference.rb +2 -2
  37. data/lib/expressir/model/expressions/index_reference.rb +3 -3
  38. data/lib/expressir/model/expressions/interval.rb +5 -5
  39. data/lib/expressir/model/expressions/query_expression.rb +6 -4
  40. data/lib/expressir/model/expressions/simple_reference.rb +5 -1
  41. data/lib/expressir/model/expressions/unary_expression.rb +2 -2
  42. data/lib/expressir/model/function.rb +23 -21
  43. data/lib/expressir/model/identifier.rb +6 -3
  44. data/lib/expressir/model/interface.rb +4 -4
  45. data/lib/expressir/model/interface_item.rb +2 -2
  46. data/lib/expressir/model/interfaced_item.rb +10 -9
  47. data/lib/expressir/model/literals/binary.rb +1 -1
  48. data/lib/expressir/model/literals/integer.rb +1 -1
  49. data/lib/expressir/model/literals/logical.rb +1 -1
  50. data/lib/expressir/model/literals/real.rb +1 -1
  51. data/lib/expressir/model/literals/string.rb +2 -2
  52. data/lib/expressir/model/model_element.rb +39 -27
  53. data/lib/expressir/model/parameter.rb +10 -3
  54. data/lib/expressir/model/procedure.rb +22 -20
  55. data/lib/expressir/model/remark_item.rb +15 -0
  56. data/lib/expressir/model/repository.rb +2 -2
  57. data/lib/expressir/model/rule.rb +27 -25
  58. data/lib/expressir/model/schema.rb +24 -20
  59. data/lib/expressir/model/schema_version.rb +15 -0
  60. data/lib/expressir/model/schema_version_item.rb +15 -0
  61. data/lib/expressir/model/statements/alias.rb +7 -5
  62. data/lib/expressir/model/statements/assignment.rb +2 -2
  63. data/lib/expressir/model/statements/call.rb +3 -3
  64. data/lib/expressir/model/statements/case.rb +4 -4
  65. data/lib/expressir/model/statements/case_action.rb +3 -3
  66. data/lib/expressir/model/statements/compound.rb +2 -2
  67. data/lib/expressir/model/statements/if.rb +5 -5
  68. data/lib/expressir/model/statements/repeat.rb +11 -9
  69. data/lib/expressir/model/statements/return.rb +1 -1
  70. data/lib/expressir/model/subtype_constraint.rb +13 -6
  71. data/lib/expressir/model/type.rb +12 -10
  72. data/lib/expressir/model/types/aggregate.rb +9 -2
  73. data/lib/expressir/model/types/array.rb +5 -5
  74. data/lib/expressir/model/types/bag.rb +3 -3
  75. data/lib/expressir/model/types/binary.rb +2 -2
  76. data/lib/expressir/model/types/enumeration.rb +5 -7
  77. data/lib/expressir/model/types/generic.rb +8 -1
  78. data/lib/expressir/model/types/generic_entity.rb +8 -1
  79. data/lib/expressir/model/types/list.rb +4 -4
  80. data/lib/expressir/model/types/real.rb +1 -1
  81. data/lib/expressir/model/types/select.rb +6 -8
  82. data/lib/expressir/model/types/set.rb +3 -3
  83. data/lib/expressir/model/types/string.rb +2 -2
  84. data/lib/expressir/model/unique_rule.rb +26 -0
  85. data/lib/expressir/model/variable.rb +10 -3
  86. data/lib/expressir/model/where_rule.rb +26 -0
  87. data/lib/expressir/version.rb +1 -1
  88. data/rakelib/cross-ruby.rake +1 -1
  89. data/spec/expressir/{express_exp → express}/cache_spec.rb +9 -9
  90. data/spec/expressir/express/formatter_spec.rb +127 -0
  91. data/spec/expressir/{express_exp → express}/parser_spec.rb +24 -24
  92. data/spec/expressir/model/model_element_spec.rb +112 -60
  93. data/{original/examples → spec}/syntax/multiple.exp +1 -1
  94. data/{original/examples → spec}/syntax/multiple.yaml +19 -5
  95. data/{original/examples → spec}/syntax/multiple_formatted.exp +1 -1
  96. data/{original/examples → spec}/syntax/multiple_hyperlink_formatted.exp +4 -4
  97. data/{original/examples → spec}/syntax/multiple_schema_head_hyperlink_formatted.exp +1 -1
  98. data/{original/examples → spec}/syntax/remark.exp +12 -10
  99. data/{original/examples → spec}/syntax/remark.yaml +36 -16
  100. data/{original/examples → spec}/syntax/remark_formatted.exp +3 -1
  101. data/spec/syntax/single.exp +4 -0
  102. data/spec/syntax/single.yaml +18 -0
  103. data/spec/syntax/single_formatted.exp +10 -0
  104. data/spec/syntax/single_formatted.yaml +36 -0
  105. data/{original/examples → spec}/syntax/syntax.exp +11 -11
  106. data/{original/examples → spec}/syntax/syntax.yaml +205 -108
  107. data/{original/examples → spec}/syntax/syntax_formatted.exp +11 -11
  108. data/spec/syntax/syntax_hyperlink_formatted.exp +902 -0
  109. data/{original/examples → spec}/syntax/syntax_schema_head_formatted.exp +1 -1
  110. metadata +41 -83
  111. data/lib/expressir/express.rb +0 -11
  112. data/lib/expressir/express/aggregate_dimension.rb +0 -38
  113. data/lib/expressir/express/attribute.rb +0 -15
  114. data/lib/expressir/express/comment.rb +0 -7
  115. data/lib/expressir/express/defined_type.rb +0 -36
  116. data/lib/expressir/express/derived.rb +0 -65
  117. data/lib/expressir/express/derived_aggregate.rb +0 -43
  118. data/lib/expressir/express/entity.rb +0 -137
  119. data/lib/expressir/express/explicit.rb +0 -70
  120. data/lib/expressir/express/explicit_aggregate.rb +0 -46
  121. data/lib/expressir/express/explicit_or_derived.rb +0 -16
  122. data/lib/expressir/express/global_rule.rb +0 -44
  123. data/lib/expressir/express/interface_specification.rb +0 -51
  124. data/lib/expressir/express/interfaced_item.rb +0 -38
  125. data/lib/expressir/express/inverse.rb +0 -46
  126. data/lib/expressir/express/inverse_aggregate.rb +0 -37
  127. data/lib/expressir/express/model_element.rb +0 -7
  128. data/lib/expressir/express/named_type.rb +0 -19
  129. data/lib/expressir/express/remark.rb +0 -8
  130. data/lib/expressir/express/repository.rb +0 -306
  131. data/lib/expressir/express/schema_definition.rb +0 -96
  132. data/lib/expressir/express/subtype_constraint.rb +0 -14
  133. data/lib/expressir/express/type.rb +0 -26
  134. data/lib/expressir/express/type_aggregate.rb +0 -42
  135. data/lib/expressir/express/type_enum.rb +0 -29
  136. data/lib/expressir/express/type_parser.rb +0 -45
  137. data/lib/expressir/express/type_select.rb +0 -82
  138. data/lib/expressir/express/unique_rule.rb +0 -35
  139. data/lib/expressir/express/where_rule.rb +0 -32
  140. data/lib/expressir/express_exp/2.4/express_parser.so +0 -0
  141. data/lib/expressir/express_exp/2.5/express_parser.so +0 -0
  142. data/lib/expressir/express_exp/2.6/express_parser.so +0 -0
  143. data/lib/expressir/express_exp/2.7/express_parser.so +0 -0
  144. data/lib/expressir/express_exp/3.0/express_parser.so +0 -0
  145. data/lib/expressir/express_exp/hyperlink_formatter.rb +0 -27
  146. data/lib/expressir/express_parser.rb +0 -30
  147. data/lib/expressir/model/informal_proposition.rb +0 -18
  148. data/lib/expressir/model/unique.rb +0 -19
  149. data/lib/expressir/model/where.rb +0 -19
  150. data/lib/expressir/parser.rb +0 -6
  151. data/lib/expressir/parser/owl_parser.rb +0 -8
  152. data/original/examples/syntax/single.exp +0 -3
  153. data/original/examples/syntax/single.yaml +0 -9
  154. data/original/examples/syntax/single_formatted.exp +0 -6
  155. data/original/examples/syntax/single_formatted.yaml +0 -19
  156. data/spec/acceptance/express_to_owl_spec.rb +0 -18
  157. data/spec/expressir/express/repository_spec.rb +0 -25
  158. data/spec/expressir/express_exp/formatter_spec.rb +0 -111
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b736819e6011f68b9c9593fe26e15dc0cb2af39cc718ec41ca5ece6754bc0dd3
4
- data.tar.gz: acdfde1cc9225ee13a935ea00c68c2f47cbce093ddb00318ade2cfcb2ae32a86
3
+ metadata.gz: 84e02857a08c830d2a37eb62823db7798bd5e52bfb990508694ef7e63284413a
4
+ data.tar.gz: d9ec87bbdd174c685463f8b507d00f1ae2ea0ff2f72cce87cea509b1914045d8
5
5
  SHA512:
6
- metadata.gz: 35ff0ae3a010877e5144ea588099396a16fc06d3302b86fe7f3bfc43c3ed51d978107d1ed267b6c78b5de270d7a1a17c69879cab0b2b5a09c7cae5fa0a020f2e
7
- data.tar.gz: a6270efc8650e2e3fecc65c38600fd6b30d9e453c93a76f37b8dafbaa661b6e97f131bea02b10fffb986d2e48350fc0eb8602dfcd70eca9474f1c10911817462
6
+ metadata.gz: 7d37662b35953c9b0712b2947cf1550fbd4e3d9179bcd27fb54171e309dd48d8530cb939e765755eeb63959886ddf2030e71e27b5cac5b9f16e1f68a5ec42bee
7
+ data.tar.gz: b22d68cc8c259786a3f36c261ee4a5d3d8991d7c43649f1c703de43910ee70a2bd41cfb81763a642ffa0f53b9cad21eaeb9c21c2b63ca52dcba364b358b9db6e
@@ -40,11 +40,12 @@ jobs:
40
40
  ruby-version: ${{ matrix.ruby }}
41
41
  bundler-cache: true
42
42
 
43
- - run: bundle exec rake compile
43
+ - uses: actions/cache@v2
44
+ with:
45
+ path: lib/expressir/express/express_parser.*
46
+ key: v4-${{ runner.os }}-${{ matrix.ruby }}-${{ hashFiles('ext/express-parser/extconf.rb', 'ext/express-parser/antlrgen/**', 'ext/express-parser/express_parser.cpp', '.git/modules/ext/express-parser/antlr4-upstream/HEAD') }}
44
47
 
45
- - run: bundle exec rake
48
+ - if: hashFiles('lib/expressir/express/express_parser.*') == ''
49
+ run: bundle exec rake compile
46
50
 
47
- - uses: actions/upload-artifact@v2
48
- with:
49
- name: express_parser-${{ matrix.os }}-${{ matrix.ruby }}
50
- path: lib/expressir/express_exp/express_parser.so
51
+ - run: bundle exec rake
@@ -12,8 +12,27 @@ on:
12
12
  tags: [ v* ]
13
13
 
14
14
  jobs:
15
+ bump:
16
+ runs-on: ubuntu-18.04
17
+ steps:
18
+ - uses: actions/checkout@v2
19
+ with:
20
+ submodules: recursive
21
+
22
+ - uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: '2.6'
25
+
26
+ - if: ${{ github.event_name == 'workflow_dispatch' }} # unfortunatelly cannot keep this condition on job level
27
+ run: |
28
+ git config user.name github-actions
29
+ git config user.email github-actions@github.com
30
+ gem install gem-release
31
+ gem bump --version ${{ github.event.inputs.next_version }} --tag --push
32
+
15
33
  pack:
16
34
  runs-on: ubuntu-18.04
35
+ needs: bump
17
36
  strategy:
18
37
  fail-fast: false
19
38
  matrix:
@@ -26,13 +45,10 @@ jobs:
26
45
  - uses: ruby/setup-ruby@v1
27
46
  with:
28
47
  ruby-version: '2.6'
29
- bundler-cache: true
48
+ # bundler-cache: true important to not use cache because it leads to "cannot find -lrice"
49
+ # more info https://github.com/lutaml/expressir/runs/2097658383?check_suite_focus=true#step:7:2126
30
50
 
31
- - if: ${{ github.event_name == 'workflow_dispatch' }}
32
- run: |
33
- git config user.name github-actions
34
- git config user.email github-actions@github.com
35
- gem bump --version ${{ github.event.inputs.next_version }} --tag --push
51
+ - run: bundle install --jobs 4 --retry 3
36
52
 
37
53
  # build gem WITHOUT pre-built native extension
38
54
  - run: gem build expressir.gemspec
data/.gitignore CHANGED
@@ -8,8 +8,8 @@
8
8
  /tmp/
9
9
  /Gemfile.lock
10
10
  /.idea
11
- /lib/expressir/express_exp/express_parser.bundle
12
- /original/examples/syntax/*-pretty.exp
11
+ /lib/expressir/express/express_parser.bundle
12
+ /spec/syntax/*-pretty.exp
13
13
 
14
14
  # rspec failure tracking
15
15
  .rspec_status
data/demo.rb CHANGED
@@ -1,18 +1,18 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'expressir'
4
- require 'expressir/express_exp/parser'
4
+ require 'expressir/express/parser'
5
5
 
6
6
  # This file is from:
7
7
  # https://github.com/metanorma/annotated-express/blob/master/data/resources/action_schema/action_schema.exp
8
8
  file = 'action_schema.exp'
9
9
 
10
- # repo = Expressir::ExpressExp::Parser.from_exp(file)
10
+ # repo = Expressir::Express::Parser.from_exp(file)
11
11
  # schema = repo.schemas.find{|schema| schema.id == "support_resource_schema"}
12
12
 
13
- repo = Expressir::ExpressExp::Parser.from_exp(file)
13
+ repo = Expressir::Express::Parser.from_exp(file)
14
14
  schema = repo.schemas.find{|schema| schema.id == "action_schema"}
15
15
  entity = schema.entities.find{|entity| entity.id == "action_directive_relationship"}
16
- where = entity.where.find{|where| where.id == "WR1"}
16
+ where_rule = entity.where_rules.find{|where_rule| where_rule.id == "WR1"}
17
17
 
18
- puts where.inspect
18
+ puts where_rule.inspect
data/exe/format CHANGED
@@ -1,81 +1,18 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "yaml"
4
- require "tempfile"
5
- require "expressir/express_exp/parser"
6
- require "expressir/express_exp/formatter"
7
- require "expressir/express_exp/schema_head_formatter"
8
- require "expressir/express_exp/hyperlink_formatter"
9
- require "expressir/express_exp/cache"
4
+ require "expressir/express/parser"
5
+ require "expressir/express/formatter"
6
+ require "expressir/express/schema_head_formatter"
7
+ require "expressir/express/hyperlink_formatter"
10
8
 
11
- exp_files = [
12
- # basic test
13
- # '../iso-10303-stepmod/data/resources/action_schema/action_schema_annotated.exp',
14
- # '../iso-10303-stepmod/data/resources/basic_attribute_schema/basic_attribute_schema_annotated.exp',
15
- # '../iso-10303-stepmod/data/resources/support_resource_schema/support_resource_schema_annotated.exp',
16
- # cyclic reference test
17
- # '../iso-10303-stepmod/data/modules/analysis/mim_annotated.exp',
18
- # '../iso-10303-stepmod/data/modules/analysis_product_relationships/mim_annotated.exp',
19
- # cyclic reference test 2
20
- # '../iso-10303-stepmod/data/resources/product_property_definition_schema/product_property_definition_schema_annotated.exp',
21
- # '../iso-10303-stepmod/data/resources/product_property_representation_schema/product_property_representation_schema_annotated.exp',
22
- # renamed reference test (36s)
23
- # '../iso-10303-stepmod/ballots/ballots/ap210_wg12/express/resources/mathematical_functions_schema.exp',
24
- # '../iso-10303-stepmod/data/resources/iso13584_expressions_schema/iso13584_expressions_schema.exp',
25
- # annotated-express test (12s)
26
- # see https://github.com/metanorma/annotated-express/blob/master/data/documents/resources/fundamentals_of_product_description_and_support/sections/04-schemas.adoc
27
- '../iso-10303-stepmod/data/resources/action_schema/action_schema_annotated.exp',
28
- '../iso-10303-stepmod/data/resources/application_context_schema/application_context_schema_annotated.exp',
29
- '../iso-10303-stepmod/data/resources/approval_schema/approval_schema_annotated.exp',
30
- '../iso-10303-stepmod/data/resources/basic_attribute_schema/basic_attribute_schema_annotated.exp',
31
- '../iso-10303-stepmod/data/resources/certification_schema/certification_schema_annotated.exp',
32
- '../iso-10303-stepmod/data/resources/contract_schema/contract_schema_annotated.exp',
33
- '../iso-10303-stepmod/data/resources/date_time_schema/date_time_schema_annotated.exp',
34
- '../iso-10303-stepmod/data/resources/document_schema/document_schema.exp',
35
- '../iso-10303-stepmod/data/resources/effectivity_schema/effectivity_schema_annotated.exp',
36
- '../iso-10303-stepmod/data/resources/experience_schema/experience_schema_annotated.exp',
37
- '../iso-10303-stepmod/data/resources/external_reference_schema/external_reference_schema_annotated.exp',
38
- '../iso-10303-stepmod/data/resources/group_schema/group_schema_annotated.exp',
39
- '../iso-10303-stepmod/data/resources/language_schema/language_schema_annotated.exp',
40
- '../iso-10303-stepmod/data/resources/location_schema/location_schema_annotated.exp',
41
- '../iso-10303-stepmod/data/resources/management_resources_schema/management_resources_schema_annotated.exp',
42
- '../iso-10303-stepmod/data/resources/measure_schema/measure_schema_annotated.exp',
43
- '../iso-10303-stepmod/data/resources/person_organization_schema/person_organization_schema_annotated.exp',
44
- '../iso-10303-stepmod/data/resources/process_property_schema/process_property_schema_annotated.exp',
45
- '../iso-10303-stepmod/data/resources/product_definition_schema/product_definition_schema_annotated.exp',
46
- '../iso-10303-stepmod/data/resources/product_property_definition_schema/product_property_definition_schema_annotated.exp',
47
- '../iso-10303-stepmod/data/resources/product_property_representation_schema/product_property_representation_schema_annotated.exp',
48
- '../iso-10303-stepmod/data/resources/qualifications_schema/qualifications_schema_annotated.exp',
49
- '../iso-10303-stepmod/data/resources/security_classification_schema/security_classification_schema_annotated.exp',
50
- '../iso-10303-stepmod/data/resources/support_resource_schema/support_resource_schema_annotated.exp',
51
- # full test (6m18s + 8s = 6m26s)
52
- # *`bundle exec ../stepmod-utils/exe/stepmod-find-express-files ../iso-10303-stepmod`.strip.split("\n").map{|file| File.exists?(file.sub(/\.exp$/, '_annotated.exp')) ? file.sub(/\.exp$/, '_annotated.exp') : file}
53
- ]
9
+ exp_files = ARGV
54
10
 
55
- start = Time.now
56
- repository = Expressir::ExpressExp::Parser.from_files(exp_files)
57
- puts "Parser.from_files time: #{(Time.now - start).round(2)}s"
58
-
59
- temp_file = Tempfile.new
60
- begin
61
- start = Time.now
62
- Expressir::ExpressExp::Cache.to_file(temp_file, repository)
63
- puts "Cache.to_file time: #{(Time.now - start).round(2)}s"
64
-
65
- start = Time.now
66
- repository = Expressir::ExpressExp::Cache.from_file(temp_file)
67
- puts "Cache.from_file time: #{(Time.now - start).round(2)}s"
68
- ensure
69
- temp_file.close
70
- temp_file.unlink
71
- end
72
-
73
- start = Time.now
74
- formatter = Class.new(Expressir::ExpressExp::Formatter) do
75
- include Expressir::ExpressExp::SchemaHeadFormatter
76
- include Expressir::ExpressExp::HyperlinkFormatter
11
+ repository = Expressir::Express::Parser.from_files(exp_files)
12
+ formatter = Class.new(Expressir::Express::Formatter) do
13
+ include Expressir::Express::SchemaHeadFormatter
14
+ include Expressir::Express::HyperlinkFormatter
77
15
  end
78
16
  result = repository.to_hash(formatter: formatter, skip_empty: true)
79
- puts "Repository.to_hash time: #{(Time.now - start).round(2)}s"
80
17
 
81
- # puts YAML.dump(result)
18
+ puts YAML.dump(result)
data/exe/format-test ADDED
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "yaml"
4
+ require "tempfile"
5
+ require "expressir/express/parser"
6
+ require "expressir/express/formatter"
7
+ require "expressir/express/schema_head_formatter"
8
+ require "expressir/express/hyperlink_formatter"
9
+ require "expressir/express/cache"
10
+
11
+ exp_files = [
12
+ # basic test
13
+ # '../iso-10303-stepmod/data/resources/action_schema/action_schema_annotated.exp',
14
+ # '../iso-10303-stepmod/data/resources/basic_attribute_schema/basic_attribute_schema_annotated.exp',
15
+ # '../iso-10303-stepmod/data/resources/support_resource_schema/support_resource_schema_annotated.exp',
16
+ # cyclic reference test
17
+ # '../iso-10303-stepmod/data/modules/analysis/mim_annotated.exp',
18
+ # '../iso-10303-stepmod/data/modules/analysis_product_relationships/mim_annotated.exp',
19
+ # cyclic reference test 2
20
+ # '../iso-10303-stepmod/data/resources/product_property_definition_schema/product_property_definition_schema_annotated.exp',
21
+ # '../iso-10303-stepmod/data/resources/product_property_representation_schema/product_property_representation_schema_annotated.exp',
22
+ # renamed reference test (36s)
23
+ # '../iso-10303-stepmod/ballots/ballots/ap210_wg12/express/resources/mathematical_functions_schema.exp',
24
+ # '../iso-10303-stepmod/data/resources/iso13584_expressions_schema/iso13584_expressions_schema.exp',
25
+ # annotated-express test (12s)
26
+ # see https://github.com/metanorma/annotated-express/blob/master/data/documents/resources/fundamentals_of_product_description_and_support/sections/04-schemas.adoc
27
+ '../iso-10303-stepmod/data/resources/action_schema/action_schema_annotated.exp',
28
+ '../iso-10303-stepmod/data/resources/application_context_schema/application_context_schema_annotated.exp',
29
+ '../iso-10303-stepmod/data/resources/approval_schema/approval_schema_annotated.exp',
30
+ '../iso-10303-stepmod/data/resources/basic_attribute_schema/basic_attribute_schema_annotated.exp',
31
+ '../iso-10303-stepmod/data/resources/certification_schema/certification_schema_annotated.exp',
32
+ '../iso-10303-stepmod/data/resources/contract_schema/contract_schema_annotated.exp',
33
+ '../iso-10303-stepmod/data/resources/date_time_schema/date_time_schema_annotated.exp',
34
+ '../iso-10303-stepmod/data/resources/document_schema/document_schema.exp',
35
+ '../iso-10303-stepmod/data/resources/effectivity_schema/effectivity_schema_annotated.exp',
36
+ '../iso-10303-stepmod/data/resources/experience_schema/experience_schema_annotated.exp',
37
+ '../iso-10303-stepmod/data/resources/external_reference_schema/external_reference_schema_annotated.exp',
38
+ '../iso-10303-stepmod/data/resources/group_schema/group_schema_annotated.exp',
39
+ '../iso-10303-stepmod/data/resources/language_schema/language_schema_annotated.exp',
40
+ '../iso-10303-stepmod/data/resources/location_schema/location_schema_annotated.exp',
41
+ '../iso-10303-stepmod/data/resources/management_resources_schema/management_resources_schema_annotated.exp',
42
+ '../iso-10303-stepmod/data/resources/measure_schema/measure_schema_annotated.exp',
43
+ '../iso-10303-stepmod/data/resources/person_organization_schema/person_organization_schema_annotated.exp',
44
+ '../iso-10303-stepmod/data/resources/process_property_schema/process_property_schema_annotated.exp',
45
+ '../iso-10303-stepmod/data/resources/product_definition_schema/product_definition_schema_annotated.exp',
46
+ '../iso-10303-stepmod/data/resources/product_property_definition_schema/product_property_definition_schema_annotated.exp',
47
+ '../iso-10303-stepmod/data/resources/product_property_representation_schema/product_property_representation_schema_annotated.exp',
48
+ '../iso-10303-stepmod/data/resources/qualifications_schema/qualifications_schema_annotated.exp',
49
+ '../iso-10303-stepmod/data/resources/security_classification_schema/security_classification_schema_annotated.exp',
50
+ '../iso-10303-stepmod/data/resources/support_resource_schema/support_resource_schema_annotated.exp',
51
+ # full test (6m18s + 8s = 6m26s)
52
+ # *`bundle exec ../stepmod-utils/exe/stepmod-find-express-files ../iso-10303-stepmod`.strip.split("\n").map{|file| File.exists?(file.sub(/\.exp$/, '_annotated.exp')) ? file.sub(/\.exp$/, '_annotated.exp') : file}
53
+ ]
54
+
55
+ start = Time.now
56
+ repository = Expressir::Express::Parser.from_files(exp_files)
57
+ puts "Parser.from_files time: #{(Time.now - start).round(2)}s"
58
+
59
+ temp_file = Tempfile.new
60
+ begin
61
+ start = Time.now
62
+ Expressir::Express::Cache.to_file(temp_file, repository)
63
+ puts "Cache.to_file time: #{(Time.now - start).round(2)}s"
64
+
65
+ start = Time.now
66
+ repository = Expressir::Express::Cache.from_file(temp_file)
67
+ puts "Cache.from_file time: #{(Time.now - start).round(2)}s"
68
+ ensure
69
+ temp_file.close
70
+ temp_file.unlink
71
+ end
72
+
73
+ start = Time.now
74
+ formatter = Class.new(Expressir::Express::Formatter) do
75
+ include Expressir::Express::SchemaHeadFormatter
76
+ include Expressir::Express::HyperlinkFormatter
77
+ end
78
+ result = repository.to_hash(formatter: formatter, skip_empty: true)
79
+ puts "Repository.to_hash time: #{(Time.now - start).round(2)}s"
80
+
81
+ # puts YAML.dump(result)
data/expressir.gemspec CHANGED
@@ -30,7 +30,6 @@ Gem::Specification.new do |spec|
30
30
 
31
31
  spec.extensions = File.join(*%w(ext express-parser extconf.rb))
32
32
 
33
- spec.add_runtime_dependency "nokogiri", "~> 1.10"
34
33
  spec.add_runtime_dependency "thor", "~> 1.0"
35
34
  spec.add_runtime_dependency "rice", "~> 3"
36
35
  spec.add_development_dependency "antlr4-native", "~> 1.1.0"
data/lib/expressir.rb CHANGED
@@ -2,7 +2,6 @@ require "expressir/version"
2
2
 
3
3
  require "expressir/cli"
4
4
  require "expressir/config"
5
- require "expressir/express"
6
5
 
7
6
  module Expressir
8
7
  class Error < StandardError; end
data/lib/expressir/cli.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require "thor"
2
2
  require "expressir/cli/ui"
3
- require "expressir/express_parser"
4
3
 
5
4
  module Expressir
6
5
  module Cli
@@ -17,11 +16,6 @@ module Expressir
17
16
  def version
18
17
  Cli.ui.say("Version #{Expressir::VERSION}")
19
18
  end
20
-
21
- desc "express-to-owl FILE", "Express to OWL conversion"
22
- def express_to_owl(file)
23
- Cli.ui.say(ExpressParser.to_owl(file))
24
- end
25
19
  end
26
20
  end
27
21
  end
@@ -3,7 +3,7 @@ require 'zlib'
3
3
  require 'expressir/model'
4
4
 
5
5
  module Expressir
6
- module ExpressExp
6
+ module Express
7
7
  class Cache
8
8
  def self.to_file(file, content, options = {})
9
9
  root_path = options[:root_path]
@@ -16,7 +16,7 @@ module Expressir
16
16
  content: content
17
17
  })
18
18
 
19
- hash = cache.to_hash(root_path: root_path, skip_empty: true)
19
+ hash = cache.to_hash(root_path: root_path)
20
20
  yaml = YAML.dump(hash)
21
21
  yaml_compressed = Zlib::Deflate.deflate(yaml)
22
22
 
@@ -35,14 +35,11 @@ module Expressir
35
35
  cache = Model::ModelElement.from_hash(hash, root_path: root_path)
36
36
 
37
37
  if cache.version != version
38
- raise CacheLoadError.new("Cache version mismatch, cache version is #{cache.version}, Expressir version is #{VERSION}")
38
+ raise Error.new("Cache version mismatch, cache version is #{cache.version}, Expressir version is #{version}")
39
39
  end
40
40
 
41
41
  cache.content
42
42
  end
43
43
  end
44
-
45
- class CacheLoadError < StandardError
46
- end
47
44
  end
48
45
  end
@@ -1,7 +1,7 @@
1
1
  require 'expressir/model'
2
2
 
3
3
  module Expressir
4
- module ExpressExp
4
+ module Express
5
5
  class Formatter
6
6
  INDENT_CHAR = ' '
7
7
  INDENT_WIDTH = 2
@@ -62,16 +62,18 @@ module Expressir
62
62
  format_rule(node)
63
63
  elsif node.is_a? Model::Schema
64
64
  format_schema(node)
65
+ elsif node.is_a? Model::SchemaVersion
66
+ format_schema_version(node)
65
67
  elsif node.is_a? Model::SubtypeConstraint
66
68
  format_subtype_constraint(node)
67
69
  elsif node.is_a? Model::Type
68
70
  format_type(node)
69
- elsif node.is_a? Model::Unique
70
- format_unique(node)
71
+ elsif node.is_a? Model::UniqueRule
72
+ format_unique_rule(node)
71
73
  elsif node.is_a? Model::Variable
72
74
  format_variable(node)
73
- elsif node.is_a? Model::Where
74
- format_where(node)
75
+ elsif node.is_a? Model::WhereRule
76
+ format_where_rule(node)
75
77
  elsif node.is_a? Model::Expressions::AggregateInitializer
76
78
  format_expressions_aggregate_initializer(node)
77
79
  elsif node.is_a? Model::Expressions::AggregateItem
@@ -314,16 +316,16 @@ module Expressir
314
316
  indent(inverse_attributes.map{|x| format(x)}.join("\n")),
315
317
  ]
316
318
  end,
317
- *if node.unique.length > 0
319
+ *if node.unique_rules.length > 0
318
320
  [
319
321
  'UNIQUE',
320
- indent(node.unique.map{|x| format(x)}.join("\n"))
322
+ indent(node.unique_rules.map{|x| format(x)}.join("\n"))
321
323
  ]
322
324
  end,
323
- *if node.where.length > 0
325
+ *if node.where_rules.length > 0
324
326
  [
325
327
  'WHERE',
326
- indent(node.where.map{|x| format(x)}.join("\n")),
328
+ indent(node.where_rules.map{|x| format(x)}.join("\n")),
327
329
  ]
328
330
  end,
329
331
  [
@@ -574,10 +576,10 @@ module Expressir
574
576
  *if node.statements.length > 0
575
577
  indent(node.statements.map{|x| format(x)}.join("\n"))
576
578
  end,
577
- *if node.where.length > 0
579
+ *if node.where_rules.length > 0
578
580
  [
579
581
  'WHERE',
580
- indent(node.where.map{|x| format(x)}.join("\n"))
582
+ indent(node.where_rules.map{|x| format(x)}.join("\n"))
581
583
  ]
582
584
  end,
583
585
  [
@@ -659,6 +661,14 @@ module Expressir
659
661
  ].join("\n")
660
662
  end
661
663
 
664
+ def format_schema_version(node)
665
+ [
666
+ "'",
667
+ node.value,
668
+ "'"
669
+ ].join('')
670
+ end
671
+
662
672
  def format_subtype_constraint(node)
663
673
  [
664
674
  [
@@ -710,13 +720,13 @@ module Expressir
710
720
  ' ',
711
721
  '=',
712
722
  ' ',
713
- format(node.type),
723
+ format(node.underlying_type),
714
724
  ';',
715
725
  ].join(''),
716
- *if node.where.length > 0
726
+ *if node.where_rules.length > 0
717
727
  [
718
728
  'WHERE',
719
- indent(node.where.map{|x| format(x)}.join("\n"))
729
+ indent(node.where_rules.map{|x| format(x)}.join("\n"))
720
730
  ]
721
731
  end,
722
732
  [
@@ -726,7 +736,7 @@ module Expressir
726
736
  ].join("\n")
727
737
  end
728
738
 
729
- def format_unique(node)
739
+ def format_unique_rule(node)
730
740
  [
731
741
  *if node.id
732
742
  [
@@ -759,7 +769,7 @@ module Expressir
759
769
  ].join('')
760
770
  end
761
771
 
762
- def format_where(node)
772
+ def format_where_rule(node)
763
773
  [
764
774
  *if node.id
765
775
  [
@@ -1289,38 +1299,41 @@ module Expressir
1289
1299
  ].join('')
1290
1300
  end,
1291
1301
  'ENUMERATION',
1292
- *if node.items.length > 0
1293
- item_indent = INDENT_CHAR * '('.length
1294
- [
1295
- ' ',
1296
- 'OF',
1297
- "\n",
1298
- indent([
1299
- '(',
1300
- node.items.map{|x| format(x)}.join(",\n#{item_indent}"),
1301
- ')'
1302
- ].join(''))
1303
- ].join('')
1304
- end,
1305
- *if node.extension_type
1302
+ *if node.based_on
1306
1303
  [
1307
1304
  ' ',
1308
1305
  'BASED_ON',
1309
1306
  ' ',
1310
- format(node.extension_type)
1307
+ format(node.based_on),
1308
+ *if node.items.length > 0
1309
+ item_indent = INDENT_CHAR * '('.length
1310
+ [
1311
+ ' ',
1312
+ 'WITH',
1313
+ "\n",
1314
+ indent([
1315
+ '(',
1316
+ node.items.map{|x| format(x)}.join(",\n#{item_indent}"),
1317
+ ')'
1318
+ ].join(''))
1319
+ ].join('')
1320
+ end
1311
1321
  ].join('')
1312
- end,
1313
- *if node.extension_items.length > 0
1314
- item_indent = INDENT_CHAR * '('.length
1322
+ else
1315
1323
  [
1316
- ' ',
1317
- 'WITH',
1318
- "\n",
1319
- indent([
1320
- '(',
1321
- node.extension_items.map{|x| format(x)}.join(",\n#{item_indent}"),
1322
- ')'
1323
- ].join(''))
1324
+ *if node.items.length > 0
1325
+ item_indent = INDENT_CHAR * '('.length
1326
+ [
1327
+ ' ',
1328
+ 'OF',
1329
+ "\n",
1330
+ indent([
1331
+ '(',
1332
+ node.items.map{|x| format(x)}.join(",\n#{item_indent}"),
1333
+ ')'
1334
+ ].join(''))
1335
+ ].join('')
1336
+ end
1324
1337
  ].join('')
1325
1338
  end
1326
1339
  ].join('')
@@ -1417,36 +1430,39 @@ module Expressir
1417
1430
  ].join('')
1418
1431
  end,
1419
1432
  'SELECT',
1420
- *if node.items.length > 0
1421
- item_indent = INDENT_CHAR * '('.length
1422
- [
1423
- "\n",
1424
- indent([
1425
- '(',
1426
- node.items.map{|x| format(x)}.join(",\n#{item_indent}"),
1427
- ')'
1428
- ].join(''))
1429
- ].join('')
1430
- end,
1431
- *if node.extension_type
1433
+ *if node.based_on
1432
1434
  [
1433
1435
  ' ',
1434
1436
  'BASED_ON',
1435
1437
  ' ',
1436
- format(node.extension_type)
1438
+ format(node.based_on),
1439
+ *if node.items.length > 0
1440
+ item_indent = INDENT_CHAR * '('.length
1441
+ [
1442
+ ' ',
1443
+ 'WITH',
1444
+ "\n",
1445
+ indent([
1446
+ '(',
1447
+ node.items.map{|x| format(x)}.join(",\n#{item_indent}"),
1448
+ ')'
1449
+ ].join(''))
1450
+ ].join('')
1451
+ end
1437
1452
  ].join('')
1438
- end,
1439
- *if node.extension_items.length > 0
1440
- item_indent = INDENT_CHAR * '('.length
1453
+ else
1441
1454
  [
1442
- ' ',
1443
- 'WITH',
1444
- "\n",
1445
- indent([
1446
- '(',
1447
- node.extension_items.map{|x| format(x)}.join(",\n#{item_indent}"),
1448
- ')'
1449
- ].join(''))
1455
+ *if node.items.length > 0
1456
+ item_indent = INDENT_CHAR * '('.length
1457
+ [
1458
+ "\n",
1459
+ indent([
1460
+ '(',
1461
+ node.items.map{|x| format(x)}.join(",\n#{item_indent}"),
1462
+ ')'
1463
+ ].join(''))
1464
+ ].join('')
1465
+ end
1450
1466
  ].join('')
1451
1467
  end
1452
1468
  ].join('')
@@ -1502,7 +1518,7 @@ module Expressir
1502
1518
  [
1503
1519
  '(*',
1504
1520
  '"',
1505
- node.path,
1521
+ node.path || node.id,
1506
1522
  '"',
1507
1523
  ].join(''),
1508
1524
  remark,
@@ -1512,7 +1528,7 @@ module Expressir
1512
1528
  [
1513
1529
  '--',
1514
1530
  '"',
1515
- node.path,
1531
+ node.path || node.id,
1516
1532
  '"',
1517
1533
  ' ',
1518
1534
  remark