Skip to content

Instantly share code, notes, and snippets.

@hanneskaeufler
Created January 22, 2019 14:55
Show Gist options
  • Save hanneskaeufler/1b51be2b6482db328d8613c1f3a07963 to your computer and use it in GitHub Desktop.
Save hanneskaeufler/1b51be2b6482db328d8613c1f3a07963 to your computer and use it in GitHub Desktop.
Find occurrences of bools
class BooleanVisitor < Crystal::Visitor
def visit(node : Crystal::BoolLiteral)
puts "Line: #{node.location.try &.line_number}"
puts "Column: #{node.location.try &.column_number}"
true
end
def visit(node : Crystal::ASTNode)
true
end
end
ast.accept(BooleanVisitor.new)
# => will print:
# Line: 2
# Column: 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment