nilac 0.0.4.2.1 → 0.0.4.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/nilac +468 -34
- data/lib/nilac/version.rb +1 -1
- data/src/nilac.rb +19 -1
- metadata +1 -1
data/bin/nilac
CHANGED
@@ -752,6 +752,8 @@ def compile(input_file_path, *output_file_name)
|
|
752
752
|
|
753
753
|
input_file_contents = input_file_contents.collect { |element| element.gsub("%=", "modequal") }
|
754
754
|
|
755
|
+
input_file_contents = input_file_contents.collect { |element| element.gsub("=~", "matchequal") }
|
756
|
+
|
755
757
|
for x in 0...input_file_contents.length
|
756
758
|
|
757
759
|
current_row = input_file_contents[x]
|
@@ -816,6 +818,8 @@ def compile(input_file_path, *output_file_name)
|
|
816
818
|
|
817
819
|
line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("notequal", "!=") }
|
818
820
|
|
821
|
+
line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("matchequal", "=~") }
|
822
|
+
|
819
823
|
return variables.uniq, line_by_line_contents
|
820
824
|
|
821
825
|
end
|
@@ -1138,6 +1142,108 @@ def compile(input_file_path, *output_file_name)
|
|
1138
1142
|
|
1139
1143
|
end
|
1140
1144
|
|
1145
|
+
def compile_hashes(input_file_contents,temporary_nila_file)
|
1146
|
+
|
1147
|
+
def compile_multiline_hashes(input_file_contents,temporary_nila_file)
|
1148
|
+
|
1149
|
+
possible_hashes = input_file_contents.reject { |element| !element.include?("{") }
|
1150
|
+
|
1151
|
+
possible_multiline_hashes = possible_hashes.reject { |element| element.include?("}") }
|
1152
|
+
|
1153
|
+
multiline_hashes = []
|
1154
|
+
|
1155
|
+
possible_multiline_hashes.each do |starting_line|
|
1156
|
+
|
1157
|
+
index = input_file_contents.index(starting_line)
|
1158
|
+
|
1159
|
+
line = starting_line
|
1160
|
+
|
1161
|
+
until line.include?("}")
|
1162
|
+
|
1163
|
+
index += 1
|
1164
|
+
|
1165
|
+
line = input_file_contents[index]
|
1166
|
+
|
1167
|
+
end
|
1168
|
+
|
1169
|
+
multiline_hashes << input_file_contents[input_file_contents.index(starting_line)..index]
|
1170
|
+
|
1171
|
+
end
|
1172
|
+
|
1173
|
+
joined_file_contents = input_file_contents.join
|
1174
|
+
|
1175
|
+
multiline_hashes.each do |hash|
|
1176
|
+
|
1177
|
+
modified_hash = hash.join
|
1178
|
+
|
1179
|
+
hash_extract = modified_hash[modified_hash.index("{")..modified_hash.index("}")]
|
1180
|
+
|
1181
|
+
hash_contents = hash_extract.split("{")[1].split("}")[0].lstrip.rstrip.split(",").collect { |element| element.lstrip.rstrip }
|
1182
|
+
|
1183
|
+
hash_contents = "{" + hash_contents.join(",") + "}"
|
1184
|
+
|
1185
|
+
joined_file_contents = joined_file_contents.sub(hash_extract, hash_contents)
|
1186
|
+
|
1187
|
+
end
|
1188
|
+
|
1189
|
+
file_id = open(temporary_nila_file, 'w')
|
1190
|
+
|
1191
|
+
file_id.write(joined_file_contents)
|
1192
|
+
|
1193
|
+
file_id.close()
|
1194
|
+
|
1195
|
+
line_by_line_contents = read_file_line_by_line(temporary_nila_file)
|
1196
|
+
|
1197
|
+
return line_by_line_contents
|
1198
|
+
|
1199
|
+
end
|
1200
|
+
|
1201
|
+
def compile_inline_hashes(input_file_contents)
|
1202
|
+
|
1203
|
+
modified_file_contents = input_file_contents.clone.collect {|element| element.gsub(/(#|%)\w?\{/,"innerrii0opol115")}
|
1204
|
+
|
1205
|
+
possible_inline_hashes = modified_file_contents.reject {|element| !element.include?("{")}
|
1206
|
+
|
1207
|
+
possible_inline_hashes.each do |hash|
|
1208
|
+
|
1209
|
+
hash_extract = hash[hash.index("{")..hash.index("}")]
|
1210
|
+
|
1211
|
+
contents = hash_extract[1...-1].split(",")
|
1212
|
+
|
1213
|
+
hash_contents = []
|
1214
|
+
|
1215
|
+
contents.each do |items|
|
1216
|
+
|
1217
|
+
items = items.lstrip.sub(":","") if items.lstrip[0] == ":"
|
1218
|
+
|
1219
|
+
key, value = items.split("=>").collect {|element| element.lstrip.rstrip} if items.include?("=>")
|
1220
|
+
|
1221
|
+
key, value = items.split(":").collect {|element| element.lstrip.rstrip} if items.include?(":")
|
1222
|
+
|
1223
|
+
key = key.gsub("'","").gsub("\"","")
|
1224
|
+
|
1225
|
+
hash_contents << " #{key}: #{value},"
|
1226
|
+
|
1227
|
+
end
|
1228
|
+
|
1229
|
+
replacement_string = "{\n" + hash_contents.join("\n") + "\n};\n"
|
1230
|
+
|
1231
|
+
input_file_contents[input_file_contents.index(hash)] = input_file_contents[input_file_contents.index(hash)].sub(hash_extract,replacement_string)
|
1232
|
+
|
1233
|
+
end
|
1234
|
+
|
1235
|
+
return input_file_contents
|
1236
|
+
|
1237
|
+
end
|
1238
|
+
|
1239
|
+
file_contents = compile_multiline_hashes(input_file_contents,temporary_nila_file)
|
1240
|
+
|
1241
|
+
file_contents = compile_inline_hashes(file_contents)
|
1242
|
+
|
1243
|
+
return file_contents
|
1244
|
+
|
1245
|
+
end
|
1246
|
+
|
1141
1247
|
def compile_strings(input_file_contents)
|
1142
1248
|
|
1143
1249
|
def compile_small_q_syntax(input_file_contents)
|
@@ -1839,6 +1945,8 @@ def compile(input_file_path, *output_file_name)
|
|
1839
1945
|
|
1840
1946
|
junk, condition = command.split("unless ")
|
1841
1947
|
|
1948
|
+
condition = condition.gsub(" and "," && ").gsub(" or "," || ").gsub(" not "," !")
|
1949
|
+
|
1842
1950
|
replacement_string = "if !(#{condition.lstrip.rstrip})\n"
|
1843
1951
|
|
1844
1952
|
modified_file_contents[modified_file_contents.index(command)] = replacement_string
|
@@ -1853,6 +1961,8 @@ def compile(input_file_path, *output_file_name)
|
|
1853
1961
|
|
1854
1962
|
junk, condition = command.split("until ")
|
1855
1963
|
|
1964
|
+
condition = condition.gsub(" and "," && ").gsub(" or "," || ").gsub(" not "," !")
|
1965
|
+
|
1856
1966
|
replacement_string = "while !(#{condition.lstrip.rstrip})\n"
|
1857
1967
|
|
1858
1968
|
modified_file_contents[modified_file_contents.index(command)] = replacement_string
|
@@ -1881,21 +1991,25 @@ def compile(input_file_path, *output_file_name)
|
|
1881
1991
|
|
1882
1992
|
line_split = line.split(plain_conditionals[index])
|
1883
1993
|
|
1994
|
+
condition = line_split[1]
|
1995
|
+
|
1996
|
+
condition = condition.gsub(" and "," && ").gsub(" or "," || ").gsub(" not "," !")
|
1997
|
+
|
1884
1998
|
if index == 0
|
1885
1999
|
|
1886
|
-
output_statement = "if (#{
|
2000
|
+
output_statement = "if (#{condition.lstrip.rstrip.gsub("?", "")}) {\n\n#{line_split[0]}\n}\n"
|
1887
2001
|
|
1888
2002
|
elsif index == 1
|
1889
2003
|
|
1890
|
-
output_statement = "while (#{
|
2004
|
+
output_statement = "while (#{condition.lstrip.rstrip.gsub("?", "")}) {\n\n#{line_split[0]}\n}\n"
|
1891
2005
|
|
1892
2006
|
elsif index == 2
|
1893
2007
|
|
1894
|
-
output_statement = "if (!(#{
|
2008
|
+
output_statement = "if (!(#{condition.lstrip.rstrip.gsub("?", "")})) {\n\n#{line_split[0]}\n}\n"
|
1895
2009
|
|
1896
2010
|
elsif index == 3
|
1897
2011
|
|
1898
|
-
output_statement = "while (!(#{
|
2012
|
+
output_statement = "while (!(#{condition.lstrip.rstrip.gsub("?", "")})) {\n\n#{line_split[0]}\n}\n"
|
1899
2013
|
|
1900
2014
|
end
|
1901
2015
|
|
@@ -2061,6 +2175,8 @@ def compile(input_file_path, *output_file_name)
|
|
2061
2175
|
|
2062
2176
|
junk, condition = starting_line.split("if")
|
2063
2177
|
|
2178
|
+
condition = condition.gsub(" and "," && ").gsub(" or "," || ").gsub(" not "," !")
|
2179
|
+
|
2064
2180
|
input_block[0] = "Euuf (#{condition.lstrip.rstrip.gsub("?", "")}) {\n"
|
2065
2181
|
|
2066
2182
|
input_block[-1] = input_block[-1].lstrip.sub("end", "}")
|
@@ -2071,6 +2187,8 @@ def compile(input_file_path, *output_file_name)
|
|
2071
2187
|
|
2072
2188
|
junk, condition = statement.split("elsuf")
|
2073
2189
|
|
2190
|
+
condition = condition.gsub(" and "," && ").gsub(" or "," || ").gsub(" not "," !")
|
2191
|
+
|
2074
2192
|
input_block[input_block.index(statement)] = "} elsuf (#{condition.lstrip.rstrip.gsub("?", "")}) {\n"
|
2075
2193
|
|
2076
2194
|
end
|
@@ -2481,6 +2599,274 @@ def compile(input_file_path, *output_file_name)
|
|
2481
2599
|
|
2482
2600
|
end
|
2483
2601
|
|
2602
|
+
def compile_loop_keyword(input_file_contents,temporary_nila_file)
|
2603
|
+
|
2604
|
+
def convert_string_to_array(input_string, temporary_nila_file)
|
2605
|
+
|
2606
|
+
file_id = open(temporary_nila_file, 'w')
|
2607
|
+
|
2608
|
+
file_id.write(input_string)
|
2609
|
+
|
2610
|
+
file_id.close()
|
2611
|
+
|
2612
|
+
line_by_line_contents = read_file_line_by_line(temporary_nila_file)
|
2613
|
+
|
2614
|
+
return line_by_line_contents
|
2615
|
+
|
2616
|
+
end
|
2617
|
+
|
2618
|
+
def extract_loop_blocks(loop_statement_indexes, input_file_contents)
|
2619
|
+
|
2620
|
+
possible_loop_blocks = []
|
2621
|
+
|
2622
|
+
loop_block_counter = 0
|
2623
|
+
|
2624
|
+
extracted_blocks = []
|
2625
|
+
|
2626
|
+
controlregexp = /(if |while |def |loop )/
|
2627
|
+
|
2628
|
+
rejectionregexp = /( if | while )/
|
2629
|
+
|
2630
|
+
for x in 0...loop_statement_indexes.length-1
|
2631
|
+
|
2632
|
+
possible_loop_blocks << input_file_contents[loop_statement_indexes[x]..loop_statement_indexes[x+1]]
|
2633
|
+
|
2634
|
+
end
|
2635
|
+
|
2636
|
+
end_counter = 0
|
2637
|
+
|
2638
|
+
end_index = []
|
2639
|
+
|
2640
|
+
current_block = []
|
2641
|
+
|
2642
|
+
possible_loop_blocks.each_with_index do |block|
|
2643
|
+
|
2644
|
+
current_block += block
|
2645
|
+
|
2646
|
+
current_block.each_with_index do |line, index|
|
2647
|
+
|
2648
|
+
if line.strip.eql? "end"
|
2649
|
+
|
2650
|
+
end_counter += 1
|
2651
|
+
|
2652
|
+
end_index << index
|
2653
|
+
|
2654
|
+
end
|
2655
|
+
|
2656
|
+
end
|
2657
|
+
|
2658
|
+
if end_counter > 0
|
2659
|
+
|
2660
|
+
until end_index.empty?
|
2661
|
+
|
2662
|
+
array_extract = current_block[0..end_index[0]].reverse
|
2663
|
+
|
2664
|
+
index_counter = 0
|
2665
|
+
|
2666
|
+
array_extract.each_with_index do |line|
|
2667
|
+
|
2668
|
+
break if (line.lstrip.index(controlregexp) != nil and line.lstrip.index(rejectionregexp).nil?)
|
2669
|
+
|
2670
|
+
index_counter += 1
|
2671
|
+
|
2672
|
+
end
|
2673
|
+
|
2674
|
+
block_extract = array_extract[0..index_counter].reverse
|
2675
|
+
|
2676
|
+
extracted_blocks << block_extract
|
2677
|
+
|
2678
|
+
block_start = current_block.index(block_extract[0])
|
2679
|
+
|
2680
|
+
block_end = current_block.index(block_extract[-1])
|
2681
|
+
|
2682
|
+
current_block[block_start..block_end] = "--loopblock#{loop_block_counter}"
|
2683
|
+
|
2684
|
+
loop_block_counter += 1
|
2685
|
+
|
2686
|
+
end_counter = 0
|
2687
|
+
|
2688
|
+
end_index = []
|
2689
|
+
|
2690
|
+
current_block.each_with_index do |line, index|
|
2691
|
+
|
2692
|
+
if line.strip.eql? "end"
|
2693
|
+
|
2694
|
+
end_counter += 1
|
2695
|
+
|
2696
|
+
end_index << index
|
2697
|
+
|
2698
|
+
end
|
2699
|
+
|
2700
|
+
end
|
2701
|
+
|
2702
|
+
end
|
2703
|
+
|
2704
|
+
end
|
2705
|
+
|
2706
|
+
end
|
2707
|
+
|
2708
|
+
return current_block, extracted_blocks
|
2709
|
+
|
2710
|
+
end
|
2711
|
+
|
2712
|
+
def compile_loop_syntax(input_block)
|
2713
|
+
|
2714
|
+
modified_input_block = input_block.dup
|
2715
|
+
|
2716
|
+
strings = []
|
2717
|
+
|
2718
|
+
string_counter = 0
|
2719
|
+
|
2720
|
+
input_block.each_with_index do |line, index|
|
2721
|
+
|
2722
|
+
if line.include?("\"")
|
2723
|
+
|
2724
|
+
opening_quotes = line.index("\"")
|
2725
|
+
|
2726
|
+
string_extract = line[opening_quotes..line.index("\"", opening_quotes+1)]
|
2727
|
+
|
2728
|
+
strings << string_extract
|
2729
|
+
|
2730
|
+
modified_input_block[index] = modified_input_block[index].sub(string_extract, "--string{#{string_counter}}")
|
2731
|
+
|
2732
|
+
string_counter += 1
|
2733
|
+
|
2734
|
+
end
|
2735
|
+
|
2736
|
+
end
|
2737
|
+
|
2738
|
+
input_block = modified_input_block
|
2739
|
+
|
2740
|
+
starting_line = input_block[0]
|
2741
|
+
|
2742
|
+
starting_line = starting_line + "\n" if starting_line.lstrip == starting_line
|
2743
|
+
|
2744
|
+
input_block[0] = "whaaleskey (true) {\n"
|
2745
|
+
|
2746
|
+
input_block[-1] = input_block[-1].lstrip.sub("end", "}")
|
2747
|
+
|
2748
|
+
modified_input_block = input_block.dup
|
2749
|
+
|
2750
|
+
input_block.each_with_index do |line, index|
|
2751
|
+
|
2752
|
+
if line.include?("--string{")
|
2753
|
+
|
2754
|
+
junk, remains = line.split("--string{")
|
2755
|
+
|
2756
|
+
string_index, junk = remains.split("}")
|
2757
|
+
|
2758
|
+
modified_input_block[index] = modified_input_block[index].sub("--string{#{string_index.strip}}", strings[string_index.strip.to_i])
|
2759
|
+
|
2760
|
+
end
|
2761
|
+
|
2762
|
+
end
|
2763
|
+
|
2764
|
+
return modified_input_block
|
2765
|
+
|
2766
|
+
end
|
2767
|
+
|
2768
|
+
possible_loop_statements = input_file_contents.reject { |element| !element.include?("loop") }
|
2769
|
+
|
2770
|
+
if !possible_loop_statements.empty?
|
2771
|
+
|
2772
|
+
loop_statement_indexes = []
|
2773
|
+
|
2774
|
+
possible_loop_statements.each do |statement|
|
2775
|
+
|
2776
|
+
loop_statement_indexes << input_file_contents.dup.each_index.select { |index| input_file_contents[index] == statement }
|
2777
|
+
|
2778
|
+
end
|
2779
|
+
|
2780
|
+
loop_statement_indexes = [0] + loop_statement_indexes.flatten + [-1]
|
2781
|
+
|
2782
|
+
controlregexp = /(if |def )/
|
2783
|
+
|
2784
|
+
modified_input_contents, extracted_statements = extract_loop_blocks(loop_statement_indexes, input_file_contents.clone)
|
2785
|
+
|
2786
|
+
joined_blocks = extracted_statements.collect { |element| element.join }
|
2787
|
+
|
2788
|
+
loop_statements = joined_blocks.reject { |element| element.index(controlregexp) != nil }
|
2789
|
+
|
2790
|
+
rejected_elements = joined_blocks - loop_statements
|
2791
|
+
|
2792
|
+
rejected_elements_index = []
|
2793
|
+
|
2794
|
+
rejected_elements.each do |element|
|
2795
|
+
|
2796
|
+
rejected_elements_index << joined_blocks.each_index.select { |index| joined_blocks[index] == element }
|
2797
|
+
|
2798
|
+
end
|
2799
|
+
|
2800
|
+
loop_blocks_index = (0...extracted_statements.length).to_a
|
2801
|
+
|
2802
|
+
rejected_elements_index = rejected_elements_index.flatten
|
2803
|
+
|
2804
|
+
loop_blocks_index -= rejected_elements_index
|
2805
|
+
|
2806
|
+
modified_loop_statements = loop_statements.collect { |string| convert_string_to_array(string, temporary_nila_file) }
|
2807
|
+
|
2808
|
+
modified_loop_statements = modified_loop_statements.collect { |block| compile_loop_syntax(block) }.reverse
|
2809
|
+
|
2810
|
+
loop_blocks_index = loop_blocks_index.collect { |element| "--loopblock#{element}" }.reverse
|
2811
|
+
|
2812
|
+
rejected_elements_index = rejected_elements_index.collect { |element| "--loopblock#{element}" }.reverse
|
2813
|
+
|
2814
|
+
rejected_elements = rejected_elements.reverse
|
2815
|
+
|
2816
|
+
joined_file_contents = modified_input_contents.join
|
2817
|
+
|
2818
|
+
until loop_blocks_index.empty? and rejected_elements_index.empty?
|
2819
|
+
|
2820
|
+
if !loop_blocks_index.empty?
|
2821
|
+
|
2822
|
+
if joined_file_contents.include?(loop_blocks_index[0])
|
2823
|
+
|
2824
|
+
joined_file_contents = joined_file_contents.sub(loop_blocks_index[0], modified_loop_statements[0].join)
|
2825
|
+
|
2826
|
+
loop_blocks_index.delete_at(0)
|
2827
|
+
|
2828
|
+
modified_loop_statements.delete_at(0)
|
2829
|
+
|
2830
|
+
else
|
2831
|
+
|
2832
|
+
joined_file_contents = joined_file_contents.sub(rejected_elements_index[0], rejected_elements[0].join)
|
2833
|
+
|
2834
|
+
rejected_elements_index.delete_at(0)
|
2835
|
+
|
2836
|
+
rejected_elements.delete_at(0)
|
2837
|
+
|
2838
|
+
end
|
2839
|
+
|
2840
|
+
else
|
2841
|
+
|
2842
|
+
joined_file_contents = joined_file_contents.sub(rejected_elements_index[0], rejected_elements[0].join)
|
2843
|
+
|
2844
|
+
rejected_elements_index.delete_at(0)
|
2845
|
+
|
2846
|
+
rejected_elements.delete_at(0)
|
2847
|
+
|
2848
|
+
end
|
2849
|
+
|
2850
|
+
end
|
2851
|
+
|
2852
|
+
else
|
2853
|
+
|
2854
|
+
joined_file_contents = input_file_contents.join
|
2855
|
+
|
2856
|
+
end
|
2857
|
+
|
2858
|
+
file_id = open(temporary_nila_file, 'w')
|
2859
|
+
|
2860
|
+
file_id.write(joined_file_contents)
|
2861
|
+
|
2862
|
+
file_id.close()
|
2863
|
+
|
2864
|
+
line_by_line_contents = read_file_line_by_line(temporary_nila_file)
|
2865
|
+
|
2866
|
+
return line_by_line_contents
|
2867
|
+
|
2868
|
+
end
|
2869
|
+
|
2484
2870
|
def ignore_statement_modifiers(input_block)
|
2485
2871
|
|
2486
2872
|
modified_input_block = input_block.dup
|
@@ -2557,6 +2943,8 @@ def compile(input_file_path, *output_file_name)
|
|
2557
2943
|
|
2558
2944
|
file_contents = compile_regular_while(file_contents, temporary_nila_file)
|
2559
2945
|
|
2946
|
+
file_contents = compile_loop_keyword(file_contents,temporary_nila_file)
|
2947
|
+
|
2560
2948
|
file_contents = replace_statement_modifiers(file_contents, rejected_lines)
|
2561
2949
|
|
2562
2950
|
file_contents = compile_inline_conditionals(file_contents, temporary_nila_file)
|
@@ -2587,9 +2975,9 @@ def compile(input_file_path, *output_file_name)
|
|
2587
2975
|
|
2588
2976
|
reject_regexp = /(function |Euuf |if |else|elsuf|switch |case|while |whaaleskey |for )/
|
2589
2977
|
|
2590
|
-
modified_file_contents =
|
2978
|
+
modified_file_contents = input_file_contents.dup
|
2591
2979
|
|
2592
|
-
input_file_contents.
|
2980
|
+
input_file_contents.each_with_index do |line,index|
|
2593
2981
|
|
2594
2982
|
if line.index(reject_regexp) == nil
|
2595
2983
|
|
@@ -2601,36 +2989,20 @@ def compile(input_file_path, *output_file_name)
|
|
2601
2989
|
|
2602
2990
|
if !line.lstrip.eql?("}\n\n")
|
2603
2991
|
|
2604
|
-
|
2992
|
+
if line.rstrip[-1] != "[" and line.rstrip[-1] != "{" and line.rstrip[-1] != "," and line.rstrip[-1] != ";"
|
2605
2993
|
|
2606
|
-
|
2994
|
+
modified_file_contents[index] = line.rstrip + ";\n\n"
|
2607
2995
|
|
2608
|
-
|
2996
|
+
end
|
2609
2997
|
|
2610
2998
|
end
|
2611
2999
|
|
2612
|
-
else
|
2613
|
-
|
2614
|
-
modified_file_contents << line
|
2615
|
-
|
2616
3000
|
end
|
2617
3001
|
|
2618
|
-
else
|
2619
|
-
|
2620
|
-
modified_file_contents << line
|
2621
|
-
|
2622
3002
|
end
|
2623
3003
|
|
2624
|
-
else
|
2625
|
-
|
2626
|
-
modified_file_contents << line
|
2627
|
-
|
2628
3004
|
end
|
2629
3005
|
|
2630
|
-
else
|
2631
|
-
|
2632
|
-
modified_file_contents << line
|
2633
|
-
|
2634
3006
|
end
|
2635
3007
|
|
2636
3008
|
end
|
@@ -2781,7 +3153,7 @@ def compile(input_file_path, *output_file_name)
|
|
2781
3153
|
|
2782
3154
|
def extract_blocks(file_contents)
|
2783
3155
|
|
2784
|
-
javascript_regexp = /(if |while |function |function\()/
|
3156
|
+
javascript_regexp = /(if |while |function |function\(|((=|:)\s+\{))/
|
2785
3157
|
|
2786
3158
|
block_starting_lines = file_contents.dup.reject { |element| element.index(javascript_regexp).nil? }[1..-1]
|
2787
3159
|
|
@@ -2797,7 +3169,7 @@ def compile(input_file_path, *output_file_name)
|
|
2797
3169
|
|
2798
3170
|
end
|
2799
3171
|
|
2800
|
-
block_ending_lines = file_contents.dup.each_index.select { |index| file_contents[index].eql? " }\n" }
|
3172
|
+
block_ending_lines = file_contents.dup.each_index.select { |index| (file_contents[index].eql? " }\n" or file_contents[index].eql? " };\n")}
|
2801
3173
|
|
2802
3174
|
modified_file_contents = file_contents.dup
|
2803
3175
|
|
@@ -2827,7 +3199,7 @@ def compile(input_file_path, *output_file_name)
|
|
2827
3199
|
|
2828
3200
|
end
|
2829
3201
|
|
2830
|
-
block_ending_lines = modified_file_contents.dup.each_index.select { |index| modified_file_contents[index].eql? " }\n" }
|
3202
|
+
block_ending_lines = modified_file_contents.dup.each_index.select { |index| (modified_file_contents[index].eql? " }\n" or modified_file_contents[index].eql? " };\n") }
|
2831
3203
|
|
2832
3204
|
starting_index = starting_line_indices[0]
|
2833
3205
|
|
@@ -2882,7 +3254,7 @@ def compile(input_file_path, *output_file_name)
|
|
2882
3254
|
|
2883
3255
|
if !code_block_starting_locations.empty?
|
2884
3256
|
|
2885
|
-
controlregexp = /(if |while |function |function\()/
|
3257
|
+
controlregexp = /(if |while |function |function\(|((=|:)\s+\{))/
|
2886
3258
|
|
2887
3259
|
code_block_starting_locations = [0, code_block_starting_locations, -1].flatten
|
2888
3260
|
|
@@ -2910,7 +3282,7 @@ def compile(input_file_path, *output_file_name)
|
|
2910
3282
|
|
2911
3283
|
current_block.each_with_index do |line, index|
|
2912
3284
|
|
2913
|
-
if line.lstrip.eql? "}\n"
|
3285
|
+
if line.lstrip.eql? "}\n" or line.lstrip.eql?("};\n")
|
2914
3286
|
|
2915
3287
|
end_counter += 1
|
2916
3288
|
|
@@ -3012,7 +3384,7 @@ def compile(input_file_path, *output_file_name)
|
|
3012
3384
|
|
3013
3385
|
end
|
3014
3386
|
|
3015
|
-
javascript_regexp = /(if |while |function |function\()/
|
3387
|
+
javascript_regexp = /(if |while |function |function\(|((=|:)\s+\{))/
|
3016
3388
|
|
3017
3389
|
javascript_file_contents = javascript_file_contents.collect { |element| element.sub("Euuf", "if") }
|
3018
3390
|
|
@@ -3178,9 +3550,49 @@ def compile(input_file_path, *output_file_name)
|
|
3178
3550
|
|
3179
3551
|
end
|
3180
3552
|
|
3181
|
-
|
3553
|
+
def compile_match_operator(input_string)
|
3554
|
+
|
3555
|
+
rejection_exp = /( aannddy | orriioo |nnoottyy )/
|
3556
|
+
|
3557
|
+
if input_string.include?("=~")
|
3558
|
+
|
3559
|
+
input_string = input_string.gsub(" && "," aannddy ").gsub(" || "," orriioo ").gsub("!","nnoottyy")
|
3560
|
+
|
3561
|
+
left, right = input_string.split("=~")
|
3562
|
+
|
3563
|
+
if left.index(rejection_exp) != nil
|
3564
|
+
|
3565
|
+
left = left[left.index(rejection_exp)..-1]
|
3566
|
+
|
3567
|
+
elsif left.index(/\(/)
|
3568
|
+
|
3569
|
+
left = left[left.index(/\(/)+1..-1]
|
3570
|
+
|
3571
|
+
end
|
3572
|
+
|
3573
|
+
if right.index(rejection_exp) != nil
|
3574
|
+
|
3575
|
+
right = right[0...right.index(rejection_exp)]
|
3576
|
+
|
3577
|
+
elsif right.index(/\)/)
|
3578
|
+
|
3579
|
+
right = right[0...right.index(/\)/)]
|
3580
|
+
|
3581
|
+
end
|
3582
|
+
|
3583
|
+
original_string = "#{left}=~#{right}"
|
3584
|
+
|
3585
|
+
replacement_string = "#{left.rstrip} = #{left.rstrip}.match(#{right.lstrip.rstrip})"
|
3182
3586
|
|
3183
|
-
|
3587
|
+
input_string = input_string.sub(original_string,replacement_string)
|
3588
|
+
|
3589
|
+
input_string = input_string.gsub(" aannddy "," && ").gsub(" orriioo "," || ").gsub("nnoottyy","!")
|
3590
|
+
|
3591
|
+
end
|
3592
|
+
|
3593
|
+
return input_string
|
3594
|
+
|
3595
|
+
end
|
3184
3596
|
|
3185
3597
|
input_file_contents = input_file_contents.collect { |element| element.sub("==", "===") }
|
3186
3598
|
|
@@ -3190,6 +3602,8 @@ def compile(input_file_path, *output_file_name)
|
|
3190
3602
|
|
3191
3603
|
input_file_contents = input_file_contents.collect { |element| compile_power_operator(element) }
|
3192
3604
|
|
3605
|
+
input_file_contents = input_file_contents.collect {|element| compile_match_operator(element)}
|
3606
|
+
|
3193
3607
|
return input_file_contents
|
3194
3608
|
|
3195
3609
|
end
|
@@ -3229,6 +3643,8 @@ def compile(input_file_path, *output_file_name)
|
|
3229
3643
|
|
3230
3644
|
file_contents = compile_interpolated_strings(file_contents)
|
3231
3645
|
|
3646
|
+
file_contents = compile_hashes(file_contents,temp_file)
|
3647
|
+
|
3232
3648
|
file_contents = compile_conditional_structures(file_contents, temp_file)
|
3233
3649
|
|
3234
3650
|
file_contents = compile_arrays(file_contents, temp_file)
|
@@ -3329,7 +3745,7 @@ def find_file_path(input_path, file_extension)
|
|
3329
3745
|
|
3330
3746
|
end
|
3331
3747
|
|
3332
|
-
nilac_version = "0.0.4.2.
|
3748
|
+
nilac_version = "0.0.4.2.2"
|
3333
3749
|
|
3334
3750
|
opts = Slop.parse do
|
3335
3751
|
on :c, :compile=, 'Compile Nila File', as:Array, delimiter:":"
|
@@ -3384,6 +3800,24 @@ opts = Slop.parse do
|
|
3384
3800
|
|
3385
3801
|
end
|
3386
3802
|
|
3803
|
+
on :release, 'Build and Release Nilac for Rubygems' do
|
3804
|
+
|
3805
|
+
file_path = Dir.pwd + "/src/nilac.rb"
|
3806
|
+
|
3807
|
+
create_mac_executable(file_path)
|
3808
|
+
|
3809
|
+
FileUtils.mv("#{file_path[0...-3]}", "#{Dir.pwd}/bin/nilac")
|
3810
|
+
|
3811
|
+
`git commit -am "Updated Executable to #{nilac_version}"`
|
3812
|
+
|
3813
|
+
output = `rake release`
|
3814
|
+
|
3815
|
+
puts "Build Successful!"
|
3816
|
+
|
3817
|
+
puts output
|
3818
|
+
|
3819
|
+
end
|
3820
|
+
|
3387
3821
|
on :u, :update, 'Check if Nilac is up to date.' do
|
3388
3822
|
|
3389
3823
|
outdated_gems = `gem outdated`
|
data/lib/nilac/version.rb
CHANGED
data/src/nilac.rb
CHANGED
@@ -3743,7 +3743,7 @@ def find_file_path(input_path, file_extension)
|
|
3743
3743
|
|
3744
3744
|
end
|
3745
3745
|
|
3746
|
-
nilac_version = "0.0.4.2.
|
3746
|
+
nilac_version = "0.0.4.2.2"
|
3747
3747
|
|
3748
3748
|
opts = Slop.parse do
|
3749
3749
|
on :c, :compile=, 'Compile Nila File', as:Array, delimiter:":"
|
@@ -3798,6 +3798,24 @@ opts = Slop.parse do
|
|
3798
3798
|
|
3799
3799
|
end
|
3800
3800
|
|
3801
|
+
on :release, 'Build and Release Nilac for Rubygems' do
|
3802
|
+
|
3803
|
+
file_path = Dir.pwd + "/src/nilac.rb"
|
3804
|
+
|
3805
|
+
create_mac_executable(file_path)
|
3806
|
+
|
3807
|
+
FileUtils.mv("#{file_path[0...-3]}", "#{Dir.pwd}/bin/nilac")
|
3808
|
+
|
3809
|
+
`git commit -am "Updated Executable to #{nilac_version}"`
|
3810
|
+
|
3811
|
+
output = `rake release`
|
3812
|
+
|
3813
|
+
puts "Build Successful!"
|
3814
|
+
|
3815
|
+
puts output
|
3816
|
+
|
3817
|
+
end
|
3818
|
+
|
3801
3819
|
on :u, :update, 'Check if Nilac is up to date.' do
|
3802
3820
|
|
3803
3821
|
outdated_gems = `gem outdated`
|