Created
January 22, 2019 14:55
-
-
Save hanneskaeufler/1b51be2b6482db328d8613c1f3a07963 to your computer and use it in GitHub Desktop.
Find occurrences of bools
This file contains hidden or 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
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