nilac 0.0.4.1.9 → 0.0.4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/src/nilac.rb CHANGED
@@ -7,7 +7,7 @@ require 'slop'
7
7
  require 'fileutils'
8
8
 
9
9
 
10
- def compile(input_file_path,*output_file_name)
10
+ def compile(input_file_path, *output_file_name)
11
11
 
12
12
  def read_file_line_by_line(input_path)
13
13
 
@@ -45,7 +45,7 @@ def compile(input_file_path,*output_file_name)
45
45
 
46
46
  end
47
47
 
48
- def replace_multiline_comments(input_file_contents,nila_file_path,*output_js_file_path)
48
+ def replace_multiline_comments(input_file_contents, nila_file_path, *output_js_file_path)
49
49
 
50
50
  #This method will replace both the single and multiline comments
51
51
  #
@@ -53,7 +53,7 @@ def compile(input_file_path,*output_file_name)
53
53
  #
54
54
  #Multiline comment will be replaced by => --multiline_comment[n]
55
55
 
56
- def find_all_matching_indices(input_string,pattern)
56
+ def find_all_matching_indices(input_string, pattern)
57
57
 
58
58
  locations = []
59
59
 
@@ -63,7 +63,7 @@ def compile(input_file_path,*output_file_name)
63
63
 
64
64
  locations << index
65
65
 
66
- index = input_string.index(pattern,index+1)
66
+ index = input_string.index(pattern, index+1)
67
67
 
68
68
 
69
69
  end
@@ -73,7 +73,7 @@ def compile(input_file_path,*output_file_name)
73
73
 
74
74
  end
75
75
 
76
- def find_file_path(input_path,file_extension)
76
+ def find_file_path(input_path, file_extension)
77
77
 
78
78
  extension_remover = input_path.split(file_extension)
79
79
 
@@ -87,7 +87,7 @@ def compile(input_file_path,*output_file_name)
87
87
 
88
88
  end
89
89
 
90
- def find_file_name(input_path,file_extension)
90
+ def find_file_name(input_path, file_extension)
91
91
 
92
92
  extension_remover = input_path.split(file_extension)
93
93
 
@@ -109,9 +109,9 @@ def compile(input_file_path,*output_file_name)
109
109
 
110
110
  multiline_comment_counter = 1
111
111
 
112
- multiline_comments_start = find_all_matching_indices(file_contents_as_string,"=begin")
112
+ multiline_comments_start = find_all_matching_indices(file_contents_as_string, "=begin")
113
113
 
114
- multiline_comments_end = find_all_matching_indices(file_contents_as_string,"=end")
114
+ multiline_comments_end = find_all_matching_indices(file_contents_as_string, "=end")
115
115
 
116
116
  for y in 0...multiline_comments_start.length
117
117
 
@@ -121,7 +121,7 @@ def compile(input_file_path,*output_file_name)
121
121
 
122
122
  multiline_comment = file_contents_as_string[start_of_multiline_comment..end_of_multiline_comment+3]
123
123
 
124
- modified_file_contents = modified_file_contents.gsub(multiline_comment,"--multiline_comment[#{multiline_comment_counter}]\n\n")
124
+ modified_file_contents = modified_file_contents.gsub(multiline_comment, "--multiline_comment[#{multiline_comment_counter}]\n\n")
125
125
 
126
126
  multiline_comment_counter += 1
127
127
 
@@ -130,11 +130,11 @@ def compile(input_file_path,*output_file_name)
130
130
 
131
131
  end
132
132
 
133
- temporary_nila_file = find_file_path(nila_file_path,".nila") + "temp_nila.nila"
133
+ temporary_nila_file = find_file_path(nila_file_path, ".nila") + "temp_nila.nila"
134
134
 
135
135
  if output_js_file_path.empty?
136
136
 
137
- output_js_file = find_file_path(nila_file_path,".nila") + find_file_name(nila_file_path,".nila") + ".js"
137
+ output_js_file = find_file_path(nila_file_path, ".nila") + find_file_name(nila_file_path, ".nila") + ".js"
138
138
 
139
139
  else
140
140
 
@@ -156,7 +156,7 @@ def compile(input_file_path,*output_file_name)
156
156
 
157
157
  comments = multiline_comments.dup
158
158
 
159
- return line_by_line_contents,comments,temporary_nila_file,output_js_file
159
+ return line_by_line_contents, comments, temporary_nila_file, output_js_file
160
160
 
161
161
  end
162
162
 
@@ -164,19 +164,19 @@ def compile(input_file_path,*output_file_name)
164
164
 
165
165
  modified_file_contents = input_file_contents.dup
166
166
 
167
- input_file_contents.each_with_index do |line,index|
167
+ input_file_contents.each_with_index do |line, index|
168
168
 
169
169
  if line.include?("\"")
170
170
 
171
171
  first_index = line.index("\"")
172
172
 
173
- modified_line = line.sub(line[first_index..line.index("\"",first_index+1)],"--string")
173
+ modified_line = line.sub(line[first_index..line.index("\"", first_index+1)], "--string")
174
174
 
175
175
  elsif line.include?("'")
176
176
 
177
177
  first_index = line.index("'")
178
178
 
179
- modified_line = line.sub(line[first_index..line.index("'",first_index+1)],"--string")
179
+ modified_line = line.sub(line[first_index..line.index("'", first_index+1)], "--string")
180
180
 
181
181
  else
182
182
 
@@ -200,13 +200,13 @@ def compile(input_file_path,*output_file_name)
200
200
 
201
201
  end
202
202
 
203
- def compile_heredocs(input_file_contents,temporary_nila_file)
203
+ def compile_heredocs(input_file_contents, temporary_nila_file)
204
204
 
205
205
  joined_file_contents = input_file_contents.join
206
206
 
207
- possible_heredocs = input_file_contents.reject{|element| !element.include?("<<-")}
207
+ possible_heredocs = input_file_contents.reject { |element| !element.include?("<<-") }
208
208
 
209
- possible_heredocs = possible_heredocs.collect {|element| element.match(/<<-(.*|\w*)/).to_a[0]}
209
+ possible_heredocs = possible_heredocs.collect { |element| element.match(/<<-(.*|\w*)/).to_a[0] }
210
210
 
211
211
  possible_heredocs.each do |heredoc|
212
212
 
@@ -220,11 +220,11 @@ def compile(input_file_path,*output_file_name)
220
220
 
221
221
  end
222
222
 
223
- delimiter = delimiter.gsub("\"","") if quote == 2
223
+ delimiter = delimiter.gsub("\"", "") if quote == 2
224
224
 
225
- delimiter = delimiter.gsub("'","") if quote == 1
225
+ delimiter = delimiter.gsub("'", "") if quote == 1
226
226
 
227
- string_split = joined_file_contents.split(heredoc,2)
227
+ string_split = joined_file_contents.split(heredoc, 2)
228
228
 
229
229
  string_extract = string_split[1]
230
230
 
@@ -244,7 +244,7 @@ def compile(input_file_path,*output_file_name)
244
244
 
245
245
  end
246
246
 
247
- joined_file_contents = joined_file_contents.sub(heredoc + heredoc_extract + delimiter,replacement_string)
247
+ joined_file_contents = joined_file_contents.sub(heredoc + heredoc_extract + delimiter, replacement_string)
248
248
 
249
249
  end
250
250
 
@@ -263,7 +263,7 @@ def compile(input_file_path,*output_file_name)
263
263
 
264
264
  def compile_interpolated_strings(input_file_contents)
265
265
 
266
- def find_all_matching_indices(input_string,pattern)
266
+ def find_all_matching_indices(input_string, pattern)
267
267
 
268
268
  locations = []
269
269
 
@@ -273,7 +273,7 @@ def compile(input_file_path,*output_file_name)
273
273
 
274
274
  locations << index
275
275
 
276
- index = input_string.index(pattern,index+1)
276
+ index = input_string.index(pattern, index+1)
277
277
 
278
278
 
279
279
  end
@@ -285,7 +285,7 @@ def compile(input_file_path,*output_file_name)
285
285
 
286
286
  modified_file_contents = input_file_contents.dup
287
287
 
288
- single_quoted_strings = input_file_contents.reject {|element| !(element.count("'") >= 2)}
288
+ single_quoted_strings = input_file_contents.reject { |element| !(element.count("'") >= 2) }
289
289
 
290
290
  single_quoted_strings.each do |str|
291
291
 
@@ -295,9 +295,9 @@ def compile(input_file_path,*output_file_name)
295
295
 
296
296
  first_index = modified_string.index("'")
297
297
 
298
- string_extract = modified_string[first_index..modified_string.index("'",first_index+1)]
298
+ string_extract = modified_string[first_index..modified_string.index("'", first_index+1)]
299
299
 
300
- modified_string = modified_string.sub(string_extract,"--single_quoted")
300
+ modified_string = modified_string.sub(string_extract, "--single_quoted")
301
301
 
302
302
  end
303
303
 
@@ -305,13 +305,13 @@ def compile(input_file_path,*output_file_name)
305
305
 
306
306
  end
307
307
 
308
- input_file_contents.each_with_index do |line,index|
308
+ input_file_contents.each_with_index do |line, index|
309
309
 
310
310
  if line.include?("\#{")
311
311
 
312
312
  modified_line = line.dup
313
313
 
314
- interpol_starting_loc = find_all_matching_indices(modified_line,"\#{") + [-1]
314
+ interpol_starting_loc = find_all_matching_indices(modified_line, "\#{") + [-1]
315
315
 
316
316
  interpolated_strings = []
317
317
 
@@ -321,7 +321,7 @@ def compile(input_file_path,*output_file_name)
321
321
 
322
322
  string_extract = modified_line[interpol_starting_loc[0]+1..interpol_starting_loc[1]+1]
323
323
 
324
- closed_curly_brace_index = find_all_matching_indices(string_extract,"}")
324
+ closed_curly_brace_index = find_all_matching_indices(string_extract, "}")
325
325
 
326
326
  index_counter = 0
327
327
 
@@ -335,15 +335,15 @@ def compile(input_file_path,*output_file_name)
335
335
 
336
336
  if test_string.include?("{")
337
337
 
338
- test_string = test_string.reverse.sub("{","$#{index_counter}$").reverse
338
+ test_string = test_string.reverse.sub("{", "$#{index_counter}$").reverse
339
339
 
340
340
  test_string[-1] = "@#{index_counter}@"
341
341
 
342
342
  end
343
343
 
344
- string_extract = string_extract.sub(original_string,test_string)
344
+ string_extract = string_extract.sub(original_string, test_string)
345
345
 
346
- closed_curly_brace_index = find_all_matching_indices(string_extract,"}")
346
+ closed_curly_brace_index = find_all_matching_indices(string_extract, "}")
347
347
 
348
348
  index_counter += 1
349
349
 
@@ -357,23 +357,23 @@ def compile(input_file_path,*output_file_name)
357
357
 
358
358
  closing_brace_rep = interpolated_string.scan(/@\d@/)
359
359
 
360
- to_be_replaced.each_with_index do |rep,index|
360
+ to_be_replaced.each_with_index do |rep, index|
361
361
 
362
- interpolated_string = interpolated_string.sub(rep,"{").sub(closing_brace_rep[index],"}")
362
+ interpolated_string = interpolated_string.sub(rep, "{").sub(closing_brace_rep[index], "}")
363
363
 
364
364
  end
365
365
 
366
366
  interpolated_strings << interpolated_string
367
367
 
368
- modified_line = modified_line.sub(interpolated_string,"--interpolate")
368
+ modified_line = modified_line.sub(interpolated_string, "--interpolate")
369
369
 
370
- if find_all_matching_indices(modified_line,"\#{").empty?
370
+ if find_all_matching_indices(modified_line, "\#{").empty?
371
371
 
372
372
  interpol_starting_loc = []
373
373
 
374
374
  else
375
375
 
376
- interpol_starting_loc = find_all_matching_indices(modified_line,"\#{") + [-1]
376
+ interpol_starting_loc = find_all_matching_indices(modified_line, "\#{") + [-1]
377
377
 
378
378
  end
379
379
 
@@ -387,19 +387,19 @@ def compile(input_file_path,*output_file_name)
387
387
 
388
388
  replacement_string = "\" + " + interpol[2...-1]
389
389
 
390
- modified_file_contents[index] = modified_file_contents[index].sub(interpol+"\"",replacement_string)
390
+ modified_file_contents[index] = modified_file_contents[index].sub(interpol+"\"", replacement_string)
391
391
 
392
392
  elsif string_split[1].eql?("\")\n")
393
393
 
394
394
  replacement_string = "\" + " + interpol[2...-1]
395
395
 
396
- modified_file_contents[index] = modified_file_contents[index].sub(interpol+"\"",replacement_string)
396
+ modified_file_contents[index] = modified_file_contents[index].sub(interpol+"\"", replacement_string)
397
397
 
398
398
  else
399
399
 
400
400
  replacement_string = "\" + " + interpol[2...-1] + " + \""
401
401
 
402
- modified_file_contents[index] = modified_file_contents[index].sub(interpol,replacement_string)
402
+ modified_file_contents[index] = modified_file_contents[index].sub(interpol, replacement_string)
403
403
 
404
404
  end
405
405
 
@@ -433,7 +433,7 @@ def compile(input_file_path,*output_file_name)
433
433
 
434
434
  single_line_comments << comment
435
435
 
436
- current_row = current_row.gsub(comment,"--single_line_comment[#{singleline_comment_counter}]\n\n")
436
+ current_row = current_row.gsub(comment, "--single_line_comment[#{singleline_comment_counter}]\n\n")
437
437
 
438
438
  singleline_comment_counter += 1
439
439
 
@@ -445,13 +445,13 @@ def compile(input_file_path,*output_file_name)
445
445
 
446
446
  end
447
447
 
448
- return input_file_contents,single_line_comments
448
+ return input_file_contents, single_line_comments
449
449
 
450
450
  end
451
451
 
452
- def replace_named_functions(nila_file_contents,temporary_nila_file)
452
+ def replace_named_functions(nila_file_contents, temporary_nila_file)
453
453
 
454
- def extract_array(input_array,start_index,end_index)
454
+ def extract_array(input_array, start_index, end_index)
455
455
 
456
456
  return input_array[start_index..end_index]
457
457
 
@@ -545,7 +545,7 @@ def compile(input_file_path,*output_file_name)
545
545
 
546
546
  matching_level = end_blocks[top_most_level_index]
547
547
 
548
- named_code_blocks << extract_array(final_modified_file_contents,top_most_level,matching_level)
548
+ named_code_blocks << extract_array(final_modified_file_contents, top_most_level, matching_level)
549
549
 
550
550
  start_blocks.delete_at(top_most_level_index)
551
551
 
@@ -563,7 +563,7 @@ def compile(input_file_path,*output_file_name)
563
563
 
564
564
  if joined_file_contents.include?(codeblock.join)
565
565
 
566
- joined_file_contents = joined_file_contents.sub(codeblock.join,"--named_function[#{codeblock_counter}]\n")
566
+ joined_file_contents = joined_file_contents.sub(codeblock.join, "--named_function[#{codeblock_counter}]\n")
567
567
 
568
568
  codeblock_counter += 1
