class Opal::AST::Matcher
Constants
- Node
Attributes
captures[RW]
Public Class Methods
new(&block)
click to toggle source
# File lib/opal/ast/matcher.rb, line 9 def initialize(&block) @root = instance_exec(&block) end
Public Instance Methods
cap(capture)
click to toggle source
# File lib/opal/ast/matcher.rb, line 17 def cap(capture) Node.new(:capture, [capture]) end
inspect()
click to toggle source
# File lib/opal/ast/matcher.rb, line 27 def inspect "#<Opal::AST::Matcher: #{@root.inspect}>" end
match(ast)
click to toggle source
# File lib/opal/ast/matcher.rb, line 21 def match(ast) @captures = [] @root.match(ast, self) || (return false) @captures end
s(type, *children)
click to toggle source
# File lib/opal/ast/matcher.rb, line 13 def s(type, *children) Node.new(type, children) end