soml-parser/lib/salama-reader.rb

23 lines
381 B
Ruby
Raw Normal View History

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