569
569
 
@@ -597,50 +597,50 @@ def compile(input_file_path,*output_file_name)
597
597
 
598
598
  line_by_line_contents = read_file_line_by_line(temporary_nila_file)
599
599
 
600
- return line_by_line_contents,named_functions,nested_functions
600
+ return line_by_line_contents, named_functions, nested_functions
601
601
 
602
602
 
603
603
  end
604
604
 
605
- def compile_multiple_variable_initialization(input_file_contents,temporary_nila_file)
605
+ def compile_parallel_assignment(input_file_contents, temporary_nila_file)
606
606
 
607
- possible_variable_lines = input_file_contents.reject {|element| !element.include?"="}
607
+ possible_variable_lines = input_file_contents.reject { |element| !element.include? "=" }
608
608
 
609
- possible_multiple_initialization = possible_variable_lines.reject {|element| !element.split("=")[0].include?","}
609
+ possible_parallel_assignment = possible_variable_lines.reject { |element| !element.split("=")[0].include? "," }
610
610
 
611
- multiple_initialization_index = []
611
+ parallel_assignment_index = []
612
612
 
613
- possible_multiple_initialization.each do |statement|
613
+ possible_parallel_assignment.each do |statement|
614
614
 
615
- location_array = input_file_contents.each_index.select { |index| input_file_contents[index] == statement}
615
+ location_array = input_file_contents.each_index.select { |index| input_file_contents[index] == statement }
616
616
 
617
- multiple_initialization_index << location_array[0]
617
+ parallel_assignment_index << location_array[0]
618
618
 
619
619
  end
620
620
 
621
621
  modified_file_contents = input_file_contents.dup
622
622
 
623
- multiple_init_counter = 1
623
+ parallel_assignment_counter = 1
624
624
 
625
- possible_multiple_initialization.each_with_index do |line,index|
625
+ possible_parallel_assignment.each_with_index do |line, index|
626
626
 
627
627
  line_split = line.split(" = ")
628
628
 
629
629
  right_side_variables = line_split[0].split(",")
630
630
 
631
- replacement_string = "multipleinit#{multiple_init_counter} = #{line_split[1]}\n\n"
631
+ replacement_string = "_ref#{parallel_assignment_counter} = #{line_split[1]}\n\n"
632
632
 
633
633
  variable_string = ""
634
634
 
635
- right_side_variables.each_with_index do |variable,var_index|
635
+ right_side_variables.each_with_index do |variable, var_index|
636
636
 
637
- variable_string = variable_string + variable.rstrip + " = multipleinit#{multiple_init_counter}[#{var_index}]\n\n"
637
+ variable_string = variable_string + variable.rstrip + " = _ref#{parallel_assignment_counter}[#{var_index}]\n\n"
638
638
 
639
639
  end
640
640
 
641
641
  replacement_string = replacement_string + variable_string
642
642
 
643
- modified_file_contents[multiple_initialization_index[index]] = replacement_string
643
+ modified_file_contents[parallel_assignment_index[index]] = replacement_string
644
644
 
645
645
  end
646
646
 
@@ -656,7 +656,7 @@ def compile(input_file_path,*output_file_name)
656
656
 
657
657
  end
658
658
 
659
- def compile_default_values(input_file_contents,temporary_nila_file)
659
+ def compile_default_values(input_file_contents, temporary_nila_file)
660
660
 
661
661
  #This method compiles default values present in functions. An example is provided below
662
662
 
@@ -666,13 +666,13 @@ def compile(input_file_path,*output_file_name)
666
666
 
667
667
  def parse_default_values(input_function_definition)
668
668
 
669
- split1,split2 = input_function_definition.split("(")
669
+ split1, split2 = input_function_definition.split("(")
670
670
 
671
- split2,split3 = split2.split(")")
671
+ split2, split3 = split2.split(")")
672
672
 
673
673
  function_parameters = split2.split(",")
674
674
 
675
- default_value_parameters = function_parameters.reject {|element| !element.include?"="}
675
+ default_value_parameters = function_parameters.reject { |element| !element.include? "=" }
676
676
 
677
677
  replacement_parameters = []
678
678
 
@@ -688,27 +688,27 @@ def compile(input_file_path,*output_file_name)
688
688
 
689
689
  end
690
690
 
691
- return replacement_string,default_value_parameters,replacement_parameters
691
+ return replacement_string, default_value_parameters, replacement_parameters
692
692
 
693
693
  end
694
694
 
695
- possible_default_values = input_file_contents.dup.reject {|element| !element.include?("def")}
695
+ possible_default_values = input_file_contents.dup.reject { |element| !element.include?("def") }
696
696
 
697
- possible_default_values = possible_default_values.reject {|element| !element.include?("=")}
697
+ possible_default_values = possible_default_values.reject { |element| !element.include?("=") }
698
698
 
699
699
  if !possible_default_values.empty?
700
700
 
701
701
  possible_default_values.each do |line|
702
702
 
703
- current_line_index = input_file_contents.each_index.select {|index| input_file_contents[index] == line}.flatten[0]
703
+ current_line_index = input_file_contents.each_index.select { |index| input_file_contents[index] == line }.flatten[0]
704
704
 
705
- replacement_string,value_parameters,replacement_parameters = parse_default_values(line)
705
+ replacement_string, value_parameters, replacement_parameters = parse_default_values(line)
706
706
 
707
707
  modified_line = line.dup
708
708
 
709
- value_parameters.each_with_index do |val,index|
709
+ value_parameters.each_with_index do |val, index|
710
710
 
711
- modified_line = modified_line.sub(val,replacement_parameters[index])
711
+ modified_line = modified_line.sub(val, replacement_parameters[index])
712
712
 
713
713
  end
714
714
 
@@ -732,23 +732,23 @@ def compile(input_file_path,*output_file_name)
732
732
 
733
733
  end
734
734
 
735
- def get_variables(input_file_contents,temporary_nila_file)
735
+ def get_variables(input_file_contents, temporary_nila_file)
736
736
 
737
737
  variables = []
738
738
 
739
- input_file_contents = input_file_contents.collect {|element| element.gsub("==","equalequal")}
739
+ input_file_contents = input_file_contents.collect { |element| element.gsub("==", "equalequal") }
740
740
 
741
- input_file_contents = input_file_contents.collect {|element| element.gsub("!=","notequal")}
741
+ input_file_contents = input_file_contents.collect { |element| element.gsub("!=", "notequal") }
742
742
 
743
- input_file_contents = input_file_contents.collect {|element| element.gsub("+=","plusequal")}
743
+ input_file_contents = input_file_contents.collect { |element| element.gsub("+=", "plusequal") }
744
744
 
745
- input_file_contents = input_file_contents.collect {|element| element.gsub("-=","minusequal")}
745
+ input_file_contents = input_file_contents.collect { |element| element.gsub("-=", "minusequal") }
746
746
 
747
- input_file_contents = input_file_contents.collect {|element| element.gsub("*=","multiequal")}
747
+ input_file_contents = input_file_contents.collect { |element| element.gsub("*=", "multiequal") }
748
748
 
749
- input_file_contents = input_file_contents.collect {|element| element.gsub("/=","divequal")}
749
+ input_file_contents = input_file_contents.collect { |element| element.gsub("/=", "divequal") }
750
750
 
751
- input_file_contents = input_file_contents.collect {|element| element.gsub("%=","modequal")}
751
+ input_file_contents = input_file_contents.collect { |element| element.gsub("%=", "modequal") }
752
752
 
753
753
  for x in 0...input_file_contents.length
754
754
 
@@ -796,29 +796,29 @@ def compile(input_file_path,*output_file_name)
796
796
 
797
797
  variable_declaration_string = "var " + variables.uniq.sort.join(", ") + "\n\n"
798
798
 
799
- line_by_line_contents = [variable_declaration_string,line_by_line_contents].flatten
799
+ line_by_line_contents = [variable_declaration_string, line_by_line_contents].flatten
800
800
 
801
801
  end
802
802
 
803
- line_by_line_contents = line_by_line_contents.collect {|element| element.gsub("plusequal","+=")}
803
+ line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("plusequal", "+=") }
804
804
 
805
- line_by_line_contents = line_by_line_contents.collect {|element| element.gsub("minusequal","-=")}
805
+ line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("minusequal", "-=") }
806
806
 
807
- line_by_line_contents = line_by_line_contents.collect {|element| element.gsub("multiequal","*=")}
807
+ line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("multiequal", "*=") }
808
808
 
809
- line_by_line_contents = line_by_line_contents.collect {|element| element.gsub("divequal","/=")}
809
+ line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("divequal", "/=") }
810
810
 
811
- line_by_line_contents = line_by_line_contents.collect {|element| element.gsub("modequal","%=")}
811
+ line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("modequal", "%=") }
812
812
 
813
- line_by_line_contents = line_by_line_contents.collect {|element| element.gsub("equalequal","==")}
813
+ line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("equalequal", "==") }
814
814
 
815
- line_by_line_contents = line_by_line_contents.collect {|element| element.gsub("notequal","!=")}
815
+ line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("notequal", "!=") }
816
816
 
817
- return variables.uniq,line_by_line_contents
817
+ return variables.uniq, line_by_line_contents
818
818
 
819
819
  end
820
820
 
821
- def remove_question_marks(input_file_contents,variable_list,temporary_nila_file)
821
+ def remove_question_marks(input_file_contents, variable_list, temporary_nila_file)
822
822
 
823
823
  #A method to remove question marks from global variable names. Local variables are dealt
824
824
  #with in their appropriate scope.
@@ -845,7 +845,7 @@ def compile(input_file_path,*output_file_name)
845
845
 
846
846
  if var.include? "?"
847
847
 
848
- joined_file_contents = joined_file_contents.gsub(var,var[0...-1])
848
+ joined_file_contents = joined_file_contents.gsub(var, var[0...-1])
849
849
 
850
850
  end
851
851
 
@@ -863,13 +863,13 @@ def compile(input_file_path,*output_file_name)
863
863
 
864
864
  end
865
865
 
866
- def compile_arrays(input_file_contents,temporary_nila_file)
866
+ def compile_arrays(input_file_contents, temporary_nila_file)
867
867
 
868
868
  def compile_w_arrays(input_file_contents)
869
869
 
870
- def extract(input_string,pattern_start,pattern_end)
870
+ def extract(input_string, pattern_start, pattern_end)
871
871
 
872
- def find_all_matching_indices(input_string,pattern)
872
+ def find_all_matching_indices(input_string, pattern)
873
873
 
874
874
  locations = []
875
875
 
@@ -879,7 +879,7 @@ def compile(input_file_path,*output_file_name)
879
879
 
880
880
  locations << index
881
881
 
882
- index = input_string.index(pattern,index+1)
882
+ index = input_string.index(pattern, index+1)
883
883
 
884
884
 
885
885
  end
@@ -889,13 +889,13 @@ def compile(input_file_path,*output_file_name)
889
889
 
890
890
  end
891
891
 
892
- all_start_locations = find_all_matching_indices(input_string,pattern_start)
892
+ all_start_locations = find_all_matching_indices(input_string, pattern_start)
893
893
 
894
- all_end_locations = find_all_matching_indices(input_string,pattern_end)
894
+ all_end_locations = find_all_matching_indices(input_string, pattern_end)
895
895
 
896
896
  pattern = []
897
897
 
898
- all_start_locations.each_with_index do |location,index|
898
+ all_start_locations.each_with_index do |location, index|
899
899
 
900
900
  pattern << input_string[location..all_end_locations[index]]
901
901
 
@@ -917,15 +917,15 @@ def compile(input_file_path,*output_file_name)
917
917
 
918
918
  modified_file_contents = input_file_contents.dup
919
919
 
920
- input_file_contents.each_with_index do |line,index|
920
+ input_file_contents.each_with_index do |line, index|
921
921
 
922
922
  if line.include?("%w{")
923
923
 
924
- string_arrays = extract(line,"%w{","}")
924
+ string_arrays = extract(line, "%w{", "}")
925
925
 
926
926
  string_arrays.each do |array|
927
927
 
928
- modified_file_contents[index] = modified_file_contents[index].sub(array,compile_w_syntax(array))
928
+ modified_file_contents[index] = modified_file_contents[index].sub(array, compile_w_syntax(array))
929
929
 
930
930
  end
931
931
 
@@ -939,31 +939,31 @@ def compile(input_file_path,*output_file_name)
939
939
 
940
940
  def compile_array_indexing(input_file_contents)
941
941
 
942
- possible_indexing_operation = input_file_contents.dup.reject {|element| !element.include?"[" and !element.include?"]"}
942
+ possible_indexing_operation = input_file_contents.dup.reject { |element| !element.include? "[" and !element.include? "]" }
943
943
 
944
- possible_range_indexing = possible_indexing_operation.reject {|element| !element.include?".."}
944
+ possible_range_indexing = possible_indexing_operation.reject { |element| !element.include? ".." }
945
945
 
946
- triple_range_indexing = possible_range_indexing.reject {|element| !element.include?"..."}
946
+ triple_range_indexing = possible_range_indexing.reject { |element| !element.include? "..." }
947
947
 
948
948
  triple_range_indexes = []
949
949
 
950
950
  triple_range_indexing.each do |line|
951
951
 
952
- triple_range_indexes << input_file_contents.dup.each_index.select {|index| input_file_contents[index] == line}
952
+ triple_range_indexes << input_file_contents.dup.each_index.select { |index| input_file_contents[index] == line }
953
953
 
954
954
  end
955
955
 
956
956
  triple_range_indexes = triple_range_indexes.flatten
957
957
 
958
- triple_range_indexing.each_with_index do |line,index|
958
+ triple_range_indexing.each_with_index do |line, index|
959
959
 
960
- split1,split2 = line.split("[")
960
+ split1, split2 = line.split("[")
961
961
 
962
- range_index,split3 = split2.split("]")
962
+ range_index, split3 = split2.split("]")
963
963
 
964
- index_start,index_end = range_index.split "..."
964
+ index_start, index_end = range_index.split "..."
965
965
 
966
- replacement_string = nil
966
+ replacement_string = nil
967
967
 
968
968
  if index_end.strip == "end"
969
969
 
@@ -983,25 +983,25 @@ def compile(input_file_path,*output_file_name)
983
983
 
984
984
  end
985
985
 
986
- double_range_indexing = possible_range_indexing.reject {|element| !element.include?("..")}
986
+ double_range_indexing = possible_range_indexing.reject { |element| !element.include?("..") }
987
987
 
988
988
  double_range_indexes = []
989
989
 
990
990
  double_range_indexing.each do |line|
991
991
 
992
- double_range_indexes << input_file_contents.dup.each_index.select {|index| input_file_contents[index] == line}
992
+ double_range_indexes << input_file_contents.dup.each_index.select { |index| input_file_contents[index] == line }
993
993
 
994
994
  end
995
995
 
996
996
  double_range_indexes = double_range_indexes.flatten
997
997
 
998
- double_range_indexing.each_with_index do |line,index|
998
+ double_range_indexing.each_with_index do |line, index|
999
999
 
1000
- split1,split2 = line.split("[")
1000
+ split1, split2 = line.split("[")
1001
1001
 
