Skip to content

Instantly share code, notes, and snippets.

@vzvu3k6k
Last active August 29, 2015 14:15
Show Gist options
  • Save vzvu3k6k/4ca68e147f38017cbcb3 to your computer and use it in GitHub Desktop.
Save vzvu3k6k/4ca68e147f38017cbcb3 to your computer and use it in GitHub Desktop.
Ripper.lex outputs for "Incompatibility with Ruby 2.2.0 · Issue #72 · zenspider/enhanced-ruby-mode"
[[[1, 0], :on_tstring_beg, "'"],
[[1, 1], :on_tstring_content, "a"],
[[1, 2], :on_tstring_end, "'"],
[[1, 3], :on_period, "."],
[[1, 4], :on_ident, "gsub"],
[[1, 8], :on_lparen, "("],
[[1, 9], :on_tstring_beg, "'"],
[[1, 10], :on_tstring_content, "a"],
[[1, 11], :on_tstring_end, "'"],
[[1, 12], :on_comma, ","],
[[1, 13], :on_sp, " "],
[[1, 14], :on_tstring_beg, "'"],
[[1, 15], :on_tstring_content, "b"],
[[1, 16], :on_tstring_end, "'"],
[[1, 17], :on_rparen, ")"],
[[1, 18], :on_period, "\n"],
[[2, 0], :on_ident, " .gsub"],
[[2, 7], :on_lparen, "("],
[[2, 8], :on_tstring_beg, "'"],
[[2, 9], :on_tstring_content, "b"],
[[2, 10], :on_tstring_end, "'"],
[[2, 11], :on_comma, ","],
[[2, 12], :on_sp, " "],
[[2, 13], :on_tstring_beg, "'"],
[[2, 14], :on_tstring_content, "c"],
[[2, 15], :on_tstring_end, "'"],
[[2, 16], :on_rparen, ")"],
[[2, 17], :on_sp, " "],
[[2, 18], :on_comment, "# inline comment\n"],
[[3, 0], :on_period, " ."],
[[3, 3], :on_ident, "gsub"],
[[3, 7], :on_lparen, "("],
[[3, 8], :on_tstring_beg, "'"],
[[3, 9], :on_tstring_content, "c"],
[[3, 10], :on_tstring_end, "'"],
[[3, 11], :on_comma, ","],
[[3, 12], :on_sp, " "],
[[3, 13], :on_tstring_beg, "'"],
[[3, 14], :on_tstring_content, "a"],
[[3, 15], :on_tstring_end, "'"],
[[3, 16], :on_rparen, ")"],
[[3, 17], :on_nl, "\n"]]
[[[1, 0], :on_tstring_beg, "'"],
[[1, 1], :on_tstring_content, "a"],
[[1, 2], :on_tstring_end, "'"],
[[1, 3], :on_period, "."],
[[1, 4], :on_ident, "gsub"],
[[1, 8], :on_lparen, "("],
[[1, 9], :on_tstring_beg, "'"],
[[1, 10], :on_tstring_content, "a"],
[[1, 11], :on_tstring_end, "'"],
[[1, 12], :on_comma, ","],
[[1, 13], :on_sp, " "],
[[1, 14], :on_tstring_beg, "'"],
[[1, 15], :on_tstring_content, "b"],
[[1, 16], :on_tstring_end, "'"],
[[1, 17], :on_rparen, ")"],
[[1, 18], :on_ignored_nl, "\n"],
[[2, 0], :on_sp, " "],
[[2, 2], :on_period, "."],
[[2, 3], :on_ident, "gsub"],
[[2, 7], :on_lparen, "("],
[[2, 8], :on_tstring_beg, "'"],
[[2, 9], :on_tstring_content, "b"],
[[2, 10], :on_tstring_end, "'"],
[[2, 11], :on_comma, ","],
[[2, 12], :on_sp, " "],
[[2, 13], :on_tstring_beg, "'"],
[[2, 14], :on_tstring_content, "c"],
[[2, 15], :on_tstring_end, "'"],
[[2, 16], :on_rparen, ")"],
[[2, 17], :on_sp, " "],
[[2, 18], :on_comment, "# inline comment\n"],
[[1, 18], :on_ignored_nl, nil],
[[3, 0], :on_sp, " "],
[[3, 2], :on_period, "."],
[[3, 3], :on_ident, "gsub"],
[[3, 7], :on_lparen, "("],
[[3, 8], :on_tstring_beg, "'"],
[[3, 9], :on_tstring_content, "c"],
[[3, 10], :on_tstring_end, "'"],
[[3, 11], :on_comma, ","],
[[3, 12], :on_sp, " "],
[[3, 13], :on_tstring_beg, "'"],
[[3, 14], :on_tstring_content, "a"],
[[3, 15], :on_tstring_end, "'"],
[[3, 16], :on_rparen, ")"],
[[3, 17], :on_nl, "\n"]]
require "ripper"
require "pp"
s = <<HERE
'a'.gsub('a', 'b')
.gsub('b', 'c') # inline comment
.gsub('c', 'a')
HERE
pp Ripper::Lexer.parse(s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment