expressir 1.3.0.pre.5-x64-mingw-ucrt → 1.3.1-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61c936c2a884b62091a0f211c79c9868d44b9c2b3b075aec9451d9c91e48a1a3
4
- data.tar.gz: 380c3762f7e32353534dbcbfe31ac4c993a855fe9467548d03fc2b72e467f0a8
3
+ metadata.gz: de36196da3136ab1090c8640b778fc7fef3a2b23acd2462833cb3a2b31b67fc4
4
+ data.tar.gz: 3c2ff15308efee60bcf57ad263c2c63249e11fadddda143867a05f4769befc5e
5
5
  SHA512:
6
- metadata.gz: 8e3b75cd0308e4d34d6235c4a70271346753befcadfc9df46ed35f3280dcc02ef2e0c887b7299165c3b09966fb59e1248ff51d6b4eafaeef0078505cb405bf79
7
- data.tar.gz: 35f439038d2d43ac6ef680bffb6650b472a867fa6bd9cdfab72b10632109980d6f02ff7b25dbc9c9ce11293e50a18158abf5b769f65fc415a55b60f5b0ba823a
6
+ metadata.gz: c85175161ab81c6256c2e35ffe74c4936814f0b700f15383a1efa55d769893b94c1e5831e662ed3993705253f40465b038a216be315f47f77390696ba6965cc0
7
+ data.tar.gz: ebde4f1cd1a69c3b88ff0a33cd0298de691f1cc0626b4b6e4e7d56ad2d627be6b22579a25e2407be05e5f39ce68a1a4ef7811aa2db5959dfb22cb680d7b384d3
@@ -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
@@ -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@v3
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/express-parser/extconf.rb', 'ext/express-parser/antlrgen/**', 'ext/express-parser/express_parser.cpp', '.git/modules/ext/express-parser/antlr4-upstream/HEAD') }}
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@v3
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@v3
158
+ uses: actions/upload-artifact@v4
158
159
  with:
159
160
  name: pkg-${{ matrix.platform }}
160
161
  path: pkg/*.gem
@@ -173,7 +174,7 @@ jobs:
173
174
  uses: ruby/setup-ruby@master
174
175
  with:
175
176
  ruby-version: ${{ matrix.ruby }}
176
- bundler-cache: true
177
+ bundler-cache: false
177
178
  bundler: ${{ env.BUNDLER_VER }}
178
179
 
179
180
  - name: Checkout
@@ -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@v3
189
+ uses: actions/download-artifact@v4
189
190
  with:
190
191
  name: pkg-ruby
191
192
  path: pkg
@@ -212,7 +213,7 @@ jobs:
212
213
  uses: ruby/setup-ruby@master
213
214
  with:
214
215
  ruby-version: ${{ matrix.ruby }}
215
- bundler-cache: true
216
+ bundler-cache: false
216
217
  bundler: ${{ env.BUNDLER_VER }}
217
218
 
218
219
  - name: Checkout
@@ -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@v3
226
+ uses: actions/download-artifact@v4
226
227
  with:
227
228
  name: pkg-darwin
228
229
  path: pkg
@@ -250,7 +251,7 @@ jobs:
250
251
  uses: ruby/setup-ruby@master
251
252
  with:
252
253
  ruby-version: ${{ matrix.ruby }}
253
- bundler-cache: true
254
+ bundler-cache: false
254
255
  bundler: ${{ env.BUNDLER_VER }}
255
256
 
256
257
  - name: Checkout
@@ -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@v3
264
+ uses: actions/download-artifact@v4
264
265
  with:
265
266
  name: pkg-linux-gnu
266
267
  path: pkg
@@ -288,7 +289,7 @@ jobs:
288
289
  uses: ruby/setup-ruby@master
289
290
  with:
290
291
  ruby-version: ${{ matrix.ruby }}
291
- bundler-cache: true
292
+ bundler-cache: false
292
293
  bundler: ${{ env.BUNDLER_VER }}
293
294
 
294
295
  - name: Checkout
@@ -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@v3
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
@@ -46,7 +49,7 @@ jobs:
46
49
  - uses: actions/checkout@v4
47
50
  with:
48
51
  submodules: recursive
49
- #ref: main # https://github.com/actions/checkout/issues/439#issuecomment-830862188
52
+ ref: main # https://github.com/actions/checkout/issues/439#issuecomment-830862188
50
53
 
51
54
  - uses: ruby/setup-ruby@master
52
55
  with:
@@ -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@v3
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@v3
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@v3
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@v3
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@v3
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@v3
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@v3
114
+ - uses: actions/download-artifact@v4
112
115
  with:
113
116
  name: pkg-darwin
114
117
  path: pkg
@@ -130,6 +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
136
+ sleep 5
133
137
 
134
138
  verify:
135
139
  name: Verify published gem on ${{ matrix.os }}
@@ -148,7 +152,7 @@ jobs:
148
152
  bundler: ${{ env.BUNDLER_VER }}
149
153
 
150
154
  - name: Download version
151
- uses: actions/download-artifact@v3
155
+ uses: actions/download-artifact@v4
152
156
  with:
153
157
  name: version
154
158
 
@@ -169,7 +173,7 @@ jobs:
169
173
  run: apk --no-cache add bash build-base git ruby-dev gcc g++ automake
170
174
 
171
175
  - name: Download version
172
- uses: actions/download-artifact@v3
176
+ uses: actions/download-artifact@v4
173
177
  with:
174
178
  name: version
175
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
@@ -14,7 +14,7 @@
14
14
  /lib/expressir/express/*/express_parser.bundle
