nilac 0.0.4.3.9.7.1 → 0.0.4.3.9.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -2
  3. data/Rakefile +1 -1
  4. data/cookbook/case_insensitive_compare.js +13 -0
  5. data/cookbook/case_insensitive_compare.nila +7 -0
  6. data/cookbook/compare_strings.js +13 -0
  7. data/cookbook/compare_strings.nila +7 -0
  8. data/cookbook/concat11.js +13 -0
  9. data/cookbook/concat11.nila +4 -0
  10. data/cookbook/concat12.js +23 -0
  11. data/cookbook/concat12.nila +15 -0
  12. data/cookbook/find_substring.js +15 -0
  13. data/cookbook/find_substring.nila +5 -0
  14. data/cookbook/string_interpolation.js +7 -0
  15. data/cookbook/string_interpolation.nila +1 -0
  16. data/cookbook/substring_extract.js +21 -0
  17. data/cookbook/substring_extract.nila +8 -0
  18. data/examples/my_file.js +5 -0
  19. data/examples/repl.js +0 -33
  20. data/examples/repl.nila +36 -8
  21. data/examples/temp_nila.nila +63 -0
  22. data/lib/nilac.rb +83 -68
  23. data/lib/nilac/add_line_numbers.rb +17 -0
  24. data/lib/nilac/add_semicolons.rb +13 -3
  25. data/lib/nilac/compile_arrays.rb +38 -5
  26. data/lib/nilac/compile_blocks.rb +87 -25
  27. data/lib/nilac/compile_case_statement.rb +4 -0
  28. data/lib/nilac/compile_chained_comparison.rb +35 -0
  29. data/lib/nilac/compile_comments.rb +9 -0
  30. data/lib/nilac/compile_conditional_structures.rb +26 -3
  31. data/lib/nilac/compile_custom_function_map.rb +24 -2
  32. data/lib/nilac/compile_hashes.rb +3 -1
  33. data/lib/nilac/compile_heredocs.rb +2 -0
  34. data/lib/nilac/compile_inline_for.rb +13 -0
  35. data/lib/nilac/compile_interpolated_strings.rb +184 -5
  36. data/lib/nilac/compile_lambdas.rb +24 -8
  37. data/lib/nilac/compile_new_keyword.rb +37 -0
  38. data/lib/nilac/compile_nilac_options.rb +79 -0
  39. data/lib/nilac/compile_parallel_assignment.rb +3 -1
  40. data/lib/nilac/compile_ranges.rb +60 -0
  41. data/lib/nilac/compile_require_statements.rb +4 -2
  42. data/lib/nilac/compile_ruby_math.rb +20 -0
  43. data/lib/nilac/compile_ruby_methods.rb +49 -0
  44. data/lib/nilac/compile_whitespace_delimited_functions.rb +15 -1
  45. data/lib/nilac/extract_paranthesis_contents.rb +37 -0
  46. data/lib/nilac/extract_strings.rb +63 -0
  47. data/lib/nilac/fix_javascript_traps.rb +89 -0
  48. data/lib/nilac/friendly_errors.rb +128 -0
  49. data/lib/nilac/get_variables.rb +48 -14
  50. data/lib/nilac/lexical_scoped_function_variables.rb +1 -3
  51. data/lib/nilac/optimizer.rb +13 -0
  52. data/lib/nilac/paranthesis_compactor.rb +3 -1
  53. data/lib/nilac/parse_arguments.rb +21 -7
  54. data/lib/nilac/pretty_print_javascript.rb +152 -18
  55. data/lib/nilac/pretty_print_nila.rb +17 -0
  56. data/lib/nilac/replace_comparison_operators.rb +25 -0
  57. data/lib/nilac/replace_multiline_comments.rb +4 -0
  58. data/lib/nilac/replace_singleline_comments.rb +23 -0
  59. data/lib/nilac/replace_strings.rb +3 -3
  60. data/lib/nilac/rollblocks.rb +7 -3
  61. data/lib/nilac/split_semicolon_seperated_expressions.rb +3 -17
  62. data/lib/nilac/square_brackets_compactor.rb +37 -0
  63. data/lib/nilac/version.rb +1 -1
  64. data/shark/features/arrays.feature +11 -0
  65. data/shark/features/builtin_new.feature +11 -0
  66. data/shark/features/comments.feature +11 -0
  67. data/shark/features/fix_newlines.feature +1 -1
  68. data/shark/features/variables.feature +11 -0
  69. data/shark/test_files/array_string_indexing.nila +5 -1
  70. data/shark/test_files/arrays.nila +3 -0
  71. data/shark/test_files/blocks.nila +10 -0
  72. data/shark/test_files/builtin_new.nila +3 -0
  73. data/shark/test_files/case.nila +8 -0
  74. data/shark/test_files/chained_comparison.nila +19 -0
  75. data/shark/test_files/comments.nila +15 -0
  76. data/shark/test_files/correct.js +1 -1
  77. data/shark/test_files/correct_arrays.js +7 -0
  78. data/shark/test_files/correct_blocks.js +14 -1
  79. data/shark/test_files/correct_builtin_new.js +9 -0
  80. data/shark/test_files/correct_case.js +10 -2
  81. data/shark/test_files/correct_comments.js +19 -0
  82. data/shark/test_files/correct_conditional_assignment.js +1 -1
  83. data/shark/test_files/correct_default_parameters.js +1 -1
  84. data/shark/test_files/correct_for.js +1 -1
  85. data/shark/test_files/correct_hashes.js +1 -1
  86. data/shark/test_files/correct_heredoc.js +6 -2
  87. data/shark/test_files/correct_if_then_else.js +5 -1
  88. data/shark/test_files/correct_indexing.js +7 -3
  89. data/shark/test_files/correct_initialization.js +1 -1
  90. data/shark/test_files/correct_javascript_methods.js +1 -1
  91. data/shark/test_files/correct_loop.js +1 -1
  92. data/shark/test_files/correct_monkey_patch.js +1 -1
  93. data/shark/test_files/correct_multiline_array.js +1 -1
  94. data/shark/test_files/correct_multiple_return.js +1 -1
  95. data/shark/test_files/correct_numbers.js +1 -1
  96. data/shark/test_files/correct_operators.js +1 -1
  97. data/shark/test_files/correct_regular_if.js +1 -1
  98. data/shark/test_files/correct_regular_while.js +1 -1
  99. data/shark/test_files/correct_required_module.js +1 -1
  100. data/shark/test_files/correct_return.js +1 -1
  101. data/shark/test_files/correct_ruby_methods.js +1 -1
  102. data/shark/test_files/correct_single_return.js +1 -1
  103. data/shark/test_files/{perfect.js → correct_spacing.js} +1 -1
  104. data/shark/test_files/correct_splats.js +1 -2
  105. data/shark/test_files/correct_string_interpolation.js +8 -2
  106. data/shark/test_files/correct_string_operators.js +1 -1
  107. data/shark/test_files/correct_times.js +1 -1
  108. data/shark/test_files/correct_unless_until.js +2 -4
  109. data/shark/test_files/correct_variables.js +13 -0
  110. data/shark/test_files/correct_whitespace_delimiter.js +1 -1
  111. data/shark/test_files/existential_operators.nila +7 -0
  112. data/shark/test_files/expression.nila +6 -0
  113. data/shark/test_files/global_variables_client.nila +5 -0
  114. data/shark/test_files/heredoc.nila +11 -1
  115. data/shark/test_files/if_then_else.nila +3 -1
  116. data/shark/test_files/inline_for.nila +5 -0
  117. data/shark/test_files/no_return.js +11 -0
  118. data/shark/test_files/parseInt_trap.nila +3 -0
  119. data/shark/test_files/single_return.js +11 -0
  120. data/shark/test_files/string_interpolation.nila +7 -1
  121. data/shark/test_files/variables.nila +7 -0
  122. metadata +54 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4307491b9692c18501a10dada6e03bae8b1df980
