nilac 0.0.4.3.9.3 → 0.0.4.3.9.4

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: c16e08d27a86860586b382ddd8560f740a2597fb
4
- data.tar.gz: 501de8bcccee03ed6af629cca160bf3bafb9522a
3
+ metadata.gz: be01c68cfa1e5e7f6280330bf0b50bd2730edde8
4
+ data.tar.gz: ac88db8f9ed0a1138526a7b856eb20b2e3152b5e
5
5
  SHA512:
6
- metadata.gz: 4ac124f8c6e641413ba9fb1c81151e8dec78b17e56c0860d7006321cd90be83857de2e02599eae3446eaf7d7ecd2730575a8b6f5604ef7b7349d96cace900d9a
7
- data.tar.gz: 69f636a771577930580e0297635233aa0b087e992c5368edb1b67db979c8ae2f214ad252e1591ee515b7d3215e3ac69ff9adb77fa6ed0b575037e6811c5216f4
6
+ metadata.gz: 993a625a2b7e1345315e1c6dff8c1773f4d7f8306b85d7e951e74b41a2dc43f19170e86e59050e828047f0619b7bd97fc7cdce6ad5c9fa74374b967c1cc4e12a
7
+ data.tar.gz: cc64aca1ed1feddeee5f5abc18a452c11a142ed2c1dcae66538ba74fff190a406759a9d3e11db63cf832c00dbb93e282a5c2cce44584b9dd1f9c5941589d493f
@@ -2,6 +2,8 @@ require_relative 'find_all_matching_indices'
2
2
 
3
3
  require_relative 'read_file_line_by_line'
4
4
 
5
+ require_relative 'compile_interpolated_strings'
6
+
5
7
  def compile_arrays(input_file_contents, named_functions, temporary_nila_file)
6
8
 
7
9
  def compile_w_arrays(input_file_contents)
@@ -56,6 +58,78 @@ require_relative 'read_file_line_by_line'
56
58
 
57
59
  end
58
60
 
61
+ def compile_capital_w_arrays(input_file_contents)
62
+
63
+ def extract(input_string, pattern_start, pattern_end)
64
+
65
+ all_start_locations = find_all_matching_indices(input_string, pattern_start)
66
+
67
+ all_end_locations = find_all_matching_indices(input_string, pattern_end)
68
+
69
+ pattern = []
70
+
71
+ all_start_locations.each_with_index do |location, index|
72
+
73
+ pattern << input_string[location..all_end_locations[index]]
74
+
75
+ end
76
+
77
+ return pattern
78
+
79
+ end
80
+
81
+ def compile_cap_w_syntax(input_string)
82
+
83
+ modified_input_string = input_string[3...-1]
84
+
85
+ processed_string = compile_interpolated_strings([modified_input_string])
86
+
87
+ interpolated_strings = processed_string[0].inspect.scan(/\\"[\w{1,}\s\W]*\\"/).to_a
88
+
89
+ interpolated_strings.each_with_index do |val,index|
90
+
91
+ processed_string[0] = processed_string[0].inspect.sub(val+"\"","stringgy#{index}")
92
+
93
+ end
94
+
95
+ string_split = processed_string[0].split(" ")
96
+
97
+ puts processed_string[0].inspect
98
+
99
+ interpolated_strings.each_with_index do |val,index|
100
+
101
+ string_split[string_split.index("stringgy#{index}")] = val[0..-2]
102
+
103
+ end
104
+
105
+ return string_split.to_s
106
+
107
+ end
108
+
109
+ modified_file_contents = input_file_contents.dup
110
+
111
+ input_file_contents.each_with_index do |line, index|
112
+
113
+ if line.include?("%W{")
114
+
115
+ line = line + "\n" unless line[-1].eql?("\n")
116
+
117
+ string_arrays = extract(line, "%W{", "}\n")
118
+
119
+ string_arrays.each do |array|
120
+
121
+ modified_file_contents[index] = modified_file_contents[index].sub(array, compile_cap_w_syntax(array))
122
+
123
+ end
124
+
125
+ end
126
+
127
+ end
128
+
129
+ return modified_file_contents
130
+
131
+ end
132
+
59
133
  def compile_array_indexing(input_file_contents)
60
134
 
61
135
  possible_indexing_operation = input_file_contents.dup.reject { |element| !element.include? "[" and !element.include? "]" }
@@ -246,6 +320,8 @@ require_relative 'read_file_line_by_line'
246
320
 
247
321
  input_file_contents = compile_w_arrays(input_file_contents)
248
322
 
323
+ input_file_contents = compile_capital_w_arrays(input_file_contents)
324
+
249
325
  input_file_contents = compile_array_indexing(input_file_contents)
250
326
 
251
327
  input_file_contents = compile_multiline(input_file_contents, temporary_nila_file)
@@ -9,6 +9,7 @@
9
9
 
10
10
  "String",
11
11
 
12
+ "Array",
12
13
  ]
13
14
 
14
15
  end
@@ -2,6 +2,36 @@ require_relative 'find_all_matching_indices'
2
2
 
3
3
  def compile_interpolated_strings(input_file_contents)
4
4
 
