bin/nilac in nilac-0.0.4.3.4 vs bin/nilac in nilac-0.0.4.3.6
- old
+ new
@@ -331,12 +331,10 @@
until closed_curly_brace_index.empty?
test_string = string_extract[0..closed_curly_brace_index[0]]
- puts test_string
-
original_string = test_string.dup
if test_string.include?("{")
test_string = test_string.reverse.sub("{", "$#{index_counter}$").reverse
@@ -417,20 +415,52 @@
end
def replace_singleline_comments(input_file_contents)
+ def replace_strings(input_string)
+
+ string_counter = 0
+
+ while input_string.include?("\"")
+
+ string_extract = input_string[input_string.index("\"")..input_string.index("\"",input_string.index("\"")+1)]
+
+ input_string = input_string.sub(string_extract,"--repstring#{string_counter}")
+
+ string_counter += 1
+
+ end
+
+ while input_string.include?("'")
+
+ string_extract = input_string[input_string.index("'")..input_string.index("'",input_string.index("'")+1)]
+
+ input_string = input_string.sub(string_extract,"--repstring#{string_counter}")
+
+ string_counter += 1
+
+ end
+
+ return input_string
+
+ end
+
single_line_comments = []
singleline_comment_counter = 1
+ modified_file_contents = input_file_contents.clone
+
for x in 0...input_file_contents.length
- current_row = input_file_contents[x]
+ current_row = replace_strings(input_file_contents[x])
if current_row.include?("#")
+ current_row = modified_file_contents[x]
+
comment_start = current_row.index("#")
if current_row[comment_start+1] != "{"
comment = current_row[comment_start..-1]
@@ -441,17 +471,21 @@
singleline_comment_counter += 1
end
+ else
+
+ current_row = modified_file_contents[x]
+
end
- input_file_contents[x] = current_row
+ modified_file_contents[x] = current_row
end
- return input_file_contents, single_line_comments
+ return modified_file_contents, single_line_comments
end
def replace_named_functions(nila_file_contents, temporary_nila_file)
@@ -479,11 +513,11 @@
if current_row.index(nila_regexp) != nil
key_word_locations << x
- elsif current_row.lstrip.include?("end\n") || current_row.include?("end")
+ elsif current_row.lstrip.eql?("end\n") || current_row.strip.eql?("end")
end_locations << x
end
@@ -527,14 +561,14 @@
code_block_begin_string = code_block_begin_string_split.join(" ")
modified_file_contents[code_block_begin] = code_block_begin_string
- rescue NoMethodError
+ #rescue NoMethodError
+ #
+ # puts "Function compilation failed!"
- puts "Function compilation failed!"
-
end
end
final_modified_file_contents = nila_file_contents.dup
@@ -608,16 +642,46 @@
def compile_parallel_assignment(input_file_contents, temporary_nila_file)
def arrayify_right_side(input_string)
+ def replace_strings(input_string)
+
+ string_counter = 0
+
+ while input_string.include?("\"")
+
+ string_extract = input_string[input_string.index("\"")..input_string.index("\"",input_string.index("\"")+1)]
+
+ input_string = input_string.sub(string_extract,"--repstring#{string_counter}")
+
+ string_counter += 1
+
+ end
+
+ while input_string.include?("'")
+
+ string_extract = input_string[input_string.index("'")..input_string.index("'",input_string.index("'")+1)]
+
+ input_string = input_string.sub(string_extract,"--repstring#{string_counter}")
+
+ string_counter += 1
+
+ end
+
+ return input_string
+
+ end
+
+ modified_input_string = input_string.dup
+
+ input_string = replace_strings(input_string)
+
javascript_regexp = /(if |while |for |function |function\()/
if input_string.include?("=") and input_string.index(javascript_regexp) == nil and input_string.strip[0..3] != "_ref" and !input_string.split("=")[1].include?("[")
- modified_input_string = input_string.dup
-
right_side = input_string.split("=")[1]
if right_side.include?(",")
splits = right_side.split(",")
@@ -638,23 +702,23 @@
end
replacement_string = " [#{replacement_string.join(",").strip}]\n"
- input_string = input_string.sub(right_side,replacement_string)
+ modified_input_string = modified_input_string.sub(right_side,replacement_string)
end
end
- return input_string
+ return modified_input_string
end
input_file_contents = input_file_contents.collect {|element| arrayify_right_side(element)}
- possible_variable_lines = input_file_contents.reject { |element| !element.include? "=" }
+ possible_variable_lines = input_file_contents.clone.reject { |element| !element.include? "=" }
possible_parallel_assignment = possible_variable_lines.reject { |element| !element.split("=")[0].include? "," }
parallel_assignment_index = []
@@ -738,14 +802,34 @@
return replacement_string, default_value_parameters, replacement_parameters
end
- possible_default_values = input_file_contents.dup.reject { |element| !element.include?("def") }
+ reject_regexp = /(function |Euuf |if |else|elsuf|switch |case|while |whaaleskey |for )/
+ input_file_contents = input_file_contents.collect { |element| element.gsub("==", "equalequal") }
+
+ input_file_contents = input_file_contents.collect { |element| element.gsub("!=", "notequal") }
+
+ input_file_contents = input_file_contents.collect { |element| element.gsub("+=", "plusequal") }
+
+ input_file_contents = input_file_contents.collect { |element| element.gsub("-=", "minusequal") }
+
+ input_file_contents = input_file_contents.collect { |element| element.gsub("*=", "multiequal") }
+
+ input_file_contents = input_file_contents.collect { |element| element.gsub("/=", "divequal") }
+
+ input_file_contents = input_file_contents.collect { |element| element.gsub("%=", "modequal") }
+
+ input_file_contents = input_file_contents.collect { |element| element.gsub("=~", "matchequal") }
+
+ possible_default_values = input_file_contents.dup.reject { |element| (!element.include?("def")) }
+
possible_default_values = possible_default_values.reject { |element| !element.include?("=") }
+ possible_default_values = possible_default_values.reject {|element| !element.index(reject_regexp) == nil}
+
if !possible_default_values.empty?
possible_default_values.each do |line|
current_line_index = input_file_contents.each_index.select { |index| input_file_contents[index] == line }.flatten[0]
@@ -774,16 +858,60 @@
file_id.close()
line_by_line_contents = read_file_line_by_line(temporary_nila_file)
+ line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("plusequal", "+=") }
+
+ line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("minusequal", "-=") }
+
+ line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("multiequal", "*=") }
+
+ line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("divequal", "/=") }
+
+ line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("modequal", "%=") }
+
+ line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("equalequal", "==") }
+
+ line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("notequal", "!=") }
+
+ line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("matchequal", "=~") }
+
return line_by_line_contents
end
def get_variables(input_file_contents, temporary_nila_file, *loop_variables)
+ def replace_strings(input_string)
+
+ string_counter = 0
+
+ while input_string.include?("\"")
+
+ string_extract = input_string[input_string.index("\"")..input_string.index("\"",input_string.index("\"")+1)]
+
+ input_string = input_string.sub(string_extract,"--repstring#{string_counter}")
+
+ string_counter += 1
+
+ end
+
+ while input_string.include?("'")
+
+ string_extract = input_string[input_string.index("'")..input_string.index("'",input_string.index("'")+1)]
+
+ input_string = input_string.sub(string_extract,"--repstring#{string_counter}")
+
+ string_counter += 1
+
+ end
+
+ return input_string
+
+ end
+
variables = []
input_file_contents = input_file_contents.collect { |element| element.gsub("==", "equalequal") }
input_file_contents = input_file_contents.collect { |element| element.gsub("!=", "notequal") }
@@ -798,10 +926,14 @@
input_file_contents = input_file_contents.collect { |element| element.gsub("%=", "modequal") }
input_file_contents = input_file_contents.collect { |element| element.gsub("=~", "matchequal") }
+ modified_file_contents = input_file_contents.clone
+
+ input_file_contents = input_file_contents.collect {|element| replace_strings(element)}
+
javascript_regexp = /(if |while |for )/
for x in 0...input_file_contents.length
current_row = input_file_contents[x]
@@ -823,20 +955,21 @@
current_row_split[0] = current_row_split[0][0...current_row_split[0].index("[")]
end
+ current_row_split[0] = current_row_split[0].split(".",2)[0].strip if current_row_split[0].include?(".")
+
variables << current_row_split[0]
-
end
input_file_contents[x] = current_row
end
- file_contents_as_string = input_file_contents.join
+ file_contents_as_string = modified_file_contents.join
file_id = open(temporary_nila_file, 'w')
file_id.write(file_contents_as_string)
@@ -935,11 +1068,11 @@
return line_by_line_contents
end
- def compile_arrays(input_file_contents, temporary_nila_file)
+ def compile_arrays(input_file_contents, named_functions, temporary_nila_file)
def compile_w_arrays(input_file_contents)
def extract(input_string, pattern_start, pattern_end)
@@ -1187,11 +1320,11 @@
possible_operator_usage.each do |usage|
left, right = usage.split("<<")
- input_file_contents[input_file_contents.index(usage)] = left.rstrip + ".push(#{right.lstrip})"
+ input_file_contents[input_file_contents.index(usage)] = left.rstrip + ".push(#{right.strip})\n\n"
end
return input_file_contents
@@ -1203,21 +1336,61 @@
input_file_contents = compile_multiline(input_file_contents, temporary_nila_file)
input_file_contents = compile_array_operators(input_file_contents)
- return input_file_contents
+ named_functions = named_functions.collect {|func| compile_w_arrays(func)}
+ named_functions = named_functions.collect { |func| compile_array_indexing(func)}
+ named_functions = named_functions.collect {|func| compile_multiline(func, temporary_nila_file)}
+
+ named_functions = named_functions.collect {|func| compile_array_operators(func)}
+
+ return input_file_contents, named_functions
+
+
end
def compile_hashes(input_file_contents,temporary_nila_file)
def compile_multiline_hashes(input_file_contents,temporary_nila_file)
+ def replace_strings(input_string)
+
+ string_counter = 0
+
+ while input_string.include?("\"")
+
+ string_extract = input_string[input_string.index("\"")..input_string.index("\"",input_string.index("\"")+1)]
+
+ input_string = input_string.sub(string_extract,"--repstring#{string_counter}")
+
+ string_counter += 1
+
+ end
+
+ while input_string.include?("'")
+
+ string_extract = input_string[input_string.index("'")..input_string.index("'",input_string.index("'")+1)]
+
+ input_string = input_string.sub(string_extract,"--repstring#{string_counter}")
+
+ string_counter += 1
+
+ end
+
+ return input_string
+
+ end
+
javascript_regexp = /(if |while |for |function |function\()/
+ modified_file_contents = input_file_contents.clone
+
+ input_file_contents = input_file_contents.collect {|line| replace_strings(line)}
+
possible_hashes = input_file_contents.reject { |element| !element.include?("{") }
possible_multiline_hashes = possible_hashes.reject { |element| element.include?("}") }
possible_multiline_hashes = possible_multiline_hashes.reject {|element| element.index(javascript_regexp) != nil}
@@ -1226,25 +1399,25 @@
possible_multiline_hashes.each do |starting_line|
index = input_file_contents.index(starting_line)
- line = starting_line
+ line = modified_file_contents[index]
until line.include?("}\n")
index += 1
- line = input_file_contents[index]
+ line = modified_file_contents[index]
end
- multiline_hashes << input_file_contents[input_file_contents.index(starting_line)..index]
+ multiline_hashes << modified_file_contents[input_file_contents.index(starting_line)..index]
end
- joined_file_contents = input_file_contents.join
+ joined_file_contents = modified_file_contents.join
multiline_hashes.each do |hash|
modified_hash = hash.join
@@ -1308,10 +1481,12 @@
possible_inline_hashes = possible_inline_hashes.reject {|element| element.count("}") != 1}
possible_inline_hashes = possible_inline_hashes.reject {|element| element.index(javascript_regexp) != nil}
+ possible_inline_hashes = possible_inline_hashes.reject {|element| element.include?("{}")}
+
possible_inline_hashes.each do |hash|
hash = input_file_contents[modified_file_contents.index(hash)]
hash_extract = hash[hash.index("{")..hash.index("}")]
@@ -1558,12 +1733,42 @@
def lexical_scoped_variables(input_function_block)
#This method will pickup and declare all the variables inside a function block. In future, this method will be
#merged with the get variables method
- controlregexp = /(if |while |def |function |function\()/
+ def replace_strings(input_string)
+ string_counter = 0
+
+ while input_string.include?("\"")
+
+ string_extract = input_string[input_string.index("\"")..input_string.index("\"",input_string.index("\"")+1)]
+
+ input_string = input_string.sub(string_extract,"--repstring#{string_counter}")
+
+ string_counter += 1
+
+ end
+
+ while input_string.include?("'")
+
+ string_extract = input_string[input_string.index("'")..input_string.index("'",input_string.index("'")+1)]
+
+ input_string = input_string.sub(string_extract,"--repstring#{string_counter}")
+
+ string_counter += 1
+
+ end
+
+ return input_string
+
+ end
+
+ input_function_block = input_function_block.collect {|element| replace_strings(element)}
+
+ controlregexp = /(if |Euuf |while |def |function |function\()/
+
variables = []
function_name, parameters = input_function_block[0].split("(")
parameters = parameters.split(")")[0].split(",")
@@ -1642,11 +1847,11 @@
rejected_array = rejected_array[1..-1]
if !rejected_array[0].strip.eql?("}")
- if !rejected_array[0].strip.eql?("end")
+ if !rejected_array[0].strip.eql?("end") and !rejected_array[0].strip.include?("--single_line_comment")
last_statement = rejected_array[0]
replacement_string = "return #{last_statement.lstrip}"
@@ -1968,18 +2173,30 @@
function_map = function_map_replacements.keys
modified_file_contents = input_file_contents.dup
+ javascript_regexp = /(if |for |while |\(function\(|= function\(|((=|:)\s+\{))/
+
input_file_contents.each_with_index do |line, index|
function_map.each do |function|
- if line.include?(function+"(") or line.include?(function+" ")
+ if line.include?(function+"(") or line.include?(function+" ") and line.index(javascript_regexp) == nil
- modified_file_contents[index] = line.sub(function, function_map_replacements[function])
+ testsplit = line.split(function)
+ testsplit = testsplit.collect {|element| element.strip}
+
+ testsplit[0] = " " if testsplit[0].eql?("")
+
+ if testsplit[0][-1].eql?(" ") or testsplit[0].eql?("return")
+
+ modified_file_contents[index] = line.sub(function, function_map_replacements[function])
+
+ end
+
end
end
end
@@ -1995,15 +2212,18 @@
method_map_replacement = {
".split" => ".split(\" \")",
- ".strip" => ".replace(/^\s+|\s+$/g,'')",
+ ".join" => ".join()",
- ".lstrip" => ".replace(/^\s+/g,\"\")",
+ ".strip" => ".replace(/^\\s+|\\s+$/g,'')",
- ".rstrip" => ".replace(/\s+$/g,\"\")"
+ ".lstrip" => ".replace(/^\\s+/g,\"\")",
+
+ ".rstrip" => ".replace(/\\s+$/g,\"\")"
+
}
method_map = method_map_replacement.keys
method_map_regex = method_map.collect {|name| name.gsub(".","\\.")}
@@ -2014,20 +2234,26 @@
input_file_contents.each_with_index do |line, index|
if line.match(method_map_regex)
- unless method_match.include?(line+"(")
+ method_match = line.match(method_map_regex).to_a[0]
- puts line
+ unless line.include?(method_match + "(")
+ line = line.sub(method_match,method_map_replacement[method_match])
+
end
end
+ modified_file_contents[index] = line
+
end
+ return modified_file_contents
+
end
def compile_whitespace_delimited_functions(input_file_contents, function_names, temporary_nila_file)
def extract(input_string, pattern_start, pattern_end)
@@ -2270,11 +2496,11 @@
if_block_counter = 0
extracted_blocks = []
- controlregexp = /(if |while |def )/
+ controlregexp = /(if |while |def | do )/
rejectionregexp = /( if | while )/
for x in 0...if_statement_indexes.length-1
@@ -2288,12 +2514,21 @@
current_block = []
possible_if_blocks.each_with_index do |block|
- current_block += block
+ unless current_block[-1] == block[0]
+ current_block += block
+
+ else
+
+ current_block += block[1..-1]
+
+ end
+
+
current_block.each_with_index do |line, index|
if line.strip.eql? "end"
end_counter += 1
@@ -2456,11 +2691,11 @@
end
if_statement_indexes = [0] + if_statement_indexes.flatten + [-1]
- controlregexp = /(while |def )/
+ controlregexp = /(while |def | do )/
modified_input_contents, extracted_statements = extract_if_blocks(if_statement_indexes, input_file_contents.clone)
joined_blocks = extracted_statements.collect { |element| element.join }
@@ -2568,11 +2803,11 @@
while_block_counter = 0
extracted_blocks = []
- controlregexp = /(if |while |def )/
+ controlregexp = /(if |while |def | do )/
rejectionregexp = /( if | while )/
for x in 0...while_statement_indexes.length-1
@@ -2726,11 +2961,11 @@
end
while_statement_indexes = [0] + while_statement_indexes.flatten + [-1]
- controlregexp = /(if |def )/
+ controlregexp = /(if |def | do )/
modified_input_contents, extracted_statements = extract_while_blocks(while_statement_indexes, input_file_contents.clone)
joined_blocks = extracted_statements.collect { |element| element.join }
@@ -2776,21 +3011,21 @@
modified_while_statements.delete_at(0)
else
- joined_file_contents = joined_file_contents.sub(rejected_elements_index[0], rejected_elements[0].join)
+ joined_file_contents = joined_file_contents.sub(rejected_elements_index[0], rejected_elements[0])
rejected_elements_index.delete_at(0)
rejected_elements.delete_at(0)
end
else
- joined_file_contents = joined_file_contents.sub(rejected_elements_index[0], rejected_elements[0].join)
+ joined_file_contents = joined_file_contents.sub(rejected_elements_index[0], rejected_elements[0])
rejected_elements_index.delete_at(0)
rejected_elements.delete_at(0)
@@ -2838,11 +3073,11 @@
for_block_counter = 0
extracted_blocks = []
- controlregexp = /(if |while |def |for )/
+ controlregexp = /(if |while |def |for | do )/
rejectionregexp = /( if | while )/
for x in 0...for_statement_indexes.length-1
@@ -3042,11 +3277,11 @@
end
for_statement_indexes = [0] + for_statement_indexes.flatten + [-1]
- controlregexp = /(if |def |while )/
+ controlregexp = /(if |def |while | do )/
modified_input_contents, extracted_statements = extract_for_blocks(for_statement_indexes, input_file_contents.clone)
joined_blocks = extracted_statements.collect { |element| element.join }
@@ -3102,11 +3337,11 @@
end
else
- joined_file_contents = joined_file_contents.sub(rejected_elements_index[0], rejected_elements[0].join)
+ joined_file_contents = joined_file_contents.sub(rejected_elements_index[0], rejected_elements[0])
rejected_elements_index.delete_at(0)
rejected_elements.delete_at(0)
@@ -3468,12 +3703,10 @@
end
file_contents = compile_ternary_if(input_file_contents)
- puts file_contents
-
file_contents, rejected_lines = ignore_statement_modifiers(file_contents)
file_contents = replace_unless_until(file_contents)
file_contents = compile_regular_if(file_contents, temporary_nila_file)
@@ -3694,10 +3927,134 @@
return file_contents,loop_variables
end
+ def compile_blocks(input_file_contents,temporary_nila_file)
+
+ def compile_one_line_blocks(input_block)
+
+ block_parameters, block_contents = input_block[1...-1].split("|",2)[1].split("|",2)
+
+ compiled_block = "function(#{block_parameters.lstrip.rstrip}) {\n\n #{block_contents.strip} \n\n}"
+
+ return compiled_block
+
+ end
+
+ input_file_contents = input_file_contents.collect {|element| element.gsub("append","appand")}
+
+ possible_blocks = input_file_contents.reject {|line| !line.include?(" do ")}
+
+ unless possible_blocks.empty?
+
+ possible_blocks.each do |starting_line|
+
+ index_counter = starting_counter = input_file_contents.index(starting_line)
+
+ line = starting_line
+
+ until line.strip.eql?("end")
+
+ index_counter += 1
+
+ line = input_file_contents[index_counter]
+
+ end
+
+ loop_extract = input_file_contents[starting_counter..index_counter]
+
+ loop_condition, block = loop_extract.join.split(" do ")
+
+ block = block.split("end")[0]
+
+ replacement_string = "#{loop_condition.rstrip} blockky {#{block.strip}}_!"
+
+ input_file_contents[starting_counter..index_counter] = replacement_string
+
+ end
+
+ end
+
+ possible_blocks = input_file_contents.reject{ |element| !element.include?(" blockky ")}
+
+ possible_blocks = possible_blocks.reject {|element| !element.include?("{") and !element.include?("}")}
+
+ modified_file_contents = input_file_contents.clone
+
+ unless possible_blocks.empty?
+
+ possible_blocks.each do |loop|
+
+ original_loop = loop.clone
+
+ string_counter = 1
+
+ extracted_string = []
+
+ while loop.include?("\"")
+
+ string_extract = loop[loop.index("\"")..loop.index("\"",loop.index("\"")+1)]
+
+ extracted_string << string_extract
+
+ loop = loop.sub(string_extract,"--repstring#{string_counter}")
+
+ string_counter += 1
+
+ end
+
+ block_extract = loop[loop.index("{")..loop.index("}_!")]
+
+ compiled_block = ""
+
+ if block_extract.count("|") == 2
+
+ compiled_block = compile_one_line_blocks(block_extract)
+
+ extracted_string.each_with_index do |string,index|
+
+ compiled_block = compiled_block.sub("--repstring#{index+1}",string)
+
+ end
+
+ else
+
+ compiled_block = block_extract[1...-1].lstrip.rstrip
+
+ extracted_string.each_with_index do |string,index|
+
+ compiled_block = compiled_block.sub("--repstring#{index+1}",string)
+
+ end
+
+ end
+
+ caller_func = loop.split(" blockky ")[0]
+
+ replacement_string = "#{caller_func.rstrip}(#{compiled_block.lstrip})"
+
+ modified_file_contents[input_file_contents.index(original_loop)] = replacement_string
+
+ end
+
+ end
+
+ modified_file_contents = modified_file_contents.collect {|element| element.gsub("appand","append")}
+
+ file_id = open(temporary_nila_file, 'w')
+
+ file_id.write(modified_file_contents.join)
+
+ file_id.close()
+
+ line_by_line_contents = read_file_line_by_line(temporary_nila_file)
+
+ return line_by_line_contents
+
+ end
+
def add_semicolons(input_file_contents)
def comment(input_string)
if input_string.include?("--single_line_comment")
@@ -3910,11 +4267,11 @@
starting_line_indices << file_contents.index(line)
end
- block_ending_lines = file_contents.dup.each_index.select { |index| (file_contents[index].eql? " }\n" or file_contents[index].eql? " };\n")}
+ block_ending_lines = file_contents.dup.each_index.select { |index| (file_contents[index].eql? " }\n" or file_contents[index].eql? " };\n" or file_contents[index].lstrip.eql?("});\n"))}
modified_file_contents = file_contents.dup
code_blocks = []
@@ -3940,24 +4297,24 @@
starting_line_indices << modified_file_contents.index(line)
end
- block_ending_lines = modified_file_contents.dup.each_index.select { |index| (modified_file_contents[index].eql? " }\n" or modified_file_contents[index].eql? " };\n") }
+ block_ending_lines = modified_file_contents.dup.each_index.select { |index| (modified_file_contents[index].eql? " }\n" or modified_file_contents[index].eql? " };\n" or modified_file_contents[index].lstrip.eql?("});\n")) }
starting_index = starting_line_indices[0]
end
- rescue TypeError
+ #rescue TypeError
+ #
+ # puts "Whitespace was left unfixed!"
+ #
+ #rescue ArgumentError
+ #
+ # puts "Whitespace was left unfixed!"
- puts "Whitespace was left unfixed!"
-
- rescue ArgumentError
-
- puts "Whitespace was left unfixed!"
-
end
return modified_file_contents, code_blocks
end
@@ -3984,11 +4341,10 @@
code_block_locations = compact_contents.each_index.select { |index| compact_contents[index].eql? " *****\n" }
starting_index = code_block_locations[0]
-
end
return compact_contents
end
@@ -4037,11 +4393,11 @@
end
current_block.each_with_index do |line, index|
- if line.lstrip.eql? "}\n" or line.lstrip.eql?("};\n") or line.lstrip.include?("_!;\n")
+ if line.lstrip.eql? "}\n" or line.lstrip.eql?("};\n") or line.lstrip.include?("_!;\n") or line.lstrip.include?("});\n")
end_counter += 1
end_index << index
@@ -4071,21 +4427,21 @@
block_start = current_block.index(block_extract[0])
block_end = current_block.index(block_extract[-1])
- current_block[block_start..block_end] = "--block#{block_counter}"
+ current_block[block_start..block_end] = "--block#{block_counter}\n"
block_counter += 1
end_counter = 0
end_index = []
current_block.each_with_index do |line, index|
- if line.lstrip.eql? "}\n" or line.lstrip.eql?("};\n") or line.lstrip.include?("_!;\n")
+ if line.lstrip.eql? "}\n" or line.lstrip.eql?("};\n") or line.lstrip.include?("_!;\n") or line.lstrip.include?("});\n")
end_counter += 1
end_index << index
@@ -4187,19 +4543,19 @@
soft_tabs_counter += 1
current_block = [current_block[0]] + current_block[1...-1].collect { |element| soft_tabs*(soft_tabs_counter)+element } + [current_block[-1]]
- nested_block = current_block.reject { |row| !row.include?("--block") }
+ nested_block = current_block.clone.reject { |row| !row.include?("--block") }
nested_block = nested_block.collect { |element| element.split("--block")[1] }
nested_block = nested_block.collect { |element| element.rstrip.to_i }
modified_nested_block = nested_block.clone
- current_block = current_block.join
+ current_block = current_block.join("\n")
until modified_nested_block.empty?
nested_block.each do |block_index|
@@ -4408,31 +4764,33 @@
file_contents = compile_hashes(file_contents,temp_file)
file_contents = compile_conditional_structures(file_contents, temp_file)
+ file_contents = compile_blocks(file_contents,temp_file)
+
file_contents = compile_integers(file_contents)
file_contents = compile_default_values(file_contents, temp_file)
file_contents, named_functions, nested_functions = replace_named_functions(file_contents, temp_file)
comments = [singleline_comments, multiline_comments]
file_contents = compile_parallel_assignment(file_contents, temp_file)
- file_contents = compile_arrays(file_contents, temp_file)
+ file_contents,named_functions = compile_arrays(file_contents, named_functions, temp_file)
file_contents = compile_strings(file_contents)
file_contents, function_names = compile_named_functions(file_contents, named_functions, nested_functions, temp_file)
- list_of_variables, file_contents = get_variables(file_contents, temp_file,loop_vars)
+ list_of_variables, file_contents = get_variables(file_contents, temp_file,loop_vars+function_names)
file_contents, ruby_functions = compile_custom_function_map(file_contents)
- #compile_ruby_methods(file_contents)
+ file_contents = compile_ruby_methods(file_contents)
function_names << ruby_functions
list_of_variables += loop_vars
@@ -4512,10 +4870,10 @@
return remaining_string[0...remaining_string.length-path_finder]
end
-nilac_version = "0.0.4.3.3"
+nilac_version = "0.0.4.3.4"
opts = Slop.parse do
on :c, :compile=, 'Compile Nila File', as:Array, delimiter:":"
on :h, :help, 'Help With Nilac' do