4
- data.tar.gz: 2547b27d45b4867a350527ca9622b7851698e485
3
+ metadata.gz: 44907f99e8bd2ae65cc6c5e10bfbfde0ffa8d828
4
+ data.tar.gz: c7e9887180c1b8c37dea78842673d4c4ab1f6f62
5
5
  SHA512:
6
- metadata.gz: a8411c3d2a2ac183ccea27dced29bad909282c06f34d8551935990acde3314e1ec5a08a04c1a60bfbd20923db8f980ff096f265175cebe19d1b40516a95f0424
7
- data.tar.gz: 552e7cb29c913f6e95bcc20dc0b918d414e3b3111c8620a9990d91b67ee4499ffb1073040d22a763d251edac34d906d8350cff30894f8feabf2fd0b4925a026c
6
+ metadata.gz: 29cd85597e4398193eb8dd6dcd926f7c39237224346b5d2536dbbec05969b451c205475311fd72e7920036bf6344795f5684ede626b96367d1641776040051bc
7
+ data.tar.gz: 26b30c2f2123978596c05702514280717007b5c6f723030501a365c0e600a21e8f9eb1b877d89ffb8ced927d232444944d50970cd7b8c10ab4053ac6e5c5d351
data/.gitignore CHANGED
@@ -15,5 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
- .idea
19
- cookbook
18
+ .idea
data/Rakefile CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,13 @@
1
+ //Written using Nila. Visit http://adhithyan15.github.io/nila
2
+ (function () {
3
+ var input_name;
4
+
5
+ input_name = prompt("What is your name?");
6
+
7
+ if (input_name.toLowerCase() === "Jim".toLowerCase()) {
8
+ alert("Hey Jim!");
9
+ } else {
10
+ alert("Hey " + (input_name));
11
+ }
12
+
13
+ }).call(this);
@@ -0,0 +1,7 @@
1
+ input_name = prompt "What is your name?"
2
+
3
+ if input_name.downcase == "Jim".downcase
4
+ alert "Hey Jim!"
5
+ else
6
+ alert "Hey #{input_name}"
7
+ end
@@ -0,0 +1,13 @@
1
+ //Written using Nila. Visit http://adhithyan15.github.io/nila
2
+ (function() {
3
+ var input_name;
4
+
5
+ input_name = prompt("What is your name?");
6
+
7
+ if (input_name === "Jim") {
8
+ alert("Hey Jim!");
9
+ } else {
10
+ alert("Hey " + (input_name));
11
+ }
12
+
13
+ }).call(this);
@@ -0,0 +1,7 @@
1
+ input_name = prompt "What is your name?"
2
+
3
+ if input_name == "Jim"
4
+ alert "Hey Jim!"
5
+ else
6
+ alert "Hey #{input_name}"
7
+ end
@@ -0,0 +1,13 @@
1
+ //Written using Nila. Visit http://adhithyan15.github.io/nila
2
+ (function() {
3
+ var string1, string2, string3;
4
+
5
+ string1 = "This is a";
6
+
7
+ string2 = "test";
8
+
9
+ string3 = string1 + string2;
10
+
11
+ console.log(string3); //=> This is a test
12
+
13
+ }).call(this);
@@ -0,0 +1,4 @@
1
+ string1 = "This is a"
2
+ string2 = "test"
3
+ string3 = string1 + string2
4
+ puts string3 #=> This is a test
@@ -0,0 +1,23 @@
1
+ //Written using Nila. Visit http://adhithyan15.github.io/nila
2
+ (function() {
3
+ var bool1, string1, string2;
4
+
5
+ // Javascript approach
6
+
7
+ string1 = "Trust Jim: ";
8
+
9
+ bool1 = true;
10
+
11
+ string2 = string1 + bool1;
12
+
13
+ console.log(string2);
14
+
15
+ // Ruby approach
16
+
17
+ bool1 = true;
18
+
19
+ string2 = "Trust Jim: " + (bool1);
20
+
21
+ console.log(string2);
22
+
23
+ }).call(this);
@@ -0,0 +1,15 @@
1
+ # Javascript approach
2
+ string1 = "Trust Jim: "
3
+
4
+ bool1 = true
5
+
6
+ string2 = string1 + bool1
7
+
8
+ puts string2
9
+
10
+ # Ruby approach
11
+ bool1 = true
12
+
13
+ string2 = "Trust Jim: #{bool1}"
14
+
15
+ puts string2
@@ -0,0 +1,15 @@
1
+ //Written using Nila. Visit http://adhithyan15.github.io/nila
2
+ (function () {
3
+ var find_string, main_string;
4
+
5
+ main_string = "This is a test string";
6
+
7
+ find_string = "test";
8
+
9
+ if (main_string.indexOf(find_string) !== -1){
10
+ console.log("Substring found!");
11
+ }
12
+
13
+ //=> Substring found!
14
+
15
+ }).call(this);
@@ -0,0 +1,5 @@
1
+ main_string = "This is a test string"
2
+
3
+ find_string = "test"
4
+
5
+ puts "Substring found!" if main_string.include?(find_string) #=> Substring found!
@@ -0,0 +1,7 @@
1
+ //Written using Nila. Visit http://adhithyan15.github.io/nila
2
+ (function() {
3
+ var x;
4
+
5
+ console.log("I've set x to " + (x = 5, x += 1) + ".");
6
+
7
+ }).call(this);
@@ -0,0 +1 @@
1
+ puts "I've set x to #{x = 5; x += 1}."
@@ -0,0 +1,21 @@
1
+ //Written using Nila. Visit http://adhithyan15.github.io/nila
2
+ (function() {
3
+ var fruits_i_like, fruits_list, start;
4
+
5
+ fruits_i_like = "List of fruits I like:apples, oranges, pineapple and mango";
6
+
7
+ start = fruits_i_like.indexOf(":");
8
+
9
+ // Indexing Range Method
10
+
11
+ fruits_list = fruits_i_like.slice(start+1);
12
+
13
+ console.log(fruits_list);
14
+
15
+ // Slicing Method
16
+
17
+ fruits_list = fruits_i_like.slice(start+1);
18
+
19
+ console.log(fruits_list);
20
+
21
+ }).call(this);
@@ -0,0 +1,8 @@
1
+ fruits_i_like = "List of fruits I like:apples, oranges, pineapple and mango"
2
+ start = fruits_i_like.index(":")
3
+ # Indexing Range Method
4
+ fruits_list = fruits_i_like[start+1..last]
5
+ puts fruits_list
6
+ # Slicing Method
7
+ fruits_list = fruits_i_like.slice(start+1,last)
8
+ puts fruits_list
@@ -0,0 +1,5 @@
1
+ //Written using Nila. Visit http://adhithyan15.github.io/nila
2
+ (function() {
3
+ console.log((message = "Hello"));
4
+
5
+ }).call(this);
@@ -1,33 +0,0 @@
1
- //Written using Nila. Visit http://adhithyan15.github.io/nila
2
- (function() {
3
- var read, readline, rl, stream;
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
- require('fs');
10
-
11
- stream = fs.createWriteStream("my_file.nila");
12
-
13
- stream.once('open',function(fd) {
14
- stream.write("Testing!\n");
15
- stream.;
16
- });
17
-
18
- rl = readline.createInterface(process.stdin, process.stdout);
19
-
20
- rl.setPrompt('nila> ');
21
-
22
- rl.prompt();
23
-
24
- read = rl.on('line',function(line) {
25
- rl.prompt();
26
- });
27
-
28
- read.on('close',function() {
29
- console.log("Have a great day!");
30
- process.exit(0);
31
- });
32
-
33
- }).call(this);
@@ -4,14 +4,20 @@ require 'readline'
4
4
 
