Skip to content

Instantly share code, notes, and snippets.

@pocke
Created May 31, 2018 23:06
Show Gist options
  • Save pocke/5a3c604d8a4216a6a10d064b51028473 to your computer and use it in GitHub Desktop.
Save pocke/5a3c604d8a4216a6a10d064b51028473 to your computer and use it in GitHub Desktop.
require 'ripper'
class RipperEventViewer < Ripper::SexpBuilderPP
(Ripper::PARSER_EVENTS + Ripper::SCANNER_EVENTS).each do |ev|
eval <<~RUBY
def on_#{ev}(*args)
super.tap do
puts "#{'*'*50} on_#{ev}"
pp(*args)
end
end
RUBY
end
end
RipperEventViewer.parse ARGF.read
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment