nilac 0.0.4.3.4 → 0.0.4.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.idea/.name +1 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/encodings.xml +5 -0
- data/.idea/libraries/Generated_files.xml +13 -0
- data/.idea/misc.xml +5 -0
- data/.idea/modules.xml +9 -0
- data/.idea/nila.iml +21 -0
- data/.idea/scopes/scope_settings.xml +5 -0
- data/.idea/vcs.xml +7 -0
- data/.idea/watcherTasks.xml +26 -0
- data/.idea/workspace.xml +495 -0
- data/bin/nilac +422 -64
- data/examples/decBin.js +48 -0
- data/examples/decBin.nila +65 -0
- data/lib/nilac/version.rb +1 -1
- data/shark/features/ruby_methods.feature +11 -0
- data/shark/test_files/array_string_indexing.nila +2 -2
- data/shark/test_files/correct_default_parameters.js +1 -1
- data/shark/test_files/correct_initialization.js +1 -7
- data/shark/test_files/correct_multiple_return.js +1 -1
- data/shark/test_files/correct_regular_if.js +0 -1
- data/shark/test_files/correct_regular_while.js +0 -2
- data/shark/test_files/correct_ruby_methods.js +45 -0
- data/shark/test_files/multiple_initialization.nila +0 -2
- data/shark/test_files/regular_if.nila +0 -2
- data/shark/test_files/regular_while.nila +0 -2
- data/shark/test_files/ruby_methods.nila +23 -1
- data/src/nilac.rb +540 -64
- metadata +17 -2
data/src/nilac.rb
CHANGED
@@ -415,16 +415,56 @@ def compile(input_file_path, *output_file_name)
|
|
415
415
|
|
416
416
|
def replace_singleline_comments(input_file_contents)
|
417
417
|
|
418
|
+
def replace_strings(input_string)
|
419
|
+
|
420
|
+
string_counter = 0
|
421
|
+
|
422
|
+
if input_string.count("\"") % 2 == 0
|
423
|
+
|
424
|
+
while input_string.include?("\"")
|
425
|
+
|
426
|
+
string_extract = input_string[input_string.index("\"")..input_string.index("\"",input_string.index("\"")+1)]
|
427
|
+
|
428
|
+
input_string = input_string.sub(string_extract,"--repstring#{string_counter}")
|
429
|
+
|
430
|
+
string_counter += 1
|
431
|
+
|
432
|
+
end
|
433
|
+
|
434
|
+
end
|
435
|
+
|
436
|
+
if input_string.count("'") % 2 == 0
|
437
|
+
|
438
|
+
while input_string.include?("'")
|
439
|
+
|
440
|
+
string_extract = input_string[input_string.index("'")..input_string.index("'",input_string.index("'")+1)]
|
441
|
+
|
442
|
+
input_string = input_string.sub(string_extract,"--repstring#{string_counter}")
|
443
|
+
|
444
|
+
string_counter += 1
|
445
|
+
|
446
|
+
end
|
447
|
+
|
448
|
+
end
|
449
|
+
|
450
|
+
return input_string
|
451
|
+
|
452
|
+
end
|
453
|
+
|
418
454
|
single_line_comments = []
|
419
455
|
|
420
456
|
singleline_comment_counter = 1
|
421
457
|
|
458
|
+
modified_file_contents = input_file_contents.clone
|
459
|
+
|
422
460
|
for x in 0...input_file_contents.length
|
423
461
|
|
424
|
-
current_row = input_file_contents[x]
|
462
|
+
current_row = replace_strings(input_file_contents[x])
|
425
463
|
|
426
464
|
if current_row.include?("#")
|
427
465
|
|
466
|
+
current_row = modified_file_contents[x]
|
467
|
+
|
428
468
|
comment_start = current_row.index("#")
|
429
469
|
|
430
470
|
if current_row[comment_start+1] != "{"
|
@@ -439,13 +479,17 @@ def compile(input_file_path, *output_file_name)
|
|
439
479
|
|
440
480
|
end
|
441
481
|
|
482
|
+
else
|
483
|
+
|
484
|
+
current_row = modified_file_contents[x]
|
485
|
+
|
442
486
|
end
|
443
487
|
|
444
|
-
|
488
|
+
modified_file_contents[x] = current_row
|
445
489
|
|
446
490
|
end
|
447
491
|
|
448
|
-
return
|
492
|
+
return modified_file_contents, single_line_comments
|
449
493
|
|
450
494
|
end
|
451
495
|
|
@@ -477,7 +521,7 @@ def compile(input_file_path, *output_file_name)
|
|
477
521
|
|
478
522
|
key_word_locations << x
|
479
523
|
|
480
|
-
elsif current_row.lstrip.
|
524
|
+
elsif current_row.lstrip.eql?("end\n") || current_row.strip.eql?("end")
|
481
525
|
|
482
526
|
end_locations << x
|
483
527
|
|
@@ -525,9 +569,9 @@ def compile(input_file_path, *output_file_name)
|
|
525
569
|
|
526
570
|
modified_file_contents[code_block_begin] = code_block_begin_string
|
527
571
|
|
528
|
-
rescue NoMethodError
|
529
|
-
|
530
|
-
|
572
|
+
#rescue NoMethodError
|
573
|
+
#
|
574
|
+
# puts "Function compilation failed!"
|
531
575
|
|
532
576
|
end
|
533
577
|
|
@@ -678,7 +722,7 @@ def compile(input_file_path, *output_file_name)
|
|
678
722
|
|
679
723
|
input_file_contents = input_file_contents.collect {|element| arrayify_right_side(element)}
|
680
724
|
|
681
|
-
possible_variable_lines = input_file_contents.reject { |element| !element.include? "=" }
|
725
|
+
possible_variable_lines = input_file_contents.clone.reject { |element| !element.include? "=" }
|
682
726
|
|
683
727
|
possible_parallel_assignment = possible_variable_lines.reject { |element| !element.split("=")[0].include? "," }
|
684
728
|
|
@@ -766,10 +810,34 @@ def compile(input_file_path, *output_file_name)
|
|
766
810
|
|
767
811
|
end
|
768
812
|
|
769
|
-
|
813
|
+
reject_regexp = /(function |Euuf |if |else|elsuf|switch |case|while |whaaleskey |for )/
|
814
|
+
|
815
|
+
input_file_contents = input_file_contents.collect { |element| element.gsub("==", "equalequal") }
|
816
|
+
|
817
|
+
input_file_contents = input_file_contents.collect { |element| element.gsub("!=", "notequal") }
|
818
|
+
|
819
|
+
input_file_contents = input_file_contents.collect { |element| element.gsub("+=", "plusequal") }
|
820
|
+
|
821
|
+
input_file_contents = input_file_contents.collect { |element| element.gsub("-=", "minusequal") }
|
822
|
+
|
823
|
+
input_file_contents = input_file_contents.collect { |element| element.gsub("*=", "multiequal") }
|
824
|
+
|
825
|
+
input_file_contents = input_file_contents.collect { |element| element.gsub("/=", "divequal") }
|
826
|
+
|
827
|
+
input_file_contents = input_file_contents.collect { |element| element.gsub("%=", "modequal") }
|
828
|
+
|
829
|
+
input_file_contents = input_file_contents.collect { |element| element.gsub("=~", "matchequal") }
|
830
|
+
|
831
|
+
input_file_contents = input_file_contents.collect { |element| element.gsub(">=", "greatequal") }
|
832
|
+
|
833
|
+
input_file_contents = input_file_contents.collect { |element| element.gsub("<=", "lessyequal") }
|
834
|
+
|
835
|
+
possible_default_values = input_file_contents.dup.reject { |element| (!element.include?("def")) }
|
770
836
|
|
771
837
|
possible_default_values = possible_default_values.reject { |element| !element.include?("=") }
|
772
838
|
|
839
|
+
possible_default_values = possible_default_values.reject {|element| !element.index(reject_regexp) == nil}
|
840
|
+
|
773
841
|
if !possible_default_values.empty?
|
774
842
|
|
775
843
|
possible_default_values.each do |line|
|
@@ -802,12 +870,60 @@ def compile(input_file_path, *output_file_name)
|
|
802
870
|
|
803
871
|
line_by_line_contents = read_file_line_by_line(temporary_nila_file)
|
804
872
|
|
873
|
+
line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("plusequal", "+=") }
|
874
|
+
|
875
|
+
line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("minusequal", "-=") }
|
876
|
+
|
877
|
+
line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("multiequal", "*=") }
|
878
|
+
|
879
|
+
line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("divequal", "/=") }
|
880
|
+
|
881
|
+
line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("modequal", "%=") }
|
882
|
+
|
883
|
+
line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("equalequal", "==") }
|
884
|
+
|
885
|
+
line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("notequal", "!=") }
|
886
|
+
|
887
|
+
line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("matchequal", "=~") }
|
888
|
+
|
889
|
+
line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("greatequal", ">=") }
|
890
|
+
|
891
|
+
line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("lessyequal", "<=") }
|
892
|
+
|
805
893
|
return line_by_line_contents
|
806
894
|
|
807
895
|
end
|
808
896
|
|
809
897
|
def get_variables(input_file_contents, temporary_nila_file, *loop_variables)
|
810
898
|
|
899
|
+
def replace_strings(input_string)
|
900
|
+
|
901
|
+
string_counter = 0
|
902
|
+
|
903
|
+
while input_string.include?("\"")
|
904
|
+
|
905
|
+
string_extract = input_string[input_string.index("\"")..input_string.index("\"",input_string.index("\"")+1)]
|
906
|
+
|
907
|
+
input_string = input_string.sub(string_extract,"--repstring#{string_counter}")
|
908
|
+
|
909
|
+
string_counter += 1
|
910
|
+
|
911
|
+
end
|
912
|
+
|
913
|
+
while input_string.include?("'")
|
914
|
+
|
915
|
+
string_extract = input_string[input_string.index("'")..input_string.index("'",input_string.index("'")+1)]
|
916
|
+
|
917
|
+
input_string = input_string.sub(string_extract,"--repstring#{string_counter}")
|
918
|
+
|
919
|
+
string_counter += 1
|
920
|
+
|
921
|
+
end
|
922
|
+
|
923
|
+
return input_string
|
924
|
+
|
925
|
+
end
|
926
|
+
|
811
927
|
variables = []
|
812
928
|
|
813
929
|
input_file_contents = input_file_contents.collect { |element| element.gsub("==", "equalequal") }
|
@@ -826,6 +942,14 @@ def compile(input_file_path, *output_file_name)
|
|
826
942
|
|
827
943
|
input_file_contents = input_file_contents.collect { |element| element.gsub("=~", "matchequal") }
|
828
944
|
|
945
|
+
input_file_contents = input_file_contents.collect { |element| element.gsub(">=", "greatequal") }
|
946
|
+
|
947
|
+
input_file_contents = input_file_contents.collect { |element| element.gsub("<=", "lessyequal") }
|
948
|
+
|
949
|
+
modified_file_contents = input_file_contents.clone
|
950
|
+
|
951
|
+
input_file_contents = input_file_contents.collect {|element| replace_strings(element)}
|
952
|
+
|
829
953
|
javascript_regexp = /(if |while |for )/
|
830
954
|
|
831
955
|
for x in 0...input_file_contents.length
|
@@ -851,6 +975,8 @@ def compile(input_file_path, *output_file_name)
|
|
851
975
|
|
852
976
|
end
|
853
977
|
|
978
|
+
current_row_split[0] = current_row_split[0].split(".",2)[0].strip if current_row_split[0].include?(".")
|
979
|
+
|
854
980
|
variables << current_row_split[0]
|
855
981
|
|
856
982
|
|
@@ -860,7 +986,7 @@ def compile(input_file_path, *output_file_name)
|
|
860
986
|
|
861
987
|
end
|
862
988
|
|
863
|
-
file_contents_as_string =
|
989
|
+
file_contents_as_string = modified_file_contents.join
|
864
990
|
|
865
991
|
file_id = open(temporary_nila_file, 'w')
|
866
992
|
|
@@ -890,14 +1016,6 @@ def compile(input_file_path, *output_file_name)
|
|
890
1016
|
|
891
1017
|
variables = variables.flatten
|
892
1018
|
|
893
|
-
if variables.length > 0
|
894
|
-
|
895
|
-
variable_declaration_string = "var " + variables.uniq.sort.join(", ") + "\n\n"
|
896
|
-
|
897
|
-
line_by_line_contents = [variable_declaration_string, line_by_line_contents].flatten
|
898
|
-
|
899
|
-
end
|
900
|
-
|
901
1019
|
line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("plusequal", "+=") }
|
902
1020
|
|
903
1021
|
line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("minusequal", "-=") }
|
@@ -914,6 +1032,10 @@ def compile(input_file_path, *output_file_name)
|
|
914
1032
|
|
915
1033
|
line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("matchequal", "=~") }
|
916
1034
|
|
1035
|
+
line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("greatequal", ">=") }
|
1036
|
+
|
1037
|
+
line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("lessyequal", "<=") }
|
1038
|
+
|
917
1039
|
return variables.uniq, line_by_line_contents
|
918
1040
|
|
919
1041
|
end
|
@@ -963,7 +1085,7 @@ def compile(input_file_path, *output_file_name)
|
|
963
1085
|
|
964
1086
|
end
|
965
1087
|
|
966
|
-
def compile_arrays(input_file_contents, temporary_nila_file)
|
1088
|
+
def compile_arrays(input_file_contents, named_functions, temporary_nila_file)
|
967
1089
|
|
968
1090
|
def compile_w_arrays(input_file_contents)
|
969
1091
|
|
@@ -1065,7 +1187,7 @@ def compile(input_file_path, *output_file_name)
|
|
1065
1187
|
|
1066
1188
|
replacement_string = nil
|
1067
1189
|
|
1068
|
-
if index_end.strip == "
|
1190
|
+
if index_end.strip == "last"
|
1069
1191
|
|
1070
1192
|
replacement_string = split1 + ".slice(#{index_start},#{split}.length)\n"
|
1071
1193
|
|
@@ -1109,9 +1231,9 @@ def compile(input_file_path, *output_file_name)
|
|
1109
1231
|
|
1110
1232
|
replacement_string = nil
|
1111
1233
|
|
1112
|
-
if index_end.strip == "
|
1234
|
+
if index_end.strip == "last"
|
1113
1235
|
|
1114
|
-
replacement_string = split1 + ".slice(#{index_start})\n"
|
1236
|
+
replacement_string = split1 + ".slice(#{index_start})" + split3.strip + "\n\n"
|
1115
1237
|
|
1116
1238
|
elsif index_end.strip == "" and index_start.strip == ""
|
1117
1239
|
|
@@ -1215,7 +1337,7 @@ def compile(input_file_path, *output_file_name)
|
|
1215
1337
|
|
1216
1338
|
left, right = usage.split("<<")
|
1217
1339
|
|
1218
|
-
input_file_contents[input_file_contents.index(usage)] = left.rstrip + ".push(#{right.
|
1340
|
+
input_file_contents[input_file_contents.index(usage)] = left.rstrip + ".push(#{right.strip})\n\n"
|
1219
1341
|
|
1220
1342
|
end
|
1221
1343
|
|
@@ -1231,7 +1353,15 @@ def compile(input_file_path, *output_file_name)
|
|
1231
1353
|
|
1232
1354
|
input_file_contents = compile_array_operators(input_file_contents)
|
1233
1355
|
|
1234
|
-
|
1356
|
+
named_functions = named_functions.collect {|func| compile_w_arrays(func)}
|
1357
|
+
|
1358
|
+
named_functions = named_functions.collect { |func| compile_array_indexing(func)}
|
1359
|
+
|
1360
|
+
named_functions = named_functions.collect {|func| compile_multiline(func, temporary_nila_file)}
|
1361
|
+
|
1362
|
+
named_functions = named_functions.collect {|func| compile_array_operators(func)}
|
1363
|
+
|
1364
|
+
return input_file_contents, named_functions
|
1235
1365
|
|
1236
1366
|
|
1237
1367
|
end
|
@@ -1240,8 +1370,40 @@ def compile(input_file_path, *output_file_name)
|
|
1240
1370
|
|
1241
1371
|
def compile_multiline_hashes(input_file_contents,temporary_nila_file)
|
1242
1372
|
|
1373
|
+
def replace_strings(input_string)
|
1374
|
+
|
1375
|
+
string_counter = 0
|
1376
|
+
|
1377
|
+
while input_string.include?("\"")
|
1378
|
+
|
1379
|
+
string_extract = input_string[input_string.index("\"")..input_string.index("\"",input_string.index("\"")+1)]
|
1380
|
+
|
1381
|
+
input_string = input_string.sub(string_extract,"--repstring#{string_counter}")
|
1382
|
+
|
1383
|
+
string_counter += 1
|
1384
|
+
|
1385
|
+
end
|
1386
|
+
|
1387
|
+
while input_string.include?("'")
|
1388
|
+
|
1389
|
+
string_extract = input_string[input_string.index("'")..input_string.index("'",input_string.index("'")+1)]
|
1390
|
+
|
1391
|
+
input_string = input_string.sub(string_extract,"--repstring#{string_counter}")
|
1392
|
+
|
1393
|
+
string_counter += 1
|
1394
|
+
|
1395
|
+
end
|
1396
|
+
|
1397
|
+
return input_string
|
1398
|
+
|
1399
|
+
end
|
1400
|
+
|
1243
1401
|
javascript_regexp = /(if |while |for |function |function\()/
|
1244
1402
|
|
1403
|
+
modified_file_contents = input_file_contents.clone
|
1404
|
+
|
1405
|
+
input_file_contents = input_file_contents.collect {|line| replace_strings(line)}
|
1406
|
+
|
1245
1407
|
possible_hashes = input_file_contents.reject { |element| !element.include?("{") }
|
1246
1408
|
|
1247
1409
|
possible_multiline_hashes = possible_hashes.reject { |element| element.include?("}") }
|
@@ -1254,21 +1416,21 @@ def compile(input_file_path, *output_file_name)
|
|
1254
1416
|
|
1255
1417
|
index = input_file_contents.index(starting_line)
|
1256
1418
|
|
1257
|
-
line =
|
1419
|
+
line = modified_file_contents[index]
|
1258
1420
|
|
1259
1421
|
until line.include?("}\n")
|
1260
1422
|
|
1261
1423
|
index += 1
|
1262
1424
|
|
1263
|
-
line =
|
1425
|
+
line = modified_file_contents[index]
|
1264
1426
|
|
1265
1427
|
end
|
1266
1428
|
|
1267
|
-
multiline_hashes <<
|
1429
|
+
multiline_hashes << modified_file_contents[input_file_contents.index(starting_line)..index]
|
1268
1430
|
|
1269
1431
|
end
|
1270
1432
|
|
1271
|
-
joined_file_contents =
|
1433
|
+
joined_file_contents = modified_file_contents.join
|
1272
1434
|
|
1273
1435
|
multiline_hashes.each do |hash|
|
1274
1436
|
|
@@ -1336,6 +1498,8 @@ def compile(input_file_path, *output_file_name)
|
|
1336
1498
|
|
1337
1499
|
possible_inline_hashes = possible_inline_hashes.reject {|element| element.index(javascript_regexp) != nil}
|
1338
1500
|
|
1501
|
+
possible_inline_hashes = possible_inline_hashes.reject {|element| element.include?("{}")}
|
1502
|
+
|
1339
1503
|
possible_inline_hashes.each do |hash|
|
1340
1504
|
|
1341
1505
|
hash = input_file_contents[modified_file_contents.index(hash)]
|
@@ -1586,7 +1750,57 @@ def compile(input_file_path, *output_file_name)
|
|
1586
1750
|
#This method will pickup and declare all the variables inside a function block. In future, this method will be
|
1587
1751
|
#merged with the get variables method
|
1588
1752
|
|
1589
|
-
|
1753
|
+
def replace_strings(input_string)
|
1754
|
+
|
1755
|
+
element = input_string.gsub("==", "equalequal")
|
1756
|
+
|
1757
|
+
element = element.gsub("!=", "notequal")
|
1758
|
+
|
1759
|
+
element = element.gsub("+=", "plusequal")
|
1760
|
+
|
1761
|
+
element = element.gsub("-=", "minusequal")
|
1762
|
+
|
1763
|
+
element = element.gsub("*=", "multiequal")
|
1764
|
+
|
1765
|
+
element = element.gsub("/=", "divequal")
|
1766
|
+
|
1767
|
+
element = element.gsub("%=", "modequal")
|
1768
|
+
|
1769
|
+
element = element.gsub("=~", "matchequal")
|
1770
|
+
|
1771
|
+
element = element.gsub(">=", "greatequal")
|
1772
|
+
|
1773
|
+
input_string = element.gsub("<=", "lessyequal")
|
1774
|
+
|
1775
|
+
string_counter = 0
|
1776
|
+
|
1777
|
+
while input_string.include?("\"")
|
1778
|
+
|
1779
|
+
string_extract = input_string[input_string.index("\"")..input_string.index("\"",input_string.index("\"")+1)]
|
1780
|
+
|
1781
|
+
input_string = input_string.sub(string_extract,"--repstring#{string_counter}")
|
1782
|
+
|
1783
|
+
string_counter += 1
|
1784
|
+
|
1785
|
+
end
|
1786
|
+
|
1787
|
+
while input_string.include?("'")
|
1788
|
+
|
1789
|
+
string_extract = input_string[input_string.index("'")..input_string.index("'",input_string.index("'")+1)]
|
1790
|
+
|
1791
|
+
input_string = input_string.sub(string_extract,"--repstring#{string_counter}")
|
1792
|
+
|
1793
|
+
string_counter += 1
|
1794
|
+
|
1795
|
+
end
|
1796
|
+
|
1797
|
+
return input_string
|
1798
|
+
|
1799
|
+
end
|
1800
|
+
|
1801
|
+
input_function_block = input_function_block.collect {|element| replace_strings(element)}
|
1802
|
+
|
1803
|
+
controlregexp = /(if |Euuf |for |while |def |function |function\()/
|
1590
1804
|
|
1591
1805
|
variables = []
|
1592
1806
|
|
@@ -1670,7 +1884,7 @@ def compile(input_file_path, *output_file_name)
|
|
1670
1884
|
|
1671
1885
|
if !rejected_array[0].strip.eql?("}")
|
1672
1886
|
|
1673
|
-
if !rejected_array[0].strip.eql?("end")
|
1887
|
+
if !rejected_array[0].strip.eql?("end") and !rejected_array[0].strip.include?("--single_line_comment")
|
1674
1888
|
|
1675
1889
|
last_statement = rejected_array[0]
|
1676
1890
|
|
@@ -1996,13 +2210,25 @@ def compile(input_file_path, *output_file_name)
|
|
1996
2210
|
|
1997
2211
|
modified_file_contents = input_file_contents.dup
|
1998
2212
|
|
2213
|
+
javascript_regexp = /(if |for |while |\(function\(|= function\(|((=|:)\s+\{))/
|
2214
|
+
|
1999
2215
|
input_file_contents.each_with_index do |line, index|
|
2000
2216
|
|
2001
2217
|
function_map.each do |function|
|
2002
2218
|
|
2003
|
-
if line.include?(function+"(") or line.include?(function+" ")
|
2219
|
+
if line.include?(function+"(") or line.include?(function+" ") and line.index(javascript_regexp) == nil
|
2220
|
+
|
2221
|
+
testsplit = line.split(function)
|
2222
|
+
|
2223
|
+
testsplit = testsplit.collect {|element| element.strip}
|
2224
|
+
|
2225
|
+
testsplit[0] = " " if testsplit[0].eql?("")
|
2004
2226
|
|
2005
|
-
|
2227
|
+
if testsplit[0][-1].eql?(" ") or testsplit[0].eql?("return")
|
2228
|
+
|
2229
|
+
modified_file_contents[index] = line.sub(function, function_map_replacements[function])
|
2230
|
+
|
2231
|
+
end
|
2006
2232
|
|
2007
2233
|
end
|
2008
2234
|
|
@@ -2029,7 +2255,14 @@ def compile(input_file_path, *output_file_name)
|
|
2029
2255
|
|
2030
2256
|
".lstrip" => ".replace(/^\\s+/g,\"\")",
|
2031
2257
|
|
2032
|
-
".rstrip" => ".replace(/\\s+$/g,\"\")"
|
2258
|
+
".rstrip" => ".replace(/\\s+$/g,\"\")",
|
2259
|
+
|
2260
|
+
".to_s" => ".toString()",
|
2261
|
+
|
2262
|
+
".reverse" => ".reverse()",
|
2263
|
+
|
2264
|
+
".empty?" => ".length == 0",
|
2265
|
+
|
2033
2266
|
}
|
2034
2267
|
|
2035
2268
|
method_map = method_map_replacement.keys
|
@@ -2062,6 +2295,85 @@ def compile(input_file_path, *output_file_name)
|
|
2062
2295
|
|
2063
2296
|
end
|
2064
2297
|
|
2298
|
+
def compile_special_keywords(input_file_contents)
|
2299
|
+
|
2300
|
+
# This method compiles some Ruby specific keywords to Javascript to make it easy to port
|
2301
|
+
# Ruby code into Javascript
|
2302
|
+
|
2303
|
+
def replace_strings(input_string)
|
2304
|
+
|
2305
|
+
string_counter = 0
|
2306
|
+
|
2307
|
+
if input_string.count("\"") % 2 == 0
|
2308
|
+
|
2309
|
+
while input_string.include?("\"")
|
2310
|
+
|
2311
|
+
string_extract = input_string[input_string.index("\"")..input_string.index("\"",input_string.index("\"")+1)]
|
2312
|
+
|
2313
|
+
input_string = input_string.sub(string_extract,"--repstring#{string_counter}")
|
2314
|
+
|
2315
|
+
string_counter += 1
|
2316
|
+
|
2317
|
+
end
|
2318
|
+
|
2319
|
+
end
|
2320
|
+
|
2321
|
+
if input_string.count("'") % 2 == 0
|
2322
|
+
|
2323
|
+
while input_string.include?("'")
|
2324
|
+
|
2325
|
+
string_extract = input_string[input_string.index("'")..input_string.index("'",input_string.index("'")+1)]
|
2326
|
+
|
2327
|
+
input_string = input_string.sub(string_extract,"--repstring#{string_counter}")
|
2328
|
+
|
2329
|
+
string_counter += 1
|
2330
|
+
|
2331
|
+
end
|
2332
|
+
|
2333
|
+
end
|
2334
|
+
|
2335
|
+
return input_string
|
2336
|
+
|
2337
|
+
end
|
2338
|
+
|
2339
|
+
keyword_replacement_map = {
|
2340
|
+
|
2341
|
+
"nil" => "null",
|
2342
|
+
|
2343
|
+
"Array.new" => "Array()"
|
2344
|
+
|
2345
|
+
}
|
2346
|
+
|
2347
|
+
special_keywords = keyword_replacement_map.keys
|
2348
|
+
|
2349
|
+
keyword_map_regex = special_keywords.collect {|name| name.gsub(".","\\.")}
|
2350
|
+
|
2351
|
+
keyword_map_regex = Regexp.new(keyword_map_regex.join("|"))
|
2352
|
+
|
2353
|
+
modified_file_contents = input_file_contents.clone
|
2354
|
+
|
2355
|
+
input_file_contents.each_with_index do |line, index|
|
2356
|
+
|
2357
|
+
if replace_strings(line).match(keyword_map_regex)
|
2358
|
+
|
2359
|
+
method_match = line.match(keyword_map_regex).to_a[0]
|
2360
|
+
|
2361
|
+
if line.split(keyword_map_regex)[0].include?("=")
|
2362
|
+
|
2363
|
+
line = line.sub(method_match,keyword_replacement_map[method_match])
|
2364
|
+
|
2365
|
+
end
|
2366
|
+
|
2367
|
+
end
|
2368
|
+
|
2369
|
+
modified_file_contents[index] = line
|
2370
|
+
|
2371
|
+
end
|
2372
|
+
|
2373
|
+
return modified_file_contents
|
2374
|
+
|
2375
|
+
end
|
2376
|
+
|
2065
2377
|
def compile_whitespace_delimited_functions(input_file_contents, function_names, temporary_nila_file)
|
2066
2378
|
|
2067
2379
|
def extract(input_string, pattern_start, pattern_end)
|
@@ -2306,7 +2618,7 @@ def compile(input_file_path, *output_file_name)
|
|
2306
2618
|
|
2307
2619
|
extracted_blocks = []
|
2308
2620
|
|
2309
|
-
controlregexp = /(if |while |def )/
|
2621
|
+
controlregexp = /(if |while |def | do )/
|
2310
2622
|
|
2311
2623
|
rejectionregexp = /( if | while )/
|
2312
2624
|
|
@@ -2324,7 +2636,16 @@ def compile(input_file_path, *output_file_name)
|
|
2324
2636
|
|
2325
2637
|
possible_if_blocks.each_with_index do |block|
|
2326
2638
|
|
2327
|
-
current_block
|
2639
|
+
unless current_block[-1] == block[0]
|
2640
|
+
|
2641
|
+
current_block += block
|
2642
|
+
|
2643
|
+
else
|
2644
|
+
|
2645
|
+
current_block += block[1..-1]
|
2646
|
+
|
2647
|
+
end
|
2648
|
+
|
2328
2649
|
|
2329
2650
|
current_block.each_with_index do |line, index|
|
2330
2651
|
|
@@ -2492,7 +2813,7 @@ def compile(input_file_path, *output_file_name)
|
|
2492
2813
|
|
2493
2814
|
if_statement_indexes = [0] + if_statement_indexes.flatten + [-1]
|
2494
2815
|
|
2495
|
-
controlregexp = /(while |def )/
|
2816
|
+
controlregexp = /(while |def | do )/
|
2496
2817
|
|
2497
2818
|
modified_input_contents, extracted_statements = extract_if_blocks(if_statement_indexes, input_file_contents.clone)
|
2498
2819
|
|
@@ -2604,7 +2925,7 @@ def compile(input_file_path, *output_file_name)
|
|
2604
2925
|
|
2605
2926
|
extracted_blocks = []
|
2606
2927
|
|
2607
|
-
controlregexp = /(if |while |def )/
|
2928
|
+
controlregexp = /(if |while |def | do )/
|
2608
2929
|
|
2609
2930
|
rejectionregexp = /( if | while )/
|
2610
2931
|
|
@@ -2762,7 +3083,7 @@ def compile(input_file_path, *output_file_name)
|
|
2762
3083
|
|
2763
3084
|
while_statement_indexes = [0] + while_statement_indexes.flatten + [-1]
|
2764
3085
|
|
2765
|
-
controlregexp = /(if |def )/
|
3086
|
+
controlregexp = /(if |def | do )/
|
2766
3087
|
|
2767
3088
|
modified_input_contents, extracted_statements = extract_while_blocks(while_statement_indexes, input_file_contents.clone)
|
2768
3089
|
|
@@ -2812,7 +3133,7 @@ def compile(input_file_path, *output_file_name)
|
|
2812
3133
|
|
2813
3134
|
else
|
2814
3135
|
|
2815
|
-
joined_file_contents = joined_file_contents.sub(rejected_elements_index[0], rejected_elements[0]
|
3136
|
+
joined_file_contents = joined_file_contents.sub(rejected_elements_index[0], rejected_elements[0])
|
2816
3137
|
|
2817
3138
|
rejected_elements_index.delete_at(0)
|
2818
3139
|
|
@@ -2822,7 +3143,7 @@ def compile(input_file_path, *output_file_name)
|
|
2822
3143
|
|
2823
3144
|
else
|
2824
3145
|
|
2825
|
-
joined_file_contents = joined_file_contents.sub(rejected_elements_index[0], rejected_elements[0]
|
3146
|
+
joined_file_contents = joined_file_contents.sub(rejected_elements_index[0], rejected_elements[0])
|
2826
3147
|
|
2827
3148
|
rejected_elements_index.delete_at(0)
|
2828
3149
|
|
@@ -2874,7 +3195,7 @@ def compile(input_file_path, *output_file_name)
|
|
2874
3195
|
|
2875
3196
|
extracted_blocks = []
|
2876
3197
|
|
2877
|
-
controlregexp = /(if |while |def |for )/
|
3198
|
+
controlregexp = /(if |while |def |for | do )/
|
2878
3199
|
|
2879
3200
|
rejectionregexp = /( if | while )/
|
2880
3201
|
|
@@ -3078,7 +3399,7 @@ def compile(input_file_path, *output_file_name)
|
|
3078
3399
|
|
3079
3400
|
for_statement_indexes = [0] + for_statement_indexes.flatten + [-1]
|
3080
3401
|
|
3081
|
-
controlregexp = /(if |def |while )/
|
3402
|
+
controlregexp = /(if |def |while | do )/
|
3082
3403
|
|
3083
3404
|
modified_input_contents, extracted_statements = extract_for_blocks(for_statement_indexes, input_file_contents.clone)
|
3084
3405
|
|
@@ -3138,7 +3459,7 @@ def compile(input_file_path, *output_file_name)
|
|
3138
3459
|
|
3139
3460
|
else
|
3140
3461
|
|
3141
|
-
joined_file_contents = joined_file_contents.sub(rejected_elements_index[0], rejected_elements[0]
|
3462
|
+
joined_file_contents = joined_file_contents.sub(rejected_elements_index[0], rejected_elements[0])
|
3142
3463
|
|
3143
3464
|
rejected_elements_index.delete_at(0)
|
3144
3465
|
|
@@ -3558,6 +3879,10 @@ def compile(input_file_path, *output_file_name)
|
|
3558
3879
|
|
3559
3880
|
input_file_contents = input_file_contents.collect { |element| element.gsub("=~", "matchequal") }
|
3560
3881
|
|
3882
|
+
input_file_contents = input_file_contents.collect { |element| element.gsub(">=", "greatequal") }
|
3883
|
+
|
3884
|
+
input_file_contents = input_file_contents.collect { |element| element.gsub("<=", "lessyequal") }
|
3885
|
+
|
3561
3886
|
javascript_regexp = /(if |while |for )/
|
3562
3887
|
|
3563
3888
|
for x in 0...input_file_contents.length
|
@@ -3700,6 +4025,8 @@ def compile(input_file_path, *output_file_name)
|
|
3700
4025
|
|
3701
4026
|
times_counter = loop.split(".times")[0].lstrip
|
3702
4027
|
|
4028
|
+
times_counter = times_counter[1...-1] if times_counter.include?("(") and times_counter.include?(")")
|
4029
|
+
|
3703
4030
|
replacement_string = "for (_i = 0, _j = #{times_counter}; _i < _j; _i += 1) {\n\n#{compiled_block}\n\n}"
|
3704
4031
|
|
3705
4032
|
modified_file_contents[input_file_contents.index(original_loop)] = replacement_string
|
@@ -3728,6 +4055,142 @@ def compile(input_file_path, *output_file_name)
|
|
3728
4055
|
|
3729
4056
|
end
|
3730
4057
|
|
4058
|
+
def compile_blocks(input_file_contents,temporary_nila_file)
|
4059
|
+
|
4060
|
+
def compile_one_line_blocks(input_block)
|
4061
|
+
|
4062
|
+
block_parameters, block_contents = input_block[1...-1].split("|",2)[1].split("|",2)
|
4063
|
+
|
4064
|
+
compiled_block = "function(#{block_parameters.lstrip.rstrip}) {\n\n #{block_contents.strip} \n\n}"
|
4065
|
+
|
4066
|
+
return compiled_block
|
4067
|
+
|
4068
|
+
end
|
4069
|
+
|
4070
|
+
input_file_contents = input_file_contents.collect {|element| element.gsub("append","appand")}
|
4071
|
+
|
4072
|
+
possible_blocks = input_file_contents.reject {|line| !line.include?(" do ")}
|
4073
|
+
|
4074
|
+
unless possible_blocks.empty?
|
4075
|
+
|
4076
|
+
possible_blocks.each do |starting_line|
|
4077
|
+
|
4078
|
+
index_counter = starting_counter = input_file_contents.index(starting_line)
|
4079
|
+
|
4080
|
+
line = starting_line
|
4081
|
+
|
4082
|
+
until line.strip.eql?("end") or line.strip.eql?("end)")
|
4083
|
+
|
4084
|
+
index_counter += 1
|
4085
|
+
|
4086
|
+
line = input_file_contents[index_counter]
|
4087
|
+
|
4088
|
+
end
|
4089
|
+
|
4090
|
+
loop_extract = input_file_contents[starting_counter..index_counter]
|
4091
|
+
|
4092
|
+
loop_condition, block = loop_extract.join.split(" do ")
|
4093
|
+
|
4094
|
+
block = block.split("end")[0]
|
4095
|
+
|
4096
|
+
replacement_string = "#{loop_condition.rstrip} blockky {#{block.strip}}_!"
|
4097
|
+
|
4098
|
+
input_file_contents[starting_counter..index_counter] = replacement_string
|
4099
|
+
|
4100
|
+
end
|
4101
|
+
|
4102
|
+
end
|
4103
|
+
|
4104
|
+
possible_blocks = input_file_contents.reject{ |element| !element.include?(" blockky ")}
|
4105
|
+
|
4106
|
+
possible_blocks = possible_blocks.reject {|element| !element.include?("{") and !element.include?("}")}
|
4107
|
+
|
4108
|
+
modified_file_contents = input_file_contents.clone
|
4109
|
+
|
4110
|
+
unless possible_blocks.empty?
|
4111
|
+
|
4112
|
+
possible_blocks.each do |loop|
|
4113
|
+
|
4114
|
+
original_loop = loop.clone
|
4115
|
+
|
4116
|
+
string_counter = 1
|
4117
|
+
|
4118
|
+
extracted_string = []
|
4119
|
+
|
4120
|
+
while loop.include?("\"")
|
4121
|
+
|
4122
|
+
string_extract = loop[loop.index("\"")..loop.index("\"",loop.index("\"")+1)]
|
4123
|
+
|
4124
|
+
extracted_string << string_extract
|
4125
|
+
|
4126
|
+
loop = loop.sub(string_extract,"--repstring#{string_counter}")
|
4127
|
+
|
4128
|
+
string_counter += 1
|
4129
|
+
|
4130
|
+
end
|
4131
|
+
|
4132
|
+
block_extract = loop[loop.index("{")..loop.index("}_!")]
|
4133
|
+
|
4134
|
+
compiled_block = ""
|
4135
|
+
|
4136
|
+
if block_extract.count("|") == 2
|
4137
|
+
|
4138
|
+
compiled_block = compile_one_line_blocks(block_extract)
|
4139
|
+
|
4140
|
+
extracted_string.each_with_index do |string,index|
|
4141
|
+
|
4142
|
+
compiled_block = compiled_block.sub("--repstring#{index+1}",string)
|
4143
|
+
|
4144
|
+
end
|
4145
|
+
|
4146
|
+
else
|
4147
|
+
|
4148
|
+
compiled_block = block_extract[1...-1].lstrip.rstrip
|
4149
|
+
|
4150
|
+
extracted_string.each_with_index do |string,index|
|
4151
|
+
|
4152
|
+
compiled_block = compiled_block.sub("--repstring#{index+1}",string)
|
4153
|
+
|
4154
|
+
end
|
4155
|
+
|
4156
|
+
end
|
4157
|
+
|
4158
|
+
caller_func = loop.split(" blockky ")[0]
|
4159
|
+
|
4160
|
+
unless caller_func.rstrip[-1] == ","
|
4161
|
+
|
4162
|
+
replacement_string = "#{caller_func.rstrip}(#{compiled_block.lstrip})"
|
4163
|
+
|
4164
|
+
else
|
4165
|
+
|
4166
|
+
caller_func_split = caller_func.split("(") if caller_func.include?("(")
|
4167
|
+
|
4168
|
+
caller_func_split = caller_func.split(" ",2) if caller_func.include?(" ")
|
4169
|
+
|
4170
|
+
replacement_string = "#{caller_func_split[0]}(#{caller_func_split[1].strip + compiled_block.lstrip})"
|
4171
|
+
|
4172
|
+
end
|
4173
|
+
|
4174
|
+
modified_file_contents[input_file_contents.index(original_loop)] = replacement_string
|
4175
|
+
|
4176
|
+
end
|
4177
|
+
|
4178
|
+
end
|
4179
|
+
|
4180
|
+
modified_file_contents = modified_file_contents.collect {|element| element.gsub("appand","append")}
|
4181
|
+
|
4182
|
+
file_id = open(temporary_nila_file, 'w')
|
4183
|
+
|
4184
|
+
file_id.write(modified_file_contents.join)
|
4185
|
+
|
4186
|
+
file_id.close()
|
4187
|
+
|
4188
|
+
line_by_line_contents = read_file_line_by_line(temporary_nila_file)
|
4189
|
+
|
4190
|
+
return line_by_line_contents
|
4191
|
+
|
4192
|
+
end
|
4193
|
+
|
3731
4194
|
def add_semicolons(input_file_contents)
|
3732
4195
|
|
3733
4196
|
def comment(input_string)
|
@@ -3864,7 +4327,7 @@ def compile(input_file_path, *output_file_name)
|
|
3864
4327
|
|
3865
4328
|
end
|
3866
4329
|
|
3867
|
-
def pretty_print_javascript(javascript_file_contents, temporary_nila_file)
|
4330
|
+
def pretty_print_javascript(javascript_file_contents, temporary_nila_file,declarable_variables)
|
3868
4331
|
|
3869
4332
|
def reset_tabs(input_file_contents)
|
3870
4333
|
|
@@ -3944,7 +4407,7 @@ def compile(input_file_path, *output_file_name)
|
|
3944
4407
|
|
3945
4408
|
end
|
3946
4409
|
|
3947
|
-
block_ending_lines = file_contents.dup.each_index.select { |index| (file_contents[index].eql? " }\n" or file_contents[index].eql? " };\n")}
|
4410
|
+
block_ending_lines = file_contents.dup.each_index.select { |index| (file_contents[index].eql? " }\n" or file_contents[index].eql? " };\n" or file_contents[index].lstrip.eql?("});\n"))}
|
3948
4411
|
|
3949
4412
|
modified_file_contents = file_contents.dup
|
3950
4413
|
|
@@ -3974,19 +4437,19 @@ def compile(input_file_path, *output_file_name)
|
|
3974
4437
|
|
3975
4438
|
end
|
3976
4439
|
|
3977
|
-
block_ending_lines = modified_file_contents.dup.each_index.select { |index| (modified_file_contents[index].eql? " }\n" or modified_file_contents[index].eql? " };\n") }
|
4440
|
+
block_ending_lines = modified_file_contents.dup.each_index.select { |index| (modified_file_contents[index].eql? " }\n" or modified_file_contents[index].eql? " };\n" or modified_file_contents[index].lstrip.eql?("});\n")) }
|
3978
4441
|
|
3979
4442
|
starting_index = starting_line_indices[0]
|
3980
4443
|
|
3981
4444
|
end
|
3982
4445
|
|
3983
|
-
rescue TypeError
|
3984
|
-
|
3985
|
-
|
3986
|
-
|
3987
|
-
rescue ArgumentError
|
3988
|
-
|
3989
|
-
|
4446
|
+
#rescue TypeError
|
4447
|
+
#
|
4448
|
+
# puts "Whitespace was left unfixed!"
|
4449
|
+
#
|
4450
|
+
#rescue ArgumentError
|
4451
|
+
#
|
4452
|
+
# puts "Whitespace was left unfixed!"
|
3990
4453
|
|
3991
4454
|
end
|
3992
4455
|
|
@@ -4018,7 +4481,6 @@ def compile(input_file_path, *output_file_name)
|
|
4018
4481
|
|
4019
4482
|
starting_index = code_block_locations[0]
|
4020
4483
|
|
4021
|
-
|
4022
4484
|
end
|
4023
4485
|
|
4024
4486
|
return compact_contents
|
@@ -4029,7 +4491,7 @@ def compile(input_file_path, *output_file_name)
|
|
4029
4491
|
|
4030
4492
|
if !code_block_starting_locations.empty?
|
4031
4493
|
|
4032
|
-
controlregexp = /(if |for |while |\(function\(|= function\(|((=|:)\s+\{))/
|
4494
|
+
controlregexp = /(if |for |while |,function\(|\(function\(|= function\(|((=|:)\s+\{))/
|
4033
4495
|
|
4034
4496
|
code_block_starting_locations = [0, code_block_starting_locations, -1].flatten
|
4035
4497
|
|
@@ -4071,7 +4533,7 @@ def compile(input_file_path, *output_file_name)
|
|
4071
4533
|
|
4072
4534
|
current_block.each_with_index do |line, index|
|
4073
4535
|
|
4074
|
-
if line.lstrip.eql? "}\n" or line.lstrip.eql?("};\n") or line.lstrip.include?("_!;\n")
|
4536
|
+
if line.lstrip.eql? "}\n" or line.lstrip.eql?("};\n") or line.lstrip.include?("_!;\n") or line.lstrip.include?("});\n")
|
4075
4537
|
|
4076
4538
|
end_counter += 1
|
4077
4539
|
|
@@ -4105,7 +4567,7 @@ def compile(input_file_path, *output_file_name)
|
|
4105
4567
|
|
4106
4568
|
block_end = current_block.index(block_extract[-1])
|
4107
4569
|
|
4108
|
-
current_block[block_start..block_end] = "--block#{block_counter}"
|
4570
|
+
current_block[block_start..block_end] = "--block#{block_counter}\n"
|
4109
4571
|
|
4110
4572
|
block_counter += 1
|
4111
4573
|
|
@@ -4115,7 +4577,7 @@ def compile(input_file_path, *output_file_name)
|
|
4115
4577
|
|
4116
4578
|
current_block.each_with_index do |line, index|
|
4117
4579
|
|
4118
|
-
if line.lstrip.eql? "}\n" or line.lstrip.eql?("};\n") or line.lstrip.include?("_!;\n")
|
4580
|
+
if line.lstrip.eql? "}\n" or line.lstrip.eql?("};\n") or line.lstrip.include?("_!;\n") or line.lstrip.include?("});\n")
|
4119
4581
|
|
4120
4582
|
end_counter += 1
|
4121
4583
|
|
@@ -4159,7 +4621,7 @@ def compile(input_file_path, *output_file_name)
|
|
4159
4621
|
|
4160
4622
|
def replace_ignored_words(input_string)
|
4161
4623
|
|
4162
|
-
ignorable_keywords = [/if/, /while/, /function/]
|
4624
|
+
ignorable_keywords = [/if/, /while/, /function/,/function/]
|
4163
4625
|
|
4164
4626
|
dummy_replacement_words = ["eeuuff", "whaalesskkey", "conffoolotion"]
|
4165
4627
|
|
@@ -4175,6 +4637,14 @@ def compile(input_file_path, *output_file_name)
|
|
4175
4637
|
|
4176
4638
|
javascript_regexp = /(if |for |while |\(function\(|= function\(|((=|:)\s+\{))/
|
4177
4639
|
|
4640
|
+
if declarable_variables.length > 0
|
4641
|
+
|
4642
|
+
declaration_string = "var " + declarable_variables.flatten.uniq.sort.join(", ") + ";\n\n"
|
4643
|
+
|
4644
|
+
javascript_file_contents = [declaration_string,javascript_file_contents].flatten
|
4645
|
+
|
4646
|
+
end
|
4647
|
+
|
4178
4648
|
javascript_file_contents = javascript_file_contents.collect { |element| element.sub("Euuf", "if") }
|
4179
4649
|
|
4180
4650
|
javascript_file_contents = javascript_file_contents.collect { |element| element.sub("whaaleskey", "while") }
|
@@ -4221,7 +4691,7 @@ def compile(input_file_path, *output_file_name)
|
|
4221
4691
|
|
4222
4692
|
current_block = [current_block[0]] + current_block[1...-1].collect { |element| soft_tabs*(soft_tabs_counter)+element } + [current_block[-1]]
|
4223
4693
|
|
4224
|
-
nested_block = current_block.reject { |row| !row.include?("--block") }
|
4694
|
+
nested_block = current_block.clone.reject { |row| !row.include?("--block") }
|
4225
4695
|
|
4226
4696
|
nested_block = nested_block.collect { |element| element.split("--block")[1] }
|
4227
4697
|
|
@@ -4229,7 +4699,7 @@ def compile(input_file_path, *output_file_name)
|
|
4229
4699
|
|
4230
4700
|
modified_nested_block = nested_block.clone
|
4231
4701
|
|
4232
|
-
current_block = current_block.join
|
4702
|
+
current_block = current_block.join("\n")
|
4233
4703
|
|
4234
4704
|
until modified_nested_block.empty?
|
4235
4705
|
|
@@ -4442,6 +4912,8 @@ def compile(input_file_path, *output_file_name)
|
|
4442
4912
|
|
4443
4913
|
file_contents = compile_conditional_structures(file_contents, temp_file)
|
4444
4914
|
|
4915
|
+
file_contents = compile_blocks(file_contents,temp_file)
|
4916
|
+
|
4445
4917
|
file_contents = compile_integers(file_contents)
|
4446
4918
|
|
4447
4919
|
file_contents = compile_default_values(file_contents, temp_file)
|
@@ -4452,18 +4924,22 @@ def compile(input_file_path, *output_file_name)
|
|
4452
4924
|
|
4453
4925
|
file_contents = compile_parallel_assignment(file_contents, temp_file)
|
4454
4926
|
|
4455
|
-
file_contents = compile_arrays(file_contents, temp_file)
|
4927
|
+
file_contents,named_functions = compile_arrays(file_contents, named_functions, temp_file)
|
4456
4928
|
|
4457
4929
|
file_contents = compile_strings(file_contents)
|
4458
4930
|
|
4931
|
+
list_of_variables, file_contents = get_variables(file_contents, temp_file,loop_vars)
|
4932
|
+
|
4459
4933
|
file_contents, function_names = compile_named_functions(file_contents, named_functions, nested_functions, temp_file)
|
4460
4934
|
|
4461
|
-
|
4935
|
+
func_names = function_names.dup
|
4462
4936
|
|
4463
4937
|
file_contents, ruby_functions = compile_custom_function_map(file_contents)
|
4464
4938
|
|
4465
4939
|
file_contents = compile_ruby_methods(file_contents)
|
4466
4940
|
|
4941
|
+
file_contents = compile_special_keywords(file_contents)
|
4942
|
+
|
4467
4943
|
function_names << ruby_functions
|
4468
4944
|
|
4469
4945
|
list_of_variables += loop_vars
|
@@ -4476,7 +4952,7 @@ def compile(input_file_path, *output_file_name)
|
|
4476
4952
|
|
4477
4953
|
file_contents = compile_comments(file_contents, comments, temp_file)
|
4478
4954
|
|
4479
|
-
file_contents = pretty_print_javascript(file_contents, temp_file)
|
4955
|
+
file_contents = pretty_print_javascript(file_contents, temp_file,list_of_variables+func_names)
|
4480
4956
|
|
4481
4957
|
file_contents = compile_operators(file_contents)
|
4482
4958
|
|