move ast code/patch here
This commit is contained in:
parent
9fe01c7b31
commit
4d9d67af5c
23
lib/bosl/ast_helper.rb
Normal file
23
lib/bosl/ast_helper.rb
Normal 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
|
@ -33,11 +33,12 @@ module Bosl
|
||||
end
|
||||
end
|
||||
|
||||
require_relative "compiler/basic_expressions"
|
||||
require_relative "ast_helper"
|
||||
require_relative "compiler/callsite_expression"
|
||||
require_relative "compiler/compound_expressions"
|
||||
require_relative "compiler/expression_list"
|
||||
require_relative "compiler/field_def"
|
||||
require_relative "compiler/field_access"
|
||||
require_relative "compiler/function_expression"
|
||||
require_relative "compiler/if_expression"
|
||||
require_relative "compiler/module_expression"
|
||||
|
Loading…
Reference in New Issue
Block a user