lib/nilac/compile_blocks.rb in nilac-0.0.4.3.9.6 vs lib/nilac/compile_blocks.rb in nilac-0.0.4.3.9.7

- old
+ new

@@ -20,10 +20,12 @@ end input_file_contents = input_file_contents.collect {|element| element.gsub("append","appand")} + input_file_contents = input_file_contents.collect {|element| element.gsub(" do"," do ").gsub("do "," do ")} + possible_blocks = input_file_contents.reject {|line| !line.include?(" do ")} unless possible_blocks.empty? possible_blocks.each do |starting_line| @@ -96,11 +98,11 @@ end else - compiled_block = block_extract[1...-1].lstrip.rstrip + compiled_block = "function() {\n\n" + block_extract[1...-1].lstrip.rstrip + "\n\n}" extracted_string.each_with_index do |string,index| compiled_block = compiled_block.sub("--repstring#{index+1}",string) @@ -116,16 +118,32 @@ else caller_func_split = caller_func.split("(") if caller_func.include?("(") - caller_func_split = caller_func.split(" ",2) if caller_func.include?(" ") + if caller_func.include?("=") + first_split = caller_func.split("=") + + caller_func_split = first_split[1].split(" ",2) + + caller_func_split[0] = first_split[0].strip + " = " + caller_func_split[0] + + else + + caller_func_split = caller_func.split(" ",2) if caller_func.include?(" ") + + end + replacement_string = "#{caller_func_split[0]}(#{caller_func_split[1].strip + compiled_block.lstrip})" end replacement_array = strToArray(replacement_string) + + replacement_array[-1] = replacement_array[-1] + "\n\n" + + replacement_array << "\n\n" variables = lexical_scoped_variables(replacement_array) if !variables.empty? \ No newline at end of file