5
5
  require 'fs'
6
6
 
7
- stream = fs.createWriteStream("my_file.nila")
7
+ require 'sys'
8
+
9
+ exec = require('child_process').exec
10
+
11
+ file_name = "#{__dirname}/my_file.nila"
12
+
13
+ output_file_name = "#{__dirname}/my_file.js"
14
+
15
+ stream = fs.createWriteStream(file_name)
8
16
 
9
17
  stream.once 'open', do |fd|
10
18
 
11
- stream.write("Testing!\n")
19
+ stream.write("# REPL Session #{new Date().to_s}\n\n")
12
20
 
13
- stream.end()
14
-
15
21
  end
16
22
 
17
23
  rl = readline.createInterface(process.stdin, process.stdout)
@@ -21,11 +27,33 @@ rl.setPrompt('nila> ')
21
27
  rl.prompt()
22
28
 
23
29
  read = rl.on 'line', do |line|
24
-
30
+ stream.write("puts (#{line})\n\n")
31
+ exec 'nilac -c my_file.nila', do |error,stdout,stderr|
32
+ if error != nil
33
+ sys.print("error: #{error}")
34
+ end
35
+ if stdout.strip == "Compilation is successful!"
36
+ exec output_file_name, do |error,stdout,stderr|
37
+ if error != nil
38
+ sys.print(error + "\n")
39
+ else
40
+ sys.print(stdout + "\n")
41
+ end
42
+ end
43
+ end
44
+ end
25
45
  rl.prompt()
