nilac 0.0.4.1.1 → 0.0.4.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/nilac +127 -58
- data/lib/nilac/version.rb +1 -1
- data/src/nilac.rb +1 -1
- metadata +1 -1
data/bin/nilac
CHANGED
@@ -319,96 +319,107 @@ def compile(input_file_path,*output_file_name)
|
|
319
319
|
|
320
320
|
end
|
321
321
|
|
322
|
-
|
322
|
+
unless key_word_locations.empty?
|
323
323
|
|
324
|
-
|
324
|
+
modified_file_contents = nila_file_contents.dup
|
325
325
|
|
326
|
-
|
326
|
+
for y in 0...end_locations.length
|
327
327
|
|
328
|
-
|
328
|
+
current_location = end_locations[y]
|
329
329
|
|
330
|
-
|
330
|
+
current_string = modified_file_contents[current_location]
|
331
331
|
|
332
|
-
|
332
|
+
finder_location = current_location
|
333
333
|
|
334
|
-
|
334
|
+
begin
|
335
335
|
|
336
|
-
|
336
|
+
while current_string.index(nila_regexp) == nil
|
337
337
|
|
338
|
-
|
338
|
+
finder_location -= 1
|
339
339
|
|
340
|
-
|
340
|
+
current_string = modified_file_contents[finder_location]
|
341
|
+
|
342
|
+
end
|
341
343
|
|
342
|
-
|
344
|
+
code_block_begin = finder_location
|
343
345
|
|
344
|
-
|
346
|
+
code_block_end = current_location
|
345
347
|
|
346
|
-
|
348
|
+
start_blocks << code_block_begin
|
347
349
|
|
348
|
-
|
350
|
+
end_blocks << code_block_end
|
349
351
|
|
350
|
-
|
352
|
+
code_block_begin_string_split = modified_file_contents[code_block_begin].split(" ")
|
351
353
|
|
352
|
-
|
354
|
+
code_block_begin_string_split[0] = code_block_begin_string_split[0].reverse
|
353
355
|
|
354
|
-
|
356
|
+
code_block_begin_string = code_block_begin_string_split.join(" ")
|
355
357
|
|
356
|
-
|
358
|
+
modified_file_contents[code_block_begin] = code_block_begin_string
|
357
359
|
|
358
|
-
|
360
|
+
rescue NoMethodError
|
359
361
|
|
360
|
-
|
362
|
+
puts "Function compilation failed!"
|
363
|
+
|
364
|
+
end
|
361
365
|
|
362
366
|
end
|
363
367
|
|
364
|
-
|
368
|
+
final_modified_file_contents = nila_file_contents.dup
|
365
369
|
|
366
|
-
|
370
|
+
joined_file_contents = final_modified_file_contents.join
|
367
371
|
|
368
|
-
|
372
|
+
while start_blocks.length != 0
|
369
373
|
|
370
|
-
|
374
|
+
top_most_level = start_blocks.min
|
371
375
|
|
372
|
-
|
376
|
+
top_most_level_index = start_blocks.index(top_most_level)
|
373
377
|
|
374
|
-
|
378
|
+
matching_level = end_blocks[top_most_level_index]
|
375
379
|
|
376
|
-
|
380
|
+
named_code_blocks << extract_array(final_modified_file_contents,top_most_level,matching_level)
|
377
381
|
|
378
|
-
|
382
|
+
start_blocks.delete_at(top_most_level_index)
|
379
383
|
|
380
|
-
|
384
|
+
end_blocks.delete(matching_level)
|
381
385
|
|
382
|
-
|
386
|
+
end
|
383
387
|
|
384
|
-
|
388
|
+
codeblock_counter = 1
|
385
389
|
|
386
|
-
|
390
|
+
named_functions = named_code_blocks.dup
|
387
391
|
|
388
|
-
|
392
|
+
nested_functions = []
|
389
393
|
|
390
|
-
|
394
|
+
named_code_blocks.each do |codeblock|
|
391
395
|
|
392
|
-
|
396
|
+
if joined_file_contents.include?(codeblock.join)
|
393
397
|
|
394
|
-
|
398
|
+
joined_file_contents = joined_file_contents.sub(codeblock.join,"--named_function[#{codeblock_counter}]\n")
|
395
399
|
|
396
|
-
|
400
|
+
codeblock_counter += 1
|
397
401
|
|
398
|
-
|
402
|
+
nested_functions = nested_functions + [[]]
|
399
403
|
|
400
|
-
|
404
|
+
else
|
401
405
|
|
402
|
-
|
406
|
+
nested_functions[codeblock_counter-2] << codeblock
|
403
407
|
|
404
|
-
|
408
|
+
named_functions.delete(codeblock)
|
405
409
|
|
406
|
-
|
410
|
+
end
|
407
411
|
|
408
412
|
end
|
409
413
|
|
410
|
-
|
414
|
+
else
|
415
|
+
|
416
|
+
joined_file_contents = nila_file_contents.join
|
411
417
|
|
418
|
+
named_functions = []
|
419
|
+
|
420
|
+
nested_functions = []
|
421
|
+
|
422
|
+
end
|
412
423
|
|
413
424
|
file_id = open(temporary_nila_file, 'w')
|
414
425
|
|
@@ -557,6 +568,10 @@ def compile(input_file_path,*output_file_name)
|
|
557
568
|
|
558
569
|
variables = []
|
559
570
|
|
571
|
+
input_file_contents = input_file_contents.collect {|element| element.gsub("==","equalequal")}
|
572
|
+
|
573
|
+
input_file_contents = input_file_contents.collect {|element| element.gsub("!=","notequal")}
|
574
|
+
|
560
575
|
input_file_contents = input_file_contents.collect {|element| element.gsub("+=","plusequal")}
|
561
576
|
|
562
577
|
input_file_contents = input_file_contents.collect {|element| element.gsub("-=","minusequal")}
|
@@ -623,6 +638,10 @@ def compile(input_file_path,*output_file_name)
|
|
623
638
|
|
624
639
|
line_by_line_contents = line_by_line_contents.collect {|element| element.gsub("modequal","%=")}
|
625
640
|
|
641
|
+
line_by_line_contents = line_by_line_contents.collect {|element| element.gsub("equalequal","==")}
|
642
|
+
|
643
|
+
line_by_line_contents = line_by_line_contents.collect {|element| element.gsub("notequal","!=")}
|
644
|
+
|
626
645
|
return variables.uniq,line_by_line_contents
|
627
646
|
|
628
647
|
end
|
@@ -1250,30 +1269,38 @@ def compile(input_file_path,*output_file_name)
|
|
1250
1269
|
|
1251
1270
|
joined_file_contents = input_file_contents.join
|
1252
1271
|
|
1253
|
-
|
1272
|
+
unless named_code_blocks.empty?
|
1254
1273
|
|
1255
|
-
|
1274
|
+
codeblock_counter = 1
|
1256
1275
|
|
1257
|
-
|
1276
|
+
function_names = []
|
1258
1277
|
|
1259
|
-
|
1278
|
+
named_code_blocks.each do |codeblock|
|
1260
1279
|
|
1261
|
-
|
1280
|
+
function_names[codeblock_counter-1] = []
|
1262
1281
|
|
1263
|
-
|
1282
|
+
joined_file_contents = joined_file_contents.sub("--named_function[#{codeblock_counter}]\n",compile_function(codeblock,temporary_nila_file).join)
|
1283
|
+
|
1284
|
+
codeblock_counter += 1
|
1264
1285
|
|
1265
|
-
|
1286
|
+
current_nested_functions = nested_functions[codeblock_counter-2]
|
1266
1287
|
|
1267
|
-
|
1288
|
+
function_names[codeblock_counter-2] << extract_function_name(codeblock)
|
1268
1289
|
|
1269
|
-
|
1290
|
+
current_nested_functions.each do |nested_function|
|
1270
1291
|
|
1271
|
-
|
1292
|
+
function_names[codeblock_counter-2] << extract_function_name(nested_function)
|
1272
1293
|
|
1273
|
-
|
1294
|
+
joined_file_contents = joined_file_contents.sub(nested_function.join,compile_function(nested_function,temporary_nila_file).join)
|
1295
|
+
|
1296
|
+
end
|
1274
1297
|
|
1275
1298
|
end
|
1276
1299
|
|
1300
|
+
else
|
1301
|
+
|
1302
|
+
function_names = []
|
1303
|
+
|
1277
1304
|
end
|
1278
1305
|
|
1279
1306
|
file_id = open(temporary_nila_file, 'w')
|
@@ -1512,7 +1539,7 @@ def compile(input_file_path,*output_file_name)
|
|
1512
1539
|
|
1513
1540
|
current_block.each_with_index do |line,index|
|
1514
1541
|
|
1515
|
-
if line.
|
1542
|
+
if line.strip.eql? "end"
|
1516
1543
|
|
1517
1544
|
end_counter += 1
|
1518
1545
|
|
@@ -1556,7 +1583,7 @@ def compile(input_file_path,*output_file_name)
|
|
1556
1583
|
|
1557
1584
|
current_block.each_with_index do |line,index|
|
1558
1585
|
|
1559
|
-
if line.
|
1586
|
+
if line.strip.eql? "end"
|
1560
1587
|
|
1561
1588
|
end_counter += 1
|
1562
1589
|
|
@@ -1578,6 +1605,32 @@ def compile(input_file_path,*output_file_name)
|
|
1578
1605
|
|
1579
1606
|
def compile_if_syntax(input_block)
|
1580
1607
|
|
1608
|
+
strings = []
|
1609
|
+
|
1610
|
+
string_counter = 0
|
1611
|
+
|
1612
|
+
modified_input_block = input_block.dup
|
1613
|
+
|
1614
|
+
input_block.each_with_index do |line,index|
|
1615
|
+
|
1616
|
+
if line.include?("\"")
|
1617
|
+
|
1618
|
+
opening_quotes = line.index("\"")
|
1619
|
+
|
1620
|
+
string_extract = line[opening_quotes..line.index("\"",opening_quotes+1)]
|
1621
|
+
|
1622
|
+
strings << string_extract
|
1623
|
+
|
1624
|
+
modified_input_block[index] = modified_input_block[index].sub(string_extract,"--string{#{string_counter}}")
|
1625
|
+
|
1626
|
+
string_counter += 1
|
1627
|
+
|
1628
|
+
end
|
1629
|
+
|
1630
|
+
end
|
1631
|
+
|
1632
|
+
input_block = modified_input_block
|
1633
|
+
|
1581
1634
|
starting_line = input_block[0]
|
1582
1635
|
|
1583
1636
|
starting_line = starting_line + "\n" if starting_line.lstrip == starting_line
|
@@ -1606,7 +1659,23 @@ def compile(input_file_path,*output_file_name)
|
|
1606
1659
|
|
1607
1660
|
end
|
1608
1661
|
|
1609
|
-
|
1662
|
+
modified_input_block = input_block.dup
|
1663
|
+
|
1664
|
+
input_block.each_with_index do |line,index|
|
1665
|
+
|
1666
|
+
if line.include?("--string{")
|
1667
|
+
|
1668
|
+
junk,remains = line.split("--string{")
|
1669
|
+
|
1670
|
+
string_index,junk = remains.split("}")
|
1671
|
+
|
1672
|
+
modified_input_block[index] = modified_input_block[index].sub("--string{#{string_index.strip}}",strings[string_index.strip.to_i])
|
1673
|
+
|
1674
|
+
end
|
1675
|
+
|
1676
|
+
end
|
1677
|
+
|
1678
|
+
return modified_input_block
|
1610
1679
|
|
1611
1680
|
end
|
1612
1681
|
|
@@ -2440,7 +2509,7 @@ def find_file_path(input_path,file_extension)
|
|
2440
2509
|
|
2441
2510
|
end
|
2442
2511
|
|
2443
|
-
nilac_version = "0.0.4.1"
|
2512
|
+
nilac_version = "0.0.4.1.2"
|
2444
2513
|
|
2445
2514
|
opts = Slop.parse do
|
2446
2515
|
on :c, :compile=, 'Compile Nila File', as:Array, delimiter:":"
|
data/lib/nilac/version.rb
CHANGED
data/src/nilac.rb
CHANGED