nilac 0.0.4.3.9.6 → 0.0.4.3.9.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/README.md +2 -0
  4. data/examples/decBin.js +2 -2
  5. data/examples/repl.js +31 -0
  6. data/examples/repl.nila +24 -0
  7. data/lib/nilac/add_semicolons.rb +1 -1
  8. data/lib/nilac/compile_blocks.rb +20 -2
  9. data/lib/nilac/compile_case_statement.rb +1 -1
  10. data/lib/nilac/compile_conditional_structures.rb +20 -8
  11. data/lib/nilac/compile_custom_function_map.rb +3 -1
  12. data/lib/nilac/compile_default_values.rb +15 -1
  13. data/lib/nilac/compile_integers.rb +147 -2
  14. data/lib/nilac/compile_lambdas.rb +22 -6
  15. data/lib/nilac/compile_loops.rb +1 -1
  16. data/lib/nilac/compile_monkey_patching.rb +189 -0
  17. data/lib/nilac/compile_named_functions.rb +44 -70
  18. data/lib/nilac/compile_parallel_assignment.rb +2 -2
  19. data/lib/nilac/compile_ruby_methods.rb +3 -1
  20. data/lib/nilac/compile_strings.rb +4 -4
  21. data/lib/nilac/friendly_errors.rb +95 -0
  22. data/lib/nilac/get_variables.rb +29 -18
  23. data/lib/nilac/lexical_scoped_function_variables.rb +6 -0
  24. data/lib/nilac/output_javascript.rb +9 -7
  25. data/lib/nilac/paranthesis_compactor.rb +37 -0
  26. data/lib/nilac/pretty_print_javascript.rb +53 -61
  27. data/lib/nilac/replace_multiline_comments.rb +6 -2
  28. data/lib/nilac/replace_named_functions.rb +41 -65
  29. data/lib/nilac/replace_strings.rb +40 -17
  30. data/lib/nilac/rollblocks.rb +86 -13
  31. data/lib/nilac/version.rb +1 -1
  32. data/lib/nilac.rb +46 -13
  33. data/shark/features/blocks.feature +11 -0
  34. data/shark/features/monkey_patch.feature +11 -0
  35. data/shark/test_files/blocks.nila +18 -0
  36. data/shark/test_files/correct_blocks.js +25 -0
  37. data/shark/test_files/correct_case.js +1 -1
  38. data/shark/test_files/correct_monkey_patch.js +24 -0
  39. data/shark/test_files/correct_multiple_return.js +2 -2
  40. data/shark/test_files/correct_splats.js +3 -3
  41. data/shark/test_files/lambda.nila +9 -1
  42. data/shark/test_files/monkey_patch.nila +18 -0
  43. data/shark/test_files/multiple_return.nila +8 -8
  44. data/shark/test_files/sample_class.nila +1 -1
  45. metadata +13 -7
  46. data/LICENSE +0 -20
  47. data/examples/countdown.nila +0 -31
  48. data/lib/nilac/compile_classes.rb +0 -19
  49. data/shark/test_files/array_sugar.nila +0 -3
  50. data/shark/test_files/class.nila +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2aae60bb21de5dafc4e90454f1b4f6fb98b222ef
4
- data.tar.gz: 5be7a1d1fa7e3ead44e3163463b3ac191ea60442
3
+ metadata.gz: f6de7275f8c55561a3d02486aff02768c38e7cb4
4
+ data.tar.gz: cbf8cef4c5d1867681d0f0b7253027b51647074c
5
5
  SHA512:
6
- metadata.gz: e049e7f5ade3d9c6f6652bce8a5cdb4489719954f3ba1dad8a5e356b48400a1d2be5a2389c6a93a92c2e7d0b541492cfea24c9cff66aa91061e511e81c0012d4
7
- data.tar.gz: e47c6c6f6f95a0e06115257adf24d8a3e2fac841883a5365920a4c0aa86c3bb10d01b67df0ca1178198578a7f9d967c1279a047e14c010545e956f8cf8b35337
6
+ metadata.gz: 56d68009d99e3700c929d48b112c970aa80571cc5040936300ef434ba81fc40aedfc5764e86bf124c59a034f39e3130b822a4f860ffe3bdd421975b8a7dbcbbe
7
+ data.tar.gz: 107673c23264e9c4146b1360c8bae88a093d9f75cb57feabf6cb6fc76da3d4793900952226db743a40d6f4433f86e908307b02db9d62ab9d4c1d01bb0ded0d00
data/.gitignore CHANGED
@@ -15,4 +15,5 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
- .idea
18
+ .idea
19
+ cookbook
data/README.md CHANGED
@@ -65,3 +65,5 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
65
65
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
66
66
 
67
67
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
68
+
69
+ [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/adhithyan15/nila/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
data/examples/decBin.js CHANGED
@@ -1,11 +1,11 @@
1
1
  //Written using Nila. Visit http://adhithyan15.github.io/nila
2
2
  (function() {
3
- var _i,_j,decimalToBinary;
3
+ var _i, _j, decimalToBinary;
4
4
 
5
5
  //This is Nila's decimal to Binary converter. It's awesome
6
6
 
7
7
  decimalToBinary = function(input_num) {
8
- var remainder, storage, numsplit, inputnum, decimalplaces, calc, decans;
8
+ var calc, decans, decimalplaces, inputnum, numsplit, remainder, storage;
9
9
  remainder = "";
10
10
  storage = [];
11
11
  if (!((input_num.indexOf(".") === -1))) {
data/examples/repl.js ADDED
@@ -0,0 +1,31 @@
1
+ //Written using Nila. Visit http://adhithyan15.github.io/nila
2
+ (function() {
3
+ var read, readline, rl;
4
+
5
+ // This is a small REPL for Nila to test out nila code and do bug fixes
6
+
7
+ readline = require('readline');
8
+
9
+ rl = readline.createInterface(process.stdin, process.stdout);
10
+
11
+ rl.setPrompt('nila> ');
12
+
13
+ rl.prompt();
14
+
15
+ read = rl.on('line',function(line) {
16
+ switch(line.trim()) {
17
+ case 'hello':
18
+ console.log("world!");
19
+ break;
20
+ default:
21
+ console.log("Say what? I might have heard " + (line.trim()));
22
+ }
23
+ rl.prompt();
24
+ });
25
+
26
+ read.on('close',function() {
27
+ console.log("Have a great day!");
28
+ process.exit(0);
29
+ });
30
+
31
+ }).call(this);
@@ -0,0 +1,24 @@
1
+ # This is a small REPL for Nila to test out nila code and do bug fixes
2
+
3
+ require 'readline'
4
+
5
+ rl = readline.createInterface(process.stdin, process.stdout)
6
+
7
+ rl.setPrompt('nila> ')
8
+
9
+ rl.prompt()
10
+
11
+ read = rl.on 'line', do |line|
12
+ case line.trim()
13
+ when 'hello'
14
+ puts "world!"
15
+ else
16
+ puts "Say what? I might have heard #{line.trim()}"
17
+ end
18
+ rl.prompt()
19
+ end
20
+
21
+ read.on 'close', do
22
+ puts "Have a great day!"
23
+ process.exit(0)
24
+ end
@@ -32,7 +32,7 @@
32
32
 
33
33
  if !line.lstrip.eql?("")
34
34
 
35
- if !line.lstrip.eql?("}\n")
35
+ if !line.lstrip.eql?("}\n") and !line.strip.eql?("}#@$")
36
36
 
37
37
  if !line.lstrip.eql?("}\n\n")
38
38
 
@@ -22,6 +22,8 @@ require_relative 'lexical_scoped_function_variables'
22
22
 
23
23
  input_file_contents = input_file_contents.collect {|element| element.gsub("append","appand")}
24
24
 
25
+ input_file_contents = input_file_contents.collect {|element| element.gsub(" do"," do ").gsub("do "," do ")}
26
+
25
27
  possible_blocks = input_file_contents.reject {|line| !line.include?(" do ")}
26
28
 
27
29
  unless possible_blocks.empty?
@@ -98,7 +100,7 @@ require_relative 'lexical_scoped_function_variables'
98
100
 
99
101
  else
100
102
 
101
- compiled_block = block_extract[1...-1].lstrip.rstrip
103
+ compiled_block = "function() {\n\n" + block_extract[1...-1].lstrip.rstrip + "\n\n}"
102
104
 
103
105
  extracted_string.each_with_index do |string,index|
104
106
 
@@ -118,7 +120,19 @@ require_relative 'lexical_scoped_function_variables'
118
120
 
119
121
  caller_func_split = caller_func.split("(") if caller_func.include?("(")
120
122
 
121
- caller_func_split = caller_func.split(" ",2) if caller_func.include?(" ")
123
+ if caller_func.include?("=")
124
+
125
+ first_split = caller_func.split("=")
126
+
127
+ caller_func_split = first_split[1].split(" ",2)
128
+
129
+ caller_func_split[0] = first_split[0].strip + " = " + caller_func_split[0]
130
+
131
+ else
132
+
133
+ caller_func_split = caller_func.split(" ",2) if caller_func.include?(" ")
134
+
135
+ end
122
136
 
123
137
  replacement_string = "#{caller_func_split[0]}(#{caller_func_split[1].strip + compiled_block.lstrip})"
124
138
 
@@ -126,6 +140,10 @@ require_relative 'lexical_scoped_function_variables'
126
140
 
127
141
  replacement_array = strToArray(replacement_string)
128
142
 
143
+ replacement_array[-1] = replacement_array[-1] + "\n\n"
144
+
145
+ replacement_array << "\n\n"
146
+
129
147
  variables = lexical_scoped_variables(replacement_array)
130
148
 
131
149
  if !variables.empty?
@@ -91,7 +91,7 @@ require_relative 'read_file_line_by_line'
91
91
 
92
92
  when_statements_index = when_statements_index.flatten
93
93
 
94
- if replace_strings(statement_block.join).include?("else\n")
94
+ if replace_strings(statement_block.join).include?("else\n") or replace_strings(statement_block.join).include?("else\r\n")
95
95
 
96
96
  else_statement = statement_block.reject {|element| !replace_strings(element).strip.eql?("else")}
97
97
 
@@ -92,19 +92,19 @@ def compile_conditional_structures(input_file_contents, temporary_nila_file)
92
92
 
93
93
  if index == 0
94
94
 
95
- output_statement = "if (#{condition.lstrip.rstrip.gsub("?", "")}) {\n\n#{line_split[0]}\n}\n"
95
+ output_statement = "if (#{condition.lstrip.rstrip.gsub("?", "")}) {\n\n#{line_split[0]}\n}#@$\n\t\t"
96
96
 
97
97
  elsif index == 1
98
98
 
99
- output_statement = "while (#{condition.lstrip.rstrip.gsub("?", "")}) {\n\n#{line_split[0]}\n}\n"
99
+ output_statement = "while (#{condition.lstrip.rstrip.gsub("?", "")}) {\n\n#{line_split[0]}\n}#@$\n\n\t"
100
100
 
101
101
  elsif index == 2
102
102
 
103
- output_statement = "if (!(#{condition.lstrip.rstrip.gsub("?", "")})) {\n\n#{line_split[0]}\n}\n"
103
+ output_statement = "if (!(#{condition.lstrip.rstrip.gsub("?", "")})) {\n\n#{line_split[0]}\n}#@$\n\t\t"
104
104
 
105
105
  elsif index == 3
106
106
 
107
- output_statement = "while (!(#{condition.lstrip.rstrip.gsub("?", "")})) {\n\n#{line_split[0]}\n}\n"
107
+ output_statement = "while (!(#{condition.lstrip.rstrip.gsub("?", "")})) {\n\n#{line_split[0]}\n}#@$\n\n\t"
108
108
 
109
109
  end
110
110
 
@@ -321,6 +321,8 @@ def compile_conditional_structures(input_file_contents, temporary_nila_file)
321
321
 
322
322
  end
323
323
 
324
+ modified_input_block[-1] = modified_input_block[-1].gsub("}","}#@$\n\t\t")
325
+
324
326
  return modified_input_block
325
327
 
326
328
  end
@@ -597,6 +599,8 @@ def compile_conditional_structures(input_file_contents, temporary_nila_file)
597
599
 
598
600
  end
599
601
 
602
+ modified_input_block[-1] = modified_input_block[-1].gsub("}","}#@$\n\n\t")
603
+
600
604
  return modified_input_block
601
605
 
602
606
  end
@@ -727,7 +731,7 @@ def compile_conditional_structures(input_file_contents, temporary_nila_file)
727
731
 
728
732
  extracted_blocks = []
729
733
 
730
- controlregexp = /(if |while |def |for | do )/
734
+ controlregexp = /(if |while |def |for | do |class )/
731
735
 
732
736
  rejectionregexp = /( if | while )/
733
737
 
@@ -783,7 +787,7 @@ def compile_conditional_structures(input_file_contents, temporary_nila_file)
783
787
 
784
788
  block_end = current_block.index(block_extract[-1])
785
789
 
786
- current_block[block_start..block_end] = "--forblock#{for_block_counter}"
790
+ current_block[block_start..block_end] = "--forblock#{for_block_counter}\n\n"
787
791
 
788
792
  for_block_counter += 1
789
793
 
@@ -911,14 +915,20 @@ def compile_conditional_structures(input_file_contents, temporary_nila_file)
911
915
 
912
916
  end
913
917
 
918
+ modified_input_block[-1] = modified_input_block[-1].gsub("}","}#@$\n\n\n")
919
+
914
920
  return modified_input_block
915
921
 
916
922
  end
917
923
 
924
+ input_file_contents = input_file_contents.collect {|element| element.gsub("forEach","fuuuuurEEEEEach")}
925
+
918
926
  possible_for_statements = input_file_contents.reject { |element| !element.include?("for") }
919
927
 
920
928
  possible_for_statements = possible_for_statements.reject {|element| element.include?("for (")}
921
929
 
930
+ input_file_contents = input_file_contents.collect {|element| element.gsub("fuuuuurEEEEEach","forEach")}
931
+
922
932
  if !possible_for_statements.empty?
923
933
 
924
934
  for_statement_indexes = []
@@ -931,7 +941,7 @@ def compile_conditional_structures(input_file_contents, temporary_nila_file)
931
941
 
932
942
  for_statement_indexes = [0] + for_statement_indexes.flatten + [-1]
933
943
 
934
- controlregexp = /(if |def |while | do )/
944
+ controlregexp = /(if |def |while | do |class )/
935
945
 
936
946
  modified_input_contents, extracted_statements = extract_for_blocks(for_statement_indexes, input_file_contents.clone)
937
947
 
@@ -981,7 +991,7 @@ def compile_conditional_structures(input_file_contents, temporary_nila_file)
981
991
 
982
992
  else
983
993
 
984
- joined_file_contents = joined_file_contents.sub(rejected_elements_index[0], rejected_elements[0].join)
994
+ joined_file_contents = joined_file_contents.sub(rejected_elements_index[0], rejected_elements[0])
985
995
 
986
996
  rejected_elements_index.delete_at(0)
987
997
 
@@ -1181,6 +1191,8 @@ def compile_conditional_structures(input_file_contents, temporary_nila_file)
1181
1191
 
1182
1192
  end
1183
1193
 
1194
+ modified_input_block[-1] = modified_input_block[-1].gsub("}","}#@$\n\n\t")
1195
+
1184
1196
  return modified_input_block
1185
1197
 
1186
1198
  end
@@ -12,7 +12,9 @@ def compile_custom_function_map(input_file_contents)
12
12
 
13
13
  "require" => "require",
14
14
 
15
- "alert" => "alert"
15
+ "alert" => "alert",
16
+
17
+ "prompt" => "prompt"
16
18
 
17
19
  }
18
20
 
@@ -65,7 +65,15 @@
65
65
 
66
66
  replacement_parameters << param.lstrip.rstrip
67
67
 
68
- replacement_string = replacement_string + "\n" + "if (#{param.lstrip.rstrip} equequ null) {\n #{paramvalue.lstrip.rstrip}\n}\n" +"\n"
68
+ if input_function_definition.include?("lambdef")
69
+
70
+ replacement_string = replacement_string + "\n" + "#iggggnnnore if (#{param.lstrip.rstrip} equequ null) {\n #iggggnnnore #{paramvalue.lstrip.rstrip}\n}#@$\n" +"\n"
71
+
72
+ else
73
+
74
+ replacement_string = replacement_string + "\n" + "if (#{param.lstrip.rstrip} equequ null) {\n #{paramvalue.lstrip.rstrip}\n}#@$\n" +"\n"
75
+
76
+ end
69
77
 
70
78
  end
71
79
 
@@ -97,6 +105,10 @@
97
105
 
98
106
  input_file_contents = input_file_contents.collect { |element| element.gsub("<=", "lessyequal") }
99
107
 
108
+ input_file_contents = input_file_contents.collect { |element| element.gsub("%--%", "{\n\n") }
109
+
110
+ input_file_contents = input_file_contents.collect { |element| element.gsub("-%%-", "\n\n}") }
111
+
100
112
  possible_default_values = input_file_contents.dup.reject { |element| (!element.include?("def")) }
101
113
 
102
114
  possible_default_values = possible_default_values.reject { |element| !element.include?("=") }
@@ -155,6 +167,8 @@
155
167
 
156
168
  line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("lessyequal", "<=") }
157
169
 
170
+ line_by_line_contents = line_by_line_contents.collect { |element| element.gsub("lambdef", "function") }
171
+
158
172
  return line_by_line_contents
159
173
 
160
174
  end
@@ -1,4 +1,7 @@
1
- def compile_integers(input_file_contents)
1
+ require_relative 'replace_strings'
2
+ require_relative 'find_all_matching_indices'
3
+
4
+ def compile_integers(input_file_contents)
2
5
 
3
6
  modified_file_contents = input_file_contents.clone
4
7
 
@@ -18,6 +21,148 @@
18
21
 
19
22
  end
20
23
 
24
+ #compile_integer_methods(modified_file_contents)
25
+
21
26
  return modified_file_contents
22
27
 
23
- end
28
+ end
29
+
30
+ def compile_integer_methods(input_file_contents)
31
+
32
+ # These methods replace Javascript's parseInt method because it can produce erroneous output when called
33
+ # without using a radix parameter
34
+
35
+ def compile_dec_method(input_calls,file_contents)
36
+
37
+ input_calls.each do |call|
38
+
39
+ modified_call = call.dup
40
+
41
+ if modified_call.include?("(") and modified_call.include?(")")
42
+
43
+ parseint_statements = []
44
+
45
+ counter = 0
46
+
47
+ while modified_call.include?(".dec")
48
+
49
+ modified_call = modified_call.sub(".dec",".bussssss")
50
+
51
+ modified_call = modified_call.gsub(".dec",".greppppplin")
52
+
53
+ modified_call = modified_call.sub(".bussssss",".dec ")
54
+
55
+ string_extract = modified_call.reverse
56
+
57
+ paranthesis_extract = [""]
58
+
59
+ two_paranthesis = ""
60
+
61
+ open_paran_index = nil
62
+
63
+ offset_value = nil
64
+
65
+ while string_extract.include?("(")
66
+
67
+ open_paran_index = string_extract.index("(")
68
+
69
+ test_extract = string_extract[0..open_paran_index].reverse
70
+
71
+ two_paranthesis = test_extract[0..test_extract.index(")")]
72
+
73
+ previous_value = paranthesis_extract[-1]
74
+
75
+ if previous_value.length > two_paranthesis.length-(two_paranthesis.count("$@"))/2
76
+
77
+ offset_value = previous_value
78
+
79
+ end
80
+
81
+ paranthesis_extract << two_paranthesis.sub("$@"*previous_value.length,previous_value)
82
+
83
+ string_extract = string_extract.sub(two_paranthesis.reverse,"@$"*paranthesis_extract[-1].length)
84
+
85
+ end
86
+
87
+ #puts paranthesis_extract.to_s
88
+
89
+ unless offset_value.nil?
90
+
91
+ paranthesis_extract = paranthesis_extract.collect {|element| element.sub("$@"*offset_value.length,offset_value)}
92
+
93
+ end
94
+
95
+ full_call = paranthesis_extract.reject {|element| !element.include?(".dec ")}
96
+
97
+ if full_call[0].include?(" .dec") or full_call[0].include?(").dec")
98
+
99
+ correct_call = paranthesis_extract[paranthesis_extract.index(full_call[0])-1]
100
+
101
+ else
102
+
103
+ incomplete_call = paranthesis_extract[paranthesis_extract.index(full_call[0])-1]
104
+
105
+ correct_call = modified_call[modified_call.index(incomplete_call)...modified_call.index(".dec")]
106
+
107
+ end
108
+
109
+ replacement_string = "parseInt(#{correct_call},10)"
110
+
111
+ parseint_statements << replacement_string
112
+
113
+ modified_call = modified_call.sub("#{correct_call}.dec","--parsesssInt{#{parseint_statements.index(replacement_string)}}")
114
+
115
+ modified_call = modified_call.gsub(".greppppplin",".dec")
116
+
117
+ end
118
+
119
+ parseint_statements.each_with_index do |statement,index|
120
+
121
+ modified_call = modified_call.sub("--parsesssInt{#{index}}",statement)
122
+
123
+ end
124
+
125
+ file_contents[file_contents.index(call)] = modified_call
126
+
127
+ elsif modified_call.index(/("[\s\D]*\w{1,}*[\s\-@%\$\^\|:;&\(\)#!~\.\,`'_=\+<>\?\/\\\{\}\w{1,}]*".dec)/)
128
+
129
+ select_regex = /("[\s\D]*\w{1,}*[\s\-@%\$\^\|:;&\(\)#!~\.\,`'_=\+<>\?\/\\\{\}\w{1,}]*".dec\s)/
130
+
131
+ while modified_call.include?(".dec")
132
+
133
+ # Our regex is not complex enough to extract the multitude of possibilities of .dec calls. So we are
134
+ # using a small trick to allow it to select all the .dec calls by adding a space next to it.
135
+
136
+ modified_call = modified_call.sub(".dec",".busssssss ")
137
+
138
+ modified_call = modified_call.gsub(/.dec\s*/,".dec")
139
+
140
+ modified_call = modified_call.sub(".busssssss ",".dec ")
141
+
142
+ call_extract = modified_call.scan(select_regex)
143
+
144
+ replacement_string = "parseInt(#{call_extract[0][0].strip.sub(".dec","")},10)"
145
+
146
+ modified_call = modified_call.sub("#{call_extract[0][0]}",replacement_string)
147
+
148
+ end
149
+
150
+ file_contents[file_contents.index(call)] = modified_call
151
+
152
+ #elsif modified_call.index()
153
+
154
+ end
155
+
156
+ end
157
+
158
+ return file_contents
159
+
160
+ end
161
+
162
+ possible_dec_calls = input_file_contents.reject {|element| !replace_strings(element).include?(".dec")}
163
+
164
+ modified_file_contents = compile_dec_method(possible_dec_calls,input_file_contents)
165
+
166
+ return modified_file_contents
167
+
168
+ end
@@ -6,13 +6,23 @@ require_relative 'add_auto_return_statement'
6
6
 
7
7
  def compile_lambdas(input_file_contents,temporary_nila_file)
8
8
 
9
- def compile_single_line_lambda(input_block)
9
+ def compile_single_line_lambda(input_block,parameterless = false)
10
10
 
11
11
  # This method compiles a single lambda into a Javascript function expression
12
12
 
13
- block_parameters, block_contents = input_block[1...-1].split("|",2)[1].split("|",2)
13
+ if parameterless
14
14
 
15
- compiled_lambda = "function(#{block_parameters.lstrip.rstrip}) {\n\n #{block_contents.strip} \n\n}"
15
+ block_contents = input_block[3...-1]
16
+
17
+ compiled_lambda = "function() {\n\n #{block_contents.strip} \n\n}"
18
+
19
+ else
20
+
21
+ block_parameters, block_contents = input_block[1...-1].split("|",2)[1].split("|",2)
22
+
23
+ compiled_lambda = "function(#{block_parameters.lstrip.rstrip}) {\n\n #{block_contents.strip} \n\n}"
24
+
25
+ end
16
26
 
17
27
  return compiled_lambda
18
28
 
@@ -36,7 +46,7 @@ def compile_lambdas(input_file_contents,temporary_nila_file)
36
46
 
37
47
  end
38
48
 
39
- input_file_contents = input_file_contents.collect {|element| element.gsub(" -> "," lambda ")}
49
+ input_file_contents = input_file_contents.collect {|element| (replace_strings(element).include?(" -> ") ? element.gsub(" -> "," lambda ") : element)}
40
50
 
41
51
  input_file_contents = input_file_contents.collect {|element| element.gsub("append","appand")}
42
52
 
@@ -126,7 +136,7 @@ def compile_lambdas(input_file_contents,temporary_nila_file)
126
136
 
127
137
  else
128
138
 
129
- compiled_lambda = lambda_extract[1...-1].lstrip.rstrip
139
+ compiled_lambda = compile_single_line_lambda(lambda_extract,true)
130
140
 
131
141
  extracted_string.each_with_index do |string,index|
132
142
 
@@ -166,7 +176,13 @@ def compile_lambdas(input_file_contents,temporary_nila_file)
166
176
 
167
177
  replacement_array[1...-1] = replacement_array[1...-1].collect {|element| "#iggggnnnore #{element}"}
168
178
 
169
- modified_file_contents[input_file_contents.index(original_loop)] = replacement_array.join
179
+ replacement_array[0] = replacement_array[0].sub("function","lambdef").sub("{\n","%--%\n")
180
+
181
+ replacement_array[-1] = replacement_array[-1].sub("}","\n-%%-")
182
+
183
+ replacement_string = replacement_array.join
184
+
185
+ modified_file_contents[input_file_contents.index(original_loop)] = replacement_string[-1].eql?(";") ? replacement_string : replacement_string + ";"
170
186
 
171
187
  end
172
188
 
@@ -182,7 +182,7 @@ require_relative 'read_file_line_by_line'
182
182
 
183
183
  times_counter = times_counter[1...-1] if times_counter.include?("(") and times_counter.include?(")")
184
184
 
185
- replacement_string = "for (_i = 0, _j = #{times_counter}; _i < _j; _i += 1) {\n\n#{compiled_block}\n\n}"
185
+ replacement_string = "for (_i = 0, _j = #{times_counter}; _i < _j; _i += 1) {\n\n#{compiled_block}\n\n}\n\n\n"
186
186
 
187
187
  modified_file_contents[input_file_contents.index(original_loop)] = replacement_string
188
188