1002
- range_index,split3 = split2.split("]")
1002
+ range_index, split3 = split2.split("]")
1003
1003
 
1004
- index_start,index_end = range_index.split ".."
1004
+ index_start, index_end = range_index.split ".."
1005
1005
 
1006
1006
  index_start = "" if index_start.nil?
1007
1007
 
@@ -1031,13 +1031,13 @@ def compile(input_file_path,*output_file_name)
1031
1031
 
1032
1032
  end
1033
1033
 
1034
- duplicating_operations = input_file_contents.dup.reject{|element| !element.include?(".dup")}
1034
+ duplicating_operations = input_file_contents.dup.reject { |element| !element.include?(".dup") }
1035
1035
 
1036
1036
  duplicating_operation_indexes = []
1037
1037
 
1038
1038
  duplicating_operations.each do |line|
1039
1039
 
1040
- duplicating_operation_indexes << input_file_contents.dup.each_index.select {|index| input_file_contents[index] == line}
1040
+ duplicating_operation_indexes << input_file_contents.dup.each_index.select { |index| input_file_contents[index] == line }
1041
1041
 
1042
1042
  end
1043
1043
 
@@ -1045,7 +1045,7 @@ def compile(input_file_path,*output_file_name)
1045
1045
 
1046
1046
  duplicating_operation_indexes.each do |index|
1047
1047
 
1048
- input_file_contents[index] = input_file_contents[index].sub(".dup",".slice(0)")
1048
+ input_file_contents[index] = input_file_contents[index].sub(".dup", ".slice(0)")
1049
1049
 
1050
1050
  end
1051
1051
 
@@ -1053,11 +1053,11 @@ def compile(input_file_path,*output_file_name)
1053
1053
 
1054
1054
  end
1055
1055
 
1056
- def compile_multiline(input_file_contents,temporary_nila_file)
1056
+ def compile_multiline(input_file_contents, temporary_nila_file)
1057
1057
 
1058
- possible_arrays = input_file_contents.reject {|element| !element.include?("[")}
1058
+ possible_arrays = input_file_contents.reject { |element| !element.include?("[") }
1059
1059
 
1060
- possible_multiline_arrays = possible_arrays.reject {|element| element.include?("]")}
1060
+ possible_multiline_arrays = possible_arrays.reject { |element| element.include?("]") }
1061
1061
 
1062
1062
  multiline_arrays = []
1063
1063
 
@@ -1087,11 +1087,11 @@ def compile(input_file_path,*output_file_name)
1087
1087
 
1088
1088
  array_extract = modified_array[modified_array.index("[")..modified_array.index("]")]
1089
1089
 
1090
- array_contents = array_extract.split("[")[1].split("]")[0].lstrip.rstrip.split(",").collect {|element| element.lstrip.rstrip}
1090
+ array_contents = array_extract.split("[")[1].split("]")[0].lstrip.rstrip.split(",").collect { |element| element.lstrip.rstrip }
1091
1091
 
1092
1092
  array_contents = "[" + array_contents.join(",") + "]"
1093
1093
 
1094
- joined_file_contents = joined_file_contents.sub(array_extract,array_contents)
1094
+ joined_file_contents = joined_file_contents.sub(array_extract, array_contents)
1095
1095
 
1096
1096
  end
1097
1097
 
@@ -1109,11 +1109,11 @@ def compile(input_file_path,*output_file_name)
1109
1109
 
1110
1110
  def compile_array_operators(input_file_contents)
1111
1111
 
1112
- possible_operator_usage = input_file_contents.reject {|element| !element.include?("<<")}
1112
+ possible_operator_usage = input_file_contents.reject { |element| !element.include?("<<") }
1113
1113
 
1114
1114
  possible_operator_usage.each do |usage|
1115
1115
 
1116
- left,right = usage.split("<<")
1116
+ left, right = usage.split("<<")
1117
1117
 
1118
1118
  input_file_contents[input_file_contents.index(usage)] = left.rstrip + ".push(#{right.lstrip})"
1119
1119
 
@@ -1127,7 +1127,7 @@ def compile(input_file_path,*output_file_name)
1127
1127
 
1128
1128
  input_file_contents = compile_array_indexing(input_file_contents)
1129
1129
 
1130
- input_file_contents = compile_multiline(input_file_contents,temporary_nila_file)
1130
+ input_file_contents = compile_multiline(input_file_contents, temporary_nila_file)
1131
1131
 
1132
1132
  input_file_contents = compile_array_operators(input_file_contents)
1133
1133
 
@@ -1138,17 +1138,15 @@ def compile(input_file_path,*output_file_name)
1138
1138
 
1139
1139
  def compile_strings(input_file_contents)
1140
1140
 
1141
- # This method will compile %q, %Q and % syntax. Heredocs support will be added in the future
1142
-
1143
1141
  def compile_small_q_syntax(input_file_contents)
1144
1142
 
1145
- possible_syntax_usage = input_file_contents.reject {|element| !element.include?("%q")}
1143
+ possible_syntax_usage = input_file_contents.reject { |element| !element.include?("%q") }
1146
1144
 
1147
1145
  possible_syntax_usage.each do |line|
1148
1146
 
1149
1147
  modified_line = line.dup
1150
1148
 
1151
- line_split = line.split("+").collect {|element| element.lstrip.rstrip}
1149
+ line_split = line.split("+").collect { |element| element.lstrip.rstrip }
1152
1150
 
1153
1151
  line_split.each do |str|
1154
1152
 
@@ -1164,15 +1162,15 @@ def compile(input_file_path,*output_file_name)
1164
1162
 
1165
1163
  if string_extract[-1].eql?(delimiter)
1166
1164
 
1167
- input_file_contents[input_file_contents.index(modified_line)] = input_file_contents[input_file_contents.index(modified_line)].sub(string_extract,"'#{string_extract[3...-1]}'")
1165
+ input_file_contents[input_file_contents.index(modified_line)] = input_file_contents[input_file_contents.index(modified_line)].sub(string_extract, "'#{string_extract[3...-1]}'")
1168
1166
 
1169
- modified_line = modified_line.sub(string_extract,"'#{string_extract[3...-1]}'")
1167
+ modified_line = modified_line.sub(string_extract, "'#{string_extract[3...-1]}'")
1170
1168
 
1171
1169
  elsif delimiter.eql?(" ")
1172
1170
 
1173
- input_file_contents[input_file_contents.index(modified_line)] = input_file_contents[input_file_contents.index(modified_line)].sub(string_extract,"'#{string_extract[3..-1]}'")
1171
+ input_file_contents[input_file_contents.index(modified_line)] = input_file_contents[input_file_contents.index(modified_line)].sub(string_extract, "'#{string_extract[3..-1]}'")
1174
1172
 
1175
- modified_line = modified_line.sub(string_extract,"'#{string_extract[3..-1]}'")
1173
+ modified_line = modified_line.sub(string_extract, "'#{string_extract[3..-1]}'")
1176
1174
 
1177
1175
  end
1178
1176
 
@@ -1186,13 +1184,13 @@ def compile(input_file_path,*output_file_name)
1186
1184
 
1187
1185
  def compile_big_q_syntax(input_file_contents)
1188
1186
 
1189
- possible_syntax_usage = input_file_contents.reject {|element| !element.include?("%Q")}
1187
+ possible_syntax_usage = input_file_contents.reject { |element| !element.include?("%Q") }
1190
1188
 
1191
1189
  possible_syntax_usage.each do |line|
1192
1190
 
1193
1191
  modified_line = line.dup
1194
1192
 
1195
- line_split = line.split("+").collect {|element| element.lstrip.rstrip}
1193
+ line_split = line.split("+").collect { |element| element.lstrip.rstrip }
1196
1194
 
1197
1195
  line_split.each do |str|
1198
1196
 
@@ -1208,15 +1206,15 @@ def compile(input_file_path,*output_file_name)
1208
1206
 
1209
1207
  if string_extract[-1].eql?(delimiter)
1210
1208
 
1211
- input_file_contents[input_file_contents.index(modified_line)] = input_file_contents[input_file_contents.index(modified_line)].sub(string_extract,"\"#{string_extract[3...-1]}\"")
1209
+ input_file_contents[input_file_contents.index(modified_line)] = input_file_contents[input_file_contents.index(modified_line)].sub(string_extract, "\"#{string_extract[3...-1]}\"")
1212
1210
 
1213
- modified_line = modified_line.sub(string_extract,"\"#{string_extract[3...-1]}\"")
1211
+ modified_line = modified_line.sub(string_extract, "\"#{string_extract[3...-1]}\"")
1214
1212
 
1215
1213
  elsif delimiter.eql?(" ")
1216
1214
 
1217
- input_file_contents[input_file_contents.index(modified_line)] = input_file_contents[input_file_contents.index(modified_line)].sub(string_extract,"\"#{string_extract[3..-1]}\"")
1215
+ input_file_contents[input_file_contents.index(modified_line)] = input_file_contents[input_file_contents.index(modified_line)].sub(string_extract, "\"#{string_extract[3..-1]}\"")
1218
1216
 
1219
- modified_line = modified_line.sub(string_extract,"\"#{string_extract[3..-1]}\"")
1217
+ modified_line = modified_line.sub(string_extract, "\"#{string_extract[3..-1]}\"")
1220
1218
 
1221
1219
  end
1222
1220
 
@@ -1230,15 +1228,15 @@ def compile(input_file_path,*output_file_name)
1230
1228
 
1231
1229
  def compile_percentage_syntax(input_file_contents)
1232
1230
 
1233
- possible_syntax_usage = input_file_contents.reject {|element| !element.include?("%")}
1231
+ possible_syntax_usage = input_file_contents.reject { |element| !element.include?("%") }
1234
1232
 
1235
- possible_syntax_usage = possible_syntax_usage.reject {|element| element.index(/(\%(\W|\s)\w{1,})/).nil?}
1233
+ possible_syntax_usage = possible_syntax_usage.reject { |element| element.index(/(\%(\W|\s)\w{1,})/).nil? }
1236
1234
 
1237
1235
  possible_syntax_usage.each do |line|
1238
1236
 
1239
1237
  modified_line = line.dup
1240
1238
 
1241
- line_split = line.split("+").collect {|element| element.lstrip.rstrip}
1239
+ line_split = line.split("+").collect { |element| element.lstrip.rstrip }
1242
1240
 
1243
1241
  line_split.each do |str|
1244
1242
 
@@ -1254,15 +1252,15 @@ def compile(input_file_path,*output_file_name)
1254
1252
 
1255
1253
  if string_extract[-1].eql?(delimiter)
1256
1254
 
1257
- input_file_contents[input_file_contents.index(modified_line)] = input_file_contents[input_file_contents.index(modified_line)].sub(string_extract,"\"#{string_extract[2...-1]}\"")
1255
+ input_file_contents[input_file_contents.index(modified_line)] = input_file_contents[input_file_contents.index(modified_line)].sub(string_extract, "\"#{string_extract[2...-1]}\"")
1258
1256
 
1259
- modified_line = modified_line.sub(string_extract,"\"#{string_extract[2...-1]}\"")
1257
+ modified_line = modified_line.sub(string_extract, "\"#{string_extract[2...-1]}\"")
1260
1258
 
1261
1259
  elsif delimiter.eql?(" ")
1262
1260
 
1263
- input_file_contents[input_file_contents.index(modified_line)] = input_file_contents[input_file_contents.index(modified_line)].sub(string_extract,"\"#{string_extract[2..-1]}\"")
1261
+ input_file_contents[input_file_contents.index(modified_line)] = input_file_contents[input_file_contents.index(modified_line)].sub(string_extract, "\"#{string_extract[2..-1]}\"")
1264
1262
 
1265
- modified_line = modified_line.sub(string_extract,"\"#{string_extract[2..-1]}\"")
1263
+ modified_line = modified_line.sub(string_extract, "\"#{string_extract[2..-1]}\"")
1266
1264
 
1267
1265
  end
1268
1266
 
@@ -1284,7 +1282,7 @@ def compile(input_file_path,*output_file_name)
1284
1282
 
1285
1283
  end
1286
1284
 
1287
- def compile_named_functions(input_file_contents,named_code_blocks,nested_functions,temporary_nila_file)
1285
+ def compile_named_functions(input_file_contents, named_code_blocks, nested_functions, temporary_nila_file)
1288
1286
 
1289
1287
  #This method compiles all the named Nila functions. Below is an example of what is meant
1290
1288
  #by named/explicit function
@@ -1326,11 +1324,11 @@ def compile(input_file_path,*output_file_name)
1326
1324
 
1327
1325
  variables = []
1328
1326
 
1329
- function_name,parameters = input_function_block[0].split("(")
1327
+ function_name, parameters = input_function_block[0].split("(")
1330
1328
 
1331
1329
  parameters = parameters.split(")")[0].split(",")
1332
1330
 
1333
- parameters = parameters.collect {|element| element.strip}
1331
+ parameters = parameters.collect { |element| element.strip }
1334
1332
 
1335
1333
  input_function_block.each do |line|
1336
1334
 
@@ -1366,7 +1364,7 @@ def compile(input_file_path,*output_file_name)
1366
1364
 
1367
1365
  end
1368
1366
 
1369
- def remove_question_marks(input_file_contents,input_list,temporary_nila_file)
1367
+ def remove_question_marks(input_file_contents, input_list, temporary_nila_file)
1370
1368
 
1371
1369
  joined_file_contents = input_file_contents.join
1372
1370
 
@@ -1374,7 +1372,7 @@ def compile(input_file_path,*output_file_name)
1374
1372
 
1375
1373
  if element.include? "?"
1376
1374
 
1377
- joined_file_contents = joined_file_contents.gsub(element,element[0...-1])
1375
+ joined_file_contents = joined_file_contents.gsub(element, element[0...-1])
1378
1376
 
1379
1377
  end
1380
1378
 
@@ -1400,7 +1398,7 @@ def compile(input_file_path,*output_file_name)
1400
1398
 
1401
1399
  if !joined_array.include?("return ")
1402
1400
 
1403
- rejected_array = reversed_input_array.reject {|content| content.lstrip.eql?("")}
1401
+ rejected_array = reversed_input_array.reject { |content| content.lstrip.eql?("") }
1404
1402
 
1405
1403
  rejected_array = rejected_array[1..-1]
1406
1404
 
@@ -1426,7 +1424,7 @@ def compile(input_file_path,*output_file_name)
1426
1424
 
1427
1425
  def compile_multiple_return(input_array)
1428
1426
 
1429
- def find_all_matching_indices(input_string,pattern)
1427
+ def find_all_matching_indices(input_string, pattern)
1430
1428
 
1431
1429
  locations = []
1432
1430
 
@@ -1436,7 +1434,7 @@ def compile(input_file_path,*output_file_name)
1436
1434
 
1437
1435
  locations << index
1438
1436
 
1439
- index = input_string.index(pattern,index+1)
1437
+ index = input_string.index(pattern, index+1)
1440
1438
 
1441
1439
 
1442
1440
  end
@@ -1448,9 +1446,9 @@ def compile(input_file_path,*output_file_name)
1448
1446
 
1449
1447
  modified_input_array = input_array.dup
1450
1448
 
