move ast code/patch here

This commit is contained in:
Torsten Ruger 2015-09-27 11:26:53 +03:00
parent 9fe01c7b31
commit 4d9d67af5c
2 changed files with 25 additions and 1 deletions

23
lib/bosl/ast_helper.rb Normal file
View File

@ -0,0 +1,23 @@
AST::Node.class_eval do
def [](name)
#puts self.inspect
children.each do |child|
if child.is_a?(AST::Node)
#puts child.type
if (child.type == name)
return child.children
end
else
#puts child.class
end
end
nil
end
def first_from( node_name )
from = self[node_name]
return nil unless from
from.first
end
end

View File

@ -33,11 +33,12 @@ module Bosl
end end
end end
require_relative "compiler/basic_expressions" require_relative "ast_helper"
require_relative "compiler/callsite_expression" require_relative "compiler/callsite_expression"
require_relative "compiler/compound_expressions" require_relative "compiler/compound_expressions"
require_relative "compiler/expression_list" require_relative "compiler/expression_list"
require_relative "compiler/field_def" require_relative "compiler/field_def"
require_relative "compiler/field_access"
require_relative "compiler/function_expression" require_relative "compiler/function_expression"
require_relative "compiler/if_expression" require_relative "compiler/if_expression"
require_relative "compiler/module_expression" require_relative "compiler/module_expression"