summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2023-08-25 08:49:28 -0400
committergit <svn-admin@ruby-lang.org>2023-08-25 12:49:37 +0000
commitec7a2fdc03cba32894e1d25606195600e152c151 (patch)
tree2d0e8de3f081b978416209017163fa107cd67a22 /lib
parentb8cab92a3f1077abae7f5210b393fc4a1a909c28 (diff)
[ruby/yarp] Fix up lex compat on Ruby HEAD
https://github.com/ruby/yarp/commit/7710cee248
Diffstat (limited to 'lib')
-rw-r--r--lib/yarp/lex_compat.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/yarp/lex_compat.rb b/lib/yarp/lex_compat.rb
index 8b63253356..66aa116493 100644
--- a/lib/yarp/lex_compat.rb
+++ b/lib/yarp/lex_compat.rb
@@ -574,6 +574,11 @@ module YARP
result = YARP.lex(source, @filepath)
result_value = result.value
previous_state = nil
+
+ # In previous versions of Ruby, Ripper wouldn't flush the bom before the
+ # first token, so we had to have a hack in place to account for that. This
+ # checks for that behavior.
+ bom_flushed = Ripper.lex("\xEF\xBB\xBF# test")[0][0][1] == 0
bom = source.byteslice(0..2) == "\xEF\xBB\xBF"
result_value.each_with_index do |(token, lex_state), index|
@@ -588,8 +593,12 @@ module YARP
if bom && lineno == 1
column -= 3
+<<<<<<< HEAD
=begin
if index == 0 && column == 0
+=======
+ if index == 0 && column == 0 && !bom_flushed
+>>>>>>> 7710cee2480 (Fix up lex compat on Ruby HEAD)
flushed =
case token.type
when :BACK_REFERENCE, :INSTANCE_VARIABLE, :CLASS_VARIABLE,