1451
- return_statements = input_array.dup.reject {|element| !element.include?"return"}
1449
+ return_statements = input_array.dup.reject { |element| !element.include? "return" }
1452
1450
 
1453
- multiple_return_statements = return_statements.dup.reject {|element| !element.include?","}
1451
+ multiple_return_statements = return_statements.dup.reject { |element| !element.include? "," }
1454
1452
 
1455
1453
  modified_multiple_return_statements = multiple_return_statements.dup
1456
1454
 
@@ -1458,19 +1456,19 @@ def compile(input_file_path,*output_file_name)
1458
1456
 
1459
1457
  multiple_return_statements.each do |statement|
1460
1458
 
1461
- location_array = modified_input_array.each_index.select { |index| modified_input_array[index] == statement}
1459
+ location_array = modified_input_array.each_index.select { |index| modified_input_array[index] == statement }
1462
1460
 
1463
1461
  return_statement_index << location_array[0]
1464
1462
 
1465
1463
  end
1466
1464
 
1467
- multiple_return_statements.each_with_index do |return_statement,index|
1465
+ multiple_return_statements.each_with_index do |return_statement, index|
1468
1466
 
1469
1467
  replacement_counter = 0
1470
1468
 
1471
1469
  if return_statement.include? "\""
1472
1470
 
1473
- starting_quotes = find_all_matching_indices(return_statement,"\"")
1471
+ starting_quotes = find_all_matching_indices(return_statement, "\"")
1474
1472
 
1475
1473
  for x in 0...(starting_quotes.length)/2
1476
1474
 
@@ -1478,9 +1476,9 @@ def compile(input_file_path,*output_file_name)
1478
1476
 
1479
1477
  replacement_counter += 1
1480
1478
 
1481
- modified_multiple_return_statements[index] = modified_multiple_return_statements[index].sub(quotes,"repstring#{1}")
1479
+ modified_multiple_return_statements[index] = modified_multiple_return_statements[index].sub(quotes, "repstring#{1}")
1482
1480
 
1483
- modified_input_array[return_statement_index[index]] = modified_multiple_return_statements[index].sub(quotes,"repstring#{1}")
1481
+ modified_input_array[return_statement_index[index]] = modified_multiple_return_statements[index].sub(quotes, "repstring#{1}")
1484
1482
 
1485
1483
  end
1486
1484
 
@@ -1488,35 +1486,35 @@ def compile(input_file_path,*output_file_name)
1488
1486
 
1489
1487
  end
1490
1488
 
1491
- modified_multiple_return_statements = modified_multiple_return_statements.reject {|element| !element.include?","}
1489
+ modified_multiple_return_statements = modified_multiple_return_statements.reject { |element| !element.include? "," }
1492
1490
 
1493
1491
  return_statement_index = []
1494
1492
 
1495
1493
  modified_multiple_return_statements.each do |statement|
1496
1494
 
1497
- location_array = modified_input_array.each_index.select { |index| modified_input_array[index] == statement}
1495
+ location_array = modified_input_array.each_index.select { |index| modified_input_array[index] == statement }
1498
1496
 
1499
1497
  return_statement_index << location_array[0]
1500
1498
 
1501
1499
  end
1502
1500
 
1503
- modified_multiple_return_statements.each_with_index do |return_statement,index|
1501
+ modified_multiple_return_statements.each_with_index do |return_statement, index|
1504
1502
 
1505
1503
  method_call_counter = 0
1506
1504
 
1507
- if return_statement.include?"("
1505
+ if return_statement.include? "("
1508
1506
 
1509
- open_paran_location = find_all_matching_indices(return_statement,"(")
1507
+ open_paran_location = find_all_matching_indices(return_statement, "(")
1510
1508
 
1511
1509
  open_paran_location.each do |paran_index|
1512
1510
 
1513
- method_call = return_statement[paran_index..return_statement.index(")",paran_index+1)]
1511
+ method_call = return_statement[paran_index..return_statement.index(")", paran_index+1)]
1514
1512
 
1515
1513
  method_call_counter += 1
1516
1514
 
1517
- modified_multiple_return_statements[index] = modified_multiple_return_statements[index].sub(method_call,"methodcall#{method_call_counter}")
1515
+ modified_multiple_return_statements[index] = modified_multiple_return_statements[index].sub(method_call, "methodcall#{method_call_counter}")
1518
1516
 
1519
- modified_input_array[return_statement_index[index]] = modified_multiple_return_statements[index].sub(method_call,"methodcall#{method_call_counter}")
1517
+ modified_input_array[return_statement_index[index]] = modified_multiple_return_statements[index].sub(method_call, "methodcall#{method_call_counter}")
1520
1518
 
1521
1519
  end
1522
1520
 
@@ -1524,13 +1522,13 @@ def compile(input_file_path,*output_file_name)
1524
1522
 
1525
1523
  end
1526
1524
 
1527
- modified_multiple_return_statements = modified_multiple_return_statements.reject {|element| !element.include?(",")}
1525
+ modified_multiple_return_statements = modified_multiple_return_statements.reject { |element| !element.include?(",") }
1528
1526
 
1529
1527
  return_statement_index = []
1530
1528
 
1531
1529
  modified_multiple_return_statements.each do |statement|
1532
1530
 
1533
- location_array = modified_input_array.each_index.select { |index| modified_input_array[index] == statement}
1531
+ location_array = modified_input_array.each_index.select { |index| modified_input_array[index] == statement }
1534
1532
 
1535
1533
  return_statement_index << location_array[0]
1536
1534
 
@@ -1552,7 +1550,7 @@ def compile(input_file_path,*output_file_name)
1552
1550
 
1553
1551
  end
1554
1552
 
1555
- def compile_function(input_array,temporary_nila_file)
1553
+ def compile_function(input_array, temporary_nila_file)
1556
1554
 
1557
1555
  modified_input_array = input_array.dup
1558
1556
 
@@ -1560,24 +1558,24 @@ def compile(input_file_path,*output_file_name)
1560
1558
 
1561
1559
  if modified_input_array[0].include?("--single")
1562
1560
 
1563
- modified_input_array[0] = input_array[0].sub "def","function"
1561
+ modified_input_array[0] = input_array[0].sub "def", "function"
1564
1562
 
1565
1563
  interim_string = modified_input_array[0].split("--single")
1566
1564
 
1567
- modified_input_array[0] = interim_string[0].rstrip + "() {\n--single" + interim_string[1]
1565
+ modified_input_array[0] = interim_string[0].rstrip + "() {\n--single" + interim_string[1]
1568
1566
 
1569
1567
 
1570
1568
  elsif modified_input_array[0].include?("--multi")
1571
1569
 
1572
- modified_input_array[0] = input_array[0].sub "def","function"
1570
+ modified_input_array[0] = input_array[0].sub "def", "function"
1573
1571
 
1574
1572
  interim_string = modified_input_array[0].split("--multi")
1575
1573
 
1576
- modified_input_array[0] = interim_string[0].rstrip + "() {\n--multi" + interim_string[1]
1574
+ modified_input_array[0] = interim_string[0].rstrip + "() {\n--multi" + interim_string[1]
1577
1575
 
1578
1576
  else
1579
1577
 
1580
- modified_input_array[0] = input_array[0].sub "def","function"
1578
+ modified_input_array[0] = input_array[0].sub "def", "function"
1581
1579
 
1582
1580
  modified_input_array[0] = modified_input_array[0].rstrip + "() {\n"
1583
1581
 
@@ -1587,24 +1585,24 @@ def compile(input_file_path,*output_file_name)
1587
1585
 
1588
1586
  if modified_input_array[0].include?("--single")
1589
1587
 
1590
- modified_input_array[0] = input_array[0].sub "def","function"
1588
+ modified_input_array[0] = input_array[0].sub "def", "function"
1591
1589
 
1592
1590
  interim_string = modified_input_array[0].split("--single")
1593
1591
 
1594
- modified_input_array[0] = interim_string[0].rstrip + " {\n--single" + interim_string[1]
1592
+ modified_input_array[0] = interim_string[0].rstrip + " {\n--single" + interim_string[1]
1595
1593
 
1596
1594
 
1597
1595
  elsif modified_input_array[0].include?("--multi")
1598
1596
 
1599
- modified_input_array[0] = input_array[0].sub "def","function"
1597
+ modified_input_array[0] = input_array[0].sub "def", "function"
1600
1598
 
1601
1599
  interim_string = modified_input_array[0].split("--multi")
1602
1600
 
1603
- modified_input_array[0] = interim_string[0].rstrip + " {\n--multi" + interim_string[1]
1601
+ modified_input_array[0] = interim_string[0].rstrip + " {\n--multi" + interim_string[1]
1604
1602
 
1605
1603
  else
1606
1604
 
1607
- modified_input_array[0] = input_array[0].sub "def","function"
1605
+ modified_input_array[0] = input_array[0].sub "def", "function"
1608
1606
 
1609
1607
  modified_input_array[0] = modified_input_array[0].rstrip + " {\n"
1610
1608
 
@@ -1612,9 +1610,9 @@ def compile(input_file_path,*output_file_name)
1612
1610
 
1613
1611
  end
1614
1612
 
1615
- modified_input_array[-1] = input_array[-1].sub "end","}\n"
1613
+ modified_input_array[-1] = input_array[-1].sub "end", "}\n"
1616
1614
 
1617
- modified_input_array = compile_multiple_variable_initialization(modified_input_array,temporary_nila_file)
1615
+ modified_input_array = compile_parallel_assignment(modified_input_array, temporary_nila_file)
1618
1616
 
1619
1617
  variables = lexical_scoped_variables(modified_input_array)
1620
1618
 
@@ -1622,11 +1620,11 @@ def compile(input_file_path,*output_file_name)
1622
1620
 
1623
1621
  variable_string = "\nvar " + variables.join(", ") + "\n"
1624
1622
 
1625
- modified_input_array.insert(1,variable_string)
1623
+ modified_input_array.insert(1, variable_string)
1626
1624
 
1627
1625
  end
1628
1626
 
1629
- modified_input_array = remove_question_marks(modified_input_array,variables,temporary_nila_file)
1627
+ modified_input_array = remove_question_marks(modified_input_array, variables, temporary_nila_file)
1630
1628
 
1631
1629
  modified_input_array = add_auto_return_statement(modified_input_array)
1632
1630
 
@@ -1644,7 +1642,7 @@ def compile(input_file_path,*output_file_name)
1644
1642
 
1645
1643
  if first_line_split[1].include?("(")
1646
1644
 
1647
- function_name,parameters = first_line_split[1].split("(")
1645
+ function_name, parameters = first_line_split[1].split("(")
1648
1646
 
1649
1647
  else
1650
1648
 
@@ -1668,7 +1666,7 @@ def compile(input_file_path,*output_file_name)
1668
1666
 
1669
1667
  function_names[codeblock_counter-1] = []
1670
1668
 
1671
- joined_file_contents = joined_file_contents.sub("--named_function[#{codeblock_counter}]\n",compile_function(codeblock,temporary_nila_file).join)
1669
+ joined_file_contents = joined_file_contents.sub("--named_function[#{codeblock_counter}]\n", compile_function(codeblock, temporary_nila_file).join)
1672
1670
 
1673
1671
  codeblock_counter += 1
1674
1672
 
@@ -1680,7 +1678,7 @@ def compile(input_file_path,*output_file_name)
1680
1678
 
1681
1679
  function_names[codeblock_counter-2] << extract_function_name(nested_function)
1682
1680
 
1683
- joined_file_contents = joined_file_contents.sub(nested_function.join,compile_function(nested_function,temporary_nila_file).join)
1681
+ joined_file_contents = joined_file_contents.sub(nested_function.join, compile_function(nested_function, temporary_nila_file).join)
1684
1682
 
1685
1683
  end
1686
1684
 
@@ -1700,7 +1698,7 @@ def compile(input_file_path,*output_file_name)
1700
1698
 
1701
1699
  line_by_line_contents = read_file_line_by_line(temporary_nila_file)
1702
1700
 
1703
- return line_by_line_contents,function_names
1701
+ return line_by_line_contents, function_names
1704
1702
 
1705
1703
  end
1706
1704
 
@@ -1719,13 +1717,13 @@ def compile(input_file_path,*output_file_name)
1719
1717
 
1720
1718
  modified_file_contents = input_file_contents.dup
1721
1719
 
1722
- input_file_contents.each_with_index do |line,index|
1720
+ input_file_contents.each_with_index do |line, index|
1723
1721
 
1724
1722
  function_map.each do |function|
1725
1723
 
1726
1724
  if line.include?(function+"(") or line.include?(function+" ")
1727
1725
 
1728
- modified_file_contents[index] = line.sub(function,function_map_replacements[function])
1726
+ modified_file_contents[index] = line.sub(function, function_map_replacements[function])
1729
1727
 
1730
1728
  end
1731
1729
 
@@ -1733,15 +1731,15 @@ def compile(input_file_path,*output_file_name)
1733
1731
 
1734
1732
  end
1735
1733
 
1736
- return modified_file_contents,function_map_replacements.values
1734
+ return modified_file_contents, function_map_replacements.values
1737
1735
 
1738
1736
  end
1739
1737
 
1740
- def compile_whitespace_delimited_functions(input_file_contents,function_names,temporary_nila_file)
1738
+ def compile_whitespace_delimited_functions(input_file_contents, function_names, temporary_nila_file)
1741
1739
 
1742
- def extract(input_string,pattern_start,pattern_end)
1740
+ def extract(input_string, pattern_start, pattern_end)
1743
1741
 
1744
- def find_all_matching_indices(input_string,pattern)
1742
+ def find_all_matching_indices(input_string, pattern)
1745
1743
 
1746
1744
  locations = []
1747
1745
 
@@ -1751,7 +1749,7 @@ def compile(input_file_path,*output_file_name)
1751
1749
 
1752
1750
  locations << index
1753
1751
 
1754
- index = input_string.index(pattern,index+1)
1752
+ index = input_string.index(pattern, index+1)
1755
1753
 
1756
1754
 
1757
1755
  end
@@ -1761,7 +1759,7 @@ def compile(input_file_path,*output_file_name)
1761
1759
 
1762
1760
  end
1763
1761
 
1764
- all_start_locations = find_all_matching_indices(input_string,pattern_start)
1762
+ all_start_locations = find_all_matching_indices(input_string, pattern_start)
1765
1763
 
1766
1764
  pattern = []
1767
1765
 
@@ -1787,19 +1785,19 @@ def compile(input_file_path,*output_file_name)
1787
1785
 
1788
1786
  list_of_functions.each do |function|
1789
1787
 
1790
- matching_strings = extract(joined_file_contents,function+" ","\n")
1788
+ matching_strings = extract(joined_file_contents, function+" ", "\n")
1791
1789
 
1792
1790
  matching_strings.each do |string|
1793
1791
 
1794
1792
  modified_string = string.dup
1795
1793
 
1796
- modified_string = modified_string.rstrip + modified_string.split(modified_string.rstrip)[1].gsub(" ","")
1794
+ modified_string = modified_string.rstrip + modified_string.split(modified_string.rstrip)[1].gsub(" ", "")
1797
1795
 
