expressir 0.2.21 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +7 -6
- data/.github/workflows/release.yml +22 -6
- data/.gitignore +2 -2
- data/demo.rb +5 -5
- data/exe/format +10 -73
- data/exe/format-test +81 -0
- data/expressir.gemspec +0 -1
- data/ext/express-parser/extconf.rb +1 -1
- data/lib/expressir.rb +0 -1
- data/lib/expressir/cli.rb +0 -6
- data/lib/expressir/{express_exp → express}/cache.rb +3 -6
- data/lib/expressir/{express_exp → express}/formatter.rb +84 -68
- data/lib/expressir/express/hyperlink_formatter.rb +22 -0
- data/lib/expressir/express/model_visitor.rb +23 -0
- data/lib/expressir/{express_exp → express}/parser.rb +16 -5
- data/lib/expressir/express/resolve_references_model_visitor.rb +29 -0
- data/lib/expressir/{express_exp → express}/schema_head_formatter.rb +1 -1
- data/lib/expressir/{express_exp → express}/visitor.rb +67 -44
- data/lib/expressir/model.rb +5 -3
- data/lib/expressir/model/attribute.rb +13 -6
- data/lib/expressir/model/cache.rb +2 -2
- data/lib/expressir/model/constant.rb +10 -3
- data/lib/expressir/model/entity.rb +18 -16
- data/lib/expressir/model/enumeration_item.rb +8 -1
- data/lib/expressir/model/expressions/aggregate_initializer.rb +2 -2
- data/lib/expressir/model/expressions/aggregate_item.rb +2 -2
- data/lib/expressir/model/expressions/attribute_reference.rb +2 -2
- data/lib/expressir/model/expressions/binary_expression.rb +3 -3
- data/lib/expressir/model/expressions/call.rb +3 -3
- data/lib/expressir/model/expressions/entity_constructor.rb +3 -3
- data/lib/expressir/model/expressions/group_reference.rb +2 -2
- data/lib/expressir/model/expressions/index_reference.rb +3 -3
- data/lib/expressir/model/expressions/interval.rb +5 -5
- data/lib/expressir/model/expressions/query_expression.rb +6 -4
- data/lib/expressir/model/expressions/simple_reference.rb +5 -1
- data/lib/expressir/model/expressions/unary_expression.rb +2 -2
- data/lib/expressir/model/function.rb +23 -21
- data/lib/expressir/model/identifier.rb +6 -3
- data/lib/expressir/model/interface.rb +4 -4
- data/lib/expressir/model/interface_item.rb +2 -2
- data/lib/expressir/model/interfaced_item.rb +10 -9
- data/lib/expressir/model/literals/binary.rb +1 -1
- data/lib/expressir/model/literals/integer.rb +1 -1
- data/lib/expressir/model/literals/logical.rb +1 -1
- data/lib/expressir/model/literals/real.rb +1 -1
- data/lib/expressir/model/literals/string.rb +2 -2
- data/lib/expressir/model/model_element.rb +39 -27
- data/lib/expressir/model/parameter.rb +10 -3
- data/lib/expressir/model/procedure.rb +22 -20
- data/lib/expressir/model/remark_item.rb +15 -0
- data/lib/expressir/model/repository.rb +2 -2
- data/lib/expressir/model/rule.rb +27 -25
- data/lib/expressir/model/schema.rb +24 -20
- data/lib/expressir/model/schema_version.rb +15 -0
- data/lib/expressir/model/schema_version_item.rb +15 -0
- data/lib/expressir/model/statements/alias.rb +7 -5
- data/lib/expressir/model/statements/assignment.rb +2 -2
- data/lib/expressir/model/statements/call.rb +3 -3
- data/lib/expressir/model/statements/case.rb +4 -4
- data/lib/expressir/model/statements/case_action.rb +3 -3
- data/lib/expressir/model/statements/compound.rb +2 -2
- data/lib/expressir/model/statements/if.rb +5 -5
- data/lib/expressir/model/statements/repeat.rb +11 -9
- data/lib/expressir/model/statements/return.rb +1 -1
- data/lib/expressir/model/subtype_constraint.rb +13 -6
- data/lib/expressir/model/type.rb +12 -10
- data/lib/expressir/model/types/aggregate.rb +9 -2
- data/lib/expressir/model/types/array.rb +5 -5
- data/lib/expressir/model/types/bag.rb +3 -3
- data/lib/expressir/model/types/binary.rb +2 -2
- data/lib/expressir/model/types/enumeration.rb +5 -7
- data/lib/expressir/model/types/generic.rb +8 -1
- data/lib/expressir/model/types/generic_entity.rb +8 -1
- data/lib/expressir/model/types/list.rb +4 -4
- data/lib/expressir/model/types/real.rb +1 -1
- data/lib/expressir/model/types/select.rb +6 -8
- data/lib/expressir/model/types/set.rb +3 -3
- data/lib/expressir/model/types/string.rb +2 -2
- data/lib/expressir/model/unique_rule.rb +26 -0
- data/lib/expressir/model/variable.rb +10 -3
- data/lib/expressir/model/where_rule.rb +26 -0
- data/lib/expressir/version.rb +1 -1
- data/rakelib/cross-ruby.rake +1 -1
- data/spec/expressir/{express_exp → express}/cache_spec.rb +9 -9
- data/spec/expressir/express/formatter_spec.rb +127 -0
- data/spec/expressir/{express_exp → express}/parser_spec.rb +24 -24
- data/spec/expressir/model/model_element_spec.rb +112 -60
- data/{original/examples → spec}/syntax/multiple.exp +1 -1
- data/{original/examples → spec}/syntax/multiple.yaml +19 -5
- data/{original/examples → spec}/syntax/multiple_formatted.exp +1 -1
- data/{original/examples → spec}/syntax/multiple_hyperlink_formatted.exp +4 -4
- data/{original/examples → spec}/syntax/multiple_schema_head_hyperlink_formatted.exp +1 -1
- data/{original/examples → spec}/syntax/remark.exp +12 -10
- data/{original/examples → spec}/syntax/remark.yaml +36 -16
- data/{original/examples → spec}/syntax/remark_formatted.exp +3 -1
- data/spec/syntax/single.exp +4 -0
- data/spec/syntax/single.yaml +18 -0
- data/spec/syntax/single_formatted.exp +10 -0
- data/spec/syntax/single_formatted.yaml +36 -0
- data/{original/examples → spec}/syntax/syntax.exp +11 -11
- data/{original/examples → spec}/syntax/syntax.yaml +205 -108
- data/{original/examples → spec}/syntax/syntax_formatted.exp +11 -11
- data/spec/syntax/syntax_hyperlink_formatted.exp +902 -0
- data/{original/examples → spec}/syntax/syntax_schema_head_formatted.exp +1 -1
- metadata +40 -82
- data/lib/expressir/express.rb +0 -11
- data/lib/expressir/express/aggregate_dimension.rb +0 -38
- data/lib/expressir/express/attribute.rb +0 -15
- data/lib/expressir/express/comment.rb +0 -7
- data/lib/expressir/express/defined_type.rb +0 -36
- data/lib/expressir/express/derived.rb +0 -65
- data/lib/expressir/express/derived_aggregate.rb +0 -43
- data/lib/expressir/express/entity.rb +0 -137
- data/lib/expressir/express/explicit.rb +0 -70
- data/lib/expressir/express/explicit_aggregate.rb +0 -46
- data/lib/expressir/express/explicit_or_derived.rb +0 -16
- data/lib/expressir/express/global_rule.rb +0 -44
- data/lib/expressir/express/interface_specification.rb +0 -51
- data/lib/expressir/express/interfaced_item.rb +0 -38
- data/lib/expressir/express/inverse.rb +0 -46
- data/lib/expressir/express/inverse_aggregate.rb +0 -37
- data/lib/expressir/express/model_element.rb +0 -7
- data/lib/expressir/express/named_type.rb +0 -19
- data/lib/expressir/express/remark.rb +0 -8
- data/lib/expressir/express/repository.rb +0 -306
- data/lib/expressir/express/schema_definition.rb +0 -96
- data/lib/expressir/express/subtype_constraint.rb +0 -14
- data/lib/expressir/express/type.rb +0 -26
- data/lib/expressir/express/type_aggregate.rb +0 -42
- data/lib/expressir/express/type_enum.rb +0 -29
- data/lib/expressir/express/type_parser.rb +0 -45
- data/lib/expressir/express/type_select.rb +0 -82
- data/lib/expressir/express/unique_rule.rb +0 -35
- data/lib/expressir/express/where_rule.rb +0 -32
- data/lib/expressir/express_exp/hyperlink_formatter.rb +0 -27
- data/lib/expressir/express_parser.rb +0 -30
- data/lib/expressir/model/informal_proposition.rb +0 -18
- data/lib/expressir/model/unique.rb +0 -19
- data/lib/expressir/model/where.rb +0 -19
- data/lib/expressir/parser.rb +0 -6
- data/lib/expressir/parser/owl_parser.rb +0 -8
- data/original/examples/syntax/single.exp +0 -3
- data/original/examples/syntax/single.yaml +0 -9
- data/original/examples/syntax/single_formatted.exp +0 -6
- data/original/examples/syntax/single_formatted.yaml +0 -19
- data/spec/acceptance/express_to_owl_spec.rb +0 -18
- data/spec/expressir/express/repository_spec.rb +0 -25
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b288f91d09464550e2670eab67a4f74fafc792d466b0e4dea25df8a461c2fa38
|
4
|
+
data.tar.gz: c912d8c9cdd4670454e69d41cb0eac9d75e932850a84cb780d79017727872c8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e06cb6104922b279ea63882e01e71f7deaa719cb5329d6f8a466ed5ae209d18f0190adbb4a191a8f09736a9df9366a1c531bea03f14a9b685fab63f0f42b4441
|
7
|
+
data.tar.gz: 3a4d3543f090c0bc7e48a60c2e0a5bf0099a0e03001687dd7c29e59ccef07779e87dee29553c1c5f6cd63df40dc057cd0e5fff633952b977cc8ef5ad05a20ccf
|
data/.github/workflows/rake.yml
CHANGED
@@ -40,11 +40,12 @@ jobs:
|
|
40
40
|
ruby-version: ${{ matrix.ruby }}
|
41
41
|
bundler-cache: true
|
42
42
|
|
43
|
-
-
|
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
|
-
-
|
48
|
+
- if: hashFiles('lib/expressir/express/express_parser.*') == ''
|
49
|
+
run: bundle exec rake compile
|
46
50
|
|
47
|
-
-
|
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
|
-
-
|
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
data/demo.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'expressir'
|
4
|
-
require 'expressir/
|
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::
|
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::
|
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
|
-
|
16
|
+
where_rule = entity.where_rules.find{|where_rule| where_rule.id == "WR1"}
|
17
17
|
|
18
|
-
puts
|
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 "
|
5
|
-
require "expressir/
|
6
|
-
require "expressir/
|
7
|
-
require "expressir/
|
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
|
-
|
56
|
-
|
57
|
-
|
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
|
-
|
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
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
|
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
|
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
|
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
|
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::
|
70
|
-
|
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::
|
74
|
-
|
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.
|
319
|
+
*if node.unique_rules.length > 0
|
318
320
|
[
|
319
321
|
'UNIQUE',
|
320
|
-
indent(node.
|
322
|
+
indent(node.unique_rules.map{|x| format(x)}.join("\n"))
|
321
323
|
]
|
322
324
|
end,
|
323
|
-
*if node.
|
325
|
+
*if node.where_rules.length > 0
|
324
326
|
[
|
325
327
|
'WHERE',
|
326
|
-
indent(node.
|
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.
|
579
|
+
*if node.where_rules.length > 0
|
578
580
|
[
|
579
581
|
'WHERE',
|
580
|
-
indent(node.
|
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.
|
723
|
+
format(node.underlying_type),
|
714
724
|
';',
|
715
725
|
].join(''),
|
716
|
-
*if node.
|
726
|
+
*if node.where_rules.length > 0
|
717
727
|
[
|
718
728
|
'WHERE',
|
719
|
-
indent(node.
|
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
|
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
|
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.
|
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.
|
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
|
-
|
1313
|
-
*if node.extension_items.length > 0
|
1314
|
-
item_indent = INDENT_CHAR * '('.length
|
1322
|
+
else
|
1315
1323
|
[
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
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.
|
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.
|
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
|
-
|
1439
|
-
*if node.extension_items.length > 0
|
1440
|
-
item_indent = INDENT_CHAR * '('.length
|
1453
|
+
else
|
1441
1454
|
[
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
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
|