2014-06-04 20:51:25 +03:00
|
|
|
require 'parslet'
|
2014-07-29 18:36:18 +03:00
|
|
|
require 'parser/salama'
|
2015-09-19 14:53:59 +03:00
|
|
|
require "ast"
|
2014-06-04 20:51:25 +03:00
|
|
|
require 'parser/transform'
|
2015-09-19 14:53:59 +03:00
|
|
|
|
|
|
|
AST::Node.class_eval do
|
|
|
|
|
|
|
|
def [](name)
|
|
|
|
puts self.inspect
|
|
|
|
children.each do |child|
|
|
|
|
if child.is_a?(AST::Node)
|
2015-09-19 16:25:42 +03:00
|
|
|
#puts child.type
|
2015-09-19 14:53:59 +03:00
|
|
|
if (child.type == name)
|
|
|
|
return child.children
|
|
|
|
end
|
|
|
|
else
|
2015-09-19 16:25:42 +03:00
|
|
|
#puts child.class
|
2015-09-19 14:53:59 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|