1798
- modified_string = modified_string.sub(function+" ",function+"(")
1796
+ modified_string = modified_string.sub(function+" ", function+"(")
1799
1797
 
1800
- modified_string = modified_string.sub("\n",")\n")
1798
+ modified_string = modified_string.sub("\n", ")\n")
1801
1799
 
1802
- joined_file_contents = joined_file_contents.sub(string,modified_string)
1800
+ joined_file_contents = joined_file_contents.sub(string, modified_string)
1803
1801
 
1804
1802
  end
1805
1803
 
@@ -1825,19 +1823,19 @@ def compile(input_file_path,*output_file_name)
1825
1823
 
1826
1824
  end
1827
1825
 
1828
- def compile_conditional_structures(input_file_contents,temporary_nila_file)
1826
+ def compile_conditional_structures(input_file_contents, temporary_nila_file)
1829
1827
 
1830
1828
  def replace_unless_until(input_file_contents)
1831
1829
 
1832
1830
  modified_file_contents = input_file_contents.clone
1833
1831
 
1834
- possible_unless_commands = input_file_contents.reject {|element| !element.include?("unless")}
1832
+ possible_unless_commands = input_file_contents.reject { |element| !element.include?("unless") }
1835
1833
 
1836
- unless_commands = possible_unless_commands.reject {|element| !element.lstrip.split("unless")[0].empty?}
1834
+ unless_commands = possible_unless_commands.reject { |element| !element.lstrip.split("unless")[0].empty? }
1837
1835
 
1838
1836
  unless_commands.each do |command|
1839
1837
 
1840
- junk,condition = command.split("unless ")
1838
+ junk, condition = command.split("unless ")
1841
1839
 
1842
1840
  replacement_string = "if !(#{condition.lstrip.rstrip})\n"
1843
1841
 
@@ -1845,13 +1843,13 @@ def compile(input_file_path,*output_file_name)
1845
1843
 
1846
1844
  end
1847
1845
 
1848
- possible_until_commands = input_file_contents.reject {|element| !element.include?("until")}
1846
+ possible_until_commands = input_file_contents.reject { |element| !element.include?("until") }
1849
1847
 
1850
- until_commands = possible_until_commands.reject {|element| !element.lstrip.split("until")[0].empty?}
1848
+ until_commands = possible_until_commands.reject { |element| !element.lstrip.split("until")[0].empty? }
1851
1849
 
1852
1850
  until_commands.each do |command|
1853
1851
 
1854
- junk,condition = command.split("until ")
1852
+ junk, condition = command.split("until ")
1855
1853
 
1856
1854
  replacement_string = "while !(#{condition.lstrip.rstrip})\n"
1857
1855
 
@@ -1863,19 +1861,19 @@ def compile(input_file_path,*output_file_name)
1863
1861
 
1864
1862
  end
1865
1863
 
1866
- def compile_inline_conditionals(input_file_contents,temporary_nila_file)
1864
+ def compile_inline_conditionals(input_file_contents, temporary_nila_file)
1867
1865
 
1868
- conditionals = [/( if )/,/( while )/,/( unless )/,/( until )/]
1866
+ conditionals = [/( if )/, /( while )/, /( unless )/, /( until )/]
1869
1867
 
1870
- plain_conditionals = [" if "," while "," unless "," until "]
1868
+ plain_conditionals = [" if ", " while ", " unless ", " until "]
1871
1869
 
1872
1870
  joined_file_contents = input_file_contents.join
1873
1871
 
1874
1872
  output_statement = ""
1875
1873
 
1876
- conditionals.each_with_index do |regex,index|
1874
+ conditionals.each_with_index do |regex, index|
1877
1875
 
1878
- matching_lines = input_file_contents.reject {|content| content.index(regex).nil?}
1876
+ matching_lines = input_file_contents.reject { |content| content.index(regex).nil? }
1879
1877
 
1880
1878
  matching_lines.each do |line|
1881
1879
 
@@ -1883,23 +1881,23 @@ def compile(input_file_path,*output_file_name)
1883
1881
 
1884
1882
  if index == 0
1885
1883
 
1886
- output_statement = "if (#{line_split[1].lstrip.rstrip.gsub("?","")}) {\n\n#{line_split[0]}\n}\n"
1884
+ output_statement = "if (#{line_split[1].lstrip.rstrip.gsub("?", "")}) {\n\n#{line_split[0]}\n}\n"
1887
1885
 
1888
1886
  elsif index == 1
1889
1887
 
1890
- output_statement = "while (#{line_split[1].lstrip.rstrip.gsub("?","")}) {\n\n#{line_split[0]}\n}\n"
1888
+ output_statement = "while (#{line_split[1].lstrip.rstrip.gsub("?", "")}) {\n\n#{line_split[0]}\n}\n"
1891
1889
 
1892
1890
  elsif index == 2
1893
1891
 
1894
- output_statement = "if (!(#{line_split[1].lstrip.rstrip.gsub("?","")})) {\n\n#{line_split[0]}\n}\n"
1892
+ output_statement = "if (!(#{line_split[1].lstrip.rstrip.gsub("?", "")})) {\n\n#{line_split[0]}\n}\n"
1895
1893
 
1896
1894
  elsif index == 3
1897
1895
 
1898
- output_statement = "while (!(#{line_split[1].lstrip.rstrip.gsub("?","")})) {\n\n#{line_split[0]}\n}\n"
1896
+ output_statement = "while (!(#{line_split[1].lstrip.rstrip.gsub("?", "")})) {\n\n#{line_split[0]}\n}\n"
1899
1897
 
1900
1898
  end
1901
1899
 
1902
- joined_file_contents = joined_file_contents.sub(line,output_statement)
1900
+ joined_file_contents = joined_file_contents.sub(line, output_statement)
1903
1901
 
1904
1902
  end
1905
1903
 
@@ -1917,9 +1915,9 @@ def compile(input_file_path,*output_file_name)
1917
1915
 
1918
1916
  end
1919
1917
 
1920
- def compile_regular_if(input_file_contents,temporary_nila_file)
1918
+ def compile_regular_if(input_file_contents, temporary_nila_file)
1921
1919
 
1922
- def convert_string_to_array(input_string,temporary_nila_file)
1920
+ def convert_string_to_array(input_string, temporary_nila_file)
1923
1921
 
1924
1922
  file_id = open(temporary_nila_file, 'w')
1925
1923
 
@@ -1933,7 +1931,7 @@ def compile(input_file_path,*output_file_name)
1933
1931
 
1934
1932
  end
1935
1933
 
1936
- def extract_if_blocks(if_statement_indexes,input_file_contents)
1934
+ def extract_if_blocks(if_statement_indexes, input_file_contents)
1937
1935
 
1938
1936
  possible_if_blocks = []
1939
1937
 
@@ -1961,7 +1959,7 @@ def compile(input_file_path,*output_file_name)
1961
1959
 
1962
1960
  current_block += block
1963
1961
 
1964
- current_block.each_with_index do |line,index|
1962
+ current_block.each_with_index do |line, index|
1965
1963
 
1966
1964
  if line.strip.eql? "end"
1967
1965
 
@@ -2005,7 +2003,7 @@ def compile(input_file_path,*output_file_name)
2005
2003
 
2006
2004
  end_index = []
2007
2005
 
2008
- current_block.each_with_index do |line,index|
2006
+ current_block.each_with_index do |line, index|
2009
2007
 
2010
2008
  if line.strip.eql? "end"
2011
2009
 
@@ -2023,7 +2021,7 @@ def compile(input_file_path,*output_file_name)
2023
2021
 
2024
2022
  end
2025
2023
 
2026
- return current_block,extracted_blocks
2024
+ return current_block, extracted_blocks
2027
2025
 
2028
2026
  end
2029
2027
 
@@ -2035,17 +2033,17 @@ def compile(input_file_path,*output_file_name)
2035
2033
 
2036
2034
  modified_input_block = input_block.dup
2037
2035
 
2038
- input_block.each_with_index do |line,index|
2036
+ input_block.each_with_index do |line, index|
2039
2037
 
2040
2038
  if line.include?("\"")
2041
2039
 
2042
2040
  opening_quotes = line.index("\"")
2043
2041
 
2044
- string_extract = line[opening_quotes..line.index("\"",opening_quotes+1)]
2042
+ string_extract = line[opening_quotes..line.index("\"", opening_quotes+1)]
2045
2043
 
2046
2044
  strings << string_extract
2047
2045
 
2048
- modified_input_block[index] = modified_input_block[index].sub(string_extract,"--string{#{string_counter}}")
2046
+ modified_input_block[index] = modified_input_block[index].sub(string_extract, "--string{#{string_counter}}")
2049
2047
 
2050
2048
  string_counter += 1
2051
2049
 
@@ -2059,23 +2057,23 @@ def compile(input_file_path,*output_file_name)
2059
2057
 
2060
2058
  starting_line = starting_line + "\n" if starting_line.lstrip == starting_line
2061
2059
 
2062
- junk,condition = starting_line.split("if")
2060
+ junk, condition = starting_line.split("if")
2063
2061
 
2064
- input_block[0] = "Euuf (#{condition.lstrip.rstrip.gsub("?","")}) {\n"
2062
+ input_block[0] = "Euuf (#{condition.lstrip.rstrip.gsub("?", "")}) {\n"
2065
2063
 
2066
- input_block[-1] = input_block[-1].lstrip.sub("end","}")
2064
+ input_block[-1] = input_block[-1].lstrip.sub("end", "}")
2067
2065
 
2068
- elsif_statements = input_block.reject {|element| !element.include?("elsuf")}
2066
+ elsif_statements = input_block.reject { |element| !element.include?("elsuf") }
2069
2067
 
2070
2068
  elsif_statements.each do |statement|
2071
2069
 
2072
- junk,condition = statement.split("elsuf")
2070
+ junk, condition = statement.split("elsuf")
2073
2071
 
2074
- input_block[input_block.index(statement)] = "} elsuf (#{condition.lstrip.rstrip.gsub("?","")}) {\n"
2072
+ input_block[input_block.index(statement)] = "} elsuf (#{condition.lstrip.rstrip.gsub("?", "")}) {\n"
2075
2073
 
2076
2074
  end
2077
2075
 
2078
- else_statements = input_block.reject {|element| !element.include?("else")}
2076
+ else_statements = input_block.reject { |element| !element.include?("else") }
2079
2077
 
2080
2078
  else_statements.each do |statement|
2081
2079
 
@@ -2085,15 +2083,15 @@ def compile(input_file_path,*output_file_name)
2085
2083
 
2086
2084
  modified_input_block = input_block.dup
2087
2085
 
2088
- input_block.each_with_index do |line,index|
2086
+ input_block.each_with_index do |line, index|
2089
2087
 
2090
2088
  if line.include?("--string{")
2091
2089
 
2092
- junk,remains = line.split("--string{")
2090
+ junk, remains = line.split("--string{")
2093
2091
 
2094
- string_index,junk = remains.split("}")
2092
+ string_index, junk = remains.split("}")
2095
2093
 
2096
- modified_input_block[index] = modified_input_block[index].sub("--string{#{string_index.strip}}",strings[string_index.strip.to_i])
2094
+ modified_input_block[index] = modified_input_block[index].sub("--string{#{string_index.strip}}", strings[string_index.strip.to_i])
2097
2095
 
2098
2096
  end
2099
2097
 
@@ -2103,13 +2101,13 @@ def compile(input_file_path,*output_file_name)
2103
2101
 
2104
2102
  end
2105
2103
 
2106
- input_file_contents = input_file_contents.collect {|element| element.sub("elsif","elsuf")}
2104
+ input_file_contents = input_file_contents.collect { |element| element.sub("elsif", "elsuf") }
2107
2105
 
2108
- possible_if_statements = input_file_contents.reject {|element| !element.include?("if")}
2106
+ possible_if_statements = input_file_contents.reject { |element| !element.include?("if") }
2109
2107
 
2110
- possible_if_statements = possible_if_statements.reject {|element| element.include?("else")}
2108
+ possible_if_statements = possible_if_statements.reject { |element| element.include?("else") }
2111
2109
 
2112
- possible_if_statements = possible_if_statements.reject {|element| element.lstrip.include?(" if ")}
2110
+ possible_if_statements = possible_if_statements.reject { |element| element.lstrip.include?(" if ") }
2113
2111
 
2114
2112
  if !possible_if_statements.empty?
2115
2113
 
@@ -2117,7 +2115,7 @@ def compile(input_file_path,*output_file_name)
2117
2115
 
2118
2116
  possible_if_statements.each do |statement|
2119
2117
 
2120
- if_statement_indexes << input_file_contents.dup.each_index.select {|index| input_file_contents[index] == statement}
2118
+ if_statement_indexes << input_file_contents.dup.each_index.select { |index| input_file_contents[index] == statement }
2121
2119
 
2122
2120
  end
2123
2121
 
@@ -2125,11 +2123,11 @@ def compile(input_file_path,*output_file_name)
2125
2123
 
2126
2124
  controlregexp = /(while |def )/
2127
2125
 
2128
- modified_input_contents,extracted_statements = extract_if_blocks(if_statement_indexes,input_file_contents.clone)
2126
+ modified_input_contents, extracted_statements = extract_if_blocks(if_statement_indexes, input_file_contents.clone)
2129
2127
 
2130
- joined_blocks = extracted_statements.collect {|element| element.join}
2128
+ joined_blocks = extracted_statements.collect { |element| element.join }
2131
2129
 
2132
- if_statements = joined_blocks.reject {|element| element.index(controlregexp) != nil}
2130
+ if_statements = joined_blocks.reject { |element| element.index(controlregexp) != nil }
2133
2131
 
2134
2132
  rejected_elements = joined_blocks - if_statements
2135
2133
 
@@ -2137,7 +2135,7 @@ def compile(input_file_path,*output_file_name)
2137
2135
 
2138
2136
  rejected_elements.each do |element|
2139
2137
 
2140
- rejected_elements_index << joined_blocks.each_index.select {|index| joined_blocks[index] == element}
2138
+ rejected_elements_index << joined_blocks.each_index.select { |index| joined_blocks[index] == element }
2141
2139
 
2142
2140
  end
2143
2141
 
@@ -2147,13 +2145,13 @@ def compile(input_file_path,*output_file_name)
2147
2145
 
2148
2146
  if_blocks_index -= rejected_elements_index
2149
2147
 
2150
- modified_if_statements = if_statements.collect {|string| convert_string_to_array(string,temporary_nila_file)}
2148
+ modified_if_statements = if_statements.collect { |string| convert_string_to_array(string, temporary_nila_file) }
2151
2149
 
2152
- modified_if_statements = modified_if_statements.collect {|block| compile_if_syntax(block)}.reverse
2150
+ modified_if_statements = modified_if_statements.collect { |block| compile_if_syntax(block) }.reverse
2153
2151
 
2154
- if_blocks_index = if_blocks_index.collect {|element| "--ifblock#{element}"}.reverse
2152
+ if_blocks_index = if_blocks_index.collect { |element| "--ifblock#{element}" }.reverse
2155
2153
 
2156
- rejected_elements_index = rejected_elements_index.collect {|element| "--ifblock#{element}"}.reverse
2154
+ rejected_elements_index = rejected_elements_index.collect { |element| "--ifblock#{element}" }.reverse
2157
2155
 
