Created
May 31, 2013 12:39
-
-
Save anonymous/5684725 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'parser/runner' | |
module Parser | |
class Runner::RubyParse < Parser::Runner | |
class PrawnProcessor < Parser::AST::Processor | |
def on_send(node) | |
p node.to_s | |
node.children.each do |child_node| | |
p child_node.class | |
p child_node.type | |
end | |
end | |
def on_if(node) | |
p "Nice, an if node\n" | |
end | |
end | |
private | |
def runner_name | |
'ruby-parse' | |
end | |
def process(buffer) | |
ast = @parser.parse(buffer) | |
PrawnProcessor.new.process(ast) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment