diff options
| author | HParker <HParker@github.com> | 2023-08-22 10:53:39 -0700 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2023-08-23 17:23:15 +0000 |
| commit | 9aca3528aa1a1545468a508b02b77bc922bb7321 (patch) | |
| tree | 34633cf611f52eec0f30bd05a79cf0c8b0b228dd /lib | |
| parent | 774845284fafd231be2208576da6669383f25998 (diff) | |
[ruby/yarp] Match EOF after newline behavior
in Ripper EOL after whitespace is returned as a on_nl node with the whitespace as the content
https://github.com/ruby/yarp/commit/be16d1deed
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/yarp/lex_compat.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/yarp/lex_compat.rb b/lib/yarp/lex_compat.rb index 7e1d9f3657..6442650931 100644 --- a/lib/yarp/lex_compat.rb +++ b/lib/yarp/lex_compat.rb @@ -630,6 +630,14 @@ module YARP end Token.new([[lineno, column], event, value, lex_state]) + + when :on_eof + prev_token = result_value[index-1][0] + if prev_token.type == :COMMENT && prev_token.location.end_offset < token.location.start_offset + tokens << Token.new([[lineno, 0], :on_nl, source.byteslice(result_value[index-1].first.location.end_offset...token.location.start_offset), lex_state]) + end + + Token.new([[lineno, column], event, value, lex_state]) else Token.new([[lineno, column], event, value, lex_state]) end |