2158
2156
  rejected_elements = rejected_elements.reverse
2159
2157
 
@@ -2165,7 +2163,7 @@ def compile(input_file_path,*output_file_name)
2165
2163
 
2166
2164
  if joined_file_contents.include?(if_blocks_index[0])
2167
2165
 
2168
- joined_file_contents = joined_file_contents.sub(if_blocks_index[0],modified_if_statements[0].join)
2166
+ joined_file_contents = joined_file_contents.sub(if_blocks_index[0], modified_if_statements[0].join)
2169
2167
 
2170
2168
  if_blocks_index.delete_at(0)
2171
2169
 
@@ -2173,7 +2171,7 @@ def compile(input_file_path,*output_file_name)
2173
2171
 
2174
2172
  else
2175
2173
 
2176
- joined_file_contents = joined_file_contents.sub(rejected_elements_index[0],rejected_elements[0])
2174
+ joined_file_contents = joined_file_contents.sub(rejected_elements_index[0], rejected_elements[0])
2177
2175
 
2178
2176
  rejected_elements_index.delete_at(0)
2179
2177
 
@@ -2183,7 +2181,7 @@ def compile(input_file_path,*output_file_name)
2183
2181
 
2184
2182
  else
2185
2183
 
2186
- joined_file_contents = joined_file_contents.sub(rejected_elements_index[0],rejected_elements[0])
2184
+ joined_file_contents = joined_file_contents.sub(rejected_elements_index[0], rejected_elements[0])
2187
2185
 
2188
2186
  rejected_elements_index.delete_at(0)
2189
2187
 
@@ -2211,9 +2209,9 @@ def compile(input_file_path,*output_file_name)
2211
2209
 
2212
2210
  end
2213
2211
 
2214
- def compile_regular_while(input_file_contents,temporary_nila_file)
2212
+ def compile_regular_while(input_file_contents, temporary_nila_file)
2215
2213
 
2216
- def convert_string_to_array(input_string,temporary_nila_file)
2214
+ def convert_string_to_array(input_string, temporary_nila_file)
2217
2215
 
2218
2216
  file_id = open(temporary_nila_file, 'w')
2219
2217
 
@@ -2227,7 +2225,7 @@ def compile(input_file_path,*output_file_name)
2227
2225
 
2228
2226
  end
2229
2227
 
2230
- def extract_while_blocks(while_statement_indexes,input_file_contents)
2228
+ def extract_while_blocks(while_statement_indexes, input_file_contents)
2231
2229
 
2232
2230
  possible_while_blocks = []
2233
2231
 
@@ -2255,7 +2253,7 @@ def compile(input_file_path,*output_file_name)
2255
2253
 
2256
2254
  current_block += block
2257
2255
 
2258
- current_block.each_with_index do |line,index|
2256
+ current_block.each_with_index do |line, index|
2259
2257
 
2260
2258
  if line.strip.eql? "end"
2261
2259
 
@@ -2299,7 +2297,7 @@ def compile(input_file_path,*output_file_name)
2299
2297
 
2300
2298
  end_index = []
2301
2299
 
2302
- current_block.each_with_index do |line,index|
2300
+ current_block.each_with_index do |line, index|
2303
2301
 
2304
2302
  if line.strip.eql? "end"
2305
2303
 
@@ -2317,7 +2315,7 @@ def compile(input_file_path,*output_file_name)
2317
2315
 
2318
2316
  end
2319
2317
 
2320
- return current_block,extracted_blocks
2318
+ return current_block, extracted_blocks
2321
2319
 
2322
2320
  end
2323
2321
 
@@ -2329,17 +2327,17 @@ def compile(input_file_path,*output_file_name)
2329
2327
 
2330
2328
  string_counter = 0
2331
2329
 
2332
- input_block.each_with_index do |line,index|
2330
+ input_block.each_with_index do |line, index|
2333
2331
 
2334
2332
  if line.include?("\"")
2335
2333
 
2336
2334
  opening_quotes = line.index("\"")
2337
2335
 
2338
- string_extract = line[opening_quotes..line.index("\"",opening_quotes+1)]
2336
+ string_extract = line[opening_quotes..line.index("\"", opening_quotes+1)]
2339
2337
 
2340
2338
  strings << string_extract
2341
2339
 
2342
- modified_input_block[index] = modified_input_block[index].sub(string_extract,"--string{#{string_counter}}")
2340
+ modified_input_block[index] = modified_input_block[index].sub(string_extract, "--string{#{string_counter}}")
2343
2341
 
2344
2342
  string_counter += 1
2345
2343
 
@@ -2353,23 +2351,23 @@ def compile(input_file_path,*output_file_name)
2353
2351
 
2354
2352
  starting_line = starting_line + "\n" if starting_line.lstrip == starting_line
2355
2353
 
2356
- junk,condition = starting_line.split("while")
2354
+ junk, condition = starting_line.split("while")
2357
2355
 
2358
- input_block[0] = "whaaleskey (#{condition.lstrip.rstrip.gsub("?","")}) {\n"
2356
+ input_block[0] = "whaaleskey (#{condition.lstrip.rstrip.gsub("?", "")}) {\n"
2359
2357
 
2360
- input_block[-1] = input_block[-1].lstrip.sub("end","}")
2358
+ input_block[-1] = input_block[-1].lstrip.sub("end", "}")
2361
2359
 
2362
2360
  modified_input_block = input_block.dup
2363
2361
 
2364
- input_block.each_with_index do |line,index|
2362
+ input_block.each_with_index do |line, index|
2365
2363
 
2366
2364
  if line.include?("--string{")
2367
2365
 
2368
- junk,remains = line.split("--string{")
2366
+ junk, remains = line.split("--string{")
2369
2367
 
2370
- string_index,junk = remains.split("}")
2368
+ string_index, junk = remains.split("}")
2371
2369
 
2372
- modified_input_block[index] = modified_input_block[index].sub("--string{#{string_index.strip}}",strings[string_index.strip.to_i])
2370
+ modified_input_block[index] = modified_input_block[index].sub("--string{#{string_index.strip}}", strings[string_index.strip.to_i])
2373
2371
 
2374
2372
  end
2375
2373
 
@@ -2379,7 +2377,7 @@ def compile(input_file_path,*output_file_name)
2379
2377
 
2380
2378
  end
2381
2379
 
2382
- possible_while_statements = input_file_contents.reject {|element| !element.include?("while")}
2380
+ possible_while_statements = input_file_contents.reject { |element| !element.include?("while") }
2383
2381
 
2384
2382
  if !possible_while_statements.empty?
2385
2383
 
@@ -2387,7 +2385,7 @@ def compile(input_file_path,*output_file_name)
2387
2385
 
2388
2386
  possible_while_statements.each do |statement|
2389
2387
 
2390
- while_statement_indexes << input_file_contents.dup.each_index.select {|index| input_file_contents[index] == statement}
2388
+ while_statement_indexes << input_file_contents.dup.each_index.select { |index| input_file_contents[index] == statement }
2391
2389
 
2392
2390
  end
2393
2391
 
@@ -2395,11 +2393,11 @@ def compile(input_file_path,*output_file_name)
2395
2393
 
2396
2394
  controlregexp = /(if |def )/
2397
2395
 
2398
- modified_input_contents,extracted_statements = extract_while_blocks(while_statement_indexes,input_file_contents.clone)
2396
+ modified_input_contents, extracted_statements = extract_while_blocks(while_statement_indexes, input_file_contents.clone)
2399
2397
 
2400
- joined_blocks = extracted_statements.collect {|element| element.join}
2398
+ joined_blocks = extracted_statements.collect { |element| element.join }
2401
2399
 
2402
- while_statements = joined_blocks.reject {|element| element.index(controlregexp) != nil}
2400
+ while_statements = joined_blocks.reject { |element| element.index(controlregexp) != nil }
2403
2401
 
2404
2402
  rejected_elements = joined_blocks - while_statements
2405
2403
 
@@ -2407,7 +2405,7 @@ def compile(input_file_path,*output_file_name)
2407
2405
 
2408
2406
  rejected_elements.each do |element|
2409
2407
 
2410
- rejected_elements_index << joined_blocks.each_index.select {|index| joined_blocks[index] == element}
2408
+ rejected_elements_index << joined_blocks.each_index.select { |index| joined_blocks[index] == element }
2411
2409
 
2412
2410
  end
2413
2411
 
@@ -2417,13 +2415,13 @@ def compile(input_file_path,*output_file_name)
2417
2415
 
2418
2416
  while_blocks_index -= rejected_elements_index
2419
2417
 
2420
- modified_while_statements = while_statements.collect {|string| convert_string_to_array(string,temporary_nila_file)}
2418
+ modified_while_statements = while_statements.collect { |string| convert_string_to_array(string, temporary_nila_file) }
2421
2419
 
2422
- modified_while_statements = modified_while_statements.collect {|block| compile_while_syntax(block)}.reverse
2420
+ modified_while_statements = modified_while_statements.collect { |block| compile_while_syntax(block) }.reverse
2423
2421
 
2424
- while_blocks_index = while_blocks_index.collect {|element| "--whileblock#{element}"}.reverse
2422
+ while_blocks_index = while_blocks_index.collect { |element| "--whileblock#{element}" }.reverse
2425
2423
 
2426
- rejected_elements_index = rejected_elements_index.collect {|element| "--whileblock#{element}"}.reverse
2424
+ rejected_elements_index = rejected_elements_index.collect { |element| "--whileblock#{element}" }.reverse
2427
2425
 
2428
2426
  rejected_elements = rejected_elements.reverse
2429
2427
 
@@ -2435,7 +2433,7 @@ def compile(input_file_path,*output_file_name)
2435
2433
 
2436
2434
  if joined_file_contents.include?(while_blocks_index[0])
2437
2435
 
2438
- joined_file_contents = joined_file_contents.sub(while_blocks_index[0],modified_while_statements[0].join)
2436
+ joined_file_contents = joined_file_contents.sub(while_blocks_index[0], modified_while_statements[0].join)
2439
2437
 
2440
2438
  while_blocks_index.delete_at(0)
2441
2439
 
@@ -2443,7 +2441,7 @@ def compile(input_file_path,*output_file_name)
2443
2441
 
2444
2442
  else
2445
2443
 
2446
- joined_file_contents = joined_file_contents.sub(rejected_elements_index[0],rejected_elements[0].join)
2444
+ joined_file_contents = joined_file_contents.sub(rejected_elements_index[0], rejected_elements[0].join)
2447
2445
 
2448
2446
  rejected_elements_index.delete_at(0)
2449
2447
 
@@ -2453,7 +2451,7 @@ def compile(input_file_path,*output_file_name)
2453
2451
 
2454
2452
  else
2455
2453
 
2456
- joined_file_contents = joined_file_contents.sub(rejected_elements_index[0],rejected_elements[0].join)
2454
+ joined_file_contents = joined_file_contents.sub(rejected_elements_index[0], rejected_elements[0].join)
2457
2455
 
2458
2456
  rejected_elements_index.delete_at(0)
2459
2457
 
@@ -2491,7 +2489,7 @@ def compile(input_file_path,*output_file_name)
2491
2489
 
2492
2490
  rejected_line_counter = 0
2493
2491
 
2494
- input_block.each_with_index do |line,index|
2492
+ input_block.each_with_index do |line, index|
2495
2493
 
2496
2494
  if line.lstrip.index(rejectionregexp) != nil
2497
2495
 
@@ -2505,11 +2503,11 @@ def compile(input_file_path,*output_file_name)
2505
2503
 
2506
2504
  end
2507
2505
 
2508
- return modified_input_block,rejected_lines
2506
+ return modified_input_block, rejected_lines
2509
2507
 
2510
2508
  end
2511
2509
 
2512
- def replace_statement_modifiers(input_block,rejected_lines)
2510
+ def replace_statement_modifiers(input_block, rejected_lines)
2513
2511
 
2514
2512
  unless rejected_lines.empty?
2515
2513
 
@@ -2523,7 +2521,7 @@ def compile(input_file_path,*output_file_name)
2523
2521
 
2524
2522
  rejected_replacements.each do |replacement_string|
2525
2523
 
2526
- input_block.each_with_index do |line,index|
2524
+ input_block.each_with_index do |line, index|
2527
2525
 
2528
2526
  break if line.include?(replacement_string.rstrip)
2529
2527
 
@@ -2537,7 +2535,7 @@ def compile(input_file_path,*output_file_name)
2537
2535
 
2538
2536
  end
2539
2537
 
2540
- indices.each_with_index do |location,index|
2538
+ indices.each_with_index do |location, index|
2541
2539
 
2542
2540
  input_block[location] = rejected_lines.values[index] + "\n\n"
2543
2541
 
@@ -2549,17 +2547,17 @@ def compile(input_file_path,*output_file_name)
2549
2547
 
2550
2548
  end
2551
2549
 
2552
- file_contents,rejected_lines = ignore_statement_modifiers(input_file_contents)
2550
+ file_contents, rejected_lines = ignore_statement_modifiers(input_file_contents)
2553
2551
 
2554
2552
  file_contents = replace_unless_until(file_contents)
2555
2553
 
2556
- file_contents = compile_regular_if(file_contents,temporary_nila_file)
2554
+ file_contents = compile_regular_if(file_contents, temporary_nila_file)
2557
2555
 
2558
- file_contents = compile_regular_while(file_contents,temporary_nila_file)
2556
+ file_contents = compile_regular_while(file_contents, temporary_nila_file)
2559
2557
 
2560
- file_contents = replace_statement_modifiers(file_contents,rejected_lines)
2558
+ file_contents = replace_statement_modifiers(file_contents, rejected_lines)
2561
2559
 
2562
- file_contents = compile_inline_conditionals(file_contents,temporary_nila_file)
2560
+ file_contents = compile_inline_conditionals(file_contents, temporary_nila_file)
2563
2561
 
2564
2562
  return file_contents
2565
2563
 
@@ -2639,7 +2637,7 @@ def compile(input_file_path,*output_file_name)
2639
2637
 
2640
2638
  end
2641
2639
 
2642
- def compile_comments(input_file_contents,comments,temporary_nila_file)
2640
+ def compile_comments(input_file_contents, comments, temporary_nila_file)
2643
2641
 
2644
2642
  #This method converts Nila comments into pure Javascript comments. This method
2645
2643
  #handles both single line and multiline comments.
@@ -2654,27 +2652,27 @@ def compile(input_file_path,*output_file_name)
2654
2652
 
2655
2653
  multi_line_comment_counter = 1
2656
2654
 
2657
- ignorable_keywords = [/if/,/while/,/function/]
2655
+ ignorable_keywords = [/if/, /while/, /function/]
2658
2656
 
2659
- dummy_replacement_words = ["eeuuff","whaalesskkey","conffoolotion"]
2657
+ dummy_replacement_words = ["eeuuff", "whaalesskkey", "conffoolotion"]
2660
2658
 
2661
2659
  for x in 0...single_line_comments.length
2662
2660
 
2663
2661
  current_singleline_comment = "--single_line_comment[#{single_line_comment_counter}]"
2664
2662
 
