diff options
| author | Kevin Newton <kddnewton@gmail.com> | 2024-06-10 13:39:16 -0400 |
|---|---|---|
| committer | Kevin Newton <kddnewton@gmail.com> | 2024-06-10 17:21:32 -0400 |
| commit | d827d3252786a5e1153f4e8bfa30f40a2aaafb95 (patch) | |
| tree | 034cc715c28be62729512c6b8bb5465ad39b9263 /lib | |
| parent | 0d5eea9957eab7515e377e2562cc5f9850ad952f (diff) | |
[ruby/prism] Provide ability to lock encoding while parsing
https://github.com/ruby/prism/commit/f7faedfb3f
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/prism/ffi.rb | 3 | ||||
| -rw-r--r-- | lib/prism/translation/parser.rb | 6 |
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/prism/ffi.rb b/lib/prism/ffi.rb index 6b48af43cc..46c4a1a755 100644 --- a/lib/prism/ffi.rb +++ b/lib/prism/ffi.rb @@ -431,6 +431,9 @@ module Prism template << "C" values << { nil => 0, "3.3.0" => 1, "3.3.1" => 1, "3.4.0" => 0, "latest" => 0 }.fetch(options[:version]) + template << "C" + values << (options[:encoding] == false ? 1 : 0) + template << "L" if (scopes = options[:scopes]) values << scopes.length diff --git a/lib/prism/translation/parser.rb b/lib/prism/translation/parser.rb index 3748fc896e..8c7eb3aa75 100644 --- a/lib/prism/translation/parser.rb +++ b/lib/prism/translation/parser.rb @@ -51,7 +51,7 @@ module Prism source = source_buffer.source offset_cache = build_offset_cache(source) - result = unwrap(Prism.parse(source, filepath: source_buffer.name, version: convert_for_prism(version), scopes: [[]]), offset_cache) + result = unwrap(Prism.parse(source, filepath: source_buffer.name, version: convert_for_prism(version), scopes: [[]], encoding: false), offset_cache) build_ast(result.value, offset_cache) ensure @@ -64,7 +64,7 @@ module Prism source = source_buffer.source offset_cache = build_offset_cache(source) - result = unwrap(Prism.parse(source, filepath: source_buffer.name, version: convert_for_prism(version), scopes: [[]]), offset_cache) + result = unwrap(Prism.parse(source, filepath: source_buffer.name, version: convert_for_prism(version), scopes: [[]], encoding: false), offset_cache) [ build_ast(result.value, offset_cache), @@ -83,7 +83,7 @@ module Prism offset_cache = build_offset_cache(source) result = begin - unwrap(Prism.parse_lex(source, filepath: source_buffer.name, version: convert_for_prism(version), scopes: [[]]), offset_cache) + unwrap(Prism.parse_lex(source, filepath: source_buffer.name, version: convert_for_prism(version), scopes: [[]], encoding: false), offset_cache) rescue ::Parser::SyntaxError raise if !recover end |
