nilac 0.0.4.3.7 → 0.0.4.3.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1134f4be8a507aaab07700dfb882b0ef88ecb985
4
- data.tar.gz: 53494da4adc0e265b169282703dafa702e3d26db
3
+ metadata.gz: 946479712b870511a2fa2aacd1d0eae1b2f71576
4
+ data.tar.gz: 1f3329086656b7245311c9b333ddaea3038e3d04
5
5
  SHA512:
6
- metadata.gz: 36b990668a578a13bffbd8ce30be8f5943cab2e9345b3b8ad356f0418bdd7844dc66d1256ad2cdc4f73d757cb0979eaf8259442c267fac9c1bb45982a3740d3c
7
- data.tar.gz: 62c848bf78ef3ef811b7affcde6dbf6c848901682b31df7ae0841d3e736bc06656cf1cb0c39d08ad79bc49323065acd075289e9161d90a4eb30b0c6d4240a097
6
+ metadata.gz: 8d2b2ce198fbcb2336e378f5a992136044f11b28ed98068d315c77c4d7d6b0b540886c7934f33ed14bed62427c0490091d42ffc2f1a635b8ac39ae0cbdd5d910
7
+ data.tar.gz: 5ea3b07089d657c3772df5105e63ca25646777356f4fe30a2003e4f4e8fa98d88e4c8c93b725f63d4ecfc1215d8a626b4d684b7e94815882cb1c93ae2dac400c
data/bin/nilac CHANGED
@@ -1490,7 +1490,7 @@ def compile(input_file_path, *output_file_name)
1490
1490
 
1491
1491
  end
1492
1492
 