26
46
  end
27
47
 
28
- read.on 'close', do
29
- puts "Have a great day!"
48
+ read.on 'close', do
49
+ stream.end()
50
+ fs.unlink file_name, do |err|
51
+ puts "Nila file couldn't be deleted!"
52
+ end
53
+ fs.unlink output_file_name, do |err|
54
+ puts "Output js file couldn't be deleted!"
55
+ end
56
+ puts "\n\nThanks for trying out Nila!\n"
57
+ puts "You can learn more about Nila at http://adhithyan15.github.io/nila\n"
30
58
  process.exit(0)
31
- end
59
+ end
@@ -0,0 +1,63 @@
1
+ --single_line_comment[1]
2
+
3
+
4
+ readline = require 'readline'
5
+
6
+ fs = require 'fs'
7
+
8
+ sys = require 'sys'
9
+
10
+ exec = require('child_process').exec
11
+
12
+ file_name = "" + (__dirname) + "/my_file.nila"
13
+
14
+ output_file_name = "" + (__dirname) + "/my_file.js"
15
+
16
+ stream = fs.createWriteStream(file_name)
17
+
18
+ stream.once 'open', do |fd|
19
+
20
+ stream.write("# REPL Session " + (new Date().to_s) + "\n\n")
21
+
22
+ end
23
+
24
+ rl = readline.createInterface(process.stdin, process.stdout)
25
+
26
+ rl.setPrompt('nila> ')
27
+
28
+ rl.prompt()
29
+
30
+ read = rl.on 'line', do |line|
31
+ stream.write("puts (" + (line) + ")\n\n")
32
+ exec 'nilac -c my_file.nila', do |error,stdout,stderr|
33
+ Euuf (error != nil) {
34
+ sys.print("error: " + (error))
35
+ }#@$
36
+
37
+ Euuf (stdout.strip == "Compilation is successful!") {
38
+ exec output_file_name, do |error,stdout,stderr|
39
+ Euuf (error != nil) {
40
+ sys.print(error + "\n")
41
+ } else {
42
+ sys.print(stdout + "\n")
43
+ }#@$
44
+
45
+ end
46
+ }#@$
47
+
48
+ end
49
+ rl.prompt()
50
+ end
51
+
52
+ read.on 'close', do
53
+ stream.enttttttttttt()
54
+ fs.unlink file_name, do |err|
55
+ puts "Nila file couldn't be deleted!"
56
+ end
57
+ fs.unlink output_file_name, do |err|
58
+ puts "Output js file couldn't be deleted!"
59
+ end
60
+ puts "\n\nThanks for trying out Nila!\n"
61
+ puts "You can learn more about Nila at http://adhithyan15.github.io/nila\n"
62
+ process.exit(0)
63
+ end
@@ -3,6 +3,8 @@
3
3
 
