nilac 0.0.3 → 0.0.3.1

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.
data/.gitignore CHANGED
@@ -1,17 +1,17 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in nilac.gemspec
4
- gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in nilac.gemspec
4
+ gemspec
data/LICENSE CHANGED
@@ -1,22 +1,22 @@
1
- Copyright (c) 2013 Adhithya Rajasekaran
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1
+ Copyright (c) 2013 Adhithya Rajasekaran
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
22
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,29 +1,4 @@
1
- # Nilac
2
-
3
- TODO: Write a gem description
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- gem 'nilac'
10
-
11
- And then execute:
12
-
13
- $ bundle
14
-
15
- Or install it yourself as:
16
-
17
- $ gem install nilac
18
-
19
- ## Usage
20
-
21
- TODO: Write usage instructions here
22
-
23
- ## Contributing
24
-
25
- 1. Fork it
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Added some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create new Pull Request
1
+ nilac
2
+ =====
3
+
4
+ Nilac is the official compiler of Nila. Gem files for the compiler are hosted here.
data/Rakefile CHANGED
@@ -1,2 +1,2 @@
1
- #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/bin/nilac CHANGED
@@ -22,6 +22,7 @@ def compile(input_file_path)
22
22
 
23
23
  end
24
24
 
25
+
25
26
  def extract_parsable_array(input_file_contents)
26
27
 
27
28
  #This method finds and removes the __END__ keyword and the following lines in a Nila file.
@@ -155,12 +156,8 @@ def compile(input_file_path)
155
156
 
156
157
  file_id.write(modified_file_contents)
157
158
 
158
- file_id2.write("//Written in Nila and compiled to Javascript. Have fun!\n\n")
159
-
160
159
  file_id.close()
161
160
 
162
- file_id2.close()
163
-
164
161
  line_by_line_contents = read_file_line_by_line(temporary_nila_file)
165
162
 
166
163
  comments = multiline_comments.dup
@@ -209,6 +206,83 @@ def compile(input_file_path)
209
206
 
210
207
  end
211
208
 
209
+ def compile_heredoc_strings(input_file_contents,temporary_nila_file)
210
+
211
+ #This method will compile all the Heredoc strings in Nila into pure
212
+ #Javascript strings. Ruby has two types of Heredocs. Currently, Nila doesn't support both of them.
213
+ #Here is an example of what Nila supports
214
+
215
+ #long_passage = <<-ipsumtext
216
+ #
217
+ #Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
218
+ #incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
219
+ #exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
220
+ #irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
221
+ #pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia
222
+ #deserunt mollit anim id est laborum.
223
+ #
224
+ #ipsumtext
225
+
226
+ def find_all_matching_indices(input_string,pattern)
227
+
228
+ locations = []
229
+
230
+ index = input_string.index(pattern)
231
+
232
+ while index != nil
233
+
234
+ locations << index
235
+
236
+ index = input_string.index(pattern,index+1)
237
+
238
+
239
+ end
240
+
241
+ return locations
242
+
243
+
244
+ end
245
+
246
+ preserve_formatting = %w{ \n \t }
247
+
248
+ joined_file_contents = input_file_contents.join
249
+
250
+ modified_file_contents = joined_file_contents.dup
251
+
252
+ heredoc_start_locations = find_all_matching_indices(joined_file_contents,"<<-")
253
+
254
+ heredoc_start_locations.each do |location|
255
+
256
+ string_extract = joined_file_contents[location..-1]
257
+
258
+ end_of_first_line = string_extract.index("\n")
259
+
260
+ name_of_heredoc = string_extract[3...end_of_first_line].rstrip
261
+
262
+ heredoc_start,heredoc_end = find_all_matching_indices(string_extract,name_of_heredoc)
263
+
264
+ heredoc = string_extract[heredoc_start..heredoc_end+name_of_heredoc.length-1]
265
+
266
+ heredoc_content = heredoc.split(name_of_heredoc)
267
+
268
+ heredoc_content = heredoc_content[1].lstrip.rstrip.gsub("\n","\\n").gsub("\t","\\t")
269
+
270
+ modified_file_contents = modified_file_contents.sub(string_extract[heredoc_start-3..heredoc_end+name_of_heredoc.length-1],"\""+heredoc_content+"\"")
271
+
272
+ end
273
+
274
+ file_id = open(temporary_nila_file, 'w')
275
+
276
+ file_id.write(modified_file_contents)
277
+
278
+ file_id.close()
279
+
280
+ line_by_line_contents = read_file_line_by_line(temporary_nila_file)
281
+
282
+ return line_by_line_contents
283
+
284
+ end
285
+
212
286
  def compile_interpolated_strings(input_file_contents)
