[ruby/prism] Fix a token incompatibility for Prism::Translation::Parser::Lexer
Prism::Translation::Parser::Lexer
This PR fixes a token incompatibility between Parser gem and Prism::Translation::Parser for beginless range:
Prism::Translation::Parser
Returns tBDOT2 token:
tBDOT2
$ bundle exec ruby -Ilib -rparser/ruby33 -ve \ 'buf = Parser::Source::Buffer.new("example.rb"); buf.source = "..42"; p Parser::Ruby33.new.tokenize(buf)[2]' ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75) [x86_64-darwin22] [[:tBDOT2, ["..", #<Parser::Source::Range example.rb 0...2>]], [:tINTEGER, [42, #<Parser::Source::Range example.rb 2...4>]]]
Previously, the parser returned tDOT2 token when parsing the following:
tDOT2
$ bundle exec ruby -Ilib -rprism -rprism/translation/parser33 -ve \ 'buf = Parser::Source::Buffer.new("example.rb"); buf.source = "..42"; p Prism::Translation::Parser33.new.tokenize(buf)[2]' ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75) [x86_64-darwin22] [[:tDOT2, ["..", #<Parser::Source::Range example.rb 0...2>]], [:tINTEGER, [42, #<Parser::Source::Range example.rb 2...4>]]]
After the update, the parser now returns tBDOT2 token for the same input:
$ bundle exec ruby -Ilib -rprism -rprism/translation/parser33 -ve \ 'buf = Parser::Source::Buffer.new("example.rb"); buf.source = "..42"; p Prism::Translation::Parser33.new.tokenize(buf)[2]' ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75) [x86_64-darwin22] [[:tBDOT2, ["..", #<Parser::Source::Range example.rb 0...2>]], [:tINTEGER, [42, #<Parser::Source::Range example.rb 2...4>]]]
This correction enables the restoration of endless_range_in_conditional.txt as a test case.
endless_range_in_conditional.txt
https://github.com/ruby/prism/commit/f624b99ab0
[ruby/prism] Fix a token incompatibility for
Prism::Translation::Parser::LexerThis PR fixes a token incompatibility between Parser gem and
Prism::Translation::Parserforbeginless range:
Parser gem (Expected)¶
Returns
tBDOT2token:Prism::Translation::Parser(Actual)¶Previously, the parser returned
tDOT2token when parsing the following:After the update, the parser now returns
tBDOT2token for the same input:This correction enables the restoration of
endless_range_in_conditional.txtas a test case.https://github.com/ruby/prism/commit/f624b99ab0