2665
- replacement_singleline_string = single_line_comments[x].sub("#","//")
2663
+ replacement_singleline_string = single_line_comments[x].sub("#", "//")
2666
2664
 
2667
- ignorable_keywords.each_with_index do |keyword,index|
2665
+ ignorable_keywords.each_with_index do |keyword, index|
2668
2666
 
2669
2667
  if replacement_singleline_string.index(keyword) != nil
2670
2668
 
2671
- replacement_singleline_string = replacement_singleline_string.sub(keyword.inspect[1...-1],dummy_replacement_words[index])
2669
+ replacement_singleline_string = replacement_singleline_string.sub(keyword.inspect[1...-1], dummy_replacement_words[index])
2672
2670
 
2673
2671
  end
2674
2672
 
2675
2673
  end
2676
2674
 
2677
- file_contents_as_string = file_contents_as_string.sub(current_singleline_comment,replacement_singleline_string)
2675
+ file_contents_as_string = file_contents_as_string.sub(current_singleline_comment, replacement_singleline_string)
2678
2676
 
2679
2677
  single_line_comment_counter += 1
2680
2678
 
@@ -2685,21 +2683,21 @@ def compile(input_file_path,*output_file_name)
2685
2683
 
2686
2684
  current_multiline_comment = "--multiline_comment[#{multi_line_comment_counter}]"
2687
2685
 
2688
- replacement_multiline_string = multiline_comments[y].sub("=begin","/*\n")
2686
+ replacement_multiline_string = multiline_comments[y].sub("=begin", "/*\n")
2689
2687
 
2690
- replacement_multiline_string = replacement_multiline_string.sub("=end","\n*/")
2688
+ replacement_multiline_string = replacement_multiline_string.sub("=end", "\n*/")
2691
2689
 
2692
- ignorable_keywords.each_with_index do |keyword,index|
2690
+ ignorable_keywords.each_with_index do |keyword, index|
2693
2691
 
2694
2692
  if replacement_multiline_string.index(keyword) != nil
2695
2693
 
2696
- replacement_multiline_string = replacement_multiline_string.sub(keyword.inspect[1...-1],dummy_replacement_words[index])
2694
+ replacement_multiline_string = replacement_multiline_string.sub(keyword.inspect[1...-1], dummy_replacement_words[index])
2697
2695
 
2698
2696
  end
2699
2697
 
2700
2698
  end
2701
2699
 
2702
- file_contents_as_string = file_contents_as_string.sub(current_multiline_comment,replacement_multiline_string)
2700
+ file_contents_as_string = file_contents_as_string.sub(current_multiline_comment, replacement_multiline_string)
2703
2701
 
2704
2702
  multi_line_comment_counter += 1
2705
2703
 
@@ -2717,7 +2715,7 @@ def compile(input_file_path,*output_file_name)
2717
2715
 
2718
2716
  end
2719
2717
 
2720
- def pretty_print_javascript(javascript_file_contents,temporary_nila_file)
2718
+ def pretty_print_javascript(javascript_file_contents, temporary_nila_file)
2721
2719
 
2722
2720
  def reset_tabs(input_file_contents)
2723
2721
 
@@ -2743,7 +2741,7 @@ def compile(input_file_path,*output_file_name)
2743
2741
 
2744
2742
  end
2745
2743
 
2746
- def find_all_matching_indices(input_string,pattern)
2744
+ def find_all_matching_indices(input_string, pattern)
2747
2745
 
2748
2746
  locations = []
2749
2747
 
@@ -2753,7 +2751,7 @@ def compile(input_file_path,*output_file_name)
2753
2751
 
2754
2752
  locations << index
2755
2753
 
2756
- index = input_string.index(pattern,index+1)
2754
+ index = input_string.index(pattern, index+1)
2757
2755
 
2758
2756
 
2759
2757
  end
@@ -2763,7 +2761,7 @@ def compile(input_file_path,*output_file_name)
2763
2761
 
2764
2762
  end
2765
2763
 
2766
- def convert_string_to_array(input_string,temporary_nila_file)
2764
+ def convert_string_to_array(input_string, temporary_nila_file)
2767
2765
 
2768
2766
  file_id = open(temporary_nila_file, 'w')
2769
2767
 
@@ -2783,9 +2781,9 @@ def compile(input_file_path,*output_file_name)
2783
2781
 
