nilac 0.0.4.3.3 → 0.0.4.3.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 +4 -4
- data/.gitignore +17 -17
- data/Gemfile +4 -4
- data/LICENSE +20 -20
- data/README.md +67 -67
- data/Rakefile +2 -2
- data/bin/nilac +4734 -4734
- data/lib/nilac.rb +5 -5
- data/lib/nilac/version.rb +3 -3
- data/nilac.gemspec +19 -19
- data/shark/features/add_auto_return_statement.feature +17 -17
- data/shark/features/array_and_string_indexing.feature +10 -10
- data/shark/features/barebones_compilation.feature +10 -10
- data/shark/features/default_method_parameters.feature +11 -11
- data/shark/features/fix_newlines.feature +12 -12
- data/shark/features/hashes.feature +10 -10
- data/shark/features/heredoc.feature +10 -10
- data/shark/features/if_then_else.feature +10 -10
- data/shark/features/loop.feature +10 -10
- data/shark/features/method_multiple_return.feature +16 -16
- data/shark/features/multiline_array.feature +10 -10
- data/shark/features/multiple_variable_initialization.feature +11 -11
- data/shark/features/numbers.feature +10 -10
- data/shark/features/regular_for.feature +10 -10
- data/shark/features/regular_if.feature +10 -10
- data/shark/features/regular_while.feature +10 -10
- data/shark/features/ruby_operators.feature +10 -10
- data/shark/features/string_interpolation.feature +10 -10
- data/shark/features/strings.feature +10 -10
- data/shark/features/times.feature +10 -10
- data/shark/features/unless_until.feature +10 -10
- data/shark/features/whitespace_delimitation.feature +10 -10
- data/shark/test_files/array_string_indexing.nila +21 -21
- data/shark/test_files/correct.js +4 -4
- data/shark/test_files/correct_default_parameters.js +22 -22
- data/shark/test_files/correct_for.js +26 -26
- data/shark/test_files/correct_hashes.js +32 -32
- data/shark/test_files/correct_heredoc.js +10 -10
- data/shark/test_files/correct_if_then_else.js +6 -6
- data/shark/test_files/correct_indexing.js +26 -26
- data/shark/test_files/correct_initialization.js +34 -34
- data/shark/test_files/correct_loop.js +14 -14
- data/shark/test_files/correct_multiline_array.js +12 -12
- data/shark/test_files/correct_multiple_return.js +20 -20
- data/shark/test_files/correct_numbers.js +8 -8
- data/shark/test_files/correct_operators.js +16 -16
- data/shark/test_files/correct_regular_if.js +13 -13
- data/shark/test_files/correct_regular_while.js +13 -13
- data/shark/test_files/correct_return.js +10 -10
- data/shark/test_files/correct_single_return.js +10 -10
- data/shark/test_files/correct_string_interpolation.js +16 -16
- data/shark/test_files/correct_string_operators.js +24 -24
- data/shark/test_files/correct_times.js +23 -23
- data/shark/test_files/correct_unless_until.js +28 -28
- data/shark/test_files/correct_whitespace_delimiter.js +16 -16
- data/shark/test_files/default_parameters.nila +12 -12
- data/shark/test_files/erratic.nila +22 -22
- data/shark/test_files/hashes.nila +22 -22
- data/shark/test_files/heredoc.nila +13 -13
- data/shark/test_files/loop.nila +5 -5
- data/shark/test_files/multiline_array.nila +12 -12
- data/shark/test_files/multiple_initialization.nila +16 -16
- data/shark/test_files/multiple_return.nila +16 -16
- data/shark/test_files/no_return.nila +6 -6
- data/shark/test_files/numbers.nila +2 -2
- data/shark/test_files/operators.nila +8 -8
- data/shark/test_files/perfect.js +16 -16
- data/shark/test_files/regular_for.nila +16 -16
- data/shark/test_files/regular_if.nila +19 -19
- data/shark/test_files/regular_while.nila +6 -6
- data/shark/test_files/ruby_methods.nila +24 -0
- data/shark/test_files/single_return.nila +6 -6
- data/shark/test_files/string_interpolation.nila +10 -10
- data/shark/test_files/string_operators.nila +19 -19
- data/shark/test_files/times.nila +12 -12
- data/shark/test_files/unless_until.nila +16 -16
- data/shark/test_files/whitespace_delimiter.nila +16 -16
- data/src/nilac.rb +4766 -4732
- metadata +4 -4
@@ -1,29 +1,29 @@
|
|
1
|
-
//Written using Nila. Visit http://adhithyan15.github.io/nila
|
2
|
-
(function() {
|
3
|
-
var i;
|
4
|
-
|
5
|
-
// This file demonstrates unless and until statements.
|
6
|
-
|
7
|
-
// Examples are from http://www.skorks.com/2009/09/a-wealth-of-ruby-loops-and-iterators/ and
|
8
|
-
|
9
|
-
// http://37signals.com/svn/posts/2699-making-sense-with-rubys-unless
|
10
|
-
|
11
|
-
if (!(person.present)) {
|
12
|
-
console.log("There's no such person");
|
13
|
-
}
|
14
|
-
|
15
|
-
if (!(person.present)) {
|
16
|
-
console.log("There's no such person");
|
17
|
-
}
|
18
|
-
|
19
|
-
i=1;
|
20
|
-
|
21
|
-
while (!(i > 10)) {
|
22
|
-
process.stdout.write("" + (i) + " ");
|
23
|
-
i+=1;
|
24
|
-
if (i === 9) {
|
25
|
-
break;
|
26
|
-
}
|
27
|
-
}
|
28
|
-
|
1
|
+
//Written using Nila. Visit http://adhithyan15.github.io/nila
|
2
|
+
(function() {
|
3
|
+
var i;
|
4
|
+
|
5
|
+
// This file demonstrates unless and until statements.
|
6
|
+
|
7
|
+
// Examples are from http://www.skorks.com/2009/09/a-wealth-of-ruby-loops-and-iterators/ and
|
8
|
+
|
9
|
+
// http://37signals.com/svn/posts/2699-making-sense-with-rubys-unless
|
10
|
+
|
11
|
+
if (!(person.present)) {
|
12
|
+
console.log("There's no such person");
|
13
|
+
}
|
14
|
+
|
15
|
+
if (!(person.present)) {
|
16
|
+
console.log("There's no such person");
|
17
|
+
}
|
18
|
+
|
19
|
+
i=1;
|
20
|
+
|
21
|
+
while (!(i > 10)) {
|
22
|
+
process.stdout.write("" + (i) + " ");
|
23
|
+
i+=1;
|
24
|
+
if (i === 9) {
|
25
|
+
break;
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
29
|
}).call(this);
|
@@ -1,17 +1,17 @@
|
|
1
|
-
//Written using Nila. Visit http://adhithyan15.github.io/nila
|
2
|
-
(function() {
|
3
|
-
var return_number, square;
|
4
|
-
|
5
|
-
square = function(input_number) {
|
6
|
-
return input_number*input_number;
|
7
|
-
};
|
8
|
-
|
9
|
-
return_number = function(input_number) {
|
10
|
-
return input_number;
|
11
|
-
};
|
12
|
-
|
13
|
-
console.log(message);
|
14
|
-
|
15
|
-
console.log(square(return_number(5)));
|
16
|
-
|
1
|
+
//Written using Nila. Visit http://adhithyan15.github.io/nila
|
2
|
+
(function() {
|
3
|
+
var return_number, square;
|
4
|
+
|
5
|
+
square = function(input_number) {
|
6
|
+
return input_number*input_number;
|
7
|
+
};
|
8
|
+
|
9
|
+
return_number = function(input_number) {
|
10
|
+
return input_number;
|
11
|
+
};
|
12
|
+
|
13
|
+
console.log(message);
|
14
|
+
|
15
|
+
console.log(square(return_number(5)));
|
16
|
+
|
17
17
|
}).call(this);
|
@@ -1,13 +1,13 @@
|
|
1
|
-
# This is a demo of default parameters
|
2
|
-
|
3
|
-
def fill(container = "cup",liquid = "coffee")
|
4
|
-
|
5
|
-
puts "Filling #{container} with #{liquid}"
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
fill()
|
10
|
-
|
11
|
-
fill("cup")
|
12
|
-
|
1
|
+
# This is a demo of default parameters
|
2
|
+
|
3
|
+
def fill(container = "cup",liquid = "coffee")
|
4
|
+
|
5
|
+
puts "Filling #{container} with #{liquid}"
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
fill()
|
10
|
+
|
11
|
+
fill("cup")
|
12
|
+
|
13
13
|
fill("bowl","soup")
|
@@ -1,22 +1,22 @@
|
|
1
|
-
hello = "world"
|
2
|
-
|
3
|
-
msg = "nila"
|
4
|
-
|
5
|
-
message = "Welcome to #{msg}"
|
6
|
-
|
7
|
-
goal_reached = 72
|
8
|
-
|
9
|
-
def square(inputnumber)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
inputnumber*inputnumber
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
1
|
+
hello = "world"
|
2
|
+
|
3
|
+
msg = "nila"
|
4
|
+
|
5
|
+
message = "Welcome to #{msg}"
|
6
|
+
|
7
|
+
goal_reached = 72
|
8
|
+
|
9
|
+
def square(inputnumber)
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
inputnumber*inputnumber
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
end
|
@@ -1,23 +1,23 @@
|
|
1
|
-
# This file demonstrates several Hash features in Nila
|
2
|
-
|
3
|
-
variable = 5
|
4
|
-
|
5
|
-
inst_section = {
|
6
|
-
'cello' => 'string',
|
7
|
-
'clarinet' => 'woodwind',
|
8
|
-
'drum': 'percussion',
|
9
|
-
'oboe' : 'woodwind',
|
10
|
-
'trumpet' => 'brass',
|
11
|
-
'violin' => 'string',
|
12
|
-
:guitar => 'string'
|
13
|
-
}
|
14
|
-
|
15
|
-
if variable == 10
|
16
|
-
print "Variable is 10"
|
17
|
-
elsif variable == 20
|
18
|
-
print "Variable is 20"
|
19
|
-
else
|
20
|
-
print "Variable is something else"
|
21
|
-
end
|
22
|
-
|
1
|
+
# This file demonstrates several Hash features in Nila
|
2
|
+
|
3
|
+
variable = 5
|
4
|
+
|
5
|
+
inst_section = {
|
6
|
+
'cello' => 'string',
|
7
|
+
'clarinet' => 'woodwind',
|
8
|
+
'drum': 'percussion',
|
9
|
+
'oboe' : 'woodwind',
|
10
|
+
'trumpet' => 'brass',
|
11
|
+
'violin' => 'string',
|
12
|
+
:guitar => 'string'
|
13
|
+
}
|
14
|
+
|
15
|
+
if variable == 10
|
16
|
+
print "Variable is 10"
|
17
|
+
elsif variable == 20
|
18
|
+
print "Variable is 20"
|
19
|
+
else
|
20
|
+
print "Variable is something else"
|
21
|
+
end
|
22
|
+
|
23
23
|
student_ages = {"Jack" => 10,"Jill" => 12,"Bob" => 14}
|
@@ -1,14 +1,14 @@
|
|
1
|
-
puts <<-Hello
|
2
|
-
Grocery list
|
3
|
-
----
|
4
|
-
1. Salad mix.
|
5
|
-
2. Strawberries.*
|
6
|
-
3. Cereal.
|
7
|
-
4. Milk.*
|
8
|
-
|
9
|
-
* Organic
|
10
|
-
Hello
|
11
|
-
|
12
|
-
numbers = [1,2,3,4,5,6,7]
|
13
|
-
|
1
|
+
puts <<-Hello
|
2
|
+
Grocery list
|
3
|
+
----
|
4
|
+
1. Salad mix.
|
5
|
+
2. Strawberries.*
|
6
|
+
3. Cereal.
|
7
|
+
4. Milk.*
|
8
|
+
|
9
|
+
* Organic
|
10
|
+
Hello
|
11
|
+
|
12
|
+
numbers = [1,2,3,4,5,6,7]
|
13
|
+
|
14
14
|
numbers << 7
|
data/shark/test_files/loop.nila
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
i=0
|
2
|
-
loop do
|
3
|
-
i+=1
|
4
|
-
print "#{i} "
|
5
|
-
break if i==10
|
1
|
+
i=0
|
2
|
+
loop do
|
3
|
+
i+=1
|
4
|
+
print "#{i} "
|
5
|
+
break if i==10
|
6
6
|
end
|
@@ -1,13 +1,13 @@
|
|
1
|
-
numbers = [1,2,3,4,5,6,7,8,9,10]
|
2
|
-
|
3
|
-
myarray = [
|
4
|
-
|
5
|
-
"string 1",
|
6
|
-
"string 2",
|
7
|
-
"string 3"
|
8
|
-
|
9
|
-
]
|
10
|
-
|
11
|
-
name = "Adhithya"
|
12
|
-
|
1
|
+
numbers = [1,2,3,4,5,6,7,8,9,10]
|
2
|
+
|
3
|
+
myarray = [
|
4
|
+
|
5
|
+
"string 1",
|
6
|
+
"string 2",
|
7
|
+
"string 3"
|
8
|
+
|
9
|
+
]
|
10
|
+
|
11
|
+
name = "Adhithya"
|
12
|
+
|
13
13
|
name[5] = "t"
|
@@ -1,17 +1,17 @@
|
|
1
|
-
# This file demonstrates multiple variable initialization
|
2
|
-
|
3
|
-
def parse_name(input_name)
|
4
|
-
|
5
|
-
name_split = input_name.split(" ")
|
6
|
-
|
7
|
-
return name_split[0],name_split[1]
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
first_name,last_name = parse_name("Adhithya Rajasekaran")
|
12
|
-
|
13
|
-
puts first_name + " " + last_name
|
14
|
-
|
15
|
-
current_val, next_val, count = 0, 1, 1
|
16
|
-
|
1
|
+
# This file demonstrates multiple variable initialization
|
2
|
+
|
3
|
+
def parse_name(input_name)
|
4
|
+
|
5
|
+
name_split = input_name.split(" ")
|
6
|
+
|
7
|
+
return name_split[0],name_split[1]
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
first_name,last_name = parse_name("Adhithya Rajasekaran")
|
12
|
+
|
13
|
+
puts first_name + " " + last_name
|
14
|
+
|
15
|
+
current_val, next_val, count = 0, 1, 1
|
16
|
+
|
17
17
|
name_split1,name_split2 = "Adhithya Rajasekaran".split((" "),1),"Adhithya Rajasekaran".split(" ",2)
|
@@ -1,17 +1,17 @@
|
|
1
|
-
# This method demonstrates multiple return values
|
2
|
-
|
3
|
-
def parse_name(input_name)
|
4
|
-
|
5
|
-
first_name,last_name = input_name.split(" ")
|
6
|
-
|
7
|
-
return first_name,last_name
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_method()
|
12
|
-
|
13
|
-
puts "Hello, Adhithya"
|
14
|
-
|
15
|
-
end
|
16
|
-
|
1
|
+
# This method demonstrates multiple return values
|
2
|
+
|
3
|
+
def parse_name(input_name)
|
4
|
+
|
5
|
+
first_name,last_name = input_name.split(" ")
|
6
|
+
|
7
|
+
return first_name,last_name
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_method()
|
12
|
+
|
13
|
+
puts "Hello, Adhithya"
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
17
|
parsed_name = parse_name("Adhithya Rajasekaran")
|
@@ -1,7 +1,7 @@
|
|
1
|
-
def subtract(num1,num2)
|
2
|
-
|
3
|
-
num1-num2
|
4
|
-
|
5
|
-
end
|
6
|
-
|
1
|
+
def subtract(num1,num2)
|
2
|
+
|
3
|
+
num1-num2
|
4
|
+
|
5
|
+
end
|
6
|
+
|
7
7
|
puts subtract(7,8)
|
@@ -1,3 +1,3 @@
|
|
1
|
-
million = 1_000_000 + 7_000_000
|
2
|
-
|
1
|
+
million = 1_000_000 + 7_000_000
|
2
|
+
|
3
3
|
puts million
|
@@ -1,9 +1,9 @@
|
|
1
|
-
a = 2**3
|
2
|
-
|
3
|
-
puts "Correct Calculation!" if a == 8
|
4
|
-
|
5
|
-
line = "My favorite language is Ruby!"
|
6
|
-
|
7
|
-
if line =~ /Ruby|Python/
|
8
|
-
puts "Scripting language mentioned: #{line}"
|
1
|
+
a = 2**3
|
2
|
+
|
3
|
+
puts "Correct Calculation!" if a == 8
|
4
|
+
|
5
|
+
line = "My favorite language is Ruby!"
|
6
|
+
|
7
|
+
if line =~ /Ruby|Python/
|
8
|
+
puts "Scripting language mentioned: #{line}"
|
9
9
|
end
|
data/shark/test_files/perfect.js
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
//Written using Nila. Visit http://adhithyan15.github.io/nila
|
2
|
-
(function() {
|
3
|
-
var goal_reached, hello, message, msg, square;
|
4
|
-
|
5
|
-
hello = "world";
|
6
|
-
|
7
|
-
msg = "nila";
|
8
|
-
|
9
|
-
message = "Welcome to " + (msg);
|
10
|
-
|
11
|
-
goal_reached = 72;
|
12
|
-
|
13
|
-
square = function(inputnumber) {
|
14
|
-
return inputnumber*inputnumber;
|
15
|
-
};
|
16
|
-
|
1
|
+
//Written using Nila. Visit http://adhithyan15.github.io/nila
|
2
|
+
(function() {
|
3
|
+
var goal_reached, hello, message, msg, square;
|
4
|
+
|
5
|
+
hello = "world";
|
6
|
+
|
7
|
+
msg = "nila";
|
8
|
+
|
9
|
+
message = "Welcome to " + (msg);
|
10
|
+
|
11
|
+
goal_reached = 72;
|
12
|
+
|
13
|
+
square = function(inputnumber) {
|
14
|
+
return inputnumber*inputnumber;
|
15
|
+
};
|
16
|
+
|
17
17
|
}).call(this);
|
@@ -1,17 +1,17 @@
|
|
1
|
-
for x in [1,2,3,4]
|
2
|
-
puts x
|
3
|
-
end
|
4
|
-
|
5
|
-
for x in 0...5
|
6
|
-
puts x
|
7
|
-
end
|
8
|
-
|
9
|
-
for x in 0..5
|
10
|
-
puts x
|
11
|
-
end
|
12
|
-
|
13
|
-
fruits = ['Apple','Banana', 'Mango']
|
14
|
-
|
15
|
-
for fruit in fruits
|
16
|
-
puts fruit
|
1
|
+
for x in [1,2,3,4]
|
2
|
+
puts x
|
3
|
+
end
|
4
|
+
|
5
|
+
for x in 0...5
|
6
|
+
puts x
|
7
|
+
end
|
8
|
+
|
9
|
+
for x in 0..5
|
10
|
+
puts x
|
11
|
+
end
|
12
|
+
|
13
|
+
fruits = ['Apple','Banana', 'Mango']
|
14
|
+
|
15
|
+
for fruit in fruits
|
16
|
+
puts fruit
|
17
17
|
end
|