4
4
  #Nila and Nilac are being crafted by Adhithya Rajasekaran and Sri Madhavi Rajasekaran
5
5
 
6
+ #All the code in this project is licensed under the MIT License
7
+
6
8
  $LOAD_PATH << File.dirname(__FILE__)
7
9
 
8
10
  module Nilac
@@ -10,6 +12,7 @@ module Nilac
10
12
  require 'nilac/version'
11
13
  require 'fileutils'
12
14
  require 'nilac/read_file_line_by_line'
15
+ require 'nilac/add_line_numbers'
13
16
  require 'nilac/find_file_name'
14
17
  require 'nilac/find_file_path'
15
18
  require 'nilac/extract_parsable_file'
@@ -47,6 +50,13 @@ module Nilac
47
50
  require 'nilac/parse_arguments'
48
51
  require 'nilac/friendly_errors'
49
52
  require 'nilac/compile_monkey_patching'
53
+ require 'nilac/compile_ranges'
54
+ require 'nilac/compile_chained_comparison'
55
+ require 'nilac/compile_new_keyword'
56
+ require 'nilac/compile_inline_for'
57
+ require 'nilac/fix_javascript_traps'
58
+ require 'nilac/compile_ruby_math'
59
+ require 'nilac/compile_nilac_options'
50
60
 