5
+ def replace_string_arrays(input_string)
6
+
7
+ def extract(input_string, pattern_start, pattern_end)
8
+
9
+ all_start_locations = find_all_matching_indices(input_string, pattern_start)
10
+
11
+ all_end_locations = find_all_matching_indices(input_string, pattern_end)
12
+
13
+ pattern = []
14
+
15
+ all_start_locations.each_with_index do |location, index|
16
+
17
+ pattern << input_string[location..all_end_locations[index]]
18
+
19
+ end
20
+
21
+ return pattern
22
+
23
+ end
24
+
25
+ if input_string.include?("%W")
26
+
27
+ input_string = input_string.sub(extract(input_string,"%W{","}\n")[0],"--stringarray")
28
+
29
+ end
30
+
31
+ return input_string
32
+
33
+ end
34
+
5
35
  modified_file_contents = input_file_contents.dup
6
36
 
7
37
  single_quoted_strings = input_file_contents.reject { |element| !(element.count("'") >= 2) }
@@ -26,7 +56,7 @@ require_relative 'find_all_matching_indices'
26
56
 
27
57
  input_file_contents.each_with_index do |line, index|
28
58
 
29
- if line.include?("\#{")
59
+ if replace_string_arrays(line+"\n").include?("\#{")
30
60
 
31
61
  modified_line = line.dup
32
62
 
data/lib/nilac/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Nilac
2
- VERSION = "0.0.4.3.9.3"
2
+ VERSION = "0.0.4.3.9.4"
3
3
  end
data/lib/nilac.rb CHANGED
@@ -274,16 +274,6 @@ module Nilac
274
274
  node_output = `node #{js_file_name} #{commandline_args.join(" ")}`
275
275
  puts node_output
276
276
 
277
- elsif opts[:release] != nil
278
-
279
- file_path = Dir.pwd + "/src/nilac.rb"
280
- create_mac_executable(file_path)
281
- FileUtils.mv("#{file_path[0...-3]}", "#{Dir.pwd}/bin/nilac")
282
- puts "Your build was successful!\n"
283
- commit_message = opts[:release][0]
284
- `git commit -am "#{commit_message}"`
285
- puts `rake release`
286
-
287
277
  elsif opts[:update] != nil
288
278
 
289
279
  puts "Checking for updates......"
@@ -320,9 +310,13 @@ module Nilac
320
310
  end
321
311
 
322
312
  end
323
-
313
+
324
314
  end
325
315
 
316
+ if ARGV.include?("--test")
317
+
326
318
  compiler = Nilac::NilaCompiler.new(ARGV)
327
319
 
328
320
  compiler.start_compile()
321
+
322
+ end
@@ -0,0 +1,11 @@
1
+ Feature: This feature brings Ruby's Syntactic Sugar for Arrays to Nila
2
+ Scenario: Input file with Ruby style arrays
3
+ Given the input file "array_sugar.nila"
4
+ When the ~compiler is run
5
+ The output file must be "array_sugar.js"
6
+ The output file must equal "correct_array_sugar.js"
7
+
8
+ Configurations:
9
+
10
+ ~compiler => lib/nilac.rb
11
+ :v $cliusage => ruby :v --compile $file
@@ -0,0 +1,9 @@
1
+ //Written using Nila. Visit http://adhithyan15.github.io/nila
2
+ (function() {
3
+ var date_time, names;
4
+
5
+ names = ["joe", "kelly", "bill", "james", "smith"];
6
+
7
+ date_time = ["\"The", "current", "date", "and", "time", "is", "\\" + (new Date().toString()) + \"];
8
+
9
+ }).call(this);
@@ -0,0 +1,3 @@
1
+ names = %w{joe kelly bill james smith}
2
+
3
+ date_time = %W{The current date and time is #{new Date().to_s}}
@@ -0,0 +1,7 @@
1
+ class Song
2
+ def initialize(name, artist, duration)
3
+ @name = name
4
+ @artist = artist
5
+ @duration = duration
6
+ end
7
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nilac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4.3.9.3
4
+ version: 0.0.4.3.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adhithya Rajasekaran
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-25 00:00:00.000000000 Z
11
+ date: 2013-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shark
@@ -88,6 +88,7 @@ files:
88
88
  - nilac.gemspec
89
89
  - shark/features/add_auto_return_statement.feature
90
90
  - shark/features/array_and_string_indexing.feature
91
+ - shark/features/array_sugar.feature
91
92
  - shark/features/barebones_compilation.feature
92
93
  - shark/features/case_when.feature
93
94
  - shark/features/default_method_parameters.feature
@@ -112,7 +113,10 @@ files:
112
113
  - shark/features/unless_until.feature
113
114
  - shark/features/whitespace_delimitation.feature
114
115
  - shark/test_files/array_string_indexing.nila
116
+ - shark/test_files/array_sugar.js
117
+ - shark/test_files/array_sugar.nila
115
118
  - shark/test_files/case.nila
119
+ - shark/test_files/class.nila
116
120
  - shark/test_files/correct.js
117
121
  - shark/test_files/correct_case.js
118
122
  - shark/test_files/correct_default_parameters.js