diff --git a/lib/bosl/ast_helper.rb b/lib/bosl/ast_helper.rb new file mode 100644 index 00000000..a1706805 --- /dev/null +++ b/lib/bosl/ast_helper.rb @@ -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 diff --git a/lib/bosl/compiler.rb b/lib/bosl/compiler.rb index 589dabdd..c2142797 100644 --- a/lib/bosl/compiler.rb +++ b/lib/bosl/compiler.rb @@ -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"