expressir 0.2.18-x86-linux → 0.2.26-x86-linux
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 -1
- data/.github/workflows/release.yml +31 -3
- data/README.adoc +3 -3
- data/exe/format +2 -49
- data/exe/format-test +81 -0
- data/lib/expressir/express_exp/2.4/express_parser.so +0 -0
- data/lib/expressir/express_exp/2.5/express_parser.so +0 -0
- data/lib/expressir/express_exp/2.6/express_parser.so +0 -0
- data/lib/expressir/express_exp/2.7/express_parser.so +0 -0
- data/lib/expressir/express_exp/3.0/express_parser.so +0 -0
- data/lib/expressir/express_exp/cache.rb +48 -0
- data/lib/expressir/express_exp/formatter.rb +2 -2
- data/lib/expressir/express_exp/hyperlink_formatter.rb +10 -15
- data/lib/expressir/express_exp/model_visitor.rb +23 -0
- data/lib/expressir/express_exp/parser.rb +14 -6
- data/lib/expressir/express_exp/resolve_references_model_visitor.rb +29 -0
- data/lib/expressir/express_exp/visitor.rb +19 -18
- data/lib/expressir/model.rb +3 -1
- data/lib/expressir/model/attribute.rb +12 -5
- data/lib/expressir/model/cache.rb +13 -0
- data/lib/expressir/model/constant.rb +9 -2
- data/lib/expressir/model/entity.rb +10 -8
- data/lib/expressir/model/enumeration_item.rb +7 -0
- data/lib/expressir/model/expressions/aggregate_initializer.rb +1 -1
- 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 +2 -2
- data/lib/expressir/model/expressions/entity_constructor.rb +2 -2
- 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 +5 -3
- 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 +13 -11
- data/lib/expressir/model/identifier.rb +6 -3
- data/lib/expressir/model/interface.rb +3 -3
- data/lib/expressir/model/interface_item.rb +2 -2
- data/lib/expressir/model/interfaced_item.rb +9 -8
- 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 +47 -26
- data/lib/expressir/model/parameter.rb +9 -2
- data/lib/expressir/model/procedure.rb +12 -10
- data/lib/expressir/model/{informal_proposition.rb → remark_item.rb} +3 -6
- data/lib/expressir/model/repository.rb +1 -1
- data/lib/expressir/model/rule.rb +14 -12
- data/lib/expressir/model/schema.rb +15 -11
- data/lib/expressir/model/statements/alias.rb +5 -3
- data/lib/expressir/model/statements/assignment.rb +2 -2
- data/lib/expressir/model/statements/call.rb +2 -2
- data/lib/expressir/model/statements/case.rb +3 -3
- data/lib/expressir/model/statements/case_action.rb +2 -2
- data/lib/expressir/model/statements/compound.rb +1 -1
- data/lib/expressir/model/statements/if.rb +3 -3
- data/lib/expressir/model/statements/repeat.rb +9 -7
- data/lib/expressir/model/statements/return.rb +1 -1
- data/lib/expressir/model/subtype_constraint.rb +11 -4
- data/lib/expressir/model/type.rb +6 -4
- data/lib/expressir/model/types/aggregate.rb +8 -1
- 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 +4 -4
- data/lib/expressir/model/types/generic.rb +7 -0
- data/lib/expressir/model/types/generic_entity.rb +7 -0
- 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 +5 -5
- data/lib/expressir/model/types/set.rb +3 -3
- data/lib/expressir/model/types/string.rb +2 -2
- data/lib/expressir/model/unique.rb +8 -1
- data/lib/expressir/model/variable.rb +9 -2
- data/lib/expressir/model/where.rb +8 -1
- data/lib/expressir/version.rb +1 -1
- data/original/examples/syntax/multiple.exp +1 -1
- data/original/examples/syntax/multiple.yaml +19 -5
- data/original/examples/syntax/multiple_formatted.exp +1 -1
- data/original/examples/syntax/multiple_hyperlink_formatted.exp +4 -4
- data/original/examples/syntax/multiple_schema_head_hyperlink_formatted.exp +1 -1
- data/original/examples/syntax/remark.exp +12 -10
- data/original/examples/syntax/remark.yaml +24 -4
- data/original/examples/syntax/remark_formatted.exp +3 -1
- data/original/examples/syntax/single.exp +1 -0
- data/original/examples/syntax/single.yaml +7 -1
- data/original/examples/syntax/single_formatted.exp +4 -0
- data/original/examples/syntax/single_formatted.yaml +15 -1
- data/original/examples/syntax/syntax.yaml +82 -1
- data/original/examples/syntax/syntax_hyperlink_formatted.exp +902 -0
- data/spec/expressir/express_exp/cache_spec.rb +64 -0
- data/spec/expressir/express_exp/formatter_spec.rb +16 -0
- data/spec/expressir/express_exp/parser_spec.rb +10 -33
- data/spec/expressir/model/model_element_spec.rb +82 -44
- metadata +10 -4
- data/original/examples/syntax/single_root_path.yaml +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a19e83ffe59a27a7d77522e0e32ea2a24904a8b1968a2ad0b6384eccbd17c1e1
|
4
|
+
data.tar.gz: 2d6dc3476e43daee8a5cfd89876d2adb00c9a4d4291a143d6a626bef142dc97b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d171a07ad68d3adc106485b89805aa2c361b0923bd0c1653ff57f32c0e2c99047ad064c2ba4358d44c2d9aac992dd3980da23dfb1885591fd8d7933619c6c2b6
|
7
|
+
data.tar.gz: 36e9f2da9d6020afef1bdd2eee141c5b03062a1c2991710370760256f1fd9c1a4f674a40c6d5aee6de81cd10cd9d85bc424dc1046b7e370b842a09fcb249b08a
|
data/.github/workflows/rake.yml
CHANGED
@@ -40,6 +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_exp/express_parser.*
|
46
|
+
key: v3-${{ 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') }}
|
47
|
+
|
48
|
+
- if: hashFiles('lib/expressir/express_exp/express_parser.*') == ''
|
49
|
+
run: bundle exec rake compile
|
44
50
|
|
45
51
|
- run: bundle exec rake
|
@@ -1,13 +1,38 @@
|
|
1
1
|
name: release
|
2
2
|
|
3
3
|
on:
|
4
|
+
workflow_dispatch:
|
5
|
+
inputs:
|
6
|
+
next_version:
|
7
|
+
description: |
|
8
|
+
Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
|
9
|
+
required: true
|
10
|
+
default: 'patch'
|
4
11
|
push:
|
5
12
|
tags: [ v* ]
|
6
|
-
workflow_dispatch:
|
7
13
|
|
8
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
|
+
|
9
33
|
pack:
|
10
34
|
runs-on: ubuntu-18.04
|
35
|
+
needs: bump
|
11
36
|
strategy:
|
12
37
|
fail-fast: false
|
13
38
|
matrix:
|
@@ -20,9 +45,12 @@ jobs:
|
|
20
45
|
- uses: ruby/setup-ruby@v1
|
21
46
|
with:
|
22
47
|
ruby-version: '2.6'
|
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
|
23
50
|
|
24
51
|
- run: bundle install --jobs 4 --retry 3
|
25
52
|
|
53
|
+
# build gem WITHOUT pre-built native extension
|
26
54
|
- run: gem build expressir.gemspec
|
27
55
|
|
28
56
|
- if: matrix.host == 'linux'
|
@@ -31,6 +59,7 @@ jobs:
|
|
31
59
|
name: pkg-ruby
|
32
60
|
path: expressir-*.gem
|
33
61
|
|
62
|
+
# build gem WITH pre-built native extension
|
34
63
|
- run: bundle exec rake gem:${{ matrix.host }}
|
35
64
|
|
36
65
|
- uses: actions/upload-artifact@v2
|
@@ -38,8 +67,7 @@ jobs:
|
|
38
67
|
name: pkg-${{ matrix.host }}
|
39
68
|
path: pkg/*.gem
|
40
69
|
|
41
|
-
|
42
|
-
release:
|
70
|
+
publish:
|
43
71
|
runs-on: ubuntu-18.04
|
44
72
|
needs: pack
|
45
73
|
steps:
|
data/README.adoc
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
= Expressir: EXPRESS in Ruby
|
2
2
|
|
3
|
-
image:https://
|
4
|
-
image:https://
|
5
|
-
image:https://github.com/lutaml/expressir/workflows/
|
3
|
+
image:https://img.shields.io/gem/v/expressir.svg["Gem Version", link="https://rubygems.org/gems/expressir"]
|
4
|
+
// image:https://codeclimate.com/github/lutaml/expressir/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/lutaml/expressir"]
|
5
|
+
image:https://github.com/lutaml/expressir/workflows/rake/badge.svg["Build Status", link="https://github.com/lutaml/expressir/actions?workflow=rake"]
|
6
6
|
|
7
7
|
== Purpose
|
8
8
|
|
data/exe/format
CHANGED
@@ -6,60 +6,13 @@ require "expressir/express_exp/formatter"
|
|
6
6
|
require "expressir/express_exp/schema_head_formatter"
|
7
7
|
require "expressir/express_exp/hyperlink_formatter"
|
8
8
|
|
9
|
-
exp_files =
|
10
|
-
# basic test
|
11
|
-
# '../iso-10303-stepmod/data/resources/action_schema/action_schema_annotated.exp',
|
12
|
-
# '../iso-10303-stepmod/data/resources/basic_attribute_schema/basic_attribute_schema_annotated.exp',
|
13
|
-
# '../iso-10303-stepmod/data/resources/support_resource_schema/support_resource_schema_annotated.exp',
|
14
|
-
# cyclic reference test
|
15
|
-
# '../iso-10303-stepmod/data/modules/analysis/mim_annotated.exp',
|
16
|
-
# '../iso-10303-stepmod/data/modules/analysis_product_relationships/mim_annotated.exp',
|
17
|
-
# cyclic reference test 2
|
18
|
-
# '../iso-10303-stepmod/data/resources/product_property_definition_schema/product_property_definition_schema_annotated.exp',
|
19
|
-
# '../iso-10303-stepmod/data/resources/product_property_representation_schema/product_property_representation_schema_annotated.exp',
|
20
|
-
# renamed reference test (36s)
|
21
|
-
# '../iso-10303-stepmod/ballots/ballots/ap210_wg12/express/resources/mathematical_functions_schema.exp',
|
22
|
-
# '../iso-10303-stepmod/data/resources/iso13584_expressions_schema/iso13584_expressions_schema.exp',
|
23
|
-
# annotated-express test (12s)
|
24
|
-
# see https://github.com/metanorma/annotated-express/blob/master/data/documents/resources/fundamentals_of_product_description_and_support/sections/04-schemas.adoc
|
25
|
-
# '../iso-10303-stepmod/data/resources/action_schema/action_schema_annotated.exp',
|
26
|
-
# '../iso-10303-stepmod/data/resources/application_context_schema/application_context_schema_annotated.exp',
|
27
|
-
# '../iso-10303-stepmod/data/resources/approval_schema/approval_schema_annotated.exp',
|
28
|
-
# '../iso-10303-stepmod/data/resources/basic_attribute_schema/basic_attribute_schema_annotated.exp',
|
29
|
-
# '../iso-10303-stepmod/data/resources/certification_schema/certification_schema_annotated.exp',
|
30
|
-
# '../iso-10303-stepmod/data/resources/contract_schema/contract_schema_annotated.exp',
|
31
|
-
# '../iso-10303-stepmod/data/resources/date_time_schema/date_time_schema_annotated.exp',
|
32
|
-
# '../iso-10303-stepmod/data/resources/document_schema/document_schema.exp',
|
33
|
-
# '../iso-10303-stepmod/data/resources/effectivity_schema/effectivity_schema_annotated.exp',
|
34
|
-
# '../iso-10303-stepmod/data/resources/experience_schema/experience_schema_annotated.exp',
|
35
|
-
# '../iso-10303-stepmod/data/resources/external_reference_schema/external_reference_schema_annotated.exp',
|
36
|
-
# '../iso-10303-stepmod/data/resources/group_schema/group_schema_annotated.exp',
|
37
|
-
# '../iso-10303-stepmod/data/resources/language_schema/language_schema_annotated.exp',
|
38
|
-
# '../iso-10303-stepmod/data/resources/location_schema/location_schema_annotated.exp',
|
39
|
-
# '../iso-10303-stepmod/data/resources/management_resources_schema/management_resources_schema_annotated.exp',
|
40
|
-
# '../iso-10303-stepmod/data/resources/measure_schema/measure_schema_annotated.exp',
|
41
|
-
# '../iso-10303-stepmod/data/resources/person_organization_schema/person_organization_schema_annotated.exp',
|
42
|
-
# '../iso-10303-stepmod/data/resources/process_property_schema/process_property_schema_annotated.exp',
|
43
|
-
# '../iso-10303-stepmod/data/resources/product_definition_schema/product_definition_schema_annotated.exp',
|
44
|
-
# '../iso-10303-stepmod/data/resources/product_property_definition_schema/product_property_definition_schema_annotated.exp',
|
45
|
-
# '../iso-10303-stepmod/data/resources/product_property_representation_schema/product_property_representation_schema_annotated.exp',
|
46
|
-
# '../iso-10303-stepmod/data/resources/qualifications_schema/qualifications_schema_annotated.exp',
|
47
|
-
# '../iso-10303-stepmod/data/resources/security_classification_schema/security_classification_schema_annotated.exp',
|
48
|
-
# '../iso-10303-stepmod/data/resources/support_resource_schema/support_resource_schema_annotated.exp',
|
49
|
-
# full test (6m18s + 8s = 6m26s)
|
50
|
-
*`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}
|
51
|
-
]
|
9
|
+
exp_files = ARGV
|
52
10
|
|
53
|
-
start = Time.now
|
54
11
|
repository = Expressir::ExpressExp::Parser.from_files(exp_files)
|
55
|
-
puts "Parsing time: #{Time.now - start}"
|
56
|
-
start2 = Time.now
|
57
12
|
formatter = Class.new(Expressir::ExpressExp::Formatter) do
|
58
13
|
include Expressir::ExpressExp::SchemaHeadFormatter
|
59
14
|
include Expressir::ExpressExp::HyperlinkFormatter
|
60
15
|
end
|
61
16
|
result = repository.to_hash(formatter: formatter, skip_empty: true)
|
62
|
-
puts "Formatting & serializing time: #{Time.now - start2}"
|
63
|
-
puts "Total time: #{Time.now - start}"
|
64
17
|
|
65
|
-
|
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_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"
|
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::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
|
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)
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'zlib'
|
3
|
+
require 'expressir/model'
|
4
|
+
|
5
|
+
module Expressir
|
6
|
+
module ExpressExp
|
7
|
+
class Cache
|
8
|
+
def self.to_file(file, content, options = {})
|
9
|
+
root_path = options[:root_path]
|
10
|
+
test_overwrite_version = options[:test_overwrite_version] # don't use, only for tests
|
11
|
+
|
12
|
+
version = test_overwrite_version || VERSION
|
13
|
+
|
14
|
+
cache = Model::Cache.new({
|
15
|
+
version: version,
|
16
|
+
content: content
|
17
|
+
})
|
18
|
+
|
19
|
+
hash = cache.to_hash(root_path: root_path, skip_empty: true)
|
20
|
+
yaml = YAML.dump(hash)
|
21
|
+
yaml_compressed = Zlib::Deflate.deflate(yaml)
|
22
|
+
|
23
|
+
File.binwrite(file, yaml_compressed)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.from_file(file, options = {})
|
27
|
+
root_path = options[:root_path]
|
28
|
+
test_overwrite_version = options[:test_overwrite_version] # don't use, only for tests
|
29
|
+
|
30
|
+
version = test_overwrite_version || VERSION
|
31
|
+
|
32
|
+
yaml_compressed = File.binread(file)
|
33
|
+
yaml = Zlib::Inflate.inflate(yaml_compressed)
|
34
|
+
hash = YAML.load(yaml)
|
35
|
+
cache = Model::ModelElement.from_hash(hash, root_path: root_path)
|
36
|
+
|
37
|
+
if cache.version != version
|
38
|
+
raise CacheLoadError.new("Cache version mismatch, cache version is #{cache.version}, Expressir version is #{version}")
|
39
|
+
end
|
40
|
+
|
41
|
+
cache.content
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class CacheLoadError < StandardError
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -1502,7 +1502,7 @@ module Expressir
|
|
1502
1502
|
[
|
1503
1503
|
'(*',
|
1504
1504
|
'"',
|
1505
|
-
node.path,
|
1505
|
+
node.path || node.id,
|
1506
1506
|
'"',
|
1507
1507
|
].join(''),
|
1508
1508
|
remark,
|
@@ -1512,7 +1512,7 @@ module Expressir
|
|
1512
1512
|
[
|
1513
1513
|
'--',
|
1514
1514
|
'"',
|
1515
|
-
node.path,
|
1515
|
+
node.path || node.id,
|
1516
1516
|
'"',
|
1517
1517
|
' ',
|
1518
1518
|
remark
|
@@ -2,25 +2,20 @@ module Expressir
|
|
2
2
|
module ExpressExp
|
3
3
|
module HyperlinkFormatter
|
4
4
|
def format_expressions_simple_reference(node)
|
5
|
-
return node.id
|
5
|
+
return node.id unless node.base_path
|
6
6
|
|
7
|
-
#
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
node.find(node.id)
|
7
|
+
# find closest node with path
|
8
|
+
current_node = node
|
9
|
+
while !current_node.path
|
10
|
+
current_node = current_node.parent
|
12
11
|
end
|
13
|
-
return node.id unless target_node
|
14
12
|
|
15
|
-
# skip
|
16
|
-
|
13
|
+
# skip if this reference and target node are in the same node with path
|
14
|
+
node_base_path_parts = node.base_path.split(".")
|
15
|
+
current_node_path_parts = current_node.path.split(".")
|
16
|
+
return node.id if node_base_path_parts[0..1] == current_node_path_parts[0..1]
|
17
17
|
|
18
|
-
|
19
|
-
node_path_parts = node.path.split(".")
|
20
|
-
target_node_path_parts = target_node.path.split(".")
|
21
|
-
return node.id if node_path_parts[0..1] == target_node_path_parts[0..1]
|
22
|
-
|
23
|
-
"{{{<<express:#{target_node.path},#{node.id}>>}}}"
|
18
|
+
"{{{<<express:#{node.base_path},#{node.id}>>}}}"
|
24
19
|
end
|
25
20
|
end
|
26
21
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "expressir/model"
|
2
|
+
|
3
|
+
module Expressir
|
4
|
+
module ExpressExp
|
5
|
+
class ModelVisitor
|
6
|
+
def visit(node)
|
7
|
+
node.class.model_attrs.each do |variable|
|
8
|
+
value = node.send(variable)
|
9
|
+
|
10
|
+
if value.is_a? Array
|
11
|
+
value.each do |value|
|
12
|
+
if value.is_a? Model::ModelElement
|
13
|
+
visit(value)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
elsif value.is_a? Model::ModelElement
|
17
|
+
visit(value)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -5,7 +5,7 @@ rescue LoadError
|
|
5
5
|
require_relative "express_parser"
|
6
6
|
end
|
7
7
|
require 'expressir/express_exp/visitor'
|
8
|
-
require '
|
8
|
+
require 'expressir/express_exp/resolve_references_model_visitor'
|
9
9
|
|
10
10
|
=begin
|
11
11
|
char_stream = Antlr4::Runtime::CharStreams.from_string(input, 'String')
|
@@ -26,7 +26,7 @@ module Expressir
|
|
26
26
|
module ExpressExp
|
27
27
|
class Parser
|
28
28
|
def self.from_file(file, options = {})
|
29
|
-
|
29
|
+
skip_references = options[:skip_references]
|
30
30
|
|
31
31
|
input = File.read(file)
|
32
32
|
|
@@ -38,16 +38,23 @@ module Expressir
|
|
38
38
|
repository = visitor.visit(parse_tree)
|
39
39
|
|
40
40
|
repository.schemas.each do |schema|
|
41
|
-
schema.file =
|
41
|
+
schema.file = file.to_s
|
42
|
+
end
|
43
|
+
|
44
|
+
unless skip_references
|
45
|
+
resolve_references_model_visitor = ResolveReferencesModelVisitor.new
|
46
|
+
resolve_references_model_visitor.visit(repository)
|
42
47
|
end
|
43
48
|
|
44
49
|
repository
|
45
50
|
end
|
46
51
|
|
47
52
|
def self.from_files(files, options = {})
|
53
|
+
skip_references = options[:skip_references]
|
54
|
+
|
48
55
|
schemas = files.each_with_index.map do |file, i|
|
49
56
|
# start = Time.now
|
50
|
-
repository = self.from_file(file, options)
|
57
|
+
repository = self.from_file(file, options.merge(skip_references: true))
|
51
58
|
# STDERR.puts "#{i+1}/#{files.length} #{file} #{Time.now - start}"
|
52
59
|
repository.schemas
|
53
60
|
end.flatten
|
@@ -56,8 +63,9 @@ module Expressir
|
|
56
63
|
schemas: schemas
|
57
64
|
})
|
58
65
|
|
59
|
-
|
60
|
-
|
66
|
+
unless skip_references
|
67
|
+
resolve_references_model_visitor = ResolveReferencesModelVisitor.new
|
68
|
+
resolve_references_model_visitor.visit(repository)
|
61
69
|
end
|
62
70
|
|
63
71
|
repository
|