nilac 0.0.4.2.5 → 0.0.4.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/nilac +30 -2
- data/lib/nilac/version.rb +1 -1
- data/src/nilac.rb +30 -2
- metadata +1 -1
data/bin/nilac
CHANGED
@@ -1973,6 +1973,32 @@ def compile(input_file_path, *output_file_name)
|
|
1973
1973
|
|
1974
1974
|
end
|
1975
1975
|
|
1976
|
+
def compile_ternary_if(input_file_contents)
|
1977
|
+
|
1978
|
+
possible_ternary_if = input_file_contents.reject{|element| !element.include?("if")}
|
1979
|
+
|
1980
|
+
possible_ternary_if = possible_ternary_if.reject {|element| !element.include?("then")}
|
1981
|
+
|
1982
|
+
possible_ternary_if.each do |statement|
|
1983
|
+
|
1984
|
+
statement_extract = statement[statement.index("if")..statement.index("end")+2]
|
1985
|
+
|
1986
|
+
condition = statement_extract.split("then")[0].split("if")[1].lstrip.rstrip
|
1987
|
+
|
1988
|
+
true_condition = statement_extract.split("then")[1].split("else")[0].lstrip.rstrip
|
1989
|
+
|
1990
|
+
false_condition = statement_extract.split("else")[1].split("end")[0].lstrip.rstrip
|
1991
|
+
|
1992
|
+
replacement_string = "#{condition} ? #{true_condition} : #{false_condition}"
|
1993
|
+
|
1994
|
+
input_file_contents[input_file_contents.index(statement)] = input_file_contents[input_file_contents.index(statement)].sub(statement_extract,replacement_string)
|
1995
|
+
|
1996
|
+
end
|
1997
|
+
|
1998
|
+
return input_file_contents
|
1999
|
+
|
2000
|
+
end
|
2001
|
+
|
1976
2002
|
def compile_inline_conditionals(input_file_contents, temporary_nila_file)
|
1977
2003
|
|
1978
2004
|
conditionals = [/( if )/, /( while )/, /( unless )/, /( until )/]
|
@@ -2935,7 +2961,9 @@ def compile(input_file_path, *output_file_name)
|
|
2935
2961
|
|
2936
2962
|
end
|
2937
2963
|
|
2938
|
-
file_contents
|
2964
|
+
file_contents = compile_ternary_if(input_file_contents)
|
2965
|
+
|
2966
|
+
file_contents, rejected_lines = ignore_statement_modifiers(file_contents)
|
2939
2967
|
|
2940
2968
|
file_contents = replace_unless_until(file_contents)
|
2941
2969
|
|
@@ -3745,7 +3773,7 @@ def find_file_path(input_path, file_extension)
|
|
3745
3773
|
|
3746
3774
|
end
|
3747
3775
|
|
3748
|
-
nilac_version = "0.0.4.2.
|
3776
|
+
nilac_version = "0.0.4.2.6"
|
3749
3777
|
|
3750
3778
|
opts = Slop.parse do
|
3751
3779
|
on :c, :compile=, 'Compile Nila File', as:Array, delimiter:":"
|
data/lib/nilac/version.rb
CHANGED
data/src/nilac.rb
CHANGED
@@ -1971,6 +1971,32 @@ def compile(input_file_path, *output_file_name)
|
|
1971
1971
|
|
1972
1972
|
end
|
1973
1973
|
|
1974
|
+
def compile_ternary_if(input_file_contents)
|
1975
|
+
|
1976
|
+
possible_ternary_if = input_file_contents.reject{|element| !element.include?("if")}
|
1977
|
+
|
1978
|
+
possible_ternary_if = possible_ternary_if.reject {|element| !element.include?("then")}
|
1979
|
+
|
1980
|
+
possible_ternary_if.each do |statement|
|
1981
|
+
|
1982
|
+
statement_extract = statement[statement.index("if")..statement.index("end")+2]
|
1983
|
+
|
1984
|
+
condition = statement_extract.split("then")[0].split("if")[1].lstrip.rstrip
|
1985
|
+
|
1986
|
+
true_condition = statement_extract.split("then")[1].split("else")[0].lstrip.rstrip
|
1987
|
+
|
1988
|
+
false_condition = statement_extract.split("else")[1].split("end")[0].lstrip.rstrip
|
1989
|
+
|
1990
|
+
replacement_string = "#{condition} ? #{true_condition} : #{false_condition}"
|
1991
|
+
|
1992
|
+
input_file_contents[input_file_contents.index(statement)] = input_file_contents[input_file_contents.index(statement)].sub(statement_extract,replacement_string)
|
1993
|
+
|
1994
|
+
end
|
1995
|
+
|
1996
|
+
return input_file_contents
|
1997
|
+
|
1998
|
+
end
|
1999
|
+
|
1974
2000
|
def compile_inline_conditionals(input_file_contents, temporary_nila_file)
|
1975
2001
|
|
1976
2002
|
conditionals = [/( if )/, /( while )/, /( unless )/, /( until )/]
|
@@ -2933,7 +2959,9 @@ def compile(input_file_path, *output_file_name)
|
|
2933
2959
|
|
2934
2960
|
end
|
2935
2961
|
|
2936
|
-
file_contents
|
2962
|
+
file_contents = compile_ternary_if(input_file_contents)
|
2963
|
+
|
2964
|
+
file_contents, rejected_lines = ignore_statement_modifiers(file_contents)
|
2937
2965
|
|
2938
2966
|
file_contents = replace_unless_until(file_contents)
|
2939
2967
|
|
@@ -3743,7 +3771,7 @@ def find_file_path(input_path, file_extension)
|
|
3743
3771
|
|
3744
3772
|
end
|
3745
3773
|
|
3746
|
-
nilac_version = "0.0.4.2.
|
3774
|
+
nilac_version = "0.0.4.2.6"
|
3747
3775
|
|
3748
3776
|
opts = Slop.parse do
|
3749
3777
|
on :c, :compile=, 'Compile Nila File', as:Array, delimiter:":"
|