2784
2782
  javascript_regexp = /(if |while |function |function\()/
2785
2783
 
2786
- block_starting_lines = file_contents.dup.reject { |element| element.index(javascript_regexp).nil?}[1..-1]
2784
+ block_starting_lines = file_contents.dup.reject { |element| element.index(javascript_regexp).nil? }[1..-1]
2787
2785
 
2788
- block_starting_lines = block_starting_lines.reject { |element| element.include?(" ")}
2786
+ block_starting_lines = block_starting_lines.reject { |element| element.include?(" ") }
2789
2787
 
2790
2788
  initial_starting_lines = block_starting_lines.dup
2791
2789
 
@@ -2807,31 +2805,31 @@ def compile(input_file_path,*output_file_name)
2807
2805
 
2808
2806
  begin
2809
2807
 
2810
- for x in 0...initial_starting_lines.length
2808
+ for x in 0...initial_starting_lines.length
2811
2809
 
2812
- code_blocks << modified_file_contents[starting_index..block_ending_lines[0]]
2810
+ code_blocks << modified_file_contents[starting_index..block_ending_lines[0]]
2813
2811
 
2814
- modified_file_contents[starting_index..block_ending_lines[0]] = []
2812
+ modified_file_contents[starting_index..block_ending_lines[0]] = []
2815
2813
 
2816
- modified_file_contents.insert(starting_index," *****")
2814
+ modified_file_contents.insert(starting_index, " *****")
2817
2815
 
2818
- block_starting_lines = modified_file_contents.dup.reject { |element| element.index(javascript_regexp).nil?}[1..-1]
2816
+ block_starting_lines = modified_file_contents.dup.reject { |element| element.index(javascript_regexp).nil? }[1..-1]
2819
2817
 
2820
- block_starting_lines = block_starting_lines.reject { |element| element.include?(" ")}
2818
+ block_starting_lines = block_starting_lines.reject { |element| element.include?(" ") }
2821
2819
 
2822
- starting_line_indices = []
2820
+ starting_line_indices = []
2823
2821
 
2824
- block_starting_lines.each do |line|
2822
+ block_starting_lines.each do |line|
2825
2823
 
2826
- starting_line_indices << modified_file_contents.index(line)
2824
+ starting_line_indices << modified_file_contents.index(line)
2827
2825
 
2828
- end
2826
+ end
2829
2827
 
2830
- block_ending_lines = modified_file_contents.dup.each_index.select { |index| modified_file_contents[index].eql? " }\n" }
2828
+ block_ending_lines = modified_file_contents.dup.each_index.select { |index| modified_file_contents[index].eql? " }\n" }
2831
2829
 
2832
- starting_index = starting_line_indices[0]
2830
+ starting_index = starting_line_indices[0]
2833
2831
 
2834
- end
2832
+ end
2835
2833
 
2836
2834
  rescue TypeError
2837
2835
 
@@ -2843,19 +2841,19 @@ def compile(input_file_path,*output_file_name)
2843
2841
 
2844
2842
  end
2845
2843
 
2846
- return modified_file_contents,code_blocks
2844
+ return modified_file_contents, code_blocks
2847
2845
 
2848
2846
  end
2849
2847
 
2850
- compact_contents = file_contents.reject {|element| element.lstrip.eql? ""}
2848
+ compact_contents = file_contents.reject { |element| element.lstrip.eql? "" }
2851
2849
 
2852
- compact_contents,code_blocks = extract_blocks(compact_contents)
2850
+ compact_contents, code_blocks = extract_blocks(compact_contents)
2853
2851
 
2854
- processed_contents = compact_contents[1...-1].collect {|line| line+"\n"}
2852
+ processed_contents = compact_contents[1...-1].collect { |line| line+"\n" }
2855
2853
 
2856
2854
  compact_contents = [compact_contents[0]] + processed_contents + [compact_contents[-1]]
2857
2855
 
2858
- code_block_locations = compact_contents.each_index.select { |index| compact_contents[index].eql? " *****\n"}
2856
+ code_block_locations = compact_contents.each_index.select { |index| compact_contents[index].eql? " *****\n" }
2859
2857
 
2860
2858
  initial_locations = code_block_locations.dup
2861
2859
 
@@ -2867,7 +2865,7 @@ def compile(input_file_path,*output_file_name)
2867
2865
 
2868
2866
  compact_contents = compact_contents[0...starting_index] + code_blocks[x] + compact_contents[starting_index+1..-1]
2869
2867
 
2870
- code_block_locations = compact_contents.each_index.select { |index| compact_contents[index].eql? " *****\n"}
2868
+ code_block_locations = compact_contents.each_index.select { |index| compact_contents[index].eql? " *****\n" }
2871
2869
 
2872
2870
  starting_index = code_block_locations[0]
2873
2871
 
@@ -2878,13 +2876,13 @@ def compile(input_file_path,*output_file_name)
2878
2876
 
2879
2877
  end
2880
2878
 
2881
- def roll_blocks(input_file_contents,code_block_starting_locations)
2879
+ def roll_blocks(input_file_contents, code_block_starting_locations)
2882
2880
 
2883
2881
  if !code_block_starting_locations.empty?
2884
2882
 
2885
2883
  controlregexp = /(if |while |function |function\()/
2886
2884
 
2887
- code_block_starting_locations = [0,code_block_starting_locations,-1].flatten
2885
+ code_block_starting_locations = [0, code_block_starting_locations, -1].flatten
2888
2886
 
2889
2887
  possible_blocks = []
2890
2888
 
@@ -2908,7 +2906,7 @@ def compile(input_file_path,*output_file_name)
2908
2906
 
2909
2907
  current_block += block
2910
2908
 
2911
- current_block.each_with_index do |line,index|
2909
+ current_block.each_with_index do |line, index|
2912
2910
 
2913
2911
  if line.lstrip.eql? "}\n"
2914
2912
 
@@ -2952,7 +2950,7 @@ def compile(input_file_path,*output_file_name)
2952
2950
 
2953
2951
  end_index = []
2954
2952
 
2955
- current_block.each_with_index do |line,index|
2953
+ current_block.each_with_index do |line, index|
2956
2954
 
2957
2955
  if line.lstrip.eql? "}\n"
2958
2956
 
@@ -2970,11 +2968,11 @@ def compile(input_file_path,*output_file_name)
2970
2968
 
2971
2969
  end
2972
2970
 
2973
- return current_block,extracted_blocks
2971
+ return current_block, extracted_blocks
2974
2972
 
2975
2973
  else
2976
2974
 
2977
- return input_file_contents,[]
2975
+ return input_file_contents, []
2978
2976
 
2979
2977
  end
2980
2978
 
@@ -2984,11 +2982,11 @@ def compile(input_file_path,*output_file_name)
2984
2982
 
2985
2983
  fixableregexp = /(else |elsuf )/
2986
2984
 
2987
- need_fixes = input_file_contents.reject {|line| line.index(fixableregexp).nil?}
2985
+ need_fixes = input_file_contents.reject { |line| line.index(fixableregexp).nil? }
2988
2986
 
2989
2987
  need_fixes.each do |fix|
2990
2988
 
2991
- input_file_contents[input_file_contents.index(fix)] = input_file_contents[input_file_contents.index(fix)].sub(" ","")
2989
+ input_file_contents[input_file_contents.index(fix)] = input_file_contents[input_file_contents.index(fix)].sub(" ", "")
2992
2990
 
2993
2991
  end
2994
2992
 
@@ -2998,13 +2996,13 @@ def compile(input_file_path,*output_file_name)
2998
2996
 
2999
2997
  def replace_ignored_words(input_string)
3000
2998
 
3001
- ignorable_keywords = [/if/,/while/,/function/]
2999
+ ignorable_keywords = [/if/, /while/, /function/]
3002
3000
 
3003
- dummy_replacement_words = ["eeuuff","whaalesskkey","conffoolotion"]
3001
+ dummy_replacement_words = ["eeuuff", "whaalesskkey", "conffoolotion"]
3004
3002
 
3005
- dummy_replacement_words.each_with_index do |word,index|
3003
+ dummy_replacement_words.each_with_index do |word, index|
3006
3004
 
3007
- input_string = input_string.sub(word,ignorable_keywords[index].inspect[1...-1])
3005
+ input_string = input_string.sub(word, ignorable_keywords[index].inspect[1...-1])
3008
3006
 
3009
3007
  end
3010
3008
 
@@ -3014,15 +3012,15 @@ def compile(input_file_path,*output_file_name)
3014
3012
 
3015
3013
  javascript_regexp = /(if |while |function |function\()/
3016
3014
 
3017
- javascript_file_contents = javascript_file_contents.collect {|element| element.sub("Euuf","if")}
3015
+ javascript_file_contents = javascript_file_contents.collect { |element| element.sub("Euuf", "if") }
3018
3016
 
3019
- javascript_file_contents = javascript_file_contents.collect {|element| element.sub("whaaleskey","while")}
3017
+ javascript_file_contents = javascript_file_contents.collect { |element| element.sub("whaaleskey", "while") }
3020
3018
 
3021
3019
  javascript_file_contents = reset_tabs(javascript_file_contents)
3022
3020
 
3023
3021
  starting_locations = []
3024
3022
 
3025
- javascript_file_contents.each_with_index do |line,index|
3023
+ javascript_file_contents.each_with_index do |line, index|
3026
3024
 
3027
3025
  if line.index(javascript_regexp) != nil
3028
3026
 
@@ -3032,17 +3030,17 @@ def compile(input_file_path,*output_file_name)
3032
3030
 
3033
3031
  end
3034
3032
 
3035
- remaining_file_contents,blocks = roll_blocks(javascript_file_contents,starting_locations)
3033
+ remaining_file_contents, blocks = roll_blocks(javascript_file_contents, starting_locations)
3036
3034
 
3037
3035
  joined_file_contents = ""
3038
3036
 
3039
3037
  if !blocks.empty?
3040
3038
 
3041
- remaining_file_contents = remaining_file_contents.collect {|element| " " + element}
3039
+ remaining_file_contents = remaining_file_contents.collect { |element| " " + element }
3042
3040
 
3043
- main_blocks = remaining_file_contents.reject {|element| !element.include?("--block")}
3041
+ main_blocks = remaining_file_contents.reject { |element| !element.include?("--block") }
3044
3042
 
3045
- main_block_numbers = main_blocks.collect {|element| element.split("--block")[1]}
3043
+ main_block_numbers = main_blocks.collect { |element| element.split("--block")[1] }
3046
3044
 
3047
3045
  modified_blocks = main_blocks.dup
3048
3046
 
@@ -3058,13 +3056,13 @@ def compile(input_file_path,*output_file_name)
3058
3056
 
3059
3057
  soft_tabs_counter += 1
3060
3058
 
3061
- current_block = [current_block[0]] + current_block[1...-1].collect {|element| soft_tabs*(soft_tabs_counter)+element} + [current_block[-1]]
3059
+ current_block = [current_block[0]] + current_block[1...-1].collect { |element| soft_tabs*(soft_tabs_counter)+element } + [current_block[-1]]
3062
3060
 
3063
- nested_block = current_block.reject {|row| !row.include?("--block")}
3061
+ nested_block = current_block.reject { |row| !row.include?("--block") }
3064
3062
 
3065
- nested_block = nested_block.collect {|element| element.split("--block")[1]}
3063
+ nested_block = nested_block.collect { |element| element.split("--block")[1] }
3066
3064
 
3067
- nested_block = nested_block.collect {|element| element.rstrip.to_i}
3065
+ nested_block = nested_block.collect { |element| element.rstrip.to_i }
3068
3066
 
3069
3067
  modified_nested_block = nested_block.clone
3070
3068
 
@@ -3080,11 +3078,11 @@ def compile(input_file_path,*output_file_name)
3080
3078
 
3081
3079
  soft_tabs_counter += 1
3082
3080
 
3083
- nested_block_contents = [nested_block_contents[0]] + nested_block_contents[1...-1].collect {|element| soft_tabs*(soft_tabs_counter)+element} + [nested_block_contents[-1]]
3081
+ nested_block_contents = [nested_block_contents[0]] + nested_block_contents[1...-1].collect { |element| soft_tabs*(soft_tabs_counter)+element } + [nested_block_contents[-1]]
3084
3082
 
3085
- nested_block_contents = nested_block_contents.reject {|element| element.gsub(" ","").eql?("")}
3083
+ nested_block_contents = nested_block_contents.reject { |element| element.gsub(" ", "").eql?("") }
3086
3084
 
3087
- current_block = current_block.sub("--block#{block_index}",nested_block_contents.join)
3085
+ current_block = current_block.sub("--block#{block_index}", nested_block_contents.join)
3088
3086
 
3089
3087
  blocks[block_index] = nested_block_contents
3090
3088
 
@@ -3094,13 +3092,13 @@ def compile(input_file_path,*output_file_name)
3094
3092
 
3095
3093
  end
3096
3094
 
3097
- current_block = convert_string_to_array(current_block,temporary_nila_file)
3095
+ current_block = convert_string_to_array(current_block, temporary_nila_file)
3098
3096
 
3099
- nested_block = current_block.reject {|element| !element.include?("--block")}
3097
+ nested_block = current_block.reject { |element| !element.include?("--block") }
3100
3098
 
3101
- nested_block = nested_block.collect {|element| element.split("--block")[1]}
3099
+ nested_block = nested_block.collect { |element| element.split("--block")[1] }
3102
3100
 
3103
- nested_block = nested_block.collect {|element| element.rstrip.to_i}
3101
+ nested_block = nested_block.collect { |element| element.rstrip.to_i }
3104
3102
 
3105
3103
  modified_nested_block = nested_block.clone
3106
3104
 
@@ -3118,21 +3116,21 @@ def compile(input_file_path,*output_file_name)
3118
3116
 
3119
3117
  end
3120
3118
 
3121
- remaining_file_contents = ["(function() {\n",remaining_file_contents,"\n}).call(this);"].flatten
3119
+ remaining_file_contents = ["(function() {\n", remaining_file_contents, "\n}).call(this);"].flatten
3122
3120
 
3123
3121
  joined_file_contents = remaining_file_contents.join
3124
3122
 
3125
- main_blocks.each_with_index do |block_id,index|
3123
+ main_blocks.each_with_index do |block_id, index|
3126
3124
 
3127
- joined_file_contents = joined_file_contents.sub(block_id,modified_blocks[index])
3125
+ joined_file_contents = joined_file_contents.sub(block_id, modified_blocks[index])
3128
3126
 
3129
3127
  end
3130
3128
 
3131
3129
  else
3132
3130
 
3133
- remaining_file_contents = remaining_file_contents.collect {|element| " " + element}
3131
+ remaining_file_contents = remaining_file_contents.collect { |element| " " + element }
3134
3132
 
3135
- remaining_file_contents = ["(function() {\n",remaining_file_contents,"\n}).call(this);"].flatten
3133
+ remaining_file_contents = ["(function() {\n", remaining_file_contents, "\n}).call(this);"].flatten
3136
3134
 
3137
3135
  joined_file_contents = remaining_file_contents.join
3138
3136
 
@@ -3150,7 +3148,7 @@ def compile(input_file_path,*output_file_name)
3150
3148
 
3151
3149
  line_by_line_contents = fix_syntax_indentation(line_by_line_contents)
3152
3150
 
3153
- line_by_line_contents = line_by_line_contents.collect {|element| replace_ignored_words(element)}
3151
+ line_by_line_contents = line_by_line_contents.collect { |element| replace_ignored_words(element) }
3154
3152
 
3155
3153
  return line_by_line_contents
3156
3154
 
@@ -3166,9 +3164,9 @@ def compile(input_file_path,*output_file_name)
3166
3164
 
3167
3165
  matches.each do |match|
3168
3166
 
3169
- left,right = match.split("**")
3167
+ left, right = match.split("**")
3170
3168
 
3171
- input_string = input_string.sub(match,"Math.pow(#{left},#{right})")
3169
+ input_string = input_string.sub(match, "Math.pow(#{left},#{right})")
3172
3170
 
3173
3171
  end
3174
3172
 
@@ -3178,29 +3176,28 @@ def compile(input_file_path,*output_file_name)
3178
3176
 
3179
3177
  end
3180
3178
 
3181
- input_file_contents = input_file_contents.collect {|element| element.sub(" and "," && ")}
3179
+ input_file_contents = input_file_contents.collect { |element| element.sub(" and ", " && ") }
3182
3180
 
3183
- input_file_contents = input_file_contents.collect {|element| element.sub(" or "," || ")}
3181
+ input_file_contents = input_file_contents.collect { |element| element.sub(" or ", " || ") }
3184
3182
 
3185
- input_file_contents = input_file_contents.collect {|element| element.sub("==","===")}
3183
+ input_file_contents = input_file_contents.collect { |element| element.sub("==", "===") }
3186
3184
 
3187
- input_file_contents = input_file_contents.collect {|element| element.sub("!=","!==")}
3185
+ input_file_contents = input_file_contents.collect { |element| element.sub("!=", "!==") }
3188
3186
 
3189
- input_file_contents = input_file_contents.collect {|element| element.sub("elsuf","else if")}
3187
+ input_file_contents = input_file_contents.collect { |element| element.sub("elsuf", "else if") }
3190
3188
 
3191
- input_file_contents = input_file_contents.collect {|element| compile_power_operator(element)}
3189
+ input_file_contents = input_file_contents.collect { |element| compile_power_operator(element) }
3192
3190
 
3193
3191
  return input_file_contents
3194
3192
 
3195
3193
  end
3196
3194
 
3197
- def pretty_print_nila(input_file_contents,temporary_nila_file)
3198
-
3195
+ def pretty_print_nila(input_file_contents, temporary_nila_file)
3199
3196
 
3200
3197
 
3201
3198
  end
3202
3199
 
3203
- def output_javascript(file_contents,output_file,temporary_nila_file)
3200
+ def output_javascript(file_contents, output_file, temporary_nila_file)
3204
3201
 
3205
3202
  file_id = open(output_file, 'w')
3206
3203
 
@@ -3220,51 +3217,51 @@ def compile(input_file_path,*output_file_name)
3220
3217
 
3221
3218
  file_contents = extract_parsable_file(file_contents)
3222
3219
 
3223
- file_contents,multiline_comments,temp_file,output_js_file = replace_multiline_comments(file_contents,input_file_path,*output_file_name)
3220
+ file_contents, multiline_comments, temp_file, output_js_file = replace_multiline_comments(file_contents, input_file_path, *output_file_name)
3224
3221
 
3225
- file_contents,singleline_comments = replace_singleline_comments(file_contents)
3222
+ file_contents, singleline_comments = replace_singleline_comments(file_contents)
3226
3223
 
3227
3224
  file_contents = split_semicolon_seperated_expressions(file_contents)
3228
3225
 
3229
- file_contents = compile_heredocs(file_contents,temp_file)
3226
+ file_contents = compile_heredocs(file_contents, temp_file)
3230
3227
 
3231
3228
  file_contents = compile_interpolated_strings(file_contents)
3232
3229
 
3233
- file_contents = compile_conditional_structures(file_contents,temp_file)
3230
+ file_contents = compile_conditional_structures(file_contents, temp_file)
3234
3231
 
3235
- file_contents = compile_arrays(file_contents,temp_file)
3232
+ file_contents = compile_arrays(file_contents, temp_file)
3236
3233
 
3237
3234
  file_contents = compile_strings(file_contents)
3238
3235
 
3239
- file_contents = compile_default_values(file_contents,temp_file)
3236
+ file_contents = compile_default_values(file_contents, temp_file)
3240
3237
 
3241
- file_contents,named_functions,nested_functions = replace_named_functions(file_contents,temp_file)
3238
+ file_contents, named_functions, nested_functions = replace_named_functions(file_contents, temp_file)
3242
3239
 
3243
- comments = [singleline_comments,multiline_comments]
3240
+ comments = [singleline_comments, multiline_comments]
3244
3241
 
3245
- file_contents = compile_multiple_variable_initialization(file_contents,temp_file)
3242
+ file_contents = compile_parallel_assignment(file_contents, temp_file)
3246
3243
 
3247
- list_of_variables,file_contents = get_variables(file_contents,temp_file)
3244
+ list_of_variables, file_contents = get_variables(file_contents, temp_file)
3248
3245
 
3249
- file_contents, function_names = compile_named_functions(file_contents,named_functions,nested_functions,temp_file)
3246
+ file_contents, function_names = compile_named_functions(file_contents, named_functions, nested_functions, temp_file)
3250
3247
 
3251
3248
  file_contents, ruby_functions = compile_custom_function_map(file_contents)
3252
3249
 
3253
3250
  function_names << ruby_functions
3254
3251
 
3255
- file_contents = compile_whitespace_delimited_functions(file_contents,function_names,temp_file)
3252
+ file_contents = compile_whitespace_delimited_functions(file_contents, function_names, temp_file)
3256
3253
 
3257
- file_contents = remove_question_marks(file_contents,list_of_variables,temp_file)
3254
+ file_contents = remove_question_marks(file_contents, list_of_variables, temp_file)
3258
3255
 
3259
3256
  file_contents = add_semicolons(file_contents)
3260
3257
 
3261
- file_contents = compile_comments(file_contents,comments,temp_file)
3258
+ file_contents = compile_comments(file_contents, comments, temp_file)
3262
3259
 
3263
- file_contents = pretty_print_javascript(file_contents,temp_file)
3260
+ file_contents = pretty_print_javascript(file_contents, temp_file)
3264
3261
 
3265
3262
  file_contents = compile_operators(file_contents)
3266
3263
 
3267
- output_javascript(file_contents,output_js_file,temp_file)
3264
+ output_javascript(file_contents, output_js_file, temp_file)
3268
3265
 
3269
3266
  puts "Compilation is successful!"
3270
3267
 
@@ -3292,9 +3289,9 @@ def create_mac_executable(input_file)
3292
3289
 
3293
3290
  mac_file_contents = ["#!/usr/bin/env ruby\n\n"] + read_file_line_by_line(input_file)
3294
3291
 
3295
- mac_file_path = input_file.sub(".rb","")
3292
+ mac_file_path = input_file.sub(".rb", "")
3296
3293
 
3297
- file_id = open(mac_file_path,"w")
3294
+ file_id = open(mac_file_path, "w")
3298
3295
 
3299
3296
  file_id.write(mac_file_contents.join)
3300
3297
 
@@ -3302,7 +3299,7 @@ def create_mac_executable(input_file)
3302
3299
 
3303
3300
  end
3304
3301
 
3305
- def find_file_name(input_path,file_extension)
3302
+ def find_file_name(input_path, file_extension)
3306
3303
 
3307
3304
  extension_remover = input_path.split(file_extension)
3308
3305
 
@@ -3316,7 +3313,7 @@ def find_file_name(input_path,file_extension)
3316
3313
 
3317
3314
  end
3318
3315
 
3319
- def find_file_path(input_path,file_extension)
3316
+ def find_file_path(input_path, file_extension)
3320
3317
 
3321
3318
  extension_remover = input_path.split(file_extension)
3322
3319
 
@@ -3330,7 +3327,7 @@ def find_file_path(input_path,file_extension)
3330
3327
 
3331
3328
  end
3332
3329
 
3333
- nilac_version = "0.0.4.1.9"
3330
+ nilac_version = "0.0.4.2.0"
3334
3331
 
3335
3332
  opts = Slop.parse do
3336
3333
  on :c, :compile=, 'Compile Nila File', as:Array, delimiter:":"
@@ -3379,7 +3376,7 @@ opts = Slop.parse do
3379
3376
 
3380
3377
  create_mac_executable(file_path)
3381
3378
 
3382
- FileUtils.mv("#{file_path[0...-3]}","#{Dir.pwd}/bin/nilac")
3379
+ FileUtils.mv("#{file_path[0...-3]}", "#{Dir.pwd}/bin/nilac")
3383
3380
 
3384
3381
  puts "Build Successful!"
3385
3382
 
@@ -3453,7 +3450,7 @@ if opts[:compile] != nil
3453
3450
 
3454
3451
  files = Dir.glob(File.join(folder_path, "*"))
3455
3452
 
3456
- files = files.reject {|path| !path.include? ".nila"}
3453
+ files = files.reject { |path| !path.include? ".nila" }
3457
3454
 
3458
3455
  files.each do |file|
3459
3456
 
@@ -3481,7 +3478,7 @@ if opts[:compile] != nil
3481
3478
 
3482
3479
  output_file_path = output_file
3483
3480
 
3484
- compile(input_file_path,output_file_path)
3481
+ compile(input_file_path, output_file_path)
3485
3482
 
3486
3483
  elsif input[-1].eql? "/" and output[-1].eql? "/"
3487
3484
 
@@ -3497,15 +3494,15 @@ if opts[:compile] != nil
3497
3494
 
3498
3495
  files = Dir.glob(File.join(input_folder_path, "*"))
3499
3496
 
3500
- files = files.reject {|path| !path.include? ".nila"}
3497
+ files = files.reject { |path| !path.include? ".nila" }
3501
3498
 
3502
3499
  files.each do |file|
3503
3500
 
3504
3501
  input_file_path = file
3505
3502
 
3506
- output_file_path = output_folder_path + find_file_name(file,".nila") + ".js"
3503
+ output_file_path = output_folder_path + find_file_name(file, ".nila") + ".js"
3507
3504
 
3508
- compile(input_file_path,output_file_path)
3505
+ compile(input_file_path, output_file_path)
3509
3506
 
3510
3507
  end
3511
3508
 
@@ -3523,7 +3520,7 @@ elsif opts[:run] != nil
3523
3520
 
3524
3521
  compile(file_path)
3525
3522
 
3526
- js_file_name = find_file_path(file_path,".nila") + find_file_name(file_path,".nila") + ".js"
3523
+ js_file_name = find_file_path(file_path, ".nila") + find_file_name(file_path, ".nila") + ".js"
3527
3524
 
3528
3525
  node_output = `node #{js_file_name}`
3529
3526