51
61
  class NilaCompiler
52
62
 
@@ -58,7 +68,7 @@ module Nilac
58
68
 
59
69
  end
60
70
 
61
- def compile(input_file_path, options = [], *output_file_name)
71
+ def compile(input_file_path, options = {}, *output_file_name)
62
72
 
63
73
  message,proceed = file_exist?(input_file_path)
64
74
 
@@ -66,135 +76,140 @@ module Nilac
66
76
 
67
77
  file_contents = read_file_line_by_line(input_file_path)
68
78
 
79
+ line_numbered_file_contents = add_line_numbers(file_contents)
80
+
69
81
  file_contents = file_contents.collect {|element| element.gsub("\r\n","\n")}
70
82
 
83
+ file_contents = file_contents.collect {|element| element.gsub(".end",".enttttttttttt")}
84
+
71
85
  file_contents = extract_parsable_file(file_contents)
72
86
 
73
87
  file_contents = compile_require_statements(file_contents)
74
88
 
75
- file_contents, multiline_comments, temp_file, output_js_file = replace_multiline_comments(file_contents, input_file_path, *output_file_name)
89
+ proceed = check_comments(line_numbered_file_contents)
76
90
 
77
- file_contents, singleline_comments = replace_singleline_comments(file_contents)
91
+ if proceed
78
92
 
79
- file_contents = split_semicolon_seperated_expressions(file_contents)
93
+ file_contents, multiline_comments, temp_file, output_js_file = replace_multiline_comments(file_contents, input_file_path, *output_file_name)
80
94
 
81
- file_contents = compile_heredocs(file_contents, temp_file)
95
+ file_contents, singleline_comments = replace_singleline_comments(file_contents)
82
96
 
83
- file_contents,lambda_names = compile_lambdas(file_contents,temp_file)
97
+ file_contents = split_semicolon_seperated_expressions(file_contents)
84
98
 
85
- file_contents,loop_vars = compile_loops(file_contents,temp_file)
99
+ file_contents = compile_ranges(file_contents)
86
100
 
87
- file_contents = compile_interpolated_strings(file_contents)
101
+ file_contents = compile_heredocs(file_contents, temp_file)
88
102
 
89
- file_contents = compile_hashes(file_contents,temp_file)
103
+ file_contents,lambda_names = compile_lambdas(file_contents,temp_file)
90
104
 
91
- file_contents = compile_case_statement(file_contents,temp_file)
105
+ file_contents,loop_vars = compile_loops(file_contents,temp_file)
92
106
 
93
- file_contents = compile_conditional_structures(file_contents, temp_file)
107
+ file_contents, interpolation_vars = compile_interpolated_strings(file_contents)
94
108
 
