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