Skip to content

Commit 0bef466

Browse files
author
Arthur Melton
committed
have to do "use os" to use os stuff
1 parent bacc966 commit 0bef466

File tree

4 files changed

+112
-97
lines changed

4 files changed

+112
-97
lines changed

examples/test.nys

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
log(arg(0));
1+
use os;
2+
log(os);

src/main.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ fn main() {
2727
let mut compile = false;
2828
let mut hard = false;
2929
let mut run = false;
30+
let mut uses:Vec<String> = vec!["false".to_string()];
3031
for arg in args {
3132
if arg == "--dev" {
3233
dev = true;
@@ -102,7 +103,7 @@ fn main() {
102103
let to_parse = lexer::lexer(contents, dev);
103104
let _output = run::run(
104105
to_parse,
105-
dev,
106+
dev, uses.clone(),
106107
Vec::new(),
107108
Vec::new(),
108109
Vec::new(),
@@ -135,7 +136,7 @@ fn main() {
135136
let to_parse = lexer::lexer(contents, dev);
136137
let _output = run::run(
137138
to_parse,
138-
dev,
139+
dev, uses,
139140
Vec::new(),
140141
Vec::new(),
141142
Vec::new(),
@@ -164,7 +165,7 @@ fn main() {
164165
if hard {
165166
contents = run::hard(
166167
contents,
167-
dev,
168+
dev, uses,
168169
Vec::new(),
169170
Vec::new(),
170171
Vec::new(),
@@ -227,7 +228,7 @@ fn main() {
227228
let output = run::run([r\""
228229
.to_string();
229230
ruturns.push_str(content.join("\", r\"").as_str());
230-
ruturns.push_str("\"].to_vec().iter().map(|s| s.to_string()).collect(), dev, Vec::new(), Vec::new(), Vec::new(), Vec::new(), Vec::new(), Vec::new());
231+
ruturns.push_str("\"].to_vec().iter().map(|s| s.to_string()).collect(), dev, uses, Vec::new(), Vec::new(), Vec::new(), Vec::new(), Vec::new(), Vec::new());
231232
}");
232233
ruturns.to_string()
233234
}

src/run.rs

Lines changed: 44 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ extern crate meval;
88

99
pub fn run(
1010
mut contents: Vec<String>,
11-
dev: bool,
11+
dev: bool, mut uses: Vec<String>,
1212
mut memory_names: Vec<String>,
1313
mut memory_values: Vec<String>,
1414
mut memory_types: Vec<String>,
@@ -73,7 +73,7 @@ pub fn run(
7373
func_names.clone(),
7474
func_par.clone(),
7575
func_code.clone(),
76-
dev,
76+
dev, uses.clone(),
7777
);
7878
}
7979
//divider--
@@ -87,7 +87,7 @@ pub fn run(
8787
func_names,
8888
func_par,
8989
func_code,
90-
dev,
90+
dev, uses.clone(),
9191
0,
9292
)
9393
.first()
@@ -96,6 +96,11 @@ pub fn run(
9696
.trim()
9797
.to_string();
9898
}
99+
"use" => {
100+
if contents[x+1].as_str() == "os" {
101+
uses[0] = "true".to_string();
102+
}
103+
}
99104
//divider--
100105
"request" => {
101106
let _output = functions::request(
@@ -107,7 +112,7 @@ pub fn run(
107112
func_names.clone(),
108113
func_par.clone(),
109114
func_code.clone(),
110-
dev,
115+
dev, uses.clone(),
111116
);
112117
}
113118
//divider--
@@ -121,6 +126,7 @@ pub fn run(
121126
let func_names_save = func_names.clone();
122127
let func_par_save = func_par.clone();
123128
let func_code_save = func_code.clone();
129+
let uses_save = uses.clone();
124130
let handle = thread::spawn(move || {
125131
let stringreturn = functions::getstring(
126132
x,
@@ -131,7 +137,7 @@ pub fn run(
131137
func_names_save.clone(),
132138
func_par_save.clone(),
133139
func_code_save.clone(),
134-
dev,
140+
dev, uses_save,
135141
0,
136142
)
137143
.first()
@@ -191,6 +197,7 @@ pub fn run(
191197
func_names.clone(),
192198
func_par.clone(),
193199
func_code.clone(),
200+
uses.clone()
194201
);
195202
if number_of_times > 0 as f64 {
196203
let mut n = 0;
@@ -290,6 +297,7 @@ pub fn run(
290297
func_names.clone(),
291298
func_par.clone(),
292299
func_code.clone(),
300+
uses.clone()
293301
);
294302
thread::sleep(time::Duration::from_millis(number_of_times as u64));
295303
}
@@ -304,7 +312,7 @@ pub fn run(
304312
func_names.clone(),
305313
func_par.clone(),
306314
func_code.clone(),
307-
dev,
315+
dev, uses.clone(),
308316
);
309317
}
310318
//divider--
@@ -318,7 +326,7 @@ pub fn run(
318326
func_names.clone(),
319327
func_par.clone(),
320328
func_code.clone(),
321-
dev,
329+
dev, uses.clone(),
322330
);
323331
if r.is_err() {
324332
error("Could not set file contents.".to_string());
@@ -335,7 +343,7 @@ pub fn run(
335343
func_names.clone(),
336344
func_par.clone(),
337345
func_code.clone(),
338-
dev,
346+
dev, uses.clone(),
339347
);
340348
readfrom = x;
341349
skiperwiper = true;
@@ -387,7 +395,7 @@ pub fn run(
387395
func_names.clone(),
388396
func_par.clone(),
389397
func_code.clone(),
390-
dev,
398+
dev, uses.clone(),
391399
"".to_string(),
392400
);
393401
readfrom = x;
@@ -505,7 +513,7 @@ pub fn run(
505513
func_names.clone(),
506514
func_par.clone(),
507515
func_code.clone(),
508-
dev,
516+
dev, uses.clone(),
509517
0,
510518
)
511519
.join("zzGVgfHaNtPMe7H9RRyx3rWC9JyyZdMkc2v")
@@ -530,7 +538,7 @@ pub fn run(
530538
let mut location = 0;
531539
for items in 0..group_memory.len() {
532540
if items < group_memory.len() - 1
533-
&& group_memory[items + 1].parse::<i32>().is_ok()
541+
&& group_memory[items + 1].parse::<f64>().is_ok()
534542
&& group_memory[items] == clone_class.clone()
535543
{
536544
location = items + (d * 2) + 3;
@@ -705,7 +713,7 @@ pub fn run(
705713
func_names.clone(),
706714
func_par.clone(),
707715
func_code.clone(),
708-
dev,
716+
dev, uses.clone(),
709717
3,
710718
)
711719
.join("zzGVgfHaNtPMe7H9RRyx3rWC9JyyZdMkc2v");
@@ -791,7 +799,7 @@ pub fn run(
791799
func_names.clone(),
792800
func_par.clone(),
793801
func_code.clone(),
794-
dev,
802+
dev, uses.clone(),
795803
2,
796804
)
797805
.first()
@@ -875,17 +883,17 @@ pub fn run(
875883
|| (output[item] == "!="
876884
&& output[item - 1] != output[item + 1])
877885
|| (output[item] == ">="
878-
&& output[item - 1].parse::<i32>().unwrap()
879-
>= output[item + 1].parse::<i32>().unwrap())
886+
&& output[item - 1].parse::<f64>().unwrap()
887+
>= output[item + 1].parse::<f64>().unwrap())
880888
|| (output[item] == "<="
881-
&& output[item - 1].parse::<i32>().unwrap()
882-
<= output[item + 1].parse::<i32>().unwrap())
889+
&& output[item - 1].parse::<f64>().unwrap()
890+
<= output[item + 1].parse::<f64>().unwrap())
883891
|| (output[item] == "<"
884-
&& output[item - 1].parse::<i32>().unwrap()
885-
< output[item + 1].parse::<i32>().unwrap())
892+
&& output[item - 1].parse::<f64>().unwrap()
893+
< output[item + 1].parse::<f64>().unwrap())
886894
|| (output[item] == ">"
887-
&& output[item - 1].parse::<i32>().unwrap()
888-
> output[item + 1].parse::<i32>().unwrap())
895+
&& output[item - 1].parse::<f64>().unwrap()
896+
> output[item + 1].parse::<f64>().unwrap())
889897
{
890898
output[item] = "true".to_string();
891899
output[item - 1] = "".to_string();
@@ -895,17 +903,17 @@ pub fn run(
895903
|| (output[item] == "!="
896904
&& !(output[item - 1] != output[item + 1]))
897905
|| (output[item] == ">="
898-
&& !(output[item - 1].parse::<i32>().unwrap()
899-
>= output[item + 1].parse::<i32>().unwrap()))
906+
&& !(output[item - 1].parse::<f64>().unwrap()
907+
>= output[item + 1].parse::<f64>().unwrap()))
900908
|| (output[item] == "<="
901-
&& !(output[item - 1].parse::<i32>().unwrap()
902-
<= output[item + 1].parse::<i32>().unwrap()))
909+
&& !(output[item - 1].parse::<f64>().unwrap()
910+
<= output[item + 1].parse::<f64>().unwrap()))
903911
|| (output[item] == "<"
904-
&& !(output[item - 1].parse::<i32>().unwrap()
905-
< output[item + 1].parse::<i32>().unwrap()))
912+
&& !(output[item - 1].parse::<f64>().unwrap()
913+
< output[item + 1].parse::<f64>().unwrap()))
906914
|| (output[item] == ">"
907-
&& !(output[item - 1].parse::<i32>().unwrap()
908-
> output[item + 1].parse::<i32>().unwrap()))
915+
&& !(output[item - 1].parse::<f64>().unwrap()
916+
> output[item + 1].parse::<f64>().unwrap()))
909917
{
910918
output[item] = "false".to_string();
911919
output[item - 1] = "".to_string();
@@ -1025,7 +1033,7 @@ pub fn run(
10251033
func_names.clone(),
10261034
func_par.clone(),
10271035
func_code.clone(),
1028-
dev,
1036+
dev, uses.clone(),
10291037
0,
10301038
);
10311039
for t in func_par[postion]
@@ -1035,7 +1043,7 @@ pub fn run(
10351043
}
10361044
let _output = run(
10371045
contetntstr,
1038-
dev,
1046+
dev, uses.clone(),
10391047
contetntstr1.clone(),
10401048
contetntstr2.clone(),
10411049
memory_types.clone(),
@@ -1089,7 +1097,7 @@ pub fn run(
10891097
func_names.clone(),
10901098
func_par.clone(),
10911099
func_code.clone(),
1092-
dev,
1100+
dev, uses.clone(),
10931101
0,
10941102
)
10951103
.join("zzGVgfHaNtPMe7H9RRyx3rWC9JyyZdMkc2v")
@@ -1107,6 +1115,7 @@ pub fn run(
11071115
func_names.clone(),
11081116
func_par.clone(),
11091117
func_code.clone(),
1118+
uses.clone()
11101119
);
11111120
let mut skipz = false;
11121121
let mut nigro = 0;
@@ -1155,7 +1164,7 @@ pub fn run(
11551164
func_names.clone(),
11561165
func_par.clone(),
11571166
func_code.clone(),
1158-
dev,
1167+
dev, uses.clone(),
11591168
0,
11601169
)
11611170
.join("zzGVgfHaNtPMe7H9RRyx3rWC9JyyZdMkc2v")
@@ -1183,7 +1192,7 @@ pub fn run(
11831192

11841193
pub(crate) fn hard(
11851194
mut contents: Vec<String>,
1186-
dev: bool,
1195+
dev: bool, uses: Vec<String>,
11871196
memory_names: Vec<String>,
11881197
memory_values: Vec<String>,
11891198
memory_types: Vec<String>,
@@ -1229,7 +1238,7 @@ pub(crate) fn hard(
12291238
func_names.clone(),
12301239
func_par.clone(),
12311240
func_code.clone(),
1232-
dev,
1241+
dev, uses.clone(),
12331242
"".to_string(),
12341243
);
12351244
skiperwiper = true;

0 commit comments

Comments
 (0)