Skip to content

Instantly share code, notes, and snippets.

@headius
Last active March 1, 2023 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save headius/097e0fafbfa6e890f37ea67019cc0279 to your computer and use it in GitHub Desktop.
Save headius/097e0fafbfa6e890f37ea67019cc0279 to your computer and use it in GitHub Desktop.

Code:

def foo
  <<~Q
  Qend

JRuby:

nil
#<Ripper::Lexer::Elem: on_kw@1:0:FNAME: "def">
#<Ripper::Lexer::Elem: on_sp@1:3:FNAME: " ">
#<Ripper::Lexer::Elem: on_ident@1:4:ENDFN: "foo">
#<Ripper::Lexer::Elem: on_nl@1:7:BEG: "\n">
#<Ripper::Lexer::Elem: on_sp@2:0:BEG: "  ">
#<Ripper::Lexer::Elem: on_parse_error@2:2:END: "<<~Q": syntax error, unexpected end-of-file>
#<Ripper::Lexer::Elem: on_parse_error@2:2:END: "<<~Q": syntax error, unexpected end-of-file>
#<Ripper::Lexer::Elem: on_heredoc_beg@2:2:BEG: "<<~Q">
#<Ripper::Lexer::Elem: on_tstring_content@3:0:BEG: "  Qend\n">

MRI:

#<Ripper::Lexer::Elem: on_kw@1:0:FNAME: "def">
#<Ripper::Lexer::Elem: on_sp@1:3:FNAME: " ">
#<Ripper::Lexer::Elem: on_ident@1:4:ENDFN: "foo">
#<Ripper::Lexer::Elem: on_nl@1:7:BEG: "\n">
#<Ripper::Lexer::Elem: on_sp@2:0:BEG: "  ">
#<Ripper::Lexer::Elem: on_heredoc_beg@2:2:BEG: "<<~Q">
#<Ripper::Lexer::Elem: compile_error@2:5:BEG: "Q": can't find string "Q" anywhere before EOF>
#<Ripper::Lexer::Elem: on_parse_error@2:6:BEG: "\n": syntax error, unexpected end-of-input, expecting `end'>
#<Ripper::Lexer::Elem: on_nl@2:6:BEG: "\n">
#<Ripper::Lexer::Elem: on_tstring_content@3:0:BEG: "  Qend\n">
@headius
Copy link
Author

headius commented Mar 1, 2023

Linked from jruby/jruby#7640

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment