nilac 0.0.4.1.1 → 0.0.4.1.2

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