nilac 0.0.4.1.9 → 0.0.4.2.0

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