1493
- javascript_regexp = /(if |while |for |function |function\(|%[qQ]*\{)/
1493
+ javascript_regexp = /(if |while |for |function |function\(|%[qQw]*\{)/
1494
1494
 
1495
1495
  modified_file_contents = input_file_contents.clone.collect {|element| replace_strings(element)}
1496
1496
 
@@ -2265,6 +2265,10 @@ def compile(input_file_path, *output_file_name)
2265
2265
 
2266
2266
  ".empty?" => ".length == 0",
2267
2267
 
2268
+ ".upcase" => ".toUpperCase()",
2269
+
2270
+ ".downcase" => ".toLowerCase()",
2271
+
2268
2272
  }
2269
2273
 
2270
2274
  method_map = method_map_replacement.keys
@@ -2342,7 +2346,7 @@ def compile(input_file_path, *output_file_name)
2342
2346
 
2343
2347
  "nil" => "null",
2344
2348
 
2345
- "Array.new" => "Array()"
2349
+ "Array.new" => "new Array()"
2346
2350
 
2347
2351
  }
2348
2352
 
@@ -3847,6 +3851,207 @@ def compile(input_file_path, *output_file_name)
3847
3851
 
3848
3852
  end
3849
3853
 
3854
+ def compile_case_statement(input_file_contents,temporary_nila_file)
3855
+
3856
+ # This method compiles simple Ruby style case statements to Javascript
3857
+ # equivalent switch case statements
3858
+
3859
+ # For an example, look at shark/test_files/case.nila
3860
+
3861
+ def replace_strings(input_string)
3862
+
3863
+ string_counter = 0
3864
+
3865
+ if input_string.count("\"") % 2 == 0
3866
+
3867
+ while input_string.include?("\"")
3868
+
3869
+ string_extract = input_string[input_string.index("\"")..input_string.index("\"",input_string.index("\"")+1)]
3870
+
3871
+ input_string = input_string.sub(string_extract,"--repstring#{string_counter}")
3872
+
3873
+ string_counter += 1
3874
+
3875
+ end
3876
+
3877
+ end
3878
+
3879
+ if input_string.count("'") % 2 == 0
3880
+
3881
+ while input_string.include?("'")
3882
+
3883
+ string_extract = input_string[input_string.index("'")..input_string.index("'",input_string.index("'")+1)]
3884
+
3885
+ input_string = input_string.sub(string_extract,"--repstring#{string_counter}")
3886
+
3887
+ string_counter += 1
3888
+
3889
+ end
3890
+
3891
+ end
3892
+
3893
+ return input_string
3894
+
3895
+ end
3896
+
3897
+ def compile_when_statement(input_block)
3898
+
3899
+ condition,body = input_block[0],input_block[1..-1]
3900
+
3901
+ if replace_strings(condition.split("when ")[1]).include?(",")
3902
+
3903
+ condition_cases = condition.split("when ")[1].split(",").collect {|element| element.strip}
3904
+
3905
+ case_replacement = []
3906
+
3907
+ condition_cases.each do |ccase|
3908
+
3909
+ case_replacement << "case #{ccase}:%$%$ {\n\n"
3910
+
3911
+ case_replacement << body.collect {|element| " " + element.strip + "\n\n"}
3912
+
3913
+ case_replacement << " break\n%$%$\n}\n"
3914
+
3915
+ end
3916
+
3917
+ else
3918
+
3919
+ case_replacement = []
3920
+
3921
+ condition_case = condition.split("when ")[1].strip
3922
+
3923
+ case_replacement << "case #{condition_case}:%$%$ {\n\n"
3924
+
3925
+ case_replacement << body.collect {|element| " " + element.strip + "\n\n"}
3926
+
3927
+ case_replacement << " break\n%$%$\n}\n"
3928
+
3929
+ end
3930
+
3931
+ return case_replacement.join
3932
+
3933
+ end
3934
+
3935
+ modified_file_contents = input_file_contents.clone
3936
+
3937
+ possible_case_statements = input_file_contents.reject {|element| !element.include?("case ")}
3938
+
3939
+ case_statements = []
3940
+
3941
+ possible_case_statements.each do |statement|
3942
+
3943
+ starting_index = input_file_contents.index(statement)
3944
+
3945
+ index = starting_index
3946
+
3947
+ until input_file_contents[index].strip.eql?("end")
3948
+
3949
+ index += 1
3950
+
3951
+ end
3952
+
3953
+ case_statements << input_file_contents[starting_index..index].collect {|element| element.clone}.clone
3954
+
3955
+ end
3956
+
3957
+ legacy = case_statements.collect {|element| element.clone}
3958
+
3959
+ replacement_strings = []
3960
+
3961
+ case_statements.each do |statement_block|
3962
+
3963
+ condition = statement_block[0].split("case")[1].strip
3964
+
3965
+ statement_block[0] = "switch(#{condition}) {\n\n"
3966
+
3967
+ when_statements = statement_block.reject {|element| !replace_strings(element).include?("when")}
3968
+
3969
+ when_statements_index = []
3970
+
3971
+ when_statements.each do |statement|
3972
+
3973
+ when_statements_index << statement_block.each_index.select{|index| statement_block[index] == statement}
3974
+
3975
+ end
3976
+
3977
+ when_statements_index = when_statements_index.flatten
3978
+
3979
+ if replace_strings(statement_block.join).include?("else\n")
3980
+
3981
+ else_statement = statement_block.reject {|element| !replace_strings(element).strip.eql?("else")}
3982
+
3983
+ else_block = statement_block[statement_block.index(else_statement[0])+1...-1]
3984
+
3985
+ when_statements_index = when_statements_index + statement_block.each_index.select {|index| statement_block[index] == else_statement[0] }.to_a
3986
+
3987
+ when_statements_index = when_statements_index.flatten
3988
+
3989
+ statement_block[statement_block.index(else_statement[0])..-1] = ["default: %$%$ {\n\n",else_block.collect{|element| " " + element.strip + "\n\n"},"%$%$\n}\n\n}\n\n"].flatten
3990
+
3991
+ when_statement_blocks = []
3992
+
3993
+ when_statements.each_with_index do |statement,ind|
3994
+
3995
+ when_block = statement_block[when_statements_index[ind]...when_statements_index[ind+1]]
3996
+
3997
+ when_statement_blocks << when_block
3998
+
3999
+ end
4000
+
4001
+ replacement_blocks = when_statement_blocks.collect {|element| compile_when_statement(element)}
4002
+
4003
+ else
4004
+
4005
+ statement_block[-1] = "}\n\n" if statement_block[-1].strip.eql?("end")
4006
+
4007
+ when_statement_blocks = []
4008
+
4009
+ when_statements_index << -1
4010
+
4011
+ when_statements.each_with_index do |statement,ind|
4012
+
4013
+ when_block = statement_block[when_statements_index[ind]...when_statements_index[ind+1]]
4014
+
4015
+ when_statement_blocks << when_block
4016
+
4017
+ end
4018
+
4019
+ replacement_blocks = when_statement_blocks.collect {|element| compile_when_statement(element)}
4020
+
4021
+ end
4022
+
4023
+ statement_block = statement_block.join
4024
+
4025
+ when_statement_blocks.each_with_index do |blck,index|
4026
+
4027
+ statement_block = statement_block.sub(blck.join,replacement_blocks[index])
4028
+
4029
+ end
4030
+
4031
+ replacement_strings << statement_block
4032
+
4033
+ end
4034
+
4035
+ joined_file_contents = modified_file_contents.join
4036
+
4037
+ legacy.each_with_index do |statement,index|
4038
+
4039
+ joined_file_contents = joined_file_contents.sub(statement.join,replacement_strings[index])
4040
+
4041
+ end
4042
+
4043
+ file_id = open(temporary_nila_file, 'w')
4044
+
4045
+ file_id.write(joined_file_contents)
4046
+
4047
+ file_id.close()
4048
+
4049
+ line_by_line_contents = read_file_line_by_line(temporary_nila_file)
4050
+
4051
+ return line_by_line_contents
4052
+
4053
+ end
4054
+
3850
4055
  def compile_loops(input_file_contents,temporary_nila_file)
3851
4056
 
3852
4057
  def compile_times_loop(input_file_contents,temporary_nila_file)
@@ -4393,7 +4598,7 @@ def compile(input_file_path, *output_file_name)
4393
4598
 
4394
4599
  def extract_blocks(file_contents)
4395
4600
 
4396
- javascript_regexp = /(if |while |for |function\(|((=|:)\s+\{))/
4601
+ javascript_regexp = /(if |while |for |case |default:|switch\(|function\(|((=|:)\s+\{))/
4397
4602
 
4398
4603
  block_starting_lines = file_contents.dup.reject { |element| element.index(javascript_regexp).nil? }[1..-1]
4399
4604
 
@@ -4493,7 +4698,7 @@ def compile(input_file_path, *output_file_name)
4493
4698
 
4494
4699
  if !code_block_starting_locations.empty?
4495
4700
 
4496
- controlregexp = /(if |for |while |,function\(|\(function\(|= function\(|((=|:)\s+\{))/
4701
+ controlregexp = /(if |for |while |case |default:|switch\(|,function\(|\(function\(|= function\(|((=|:)\s+\{))/
4497
4702
 
4498
4703
  code_block_starting_locations = [0, code_block_starting_locations, -1].flatten
4499
4704
 
@@ -4637,7 +4842,7 @@ def compile(input_file_path, *output_file_name)
4637
4842
 
4638
4843
  end
4639
4844
 
4640
- javascript_regexp = /(if |for |while |\(function\(|= function\(|((=|:)\s+\{))/
4845
+ javascript_regexp = /(if |for |while |case |default:|switch\(|\(function\(|= function\(|((=|:)\s+\{))/
4641
4846
 
4642
4847
  if declarable_variables.length > 0
4643
4848
 
@@ -4779,8 +4984,22 @@ def compile(input_file_path, *output_file_name)
4779
4984
 
4780
4985
  line_by_line_contents = read_file_line_by_line(temporary_nila_file)
4781
4986
 
4987
+ line_by_line_contents = line_by_line_contents.collect {|element| element.gsub("%$%$ {","")}
4988
+
4782
4989
  line_by_line_contents = fix_newlines(line_by_line_contents)
4783
4990
 
4991
+ removable_indices = line_by_line_contents.each_index.select {|index| line_by_line_contents[index].strip == "%$%$;" }
4992
+
4993
+ while line_by_line_contents.join.include?("%$%$;")
4994
+
4995
+ line_by_line_contents.delete_at(removable_indices[0])
4996
+
4997
+ line_by_line_contents.delete_at(removable_indices[0])
4998
+
4999
+ removable_indices = line_by_line_contents.each_index.select {|index| line_by_line_contents[index].strip == "%$%$;" }
5000
+
5001
+ end
5002
+
4784
5003
  line_by_line_contents = fix_syntax_indentation(line_by_line_contents)
4785
5004
 
4786
5005
  line_by_line_contents = line_by_line_contents.collect { |element| replace_ignored_words(element) }
@@ -4912,6 +5131,8 @@ def compile(input_file_path, *output_file_name)
4912
5131
 
4913
5132
  file_contents = compile_hashes(file_contents,temp_file)
4914
5133
 
5134
+ file_contents = compile_case_statement(file_contents,temp_file)
5135
+
4915
5136
  file_contents = compile_conditional_structures(file_contents, temp_file)
4916
5137
 
4917
5138
  file_contents = compile_blocks(file_contents,temp_file)
@@ -5024,7 +5245,7 @@ def find_file_path(input_path, file_extension)
5024
5245
 
5025
5246
  end
5026
5247
 
5027
- nilac_version = "0.0.4.3.4"
5248
+ nilac_version = "0.0.4.3.8"
5028
5249
 
5029
5250
  opts = Slop.parse do
5030
5251
  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.3.7"
2
+ VERSION = "0.0.4.3.8"
3
3
  end
@@ -0,0 +1,11 @@
1
+ Feature: This feature bring Ruby's case when structure to Nila
2
+ Scenario: Input file with multiple case when structures
3
+ Given the input file "case.nila"
4
+ When the ~compiler is run
5
+ The output file must be "case.js"
6
+ The output file must equal "correct_case.js"
7
+
8
+ Configurations:
9
+
10
+ ~compiler => src/nilac.rb
11
+ :v $cliusage => ruby :v --compile $file
@@ -0,0 +1,23 @@
1
+ grades = %w{A B A C D F}
2
+
3
+ for grade in grades
4
+
5
+ case grade
6
+ when "A", "B"
7
+ puts 'You are pretty smart!'
8
+ when "C"
9
+ puts 'You are intelligent!'
10
+ end
11
+
12
+ end
13
+
14
+ num = 5
15
+
16
+ case num
17
+ when 1
18
+ puts 'Your input was 1'
19
+ when 2
20
+ puts 'Your input was 2'
21
+ else
22
+ puts "Your input was greater than 2"
23
+ end
@@ -0,0 +1,35 @@
1
+ //Written using Nila. Visit http://adhithyan15.github.io/nila
2
+ (function() {
3
+ var _i, _j, grade, grades, num;
4
+
5
+ grades = ["A", "B", "A", "C", "D", "F"];
6
+
7
+ for (_i = 0, _j = grades.length; _i < _j; _i += 1) {
8
+ grade = grades[_i];
9
+ switch(grade) {
10
+ case "A":
11
+ console.log('You are pretty smart!');
12
+ break;
13
+ case "B":
14
+ console.log('You are pretty smart!');
15
+ break;
16
+ case "C":
17
+ console.log('You are intelligent!');
18
+ break;
19
+ }
20
+ }
21
+
22
+ num = 5;
23
+
24
+ switch(num) {
25
+ case 1:
26
+ console.log('Your input was 1');
27
+ break;
28
+ case 2:
29
+ console.log('Your input was 2');
30
+ break;
31
+ default:
32
+ console.log("Your input was greater than 2");
33
+ }
34
+
35
+ }).call(this);
data/src/nilac.rb CHANGED
@@ -1488,7 +1488,7 @@ def compile(input_file_path, *output_file_name)
1488
1488
 
1489
1489
  end
1490
1490
 
1491
- javascript_regexp = /(if |while |for |function |function\(|%[qQ]*\{)/
1491
+ javascript_regexp = /(if |while |for |function |function\(|%[qQw]*\{)/
1492
1492
 
1493
1493
  modified_file_contents = input_file_contents.clone.collect {|element| replace_strings(element)}
1494
1494
 
@@ -2263,6 +2263,10 @@ def compile(input_file_path, *output_file_name)
2263
2263
 
2264
2264
  ".empty?" => ".length == 0",
2265
2265
 
2266
+ ".upcase" => ".toUpperCase()",
2267
+
2268
+ ".downcase" => ".toLowerCase()",
2269
+
2266
2270
  }
2267
2271
 
2268
2272
  method_map = method_map_replacement.keys
@@ -2340,7 +2344,7 @@ def compile(input_file_path, *output_file_name)
2340
2344
 
2341
2345
  "nil" => "null",
2342
2346
 
2343
- "Array.new" => "Array()"
2347
+ "Array.new" => "new Array()"
2344
2348
 
2345
2349
  }
2346
2350
 
@@ -3845,6 +3849,207 @@ def compile(input_file_path, *output_file_name)
3845
3849
 
3846
3850
  end
3847
3851
 
3852
+ def compile_case_statement(input_file_contents,temporary_nila_file)
3853
+
3854
+ # This method compiles simple Ruby style case statements to Javascript
3855
+ # equivalent switch case statements
3856
+
3857
+ # For an example, look at shark/test_files/case.nila
3858
+
3859
+ def replace_strings(input_string)
3860
+
3861
+ string_counter = 0
3862
+
3863
+ if input_string.count("\"") % 2 == 0
3864
+
3865
+ while input_string.include?("\"")
3866
+
3867
+ string_extract = input_string[input_string.index("\"")..input_string.index("\"",input_string.index("\"")+1)]
3868
+
3869
+ input_string = input_string.sub(string_extract,"--repstring#{string_counter}")
3870
+
3871
+ string_counter += 1
3872
+
3873
+ end
3874
+
3875
+ end
3876
+
3877
+ if input_string.count("'") % 2 == 0
3878
+
3879
+ while input_string.include?("'")
3880
+
3881
+ string_extract = input_string[input_string.index("'")..input_string.index("'",input_string.index("'")+1)]
3882
+
3883
+ input_string = input_string.sub(string_extract,"--repstring#{string_counter}")
3884
+
3885
+ string_counter += 1
3886
+
3887
+ end
3888
+
3889
+ end
3890
+
3891
+ return input_string
3892
+
3893
+ end
3894
+
3895
+ def compile_when_statement(input_block)
3896
+
3897
+ condition,body = input_block[0],input_block[1..-1]
3898
+
3899
+ if replace_strings(condition.split("when ")[1]).include?(",")
3900
+
3901
+ condition_cases = condition.split("when ")[1].split(",").collect {|element| element.strip}
3902
+
3903
+ case_replacement = []
3904
+
3905
+ condition_cases.each do |ccase|
3906
+
3907
+ case_replacement << "case #{ccase}:%$%$ {\n\n"
3908
+
3909
+ case_replacement << body.collect {|element| " " + element.strip + "\n\n"}
3910
+
3911
+ case_replacement << " break\n%$%$\n}\n"
3912
+
3913
+ end
3914
+
3915
+ else
3916
+
3917
+ case_replacement = []
3918
+
3919
+ condition_case = condition.split("when ")[1].strip
3920
+
3921
+ case_replacement << "case #{condition_case}:%$%$ {\n\n"
3922
+
3923
+ case_replacement << body.collect {|element| " " + element.strip + "\n\n"}
3924
+
3925
+ case_replacement << " break\n%$%$\n}\n"
3926
+
3927
+ end
3928
+
3929
+ return case_replacement.join
3930
+
3931
+ end
3932
+
3933
+ modified_file_contents = input_file_contents.clone
3934
+
3935
+ possible_case_statements = input_file_contents.reject {|element| !element.include?("case ")}
3936
+
3937
+ case_statements = []
3938
+
3939
+ possible_case_statements.each do |statement|
3940
+
3941
+ starting_index = input_file_contents.index(statement)
3942
+
3943
+ index = starting_index
3944
+
3945
+ until input_file_contents[index].strip.eql?("end")
3946
+
3947
+ index += 1
3948
+
3949
+ end
3950
+
3951
+ case_statements << input_file_contents[starting_index..index].collect {|element| element.clone}.clone
3952
+
3953
+ end
3954
+
3955
+ legacy = case_statements.collect {|element| element.clone}
3956
+
3957
+ replacement_strings = []
3958
+
3959
+ case_statements.each do |statement_block|
3960
+
3961
+ condition = statement_block[0].split("case")[1].strip
3962
+
3963
+ statement_block[0] = "switch(#{condition}) {\n\n"
3964
+
3965
+ when_statements = statement_block.reject {|element| !replace_strings(element).include?("when")}
3966
+
3967
+ when_statements_index = []
3968
+
3969
+ when_statements.each do |statement|
3970
+
3971
+ when_statements_index << statement_block.each_index.select{|index| statement_block[index] == statement}
3972
+
3973
+ end
3974
+
3975
+ when_statements_index = when_statements_index.flatten
3976
+
3977
+ if replace_strings(statement_block.join).include?("else\n")
3978
+
3979
+ else_statement = statement_block.reject {|element| !replace_strings(element).strip.eql?("else")}
3980
+
3981
+ else_block = statement_block[statement_block.index(else_statement[0])+1...-1]
3982
+
3983
+ when_statements_index = when_statements_index + statement_block.each_index.select {|index| statement_block[index] == else_statement[0] }.to_a
3984
+
3985
+ when_statements_index = when_statements_index.flatten
3986
+
3987
+ statement_block[statement_block.index(else_statement[0])..-1] = ["default: %$%$ {\n\n",else_block.collect{|element| " " + element.strip + "\n\n"},"%$%$\n}\n\n}\n\n"].flatten
3988
+
3989
+ when_statement_blocks = []
3990
+
3991
+ when_statements.each_with_index do |statement,ind|
3992
+
3993
+ when_block = statement_block[when_statements_index[ind]...when_statements_index[ind+1]]
3994
+
3995
+ when_statement_blocks << when_block
3996
+
3997
+ end
3998
+
3999
+ replacement_blocks = when_statement_blocks.collect {|element| compile_when_statement(element)}
4000
+
4001
+ else
4002
+
4003
+ statement_block[-1] = "}\n\n" if statement_block[-1].strip.eql?("end")
4004
+
4005
+ when_statement_blocks = []
4006
+
4007
+ when_statements_index << -1
4008
+
4009
+ when_statements.each_with_index do |statement,ind|
4010
+
4011
+ when_block = statement_block[when_statements_index[ind]...when_statements_index[ind+1]]
4012
+
4013
+ when_statement_blocks << when_block
4014
+
4015
+ end
4016
+
4017
+ replacement_blocks = when_statement_blocks.collect {|element| compile_when_statement(element)}
4018
+
4019
+ end
4020
+
4021
+ statement_block = statement_block.join
4022
+
4023
+ when_statement_blocks.each_with_index do |blck,index|
4024
+
4025
+ statement_block = statement_block.sub(blck.join,replacement_blocks[index])
4026
+
4027
+ end
4028
+
4029
+ replacement_strings << statement_block
4030
+
4031
+ end
4032
+
4033
+ joined_file_contents = modified_file_contents.join
4034
+
4035
+ legacy.each_with_index do |statement,index|
4036
+
4037
+ joined_file_contents = joined_file_contents.sub(statement.join,replacement_strings[index])
4038
+
4039
+ end
4040
+
4041
+ file_id = open(temporary_nila_file, 'w')
4042
+
4043
+ file_id.write(joined_file_contents)
4044
+
4045
+ file_id.close()
4046
+
4047
+ line_by_line_contents = read_file_line_by_line(temporary_nila_file)
4048
+
4049
+ return line_by_line_contents
4050
+
4051
+ end
4052
+
3848
4053
  def compile_loops(input_file_contents,temporary_nila_file)
3849
4054
 
3850
4055
  def compile_times_loop(input_file_contents,temporary_nila_file)
@@ -4391,7 +4596,7 @@ def compile(input_file_path, *output_file_name)
4391
4596
 
4392
4597
  def extract_blocks(file_contents)
4393
4598
 
4394
- javascript_regexp = /(if |while |for |function\(|((=|:)\s+\{))/
4599
+ javascript_regexp = /(if |while |for |case |default:|switch\(|function\(|((=|:)\s+\{))/
4395
4600
 
4396
4601
  block_starting_lines = file_contents.dup.reject { |element| element.index(javascript_regexp).nil? }[1..-1]
4397
4602
 
@@ -4491,7 +4696,7 @@ def compile(input_file_path, *output_file_name)
4491
4696
 
4492
4697
  if !code_block_starting_locations.empty?
4493
4698
 
4494
- controlregexp = /(if |for |while |,function\(|\(function\(|= function\(|((=|:)\s+\{))/
4699
+ controlregexp = /(if |for |while |case |default:|switch\(|,function\(|\(function\(|= function\(|((=|:)\s+\{))/
4495
4700
 
4496
4701
  code_block_starting_locations = [0, code_block_starting_locations, -1].flatten
4497
4702
 
@@ -4635,7 +4840,7 @@ def compile(input_file_path, *output_file_name)
4635
4840
 
4636
4841
  end
4637
4842
 
4638
- javascript_regexp = /(if |for |while |\(function\(|= function\(|((=|:)\s+\{))/
4843
+ javascript_regexp = /(if |for |while |case |default:|switch\(|\(function\(|= function\(|((=|:)\s+\{))/
4639
4844
 
4640
4845
  if declarable_variables.length > 0
4641
4846
 
@@ -4777,8 +4982,22 @@ def compile(input_file_path, *output_file_name)
4777
4982
 
4778
4983
  line_by_line_contents = read_file_line_by_line(temporary_nila_file)
4779
4984
 
4985
+ line_by_line_contents = line_by_line_contents.collect {|element| element.gsub("%$%$ {","")}
4986
+
4780
4987
  line_by_line_contents = fix_newlines(line_by_line_contents)
4781
4988
 
4989
+ removable_indices = line_by_line_contents.each_index.select {|index| line_by_line_contents[index].strip == "%$%$;" }
4990
+
4991
+ while line_by_line_contents.join.include?("%$%$;")
4992
+
4993
+ line_by_line_contents.delete_at(removable_indices[0])
4994
+
4995
+ line_by_line_contents.delete_at(removable_indices[0])
4996
+
4997
+ removable_indices = line_by_line_contents.each_index.select {|index| line_by_line_contents[index].strip == "%$%$;" }
4998
+
4999
+ end
5000
+
4782
5001
  line_by_line_contents = fix_syntax_indentation(line_by_line_contents)
4783
5002
 
4784
5003
  line_by_line_contents = line_by_line_contents.collect { |element| replace_ignored_words(element) }
@@ -4910,6 +5129,8 @@ def compile(input_file_path, *output_file_name)
4910
5129
 
4911
5130
  file_contents = compile_hashes(file_contents,temp_file)
4912
5131
 
5132
+ file_contents = compile_case_statement(file_contents,temp_file)
5133
+
4913
5134
  file_contents = compile_conditional_structures(file_contents, temp_file)
4914
5135
 
4915
5136
  file_contents = compile_blocks(file_contents,temp_file)
@@ -5022,7 +5243,7 @@ def find_file_path(input_path, file_extension)
5022
5243
 
5023
5244
  end
5024
5245
 
5025
- nilac_version = "0.0.4.3.4"
5246
+ nilac_version = "0.0.4.3.8"
5026
5247
 
5027
5248
  opts = Slop.parse do
5028
5249
  on :c, :compile=, 'Compile Nila File', as:Array, delimiter:":"