95
- file_contents = compile_blocks(file_contents,temp_file)
109
+ file_contents = compile_hashes(file_contents,temp_file)
96
110
 
97
- file_contents = compile_integers(file_contents)
111
+ file_contents = compile_case_statement(file_contents,temp_file)
98
112
 
99
- file_contents = compile_default_values(file_contents, temp_file)
113
+ compile_inline_for(file_contents)
100
114
 
101
- file_contents, named_functions, nested_functions = replace_named_functions(file_contents, temp_file)
115
+ file_contents = compile_conditional_structures(file_contents, temp_file)
102
116
 
103
- comments = [singleline_comments, multiline_comments]
117
+ file_contents = compile_blocks(file_contents,temp_file)
104
118
 
105
- file_contents = compile_parallel_assignment(file_contents, temp_file)
119
+ file_contents = compile_integers(file_contents)
106
120
 
107
- file_contents,named_functions = compile_arrays(file_contents, named_functions, temp_file)
121
+ file_contents = compile_default_values(file_contents, temp_file)
108
122
 
109
- file_contents = compile_strings(file_contents)
123
+ file_contents, named_functions, nested_functions = replace_named_functions(file_contents, temp_file)
110
124
 
111
- list_of_variables, file_contents = get_variables(file_contents, temp_file,loop_vars)
125
+ comments = [singleline_comments, multiline_comments]
112
126
 
113
- file_contents, function_names = compile_named_functions(file_contents, named_functions, nested_functions, temp_file)
127
+ file_contents = compile_parallel_assignment(file_contents, temp_file)
114
128
 
115
- file_contents = compile_monkey_patching(file_contents,temp_file)
129
+ file_contents,named_functions = compile_arrays(file_contents, named_functions, temp_file)
116
130
 
117
- func_names = function_names.dup
131
+ file_contents = compile_strings(file_contents)
118
132
 
119
- file_contents, ruby_functions = compile_custom_function_map(file_contents)
133
+ list_of_variables, file_contents = get_variables(file_contents, temp_file,loop_vars)
120
134
 
121
- file_contents = compile_ruby_methods(file_contents)
135
+ file_contents, function_names = compile_named_functions(file_contents, named_functions, nested_functions, temp_file)
122
136
 
123
- file_contents = compile_special_keywords(file_contents)
137
+ file_contents = compile_monkey_patching(file_contents,temp_file)
124
138
 
125
- function_names << ruby_functions
139
+ func_names = function_names.dup
126
140
 
127
- function_names << lambda_names
141
+ file_contents, ruby_functions = compile_custom_function_map(file_contents)
128
142
 
129
- list_of_variables += loop_vars
143
+ file_contents = compile_ruby_methods(file_contents)
130
144
 
131
- file_contents = compile_whitespace_delimited_functions(file_contents, function_names, temp_file)
145
+ file_contents = compile_special_keywords(file_contents)
132
146
 
133
- file_contents = remove_question_marks(file_contents, list_of_variables, temp_file)
147
+ function_names << ruby_functions
134
148
 
135
- file_contents = add_semicolons(file_contents)
149
+ function_names << lambda_names
136
150
 
137
- file_contents = compile_comments(file_contents, comments, temp_file)
151
+ list_of_variables += loop_vars
138
152
 
139
- file_contents = pretty_print_javascript(file_contents, temp_file,list_of_variables+func_names)
153
+ list_of_variables += interpolation_vars
140
154
 
141
- file_contents = compile_operators(file_contents)
155
+ file_contents = compile_whitespace_delimited_functions(file_contents, function_names, temp_file)
142
156
 
143
- output_javascript(file_contents, output_js_file, temp_file)
157
+ file_contents = fix_javascript_traps(file_contents)
144
158
 
145
- puts "Compilation is successful!"
159
+ file_contents = remove_question_marks(file_contents, list_of_variables, temp_file)
146
160
 
147
- else
161
+ file_contents = add_semicolons(file_contents)
148
162
 
149
- puts message
163
+ file_contents = compile_new_keyword(file_contents)
150
164
 