15
15
  /lib/expressir/express/*/express_parser.so
16
16
  /spec/syntax/*-pretty.exp
17
- /ext/express-parser/rice-embed
17
+ /ext/express_parser/rice-embed
18
18
 
19
19
  # rspec failure tracking
20
20
  .rspec_status
data/.gitmodules CHANGED
@@ -1,5 +1,5 @@
1
- [submodule "ext/express-parser/antlr4-upstream"]
2
- path = ext/express-parser/antlr4-upstream
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", "express-parser", "express_parser.cpp")
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/express-parser/antlr4-upstream/runtime/Cpp/runtime/**/*")
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 express-parser extconf.rb))
31
+ spec.extensions = File.join(*%w(ext express_parser extconf.rb))
32
32
 
33
- spec.add_runtime_dependency "rice", "~> 4.1"
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.1.0"
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"
@@ -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 [Array<::ExpressParser::Token>] tokens
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
- @tokens[start_index..stop_index]
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
- @remark_tokens = get_tokens(ctx)
154
- @remark_tokens = @remark_tokens.select{ |x| x.channel == REMARK_CHANNEL
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
- @remark_tokens = @remark_tokens.select{|x| !@attached_remark_tokens.include?(x)}
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 = @remark_tokens.map do |remark_token|
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.downcase]
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.downcase, x]}.to_h
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.downcase]
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.downcase.split(/\./).map do |current_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.downcase, x]}.to_h
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]
@@ -1,3 +1,3 @@
1
1
  module Expressir
2
- VERSION = "1.3.0.pre.5".freeze
2
+ VERSION = "1.3.1".freeze
3
3
  end
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
 
@@ -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
- Array getTokens() {
76
- Array a;
75
+ Object getTokens() {
76
+ std::vector<TokenProxy> tk;
77
77
  for (auto token : tokens -> getTokens()) {
78
- a.push(new TokenProxy(token));
78
+ tk.push_back(TokenProxy(token));
79
79
  }
80
- return a;
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::bad_cast) {
92
- return Qnil;
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, Return().keepAlive());" }
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, Return().keepAlive())
120
- .define_method("tokens", &ParserProxyExt::getTokens)
121
- .define_method("visit", &ParserProxyExt::visit, Return().keepAlive());
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", "express-parser", "express_parser.cpp")
129
- parser_source_lines = File.read(parser_source_file).split("\n")
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)
@@ -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/express-parser"
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 "parses a file" do |example|
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 file from a different Expressir version" do |example|
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.0.pre.5
4
+ version: 1.3.1
5
5
  platform: x64-mingw-ucrt
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-16 00:00:00.000000000 Z
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.1.0
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.1.0
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"
@@ -377,9 +379,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
377
379
  version: 3.3.dev
378
380
  required_rubygems_version: !ruby/object:Gem::Requirement
379
381
  requirements:
380
- - - ">"
382
+ - - ">="
381
383
  - !ruby/object:Gem::Version
382
- version: 1.3.1
384
+ version: '0'
383
385
  requirements: []
384
386
  rubygems_version: 3.3.26
385
387
  signing_key: