expressir 1.3.0-x64-mingw32 → 1.3.1-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/codeql.yml +47 -0
- data/.github/workflows/rake.yml +9 -8
- data/.github/workflows/release.yml +13 -10
- data/.github/workflows/stress.yml +53 -0
- data/.gitignore +1 -1
- data/.gitmodules +2 -2
- data/exe/generate-parser +1 -1
- data/expressir.gemspec +4 -4
- data/lib/expressir/express/2.7/express_parser.so +0 -0
- data/lib/expressir/express/3.0/express_parser.so +0 -0
- data/lib/expressir/express/parser.rb +0 -1
- data/lib/expressir/express/visitor.rb +11 -8
- data/lib/expressir/model/declarations/schema.rb +3 -3
- data/lib/expressir/model/model_element.rb +4 -4
- data/lib/expressir/version.rb +1 -1
- data/lib/expressir.rb +20 -0
- data/rakelib/antlr4-native.rake +24 -12
- data/rakelib/cross-ruby.rake +1 -1
- data/spec/acceptance/version_spec.rb +3 -0
- data/spec/expressir/express/cache_spec.rb +2 -2
- data/spec/expressir/express/formatter_spec.rb +0 -2
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfad414779ea7432670eae3271c286115a2b4b630737e701d908024914a07875
|
4
|
+
data.tar.gz: 640e5fc9d8b563a1716b5041da47723817d712b2148168e56a15ec54aff870d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebadd761de0114f146d5c6a82faf54946f68866f86f869658a1ef23c6c679f369f6e24bf5d9eb5b3303c4e29ebfbf440465f0132a93be67c2c32aaca848dde22
|
7
|
+
data.tar.gz: 4b7af161be417bc81b14365edcc54bde3cd0c5623ffbb91ee58a8cb72bfce4193a5aec0ad16fe2d227c9fe03e8a95f8e85a742a1905a1343147bea019ed284fc
|
@@ -0,0 +1,47 @@
|
|
1
|
+
name: "CodeQL"
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ main ]
|
6
|
+
schedule:
|
7
|
+
- cron: '0 23 * * 3'
|
8
|
+
workflow_dispatch:
|
9
|
+
|
10
|
+
concurrency:
|
11
|
+
group: '${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.ref_name }}'
|
12
|
+
cancel-in-progress: true
|
13
|
+
|
14
|
+
env:
|
15
|
+
BUNDLER_VER: 2.4.22
|
16
|
+
|
17
|
+
jobs:
|
18
|
+
analyze:
|
19
|
+
name: Analyze
|
20
|
+
runs-on: ubuntu-latest
|
21
|
+
|
22
|
+
steps:
|
23
|
+
- name: Checkout
|
24
|
+
uses: actions/checkout@v4
|
25
|
+
with:
|
26
|
+
submodules: recursive
|
27
|
+
|
28
|
+
- name: Install Ruby
|
29
|
+
uses: ruby/setup-ruby@master
|
30
|
+
with:
|
31
|
+
ruby-version: 3.1
|
32
|
+
bundler: ${{ env.BUNDLER_VER }}
|
33
|
+
bundler-cache: false
|
34
|
+
|
35
|
+
- name: Bundle
|
36
|
+
run: bundle install --jobs 4 --retry 3
|
37
|
+
|
38
|
+
- name: Initialize CodeQL
|
39
|
+
uses: github/codeql-action/init@v2
|
40
|
+
with:
|
41
|
+
languages: "ruby, cpp"
|
42
|
+
|
43
|
+
- name: Build native extension
|
44
|
+
run: bundle exec rake compile
|
45
|
+
|
46
|
+
- name: Perform CodeQL Analysis
|
47
|
+
uses: github/codeql-action/analyze@v2
|
data/.github/workflows/rake.yml
CHANGED
@@ -8,6 +8,7 @@ on:
|
|
8
8
|
- '**.adoc'
|
9
9
|
- '**.md'
|
10
10
|
- .github/workflows/release.yml
|
11
|
+
- .github/workflows/codeql.yml
|
11
12
|
pull_request:
|
12
13
|
workflow_dispatch:
|
13
14
|
|
@@ -77,11 +78,11 @@ jobs:
|
|
77
78
|
run: bundle install --jobs 4 --retry 3
|
78
79
|
|
79
80
|
- name: Process cache
|
80
|
-
uses: actions/cache@
|
81
|
+
uses: actions/cache@v4
|
81
82
|
id: cache
|
82
83
|
with:
|
83
84
|
path: lib/expressir/express/express_parser.*
|
84
|
-
key: v4-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('ext/
|
85
|
+
key: v4-${{ matrix.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') }}
|
85
86
|
|
86
87
|
- name: Build native extension
|
87
88
|
if: steps.cache.outputs.cache-hit != 'true'
|
@@ -115,7 +116,7 @@ jobs:
|
|
115
116
|
run: gem build expressir.gemspec
|
116
117
|
|
117
118
|
- name: Package gem without native extension
|
118
|
-
uses: actions/upload-artifact@
|
119
|
+
uses: actions/upload-artifact@v4
|
119
120
|
with:
|
120
121
|
name: pkg-ruby
|
121
122
|
path: expressir-*.gem
|
@@ -154,7 +155,7 @@ jobs:
|
|
154
155
|
run: bundle exec rake gem:${{ matrix.platform }}
|
155
156
|
|
156
157
|
- name: Package gem with native extension
|
157
|
-
uses: actions/upload-artifact@
|
158
|
+
uses: actions/upload-artifact@v4
|
158
159
|
with:
|
159
160
|
name: pkg-${{ matrix.platform }}
|
160
161
|
path: pkg/*.gem
|
@@ -185,7 +186,7 @@ jobs:
|
|
185
186
|
run: bundle install --jobs 4 --retry 3
|
186
187
|
|
187
188
|
- name: Download packaged gem
|
188
|
-
uses: actions/download-artifact@
|
189
|
+
uses: actions/download-artifact@v4
|
189
190
|
with:
|
190
191
|
name: pkg-ruby
|
191
192
|
path: pkg
|
@@ -222,7 +223,7 @@ jobs:
|
|
222
223
|
run: bundle install --jobs 4 --retry 3
|
223
224
|
|
224
225
|
- name: Download packaged gem
|
225
|
-
uses: actions/download-artifact@
|
226
|
+
uses: actions/download-artifact@v4
|
226
227
|
with:
|
227
228
|
name: pkg-darwin
|
228
229
|
path: pkg
|
@@ -260,7 +261,7 @@ jobs:
|
|
260
261
|
run: bundle install --jobs 4 --retry 3
|
261
262
|
|
262
263
|
- name: Download packaged gem
|
263
|
-
uses: actions/download-artifact@
|
264
|
+
uses: actions/download-artifact@v4
|
264
265
|
with:
|
265
266
|
name: pkg-linux-gnu
|
266
267
|
path: pkg
|
@@ -298,7 +299,7 @@ jobs:
|
|
298
299
|
run: bundle install --jobs 4 --retry 3
|
299
300
|
|
300
301
|
- name: Download packaged gem
|
301
|
-
uses: actions/download-artifact@
|
302
|
+
uses: actions/download-artifact@v4
|
302
303
|
with:
|
303
304
|
name: pkg-windows
|
304
305
|
path: pkg
|
@@ -15,6 +15,9 @@ concurrency:
|
|
15
15
|
group: '${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.ref_name }}'
|
16
16
|
cancel-in-progress: true
|
17
17
|
|
18
|
+
env:
|
19
|
+
BUNDLER_VER: 2.4.22
|
20
|
+
|
18
21
|
jobs:
|
19
22
|
bump:
|
20
23
|
runs-on: ubuntu-latest
|
@@ -62,13 +65,13 @@ jobs:
|
|
62
65
|
gem build expressir.gemspec | grep -o 'Version: .*' | awk '{print $2}' > version
|
63
66
|
|
64
67
|
- if: matrix.platform == 'linux-gnu'
|
65
|
-
uses: actions/upload-artifact@
|
68
|
+
uses: actions/upload-artifact@v4
|
66
69
|
with:
|
67
70
|
name: pkg-ruby
|
68
71
|
path: expressir-*.gem
|
69
72
|
|
70
73
|
- if: matrix.platform == 'linux-gnu'
|
71
|
-
uses: actions/upload-artifact@
|
74
|
+
uses: actions/upload-artifact@v4
|
72
75
|
with:
|
73
76
|
name: version
|
74
77
|
path: version
|
@@ -84,7 +87,7 @@ jobs:
|
|
84
87
|
# build gem WITH pre-built native extension
|
85
88
|
- run: bundle exec rake gem:${{ matrix.platform }}
|
86
89
|
|
87
|
-
- uses: actions/upload-artifact@
|
90
|
+
- uses: actions/upload-artifact@v4
|
88
91
|
with:
|
89
92
|
name: pkg-${{ matrix.platform }}
|
90
93
|
path: pkg/*.gem
|
@@ -93,22 +96,22 @@ jobs:
|
|
93
96
|
runs-on: ubuntu-latest
|
94
97
|
needs: pack
|
95
98
|
steps:
|
96
|
-
- uses: actions/download-artifact@
|
99
|
+
- uses: actions/download-artifact@v4
|
97
100
|
with:
|
98
101
|
name: pkg-ruby
|
99
102
|
path: pkg
|
100
103
|
|
101
|
-
- uses: actions/download-artifact@
|
104
|
+
- uses: actions/download-artifact@v4
|
102
105
|
with:
|
103
106
|
name: pkg-linux-gnu
|
104
107
|
path: pkg
|
105
108
|
|
106
|
-
- uses: actions/download-artifact@
|
109
|
+
- uses: actions/download-artifact@v4
|
107
110
|
with:
|
108
111
|
name: pkg-windows
|
109
112
|
path: pkg
|
110
113
|
|
111
|
-
- uses: actions/download-artifact@
|
114
|
+
- uses: actions/download-artifact@v4
|
112
115
|
with:
|
113
116
|
name: pkg-darwin
|
114
117
|
path: pkg
|
@@ -130,7 +133,7 @@ jobs:
|
|
130
133
|
chmod 0600 ~/.gem/credentials
|
131
134
|
gem signin
|
132
135
|
for gem in pkg/*.gem; do gem push $gem -V; done
|
133
|
-
sleep
|
136
|
+
sleep 5
|
134
137
|
|
135
138
|
verify:
|
136
139
|
name: Verify published gem on ${{ matrix.os }}
|
@@ -149,7 +152,7 @@ jobs:
|
|
149
152
|
bundler: ${{ env.BUNDLER_VER }}
|
150
153
|
|
151
154
|
- name: Download version
|
152
|
-
uses: actions/download-artifact@
|
155
|
+
uses: actions/download-artifact@v4
|
153
156
|
with:
|
154
157
|
name: version
|
155
158
|
|
@@ -170,7 +173,7 @@ jobs:
|
|
170
173
|
run: apk --no-cache add bash build-base git ruby-dev gcc g++ automake
|
171
174
|
|
172
175
|
- name: Download version
|
173
|
-
uses: actions/download-artifact@
|
176
|
+
uses: actions/download-artifact@v4
|
174
177
|
with:
|
175
178
|
name: version
|
176
179
|
|
@@ -0,0 +1,53 @@
|
|
1
|
+
name: stress
|
2
|
+
|
3
|
+
on:
|
4
|
+
workflow_dispatch:
|
5
|
+
|
6
|
+
concurrency:
|
7
|
+
group: '${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.ref_name }}'
|
8
|
+
cancel-in-progress: true
|
9
|
+
|
10
|
+
env:
|
11
|
+
BUNDLER_VER: 2.4.22
|
12
|
+
GC_STRESS: true
|
13
|
+
|
14
|
+
jobs:
|
15
|
+
rake:
|
16
|
+
name: test on ruby-${{ matrix.ruby }} ${{ matrix.os }}
|
17
|
+
runs-on: ${{ matrix.os }}
|
18
|
+
strategy:
|
19
|
+
fail-fast: false
|
20
|
+
matrix:
|
21
|
+
ruby: [ '3.2', '3.1', '3.0', '2.7' ]
|
22
|
+
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
23
|
+
|
24
|
+
steps:
|
25
|
+
- name: Checkout
|
26
|
+
uses: actions/checkout@v4
|
27
|
+
with:
|
28
|
+
submodules: recursive
|
29
|
+
|
30
|
+
- name: Setup packages
|
31
|
+
if: startsWith(matrix.os, 'macos')
|
32
|
+
run: brew install autoconf automake libtool
|
33
|
+
|
34
|
+
- name: Install Ruby
|
35
|
+
uses: ruby/setup-ruby@master
|
36
|
+
with:
|
37
|
+
ruby-version: ${{ matrix.ruby }}
|
38
|
+
bundler: ${{ env.BUNDLER_VER }}
|
39
|
+
# Rice gem has issues with bundler cache
|
40
|
+
# more info https://github.com/lutaml/expressir/runs/2097658383?check_suite_focus=true#step:7:2126
|
41
|
+
# but it is not the only issue
|
42
|
+
bundler-cache: false
|
43
|
+
|
44
|
+
- name: Bundle
|
45
|
+
run: bundle install --jobs 4 --retry 3
|
46
|
+
|
47
|
+
- name: Build native extension
|
48
|
+
run: bundle exec rake compile
|
49
|
+
|
50
|
+
- name: Run tests
|
51
|
+
run: |
|
52
|
+
bundle exec rake
|
53
|
+
cat .rspec_status
|
data/.gitignore
CHANGED
data/.gitmodules
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
[submodule "ext/
|
2
|
-
path = ext/
|
1
|
+
[submodule "ext/express_parser/antlr4-upstream"]
|
2
|
+
path = ext/express_parser/antlr4-upstream
|
3
3
|
url = https://github.com/antlr/antlr4
|
4
4
|
[submodule "ext/express-grammar"]
|
5
5
|
path = ext/express-grammar
|
data/exe/generate-parser
CHANGED
@@ -18,7 +18,7 @@ generator = Antlr4Native::Generator.new(
|
|
18
18
|
generator.generate
|
19
19
|
|
20
20
|
# fix issues with generated parser
|
21
|
-
parser_source_file = File.join("ext", "
|
21
|
+
parser_source_file = File.join("ext", "express_parser", "express_parser.cpp")
|
22
22
|
parser_source_lines = File.read(parser_source_file).split("\n")
|
23
23
|
|
24
24
|
# - add ParserProxy tokens method, simple compensation for missing exposed BufferedTokenStream
|
data/expressir.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
21
21
|
|
22
22
|
spec.files = `git ls-files`.split("\n")\
|
23
|
-
+ Dir.glob("ext/
|
23
|
+
+ Dir.glob("ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/**/*")
|
24
24
|
|
25
25
|
spec.test_files = `git ls-files -- {spec}/*`.split("\n")
|
26
26
|
|
@@ -28,11 +28,11 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
spec.executables = %w[expressir]
|
30
30
|
|
31
|
-
spec.extensions = File.join(*%w(ext
|
31
|
+
spec.extensions = File.join(*%w(ext express_parser extconf.rb))
|
32
32
|
|
33
|
-
spec.add_runtime_dependency "rice", "~> 4.
|
33
|
+
spec.add_runtime_dependency "rice", "~> 4.2"
|
34
34
|
spec.add_runtime_dependency "thor", "~> 1.0"
|
35
|
-
spec.add_development_dependency "antlr4-native", "~> 2.
|
35
|
+
spec.add_development_dependency "antlr4-native", "~> 2.2"
|
36
36
|
spec.add_development_dependency "asciidoctor", "~> 2.0.13"
|
37
37
|
spec.add_development_dependency "bundler", "~> 2.3"
|
38
38
|
spec.add_development_dependency "byebug", "~> 11.1"
|
Binary file
|
Binary file
|
@@ -39,7 +39,6 @@ module Expressir
|
|
39
39
|
# so in this class we keep those C++ structure marked for GC so they are not freed
|
40
40
|
@parser = ::ExpressParser::ParserExt.new(file.to_s)
|
41
41
|
@parse_tree = @parser.syntax()
|
42
|
-
|
43
42
|
@visitor = Visitor.new(@parser.tokens, include_source: include_source)
|
44
43
|
@repository = @visitor.visit(@parse_tree)
|
45
44
|
|
@@ -40,7 +40,7 @@ module Expressir
|
|
40
40
|
|
41
41
|
private_constant :REMARK_CHANNEL
|
42
42
|
|
43
|
-
# @param [
|
43
|
+
# @param [::ExpressParser::TokenVector] Rice-wrapped std::vector<TokenProxy>
|
44
44
|
# @param [Boolean] include_source attach original source code to model elements
|
45
45
|
def initialize(tokens, include_source: nil)
|
46
46
|
@tokens = tokens
|
@@ -101,7 +101,11 @@ module Expressir
|
|
101
101
|
[ctx.start.token_index, ctx.stop.token_index]
|
102
102
|
end
|
103
103
|
|
104
|
-
|
104
|
+
selected_tokens = []
|
105
|
+
(start_index..stop_index).each do |i|
|
106
|
+
selected_tokens << @tokens[i]
|
107
|
+
end
|
108
|
+
selected_tokens
|
105
109
|
end
|
106
110
|
|
107
111
|
def attach_source(ctx, node)
|
@@ -150,15 +154,14 @@ module Expressir
|
|
150
154
|
end
|
151
155
|
|
152
156
|
def attach_remarks(ctx, node)
|
153
|
-
|
154
|
-
|
155
|
-
}
|
157
|
+
remark_tokens = get_tokens(ctx)
|
158
|
+
remark_tokens = remark_tokens.select{ |x| x.channel == REMARK_CHANNEL }
|
156
159
|
|
157
160
|
# skip already attached remarks
|
158
|
-
|
161
|
+
remark_tokens = remark_tokens.select{|x| !@attached_remark_tokens.include?(x.token_index)}
|
159
162
|
|
160
163
|
# parse remarks, find remark targets
|
161
|
-
tagged_remark_tokens =
|
164
|
+
tagged_remark_tokens = remark_tokens.map do |remark_token|
|
162
165
|
_, remark_tag, remark_text = if remark_token.text.start_with?('--')
|
163
166
|
remark_token.text.match(/^--"([^"]*)"(.*)$/).to_a
|
164
167
|
else
|
@@ -181,7 +184,7 @@ module Expressir
|
|
181
184
|
remark_target.remarks << remark_text
|
182
185
|
|
183
186
|
# mark remark as attached, so that it is not attached again at higher nesting level
|
184
|
-
@attached_remark_tokens << remark_token
|
187
|
+
@attached_remark_tokens << remark_token.token_index
|
185
188
|
end
|
186
189
|
end
|
187
190
|
|
@@ -90,13 +90,13 @@ module Expressir
|
|
90
90
|
return [] unless parent
|
91
91
|
|
92
92
|
interfaces.flat_map do |interface|
|
93
|
-
schema = parent.children_by_id[interface.schema.id.
|
93
|
+
schema = parent.children_by_id[interface.schema.id.safe_downcase]
|
94
94
|
if schema
|
95
95
|
schema_safe_children = schema.safe_children
|
96
|
-
schema_safe_children_by_id = schema_safe_children.select{|x| x.id}.map{|x| [x.id.
|
96
|
+
schema_safe_children_by_id = schema_safe_children.select{|x| x.id}.map{|x| [x.id.safe_downcase, x]}.to_h
|
97
97
|
if interface.items.length > 0
|
98
98
|
interface.items.map do |interface_item|
|
99
|
-
base_item = schema_safe_children_by_id[interface_item.ref.id.
|
99
|
+
base_item = schema_safe_children_by_id[interface_item.ref.id.safe_downcase]
|
100
100
|
if base_item
|
101
101
|
id = interface_item.id || base_item.id
|
102
102
|
create_interfaced_item(id, base_item)
|
@@ -46,7 +46,7 @@ module Expressir
|
|
46
46
|
def find(path)
|
47
47
|
return self if path.empty?
|
48
48
|
|
49
|
-
path_parts = path.
|
49
|
+
path_parts = path.safe_downcase.split(/\./).map do |current_path|
|
50
50
|
_, _, current_path = current_path.rpartition(":") # ignore prefix
|
51
51
|
current_path
|
52
52
|
end
|
@@ -82,7 +82,7 @@ module Expressir
|
|
82
82
|
|
83
83
|
# @return [Hash<String, Declaration>]
|
84
84
|
def children_by_id
|
85
|
-
@children_by_id ||= children.select{|x| x.id}.map{|x| [x.id.
|
85
|
+
@children_by_id ||= children.select{|x| x.id}.map{|x| [x.id.safe_downcase, x]}.to_h
|
86
86
|
end
|
87
87
|
|
88
88
|
# @return [nil]
|
@@ -90,7 +90,7 @@ module Expressir
|
|
90
90
|
@children_by_id = nil
|
91
91
|
nil
|
92
92
|
end
|
93
|
-
|
93
|
+
|
94
94
|
# @param [String] root_path
|
95
95
|
# @param [Express::Formatter] formatter
|
96
96
|
# @param [Boolean] include_empty
|
@@ -131,7 +131,7 @@ module Expressir
|
|
131
131
|
|
132
132
|
hash
|
133
133
|
end
|
134
|
-
|
134
|
+
|
135
135
|
# @param [Hash] hash
|
136
136
|
# @param [String] root_path
|
137
137
|
# @return [ModelElement]
|
data/lib/expressir/version.rb
CHANGED
data/lib/expressir.rb
CHANGED
@@ -7,6 +7,26 @@ Dir[File.join(__dir__, "expressir", "express", "*.rb")].sort.each do |fea|
|
|
7
7
|
require fea
|
8
8
|
end
|
9
9
|
|
10
|
+
# ..........................................................
|
11
|
+
# https://bugs.ruby-lang.org/issues/19319
|
12
|
+
# The issue is that this bug is fixed for 3.1 and above,
|
13
|
+
# but not for 3.0 or 2.7, so we need a "safe" function
|
14
|
+
# ..........................................................
|
15
|
+
|
16
|
+
if RUBY_VERSION < "3.1"
|
17
|
+
class String
|
18
|
+
def safe_downcase
|
19
|
+
each_char.map(&:downcase).join
|
20
|
+
end
|
21
|
+
end
|
22
|
+
else
|
23
|
+
class String
|
24
|
+
def safe_downcase
|
25
|
+
downcase
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
10
30
|
module Expressir
|
11
31
|
class Error < StandardError; end
|
12
32
|
|
data/rakelib/antlr4-native.rake
CHANGED
@@ -72,12 +72,12 @@ def create_pp_class_definition(parser_source_lines)
|
|
72
72
|
return detail::To_Ruby<SyntaxContextProxy>().convert(proxy);
|
73
73
|
}
|
74
74
|
|
75
|
-
|
76
|
-
|
75
|
+
Object getTokens() {
|
76
|
+
std::vector<TokenProxy> tk;
|
77
77
|
for (auto token : tokens -> getTokens()) {
|
78
|
-
|
78
|
+
tk.push_back(TokenProxy(token));
|
79
79
|
}
|
80
|
-
return
|
80
|
+
return detail::To_Ruby<std::vector<TokenProxy>>().convert(tk);
|
81
81
|
}
|
82
82
|
|
83
83
|
Object visit(VisitorProxy* visitor) {
|
@@ -88,8 +88,8 @@ def create_pp_class_definition(parser_source_lines)
|
|
88
88
|
|
89
89
|
try {
|
90
90
|
return std::any_cast<Object>(result);
|
91
|
-
} catch(std::
|
92
|
-
|
91
|
+
} catch(std::bad_any_cast) {
|
92
|
+
return Qnil;
|
93
93
|
}
|
94
94
|
}
|
95
95
|
|
@@ -105,7 +105,7 @@ def create_pp_class_definition(parser_source_lines)
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def create_class_api(parser_source_lines)
|
108
|
-
i = parser_source_lines.index { |x| x == " .define_method(\"visit\", &ParserProxy::visit
|
108
|
+
i = parser_source_lines.index { |x| x == " .define_method(\"visit\", &ParserProxy::visit);" }
|
109
109
|
parser_source_lines[i] += <<~CPP.split("\n").map { |x| x == "" ? x : " #{x}" }.join("\n")
|
110
110
|
|
111
111
|
|
@@ -116,17 +116,29 @@ def create_class_api(parser_source_lines)
|
|
116
116
|
|
117
117
|
rb_cParserExt = define_class_under<ParserProxyExt>(rb_mExpressParser, "ParserExt")
|
118
118
|
.define_constructor(Constructor<ParserProxyExt, string>())
|
119
|
-
.define_method("syntax", &ParserProxyExt::syntax
|
120
|
-
.define_method("tokens", &ParserProxyExt::getTokens)
|
121
|
-
.define_method("visit", &ParserProxyExt::visit
|
119
|
+
.define_method("syntax", &ParserProxyExt::syntax)
|
120
|
+
.define_method("tokens", &ParserProxyExt::getTokens, Return().keepAlive())
|
121
|
+
.define_method("visit", &ParserProxyExt::visit);
|
122
|
+
|
123
|
+
define_vector<std::vector<TokenProxy>>("TokenVector");
|
124
|
+
|
125
|
+
CPP
|
126
|
+
end
|
127
|
+
|
128
|
+
def create_vector_definition(parser_source_lines)
|
129
|
+
i = parser_source_lines.index { |x| x == " .define_method(\"visit\", &ParserProxy::visit);" }
|
130
|
+
parser_source_lines[i] += <<~CPP.split("\n").map { |x| x == "" ? x : " #{x}" }.join("\n")
|
122
131
|
|
123
132
|
CPP
|
124
133
|
end
|
125
134
|
|
126
135
|
def generate_extended_parser
|
127
136
|
# Generate extended parser that provide Ruby access to token stream
|
128
|
-
parser_source_file = File.join("ext", "
|
129
|
-
parser_source_lines = File.read(parser_source_file)
|
137
|
+
parser_source_file = File.join("ext", "express_parser", "express_parser.cpp")
|
138
|
+
parser_source_lines = File.read(parser_source_file)
|
139
|
+
.gsub!("bad_cast", "bad_any_cast")
|
140
|
+
.gsub!("return detail::To_Ruby<Token*>().convert(token)", "return detail::To_Ruby<TokenProxy>().convert(TokenProxy(token))")
|
141
|
+
.split("\n")
|
130
142
|
create_class_declarations(parser_source_lines)
|
131
143
|
create_tp_class_definition(parser_source_lines)
|
132
144
|
create_pp_class_definition(parser_source_lines)
|
data/rakelib/cross-ruby.rake
CHANGED
@@ -370,7 +370,7 @@ end
|
|
370
370
|
require "rake/extensiontask"
|
371
371
|
|
372
372
|
Rake::ExtensionTask.new("express_parser", GEMSPEC) do |ext|
|
373
|
-
ext.ext_dir = "ext/
|
373
|
+
ext.ext_dir = "ext/express_parser"
|
374
374
|
ext.lib_dir = File.join(*["lib", "expressir", "express", ENV.fetch("FAT_DIR", nil)].compact)
|
375
375
|
ext.config_options << ENV.fetch("EXTOPTS", nil)
|
376
376
|
ext.cross_compile = true
|
@@ -3,6 +3,9 @@ require "spec_helper"
|
|
3
3
|
RSpec.describe "Expressir" do
|
4
4
|
describe "version" do
|
5
5
|
it "has a version number" do |example|
|
6
|
+
GC.stress = ENV["GC_STRESS"] == "true"
|
7
|
+
puts "Running tests in GC stress mode. It may take a couple of hours ..." if GC.stress
|
8
|
+
|
6
9
|
print "\n[#{example.description}] "
|
7
10
|
expect(Expressir::VERSION).not_to be nil
|
8
11
|
|
@@ -40,7 +40,7 @@ RSpec.describe Expressir::Express::Cache do
|
|
40
40
|
end.to raise_error(Errno::ENOENT)
|
41
41
|
end
|
42
42
|
|
43
|
-
it "
|
43
|
+
it "loads a cache file" do |example|
|
44
44
|
print "\n[#{example.description}] "
|
45
45
|
temp_file = Tempfile.new
|
46
46
|
|
@@ -63,7 +63,7 @@ RSpec.describe Expressir::Express::Cache do
|
|
63
63
|
GC.verify_internal_consistency
|
64
64
|
end
|
65
65
|
|
66
|
-
it "fails parsing a
|
66
|
+
it "fails parsing a cache from a different Expressir version" do |example|
|
67
67
|
print "\n[#{example.description}] "
|
68
68
|
temp_file = Tempfile.new
|
69
69
|
|
@@ -11,9 +11,7 @@ RSpec.describe Expressir::Express::Formatter do
|
|
11
11
|
print "\n[#{example.description}] "
|
12
12
|
exp_file = Expressir.root_path.join("spec", "syntax", "single.exp")
|
13
13
|
formatted_exp_file = Expressir.root_path.join("spec", "syntax", "single_formatted.exp")
|
14
|
-
|
15
14
|
repo = Expressir::Express::Parser.from_file(exp_file)
|
16
|
-
|
17
15
|
result = Expressir::Express::Formatter.format(repo)
|
18
16
|
# File.write(formatted_exp_file, result)
|
19
17
|
expected_result = File.read(formatted_exp_file)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: expressir
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: x64-mingw32
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.
|
33
|
+
version: '2.2'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.
|
40
|
+
version: '2.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: asciidoctor
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -216,8 +216,10 @@ extensions: []
|
|
216
216
|
extra_rdoc_files: []
|
217
217
|
files:
|
218
218
|
- ".cross_rubies"
|
219
|
+
- ".github/workflows/codeql.yml"
|
219
220
|
- ".github/workflows/rake.yml"
|
220
221
|
- ".github/workflows/release.yml"
|
222
|
+
- ".github/workflows/stress.yml"
|
221
223
|
- ".gitignore"
|
222
224
|
- ".gitmodules"
|
223
225
|
- ".hound.yml"
|