151
- end
165
+ file_contents = compile_comments(file_contents, comments, temp_file)
152
166
 
167
+ file_contents = pretty_print_javascript(file_contents, temp_file,list_of_variables+func_names,options)
153
168
 
154
- end
169
+ file_contents = compile_operators(file_contents)
155
170
 
156
- def start_compile
171
+ file_contents = compile_ruby_math(file_contents)
157
172
 
158
- opts = parse_arguments(@input_arguments)
173
+ file_contents = file_contents.collect {|element| element.gsub(".enttttttttttt",".end")}
159
174
 
160
- nilac_version = Nilac::VERSION
175
+ if options[:print]
161
176
 
162
- if opts.values.compact.empty?
177
+ puts file_contents.join
163
178
 
164
- opts[:help] = "-h"
179
+ else
165
180
 
166
- end
181
+ output_javascript(file_contents, output_js_file, temp_file)
182
+
183
+ puts "Compilation is successful!"
167
184
 
168
- if opts[:build] != nil
185
+ end
169
186
 
170
- file_path = Dir.pwd + "/src/nilac.rb"
171
- create_mac_executable(file_path)
172
- FileUtils.mv("#{file_path[0...-3]}", "#{Dir.pwd}/bin/nilac")
173
- puts "Build Successful!"
187
+ end
174
188
 
175
- elsif opts[:compile] != nil
189
+ else
176
190
 
177
- client_optimized = false
191
+ puts message
192
+
193
+ end
178
194
 
179
- server_optimized = false
180
195
 
181
- if opts[:compile].include?("--browser") or opts[:compile].include?("--client")
196
+ end
182
197
 
183
- client_optimized = true
198
+ def start_compile
184
199
 
185
- opts[:compile] = opts[:compile].delete("--browser")
200
+ opts = parse_arguments(@input_arguments)
186
201
 
187
- opts[:compile] = opts[:compile].delete("--client")
202
+ options = compose_nilac_options(opts)
188
203
 
189
- elsif opts[:compile].include?("--server") or opts[:compile].include?("--node")
204
+ nilac_version = Nilac::VERSION
190
205
 
191
- server_optimized = true
206
+ if opts.values.compact.empty?
192
207
 
193
- opts[:compile] = opts[:compile].delete("--server")
208
+ opts[:help] = "-h"
194
209
 
195
- opts[:compile] = opts[:compile].delete("--node")
210
+ end
196
211
 
197
- end
212
+ if opts[:compile] != nil
198
213
 
199
214
  if opts[:compile].length == 1
200
215
 
@@ -204,14 +219,14 @@ module Nilac
204
219
  current_directory = Dir.pwd
205
220
  input_file = input
206
221
  file_path = current_directory + "/" + input_file
207
- compile(file_path,[client_optimized,server_optimized])
222
+ compile(file_path,options)
208
223
  elsif File.directory?(input)
209
224
  folder_path = input
210
225
  files = Dir.glob(File.join(folder_path, "*"))
211
226
  files = files.reject { |path| !path.include? ".nila" }
212
227
  files.each do |file|
213
228
  file_path = Dir.pwd + "/" + file
214
- compile(file_path,[client_optimized,server_optimized])
229
+ compile(file_path,options)
215
230
  end
216
231
  end
217
232
 
@@ -226,7 +241,7 @@ module Nilac
226
241
  output_file = output
227
242
  input_file_path = input_file
228
243
  output_file_path = output_file
229
- compile(input_file_path, [client_optimized,server_optimized],output_file_path)
244
+ compile(input_file_path,options,output_file_path)
230
245
 
231
246
  elsif File.directory?(input)
232
247
 
@@ -243,7 +258,7 @@ module Nilac
243
258
  files.each do |file|
244
259
  input_file_path = file
245
260
  output_file_path = output_folder_path + "/" + find_file_name(file, ".nila") + ".js"
246
- compile(input_file_path,[client_optimized,server_optimized],output_file_path)
261
+ compile(input_file_path,options,output_file_path)
247
262
  end
248
263
 
249
264
  end