213
287
 
214
288
  modified_file_contents = input_file_contents.dup
@@ -470,9 +544,13 @@ def compile(input_file_path)
470
544
 
471
545
  line_by_line_contents = read_file_line_by_line(temporary_nila_file)
472
546
 
473
- variable_declaration_string = "var " + variables.uniq.join(", ") + "\n\n"
547
+ if variables.length > 0
474
548
 
475
- line_by_line_contents = [variable_declaration_string,line_by_line_contents].flatten
549
+ variable_declaration_string = "var " + variables.uniq.join(", ") + "\n\n"
550
+
551
+ line_by_line_contents = [variable_declaration_string,line_by_line_contents].flatten
552
+
553
+ end
476
554
 
477
555
  return variables.uniq,line_by_line_contents
478
556
 
@@ -1334,7 +1412,7 @@ def compile(input_file_path)
1334
1412
 
1335
1413
  file_contents = split_semicolon_seperated_expressions(file_contents)
1336
1414
 
1337
- #file_contents = compile_heredoc_strings(file_contents,temp_file)
1415
+ file_contents = compile_heredoc_strings(file_contents,temp_file)
1338
1416
 
1339
1417
  file_contents = compile_interpolated_strings(file_contents)
1340
1418
 
@@ -1477,12 +1555,5 @@ OptionParser.new do |opts|
1477
1555
 
1478
1556
  end
1479
1557
 
1480
- opts.on("-v", "--version", "Version of Nilac") do
1481
-
1482
- version_number = "0.0.1"
1483
-
1484
- puts "Current Nilac Version: #{version_number}"
1485
-
1486
- end
1487
1558
 
1488
1559
  end.parse!
data/lib/nilac/version.rb CHANGED
@@ -1,3 +1,3 @@
1
- module Nilac
2
- VERSION = "0.0.3"
3
- end
1
+ module Nilac
2
+ VERSION = "0.0.3.1"
3
+ end
data/lib/nilac.rb CHANGED
@@ -1,5 +1,5 @@
1
- require "nilac/version"
2
-
3
- module Nilac
4
-
5
- end
1
+ require "nilac/version"
2
+
3
+ module Nilac
4
+
5
+ end
data/nilac.gemspec CHANGED
@@ -1,17 +1,17 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/nilac/version', __FILE__)
3
-
4
- Gem::Specification.new do |gem|
5
- gem.authors = ["Adhithya Rajasekaran"]
6
- gem.email = ["adhithyan15@gmail.com"]
7
- gem.description = %q{Nilac is the official compiler of Nila language}
8
- gem.summary = %q{Nilac compiles Nila files into line for line Javascript.}
9
- gem.homepage = "http://adhithyan15.github.com/nila"
10
-
11
- gem.files = `git ls-files`.split($\)
12
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
- gem.name = "nilac"
15
- gem.require_paths = ["lib"]
16
- gem.version = Nilac::VERSION
17
- end
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/nilac/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Adhithya Rajasekaran"]
6
+ gem.email = ["adhithyan15@gmail.com"]
7
+ gem.description = %q{Nilac is the official compiler of Nila language}
8
+ gem.summary = %q{Nilac compiles Nila files into line for line Javascript.}
9
+ gem.homepage = "http://adhithyan15.github.com/nila"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "nilac"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Nilac::VERSION
17
+ end
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.3
4
+ version: 0.0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-31 00:00:00.000000000 Z
12
+ date: 2013-05-06 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Nilac is the official compiler of Nila language
15
15
  email: