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.
Files changed (3) hide show
  1. data/lib/nilac/version.rb +1 -1
  2. data/src/nilac.rb +127 -58
  3. metadata +1 -1
data/lib/nilac/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Nilac
2
- VERSION = "0.0.4.1"
2
+ VERSION = "0.0.4.1.1"
3
3
  end
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
- modified_file_contents = nila_file_contents.dup
320
+ unless key_word_locations.empty?
321
321
 
322
- for y in 0...end_locations.length
322
+ modified_file_contents = nila_file_contents.dup
323
323
 
324
- current_location = end_locations[y]
324
+ for y in 0...end_locations.length
325
325
 
326
- current_string = modified_file_contents[current_location]
326
+ current_location = end_locations[y]
327
327
 
328
- finder_location = current_location
328
+ current_string = modified_file_contents[current_location]
329
329
 
330
- begin
330
+ finder_location = current_location
331
331
 
332
- while current_string.index(nila_regexp) == nil
332
+ begin
333
333
 
334
- finder_location -= 1
334
+ while current_string.index(nila_regexp) == nil
335
335
 
336
- current_string = modified_file_contents[finder_location]
336
+ finder_location -= 1
337
337
 
338
- end
338
+ current_string = modified_file_contents[finder_location]
339
+
340
+ end
339
341
 
340
- code_block_begin = finder_location
342
+ code_block_begin = finder_location
341
343
 
342
- code_block_end = current_location
344
+ code_block_end = current_location
343
345
 
344
- start_blocks << code_block_begin
346
+ start_blocks << code_block_begin
345
347
 
346
- end_blocks << code_block_end
348
+ end_blocks << code_block_end
347
349
 
348
- code_block_begin_string_split = modified_file_contents[code_block_begin].split(" ")
350
+ code_block_begin_string_split = modified_file_contents[code_block_begin].split(" ")
349
351
 
350
- code_block_begin_string_split[0] = code_block_begin_string_split[0].reverse
352
+ code_block_begin_string_split[0] = code_block_begin_string_split[0].reverse
351
353
 
352
- code_block_begin_string = code_block_begin_string_split.join(" ")
354
+ code_block_begin_string = code_block_begin_string_split.join(" ")
353
355
 
354
- modified_file_contents[code_block_begin] = code_block_begin_string
356
+ modified_file_contents[code_block_begin] = code_block_begin_string
355
357
 
356
- rescue NoMethodError
358
+ rescue NoMethodError
357
359
 
358
- puts "Function compilation failed!"
360
+ puts "Function compilation failed!"
361
+
362
+ end
359
363
 
360
364
  end
361
365
 
362
- end
366
+ final_modified_file_contents = nila_file_contents.dup
363
367
 
364
- final_modified_file_contents = nila_file_contents.dup
368
+ joined_file_contents = final_modified_file_contents.join
365
369
 
366
- joined_file_contents = final_modified_file_contents.join
370
+ while start_blocks.length != 0
367
371
 
368
- while start_blocks.length != 0
372
+ top_most_level = start_blocks.min
369
373
 
370
- top_most_level = start_blocks.min
374
+ top_most_level_index = start_blocks.index(top_most_level)
371
375
 
372
- top_most_level_index = start_blocks.index(top_most_level)
376
+ matching_level = end_blocks[top_most_level_index]
373
377
 
374
- matching_level = end_blocks[top_most_level_index]
378
+ named_code_blocks << extract_array(final_modified_file_contents,top_most_level,matching_level)
375
379
 
376
- named_code_blocks << extract_array(final_modified_file_contents,top_most_level,matching_level)
380
+ start_blocks.delete_at(top_most_level_index)
377
381
 
378
- start_blocks.delete_at(top_most_level_index)
382
+ end_blocks.delete(matching_level)
379
383
 
380
- end_blocks.delete(matching_level)
384
+ end
381
385
 
382
- end
386
+ codeblock_counter = 1
383
387
 
384
- codeblock_counter = 1
388
+ named_functions = named_code_blocks.dup
385
389
 
386
- named_functions = named_code_blocks.dup
390
+ nested_functions = []
387
391
 
388
- nested_functions = []
392
+ named_code_blocks.each do |codeblock|
389
393
 
390
- named_code_blocks.each do |codeblock|
394
+ if joined_file_contents.include?(codeblock.join)
391
395
 
392
- if joined_file_contents.include?(codeblock.join)
396
+ joined_file_contents = joined_file_contents.sub(codeblock.join,"--named_function[#{codeblock_counter}]\n")
393
397
 
394
- joined_file_contents = joined_file_contents.sub(codeblock.join,"--named_function[#{codeblock_counter}]\n")
398
+ codeblock_counter += 1
395
399
 
396
- codeblock_counter += 1
400
+ nested_functions = nested_functions + [[]]
397
401
 
398
- nested_functions = nested_functions + [[]]
402
+ else
399
403
 
400
- else
404
+ nested_functions[codeblock_counter-2] << codeblock
401
405
 
402
- nested_functions[codeblock_counter-2] << codeblock
406
+ named_functions.delete(codeblock)
403
407
 
404
- named_functions.delete(codeblock)
408
+ end
405
409
 
406
410
  end
407
411
 
408
- end
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
- codeblock_counter = 1
1270
+ unless named_code_blocks.empty?
1252
1271
 
1253
- function_names = []
1272
+ codeblock_counter = 1
1254
1273
 
1255
- named_code_blocks.each do |codeblock|
1274
+ function_names = []
1256
1275
 
1257
- function_names[codeblock_counter-1] = []
1276
+ named_code_blocks.each do |codeblock|
1258
1277
 
1259
- joined_file_contents = joined_file_contents.sub("--named_function[#{codeblock_counter}]\n",compile_function(codeblock,temporary_nila_file).join)
1278
+ function_names[codeblock_counter-1] = []
1260
1279
 
1261
- codeblock_counter += 1
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
- current_nested_functions = nested_functions[codeblock_counter-2]
1284
+ current_nested_functions = nested_functions[codeblock_counter-2]
1264
1285
 
1265
- function_names[codeblock_counter-2] << extract_function_name(codeblock)
1286
+ function_names[codeblock_counter-2] << extract_function_name(codeblock)
1266
1287
 
1267
- current_nested_functions.each do |nested_function|
1288
+ current_nested_functions.each do |nested_function|
1268
1289
 
1269
- function_names[codeblock_counter-2] << extract_function_name(nested_function)
1290
+ function_names[codeblock_counter-2] << extract_function_name(nested_function)
1270
1291
 
1271
- joined_file_contents = joined_file_contents.sub(nested_function.join,compile_function(nested_function,temporary_nila_file).join)
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.lstrip.eql? "end\n"
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.lstrip.eql? "end\n"
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
- return input_block
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:":"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nilac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4.1
4
+ version: 0.0.4.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: