🎨 format
Nasal Interpreter Test / mac-aarch64 (push) Has been cancelled Details
Nasal Interpreter Test / linux-x86_64 (push) Has been cancelled Details

This commit is contained in:
ValKmjolnir 2025-06-02 13:43:00 +08:00
parent 2cc5bb8625
commit af3d93ab64
53 changed files with 185 additions and 185 deletions

View File

@ -40,15 +40,15 @@ These two expressions have the same first set,so `LL(1)` is useless for this lan
Problems mentioned above have been solved for a long time, but recently i found a new problem here:
```javascript
var f=func(x,y,z){return x+y+z}
(a,b,c)=(0,1,2);
var f = func(x, y, z) { return x + y + z }
(a, b, c) = (0, 1, 2);
```
This will be recognized as this:
```javascript
var f=func(x,y,z){return x+y+z}(a,b,c)
=(0,1,2);
var f = func(x, y, z) { return x + y + z }(a, b, c)
= (0, 1, 2);
```
and causes fatal syntax error.
@ -58,9 +58,9 @@ I think this is a serious design fault.
To avoid this syntax error, change program like this, just add a semicolon:
```javascript
var f=func(x,y,z){return x+y+z};
^ here
(a,b,c)=(0,1,2);
var f = func(x, y, z) { return x + y + z };
^ here
(a, b, c) = (0, 1, 2);
```
### version 1.0 parser (last update 2019/10/14)
@ -222,8 +222,8 @@ Better use `callfv` instead of `callfh`,
making this process slow.
```javascript
var f=func(x,y){return x+y;}
f(1024,2048);
var f = func(x, y) { return x + y; }
f(1024, 2048);
```
```x86asm
@ -530,12 +530,12 @@ func <0x2a3>:
Now we add coroutine in this runtime:
```javascript
var coroutine={
create: func(function){return __cocreate;},
resume: func(co) {return __coresume;},
yield: func(args...) {return __coyield; },
status: func(co) {return __costatus;},
running:func() {return __corun; }
var coroutine = {
create: func(function) { return __cocreate; },
resume: func(co) { return __coresume; },
yield: func(args...) { return __coyield; },
status: func(co) { return __costatus; },
running: func() { return __corun; }
};
```

View File

@ -40,23 +40,23 @@
上面这个问题已经解决很久了,不过我最近发现了一个新的语法问题:
```javascript
var f=func(x,y,z){return x+y+z}
(a,b,c)=(0,1,2);
var f = func(x, y, z) { return x + y + z }
(a, b, c) = (0, 1, 2);
```
这种写法会被错误识别合并成下面这种:
```javascript
var f=func(x,y,z){return x+y+z}(a,b,c)
=(0,1,2);
var f = func(x, y, z) { return x + y + z }(a, b, c)
= (0, 1, 2);
```
语法分析器会认为这是个严重的语法错误。我在Flightgear中也测试了这个代码它内置的语法分析器也认为这是错误语法。当然我认为这是语法设计中的一个比较严重的缺漏。为了避免这个语法问题只需要添加一个分号就可以了:
```javascript
var f=func(x,y,z){return x+y+z};
^ 就是这里
(a,b,c)=(0,1,2);
var f = func(x, y, z) { return x + y + z };
^ 就是这里
(a, b, c) = (0, 1, 2);
```
### version 1.0 parser (last update 2019/10/14)
@ -193,15 +193,15 @@ for (var i=0;i<4000000;i+=1);
2021/6/3 update:
修复了垃圾收集器还是他妈的会重复收集的bug这次我设计了三个标记状态来保证垃圾是被正确收集了。
修复了垃圾收集器还是会重复收集的bug这次我设计了三个标记状态来保证垃圾是被正确收集了。
将`callf`指令拆分为`callfv`和`callfh`。并且`callfv`将直接从`val_stack`获取传参,而不是先通过一个`vm_vec`把参数收集起来再传入,后者是非常低效的做法。
建议更多使用`callfv`而不是`callfh`,因为`callfh`只能从栈上获取参数并整合为`vm_hash`之后才能传给该指令进行处理,拖慢执行速度。
```javascript
var f=func(x,y){return x+y;}
f(1024,2048);
var f = func(x, y) { return x + y; }
f(1024, 2048);
```
```x86asm
@ -475,12 +475,12 @@ func <0x2a3>:
在这个版本中我们给nasal加入了协程:
```javascript
var coroutine={
create: func(function){return __cocreate;},
resume: func(co) {return __coresume;},
yield: func(args...) {return __coyield; },
status: func(co) {return __costatus;},
running:func() {return __corun; }
var coroutine = {
create: func(function) { return __cocreate; },
resume: func(co) { return __coresume; },
yield: func(args...) { return __coyield; },
status: func(co) { return __costatus; },
running: func() { return __corun; }
};
```

View File

@ -67,7 +67,7 @@ __`vec`__ has unlimited length and can store all types of values.
```javascript
var vec = [];
var vec = [0, nil, {}, [], func(){return 0}];
var vec = [0, nil, {}, [], func() { return 0 }];
append(vec, 0, 1, 2);
```
@ -255,7 +255,7 @@ if (1) {
While loop and for loop is simalar to C/C++.
```javascript
while(condition) {
while (condition) {
continue;
}
for (var i = 0; i<10; i += 1) {
@ -327,7 +327,7 @@ var fib = func(f) {
}(
func(f) {
return func(x) {
if(x<2) return x;
if (x<2) return x;
return f(f)(x-1)+f(f)(x-2);
}
}
@ -597,7 +597,7 @@ var fib(var* args, usize size, gc* ngc) {
// if you want your function safer, try this
// nas_err will print the error info on screen
// and return vm_null for runtime to interrupt
if(num.type!=vm_num) {
if (num.type!=vm_num) {
return nas_err("extern_fib", "\"num\" must be number");
}
// ok, you must know that vm_num now is not managed by gc

View File

@ -64,7 +64,7 @@ __`vec`__ 有不受限制的长度并且可以存储所有类型的数据。(当
```javascript
var vec = [];
var vec = [0, nil, {}, [], func(){return 0}];
var vec = [0, nil, {}, [], func() { return 0 }];
append(vec, 0, 1, 2);
```
@ -247,7 +247,7 @@ if (1) {
while循环和for循环大体上与C/C++是一致的。
```javascript
while(condition) {
while (condition) {
continue;
}
for (var i = 0; i<10; i += 1) {
@ -314,7 +314,7 @@ var fib = func(f) {
}(
func(f) {
return func(x) {
if(x<2) return x;
if (x<2) return x;
return f(f)(x-1)+f(f)(x-2);
}
}
@ -579,7 +579,7 @@ var fib(var* args, usize size, gc* ngc) {
var num = args[0];
// 如果你想让这个函数有更强的稳定性,那么一定要进行合法性检查
// nas_err会输出错误信息并返回错误类型让虚拟机终止执行
if(num.type!=vm_num) {
if (num.type!=vm_num) {
return nas_err("extern_fib", "\"num\" must be number");
}
// vm_num作为普通的数字类型不是内存管理的对象所以无需申请

View File

@ -157,7 +157,7 @@ void unary_operator::accept(ast_visitor* visitor) {
}
call_expr::~call_expr() {
if(first) {
if (first) {
delete first;
}
for (auto i : calls) {

View File

@ -291,7 +291,7 @@ void codegen::func_gen(function* node) {
// var f = func(a, arg...) {return(arg)}
auto arg = std::string("arg");
// this is used to avoid confliction with defined parameter
while(local_symbol_find(arg)>=0) {
while (local_symbol_find(arg)>=0) {
arg = "0" + arg;
}
regist_symbol(arg);

View File

@ -95,7 +95,7 @@ void operand_line_counter::dump_this_file_line_counter(std::ostream& os) const {
std::vector<std::string> dbg::parse(const std::string& cmd) {
std::vector<std::string> res;
usize last = 0, pos = cmd.find(" ", 0);
while(pos!=std::string::npos) {
while (pos!=std::string::npos) {
if (pos>last) {
res.push_back(cmd.substr(last, pos-last));
}
@ -202,7 +202,7 @@ void dbg::interact() {
next = false;
std::string cmd;
step_info();
while(true) {
while (true) {
std::clog << ">> ";
std::getline(std::cin, cmd);
auto res = parse(cmd);
@ -279,7 +279,7 @@ void dbg::run(const codegen& gen,
code_line.push_back(i.line);
imm.push_back(i.num);
}
while(operand_function[code[ctx.pc]]) {
while (operand_function[code[ctx.pc]]) {
interact();
counter.add_operand_counter(code[ctx.pc]);
counter.add_code_line_counter(code_file_index[ctx.pc], code_line[ctx.pc]);

View File

@ -150,7 +150,7 @@ void filestream::load(const std::string& f) {
std::exit(1);
}
while(!in.eof()) {
while (!in.eof()) {
std::string line;
std::getline(in, line);
res.push_back(line);

View File

@ -54,7 +54,7 @@ private:
}
std::string leftpad(u64 num, usize len) {
auto tmp = std::to_string(num);
while(tmp.length()<len) {
while (tmp.length()<len) {
tmp = " "+tmp;
}
return tmp;

View File

@ -45,7 +45,7 @@ void gc::mark() {
}
// normal mark
while(!bfs.empty()) {
while (!bfs.empty()) {
var value = bfs.back();
bfs.pop_back();
if (value.type<=vm_type::vm_num ||
@ -66,7 +66,7 @@ void gc::concurrent_mark(std::vector<var>& vec, usize begin, usize end) {
}
mark_var(bfs, value);
}
while(!bfs.empty()) {
while (!bfs.empty()) {
var value = bfs.back();
bfs.pop_back();
if (value.type<=vm_type::vm_num ||

View File

@ -19,7 +19,7 @@ linker::linker(): show_path_flag(false), this_file("") {
const auto seperator = util::is_windows()? ';':':';
const auto PATH = std::string(env_get_path);
usize last = 0, position = PATH.find(seperator, 0);
while(position!=std::string::npos) {
while (position!=std::string::npos) {
std::string dirpath = PATH.substr(last, position-last);
if (dirpath.length()) {
envpath.push_back(dirpath);

View File

@ -59,7 +59,7 @@ bool lexer::is_calc_opr(char c) {
void lexer::skip_note() {
// avoid note, after this process ptr will point to '\n'
// so next loop line counter+1
while(++ptr<res.size() && res[ptr]!='\n') {}
while (++ptr<res.size() && res[ptr]!='\n') {}
}
void lexer::err_char() {
@ -114,7 +114,7 @@ tok lexer::get_type(const std::string& str) {
std::string lexer::utf8_gen() {
std::string str = "";
while(ptr<res.size() && res[ptr]<0) {
while (ptr<res.size() && res[ptr]<0) {
std::string tmp = "";
u32 nbytes = util::utf8_hdchk(res[ptr]);
if (!nbytes) {
@ -154,7 +154,7 @@ token lexer::id_gen() {
u64 begin_line = line;
u64 begin_column = column;
std::string str = "";
while(ptr<res.size() && (is_id(res[ptr]) || is_dec(res[ptr]))) {
while (ptr<res.size() && (is_id(res[ptr]) || is_dec(res[ptr]))) {
if (res[ptr]<0) { // utf-8
str += utf8_gen();
} else { // ascii
@ -177,7 +177,7 @@ token lexer::num_gen() {
if (ptr+1<res.size() && res[ptr]=='0' && res[ptr+1]=='x') {
std::string str = "0x";
ptr += 2;
while(ptr<res.size() && is_hex(res[ptr])) {
while (ptr<res.size() && is_hex(res[ptr])) {
str += res[ptr++];
}
column += str.length();
@ -196,11 +196,11 @@ token lexer::num_gen() {
} else if (ptr+1<res.size() && res[ptr]=='0' && res[ptr+1]=='o') { // generate oct number
std::string str = "0o";
ptr += 2;
while(ptr<res.size() && is_oct(res[ptr])) {
while (ptr<res.size() && is_oct(res[ptr])) {
str += res[ptr++];
}
bool erfmt = false;
while(ptr<res.size() && (is_dec(res[ptr]) || is_hex(res[ptr]))) {
while (ptr<res.size() && (is_dec(res[ptr]) || is_hex(res[ptr]))) {
erfmt = true;
str += res[ptr++];
}
@ -220,12 +220,12 @@ token lexer::num_gen() {
// generate dec number
// dec number -> [0~9][0~9]*(.[0~9]*)(e|E(+|-)0|[1~9][0~9]*)
std::string str = "";
while(ptr<res.size() && is_dec(res[ptr])) {
while (ptr<res.size() && is_dec(res[ptr])) {
str += res[ptr++];
}
if (ptr<res.size() && res[ptr]=='.') {
str += res[ptr++];
while(ptr<res.size() && is_dec(res[ptr])) {
while (ptr<res.size() && is_dec(res[ptr])) {
str += res[ptr++];
}
// "xxxx." is not a correct number
@ -247,7 +247,7 @@ token lexer::num_gen() {
if (ptr<res.size() && (res[ptr]=='-' || res[ptr]=='+')) {
str += res[ptr++];
}
while(ptr<res.size() && is_dec(res[ptr])) {
while (ptr<res.size() && is_dec(res[ptr])) {
str += res[ptr++];
}
// "xxxe(-|+)" is not a correct number
@ -278,7 +278,7 @@ token lexer::str_gen() {
std::string str = "";
const char begin = res[ptr];
++column;
while(++ptr<res.size() && res[ptr]!=begin) {
while (++ptr<res.size() && res[ptr]!=begin) {
++column;
if (res[ptr]=='\n') {
column = 0;
@ -404,8 +404,8 @@ const error& lexer::scan(const std::string& file) {
toks = {};
open(file);
while(ptr<res.size()) {
while(ptr<res.size() && skip(res[ptr])) {
while (ptr<res.size()) {
while (ptr<res.size() && skip(res[ptr])) {
// these characters will be ignored, and '\n' will cause ++line
++column;
if (res[ptr++]=='\n') {

View File

@ -10,7 +10,7 @@ const error& parse::compile(const lexer& lexer) {
root = new code_block(toks[0].loc);
while(!lookahead(tok::tk_eof)) {
while (!lookahead(tok::tk_eof)) {
root->add_expression(expression());
if (lookahead(tok::tk_semi)) {
match(tok::tk_semi);
@ -114,7 +114,7 @@ bool parse::check_comma(const tok* panic_set) {
bool parse::check_tuple() {
u64 check_ptr = ptr, curve = 1, bracket = 0, brace = 0;
while(toks[++check_ptr].type!=tok::tk_eof && curve) {
while (toks[++check_ptr].type!=tok::tk_eof && curve) {
switch(toks[check_ptr].type) {
case tok::tk_lcurve: ++curve; break;
case tok::tk_lbracket: ++bracket; break;
@ -167,7 +167,7 @@ bool parse::check_in_curve_multi_definition() {
bool parse::check_special_call() {
// special call means like this: function_name(a:1, b:2, c:3);
u64 check_ptr = ptr, curve = 1, bracket = 0, brace = 0;
while(toks[++check_ptr].type!=tok::tk_eof && curve) {
while (toks[++check_ptr].type!=tok::tk_eof && curve) {
switch(toks[check_ptr].type) {
case tok::tk_lcurve: ++curve; break;
case tok::tk_lbracket: ++bracket;break;
@ -216,7 +216,7 @@ use_stmt* parse::use_stmt_gen() {
auto node = new use_stmt(toks[ptr].loc);
match(tok::tk_use);
node->add_path(id());
while(lookahead(tok::tk_dot)) {
while (lookahead(tok::tk_dot)) {
match(tok::tk_dot);
node->add_path(id());
}
@ -276,7 +276,7 @@ vector_expr* parse::vec() {
};
auto node = new vector_expr(toks[ptr].loc);
match(tok::tk_lbracket);
while(!lookahead(tok::tk_rbracket)) {
while (!lookahead(tok::tk_rbracket)) {
node->add_element(calc());
if (lookahead(tok::tk_comma)) {
match(tok::tk_comma);
@ -294,7 +294,7 @@ vector_expr* parse::vec() {
hash_expr* parse::hash() {
auto node = new hash_expr(toks[ptr].loc);
match(tok::tk_lbrace);
while(!lookahead(tok::tk_rbrace)) {
while (!lookahead(tok::tk_rbrace)) {
node->add_member(pair());
if (lookahead(tok::tk_comma)) {
match(tok::tk_comma);
@ -342,7 +342,7 @@ function* parse::func() {
void parse::params(function* func_node) {
match(tok::tk_lcurve);
while(!lookahead(tok::tk_rcurve)) {
while (!lookahead(tok::tk_rcurve)) {
auto param = new parameter(toks[ptr].loc);
param->set_parameter_name(toks[ptr].str);
match(tok::tk_id);
@ -428,7 +428,7 @@ code_block* parse::expression_block() {
auto node = new code_block(toks[ptr].loc);
if (lookahead(tok::tk_lbrace)) {
match(tok::tk_lbrace);
while(!lookahead(tok::tk_rbrace) && !lookahead(tok::tk_eof)) {
while (!lookahead(tok::tk_rbrace) && !lookahead(tok::tk_eof)) {
node->add_expression(expression());
if (lookahead(tok::tk_semi)) {
match(tok::tk_semi);
@ -496,7 +496,7 @@ expr* parse::calc() {
expr* parse::bitwise_or() {
auto node = bitwise_xor();
while(lookahead(tok::tk_btor)) {
while (lookahead(tok::tk_btor)) {
auto tmp = new binary_operator(toks[ptr].loc);
tmp->set_operator_type(binary_operator::kind::bitwise_or);
tmp->set_left(node);
@ -511,7 +511,7 @@ expr* parse::bitwise_or() {
expr* parse::bitwise_xor() {
auto node = bitwise_and();
while(lookahead(tok::tk_btxor)) {
while (lookahead(tok::tk_btxor)) {
auto tmp = new binary_operator(toks[ptr].loc);
tmp->set_operator_type(binary_operator::kind::bitwise_xor);
tmp->set_left(node);
@ -526,7 +526,7 @@ expr* parse::bitwise_xor() {
expr* parse::bitwise_and() {
auto node = or_expr();
while(lookahead(tok::tk_btand)) {
while (lookahead(tok::tk_btand)) {
auto tmp = new binary_operator(toks[ptr].loc);
tmp->set_operator_type(binary_operator::kind::bitwise_and);
tmp->set_left(node);
@ -541,7 +541,7 @@ expr* parse::bitwise_and() {
expr* parse::or_expr() {
auto node = and_expr();
while(lookahead(tok::tk_or)) {
while (lookahead(tok::tk_or)) {
auto tmp = new binary_operator(toks[ptr].loc);
tmp->set_operator_type(binary_operator::kind::condition_or);
tmp->set_left(node);
@ -556,7 +556,7 @@ expr* parse::or_expr() {
expr* parse::and_expr() {
auto node = cmp_expr();
while(lookahead(tok::tk_and)) {
while (lookahead(tok::tk_and)) {
auto tmp = new binary_operator(toks[ptr].loc);
tmp->set_operator_type(binary_operator::kind::condition_and);
tmp->set_left(node);
@ -571,7 +571,7 @@ expr* parse::and_expr() {
expr* parse::cmp_expr() {
auto node = null_chain_expr();
while(tok::tk_cmpeq<=toks[ptr].type && toks[ptr].type<=tok::tk_geq) {
while (tok::tk_cmpeq<=toks[ptr].type && toks[ptr].type<=tok::tk_geq) {
auto tmp = new binary_operator(toks[ptr].loc);
switch(toks[ptr].type) {
case tok::tk_cmpeq: tmp->set_operator_type(binary_operator::kind::cmpeq); break;
@ -594,7 +594,7 @@ expr* parse::cmp_expr() {
expr* parse::null_chain_expr() {
auto node = additive_expr();
while(lookahead(tok::tk_quesques)) {
while (lookahead(tok::tk_quesques)) {
auto tmp = new binary_operator(toks[ptr].loc);
tmp->set_operator_type(binary_operator::kind::null_chain);
tmp->set_left(node);
@ -609,7 +609,7 @@ expr* parse::null_chain_expr() {
expr* parse::additive_expr() {
auto node = multive_expr();
while(lookahead(tok::tk_add) ||
while (lookahead(tok::tk_add) ||
lookahead(tok::tk_sub) ||
lookahead(tok::tk_floater)) {
auto tmp = new binary_operator(toks[ptr].loc);
@ -633,7 +633,7 @@ expr* parse::multive_expr() {
expr* node=(lookahead(tok::tk_sub) ||
lookahead(tok::tk_not) ||
lookahead(tok::tk_floater))? unary():scalar();
while(lookahead(tok::tk_mult) || lookahead(tok::tk_div)) {
while (lookahead(tok::tk_mult) || lookahead(tok::tk_div)) {
auto tmp = new binary_operator(toks[ptr].loc);
if (lookahead(tok::tk_mult)) {
tmp->set_operator_type(binary_operator::kind::mult);
@ -718,14 +718,14 @@ expr* parse::scalar() {
return null();
}
// check call and avoid ambiguous syntax:
// var f = func(){}
// var f = func() {}
// (var a, b, c) = (1, 2, 3);
// will be incorrectly recognized like:
// var f = func(){}(var a, b, c)
// var f = func() {}(var a, b, c)
if (is_call(toks[ptr].type) && !check_in_curve_multi_definition()) {
auto call_node = new call_expr(toks[ptr].loc);
call_node->set_first(node);
while(is_call(toks[ptr].type)) {
while (is_call(toks[ptr].type)) {
call_node->add_call(call_scalar());
}
node = call_node;
@ -776,7 +776,7 @@ call_vector* parse::callv() {
};
auto node = new call_vector(toks[ptr].loc);
match(tok::tk_lbracket);
while(!lookahead(tok::tk_rbracket)) {
while (!lookahead(tok::tk_rbracket)) {
node->add_slice(subvec());
if (lookahead(tok::tk_comma)) {
match(tok::tk_comma);
@ -807,7 +807,7 @@ call_function* parse::callf() {
auto node = new call_function(toks[ptr].loc);
bool special_call=check_special_call();
match(tok::tk_lcurve);
while(!lookahead(tok::tk_rcurve)) {
while (!lookahead(tok::tk_rcurve)) {
node->add_argument(special_call?pair():calc());
if (lookahead(tok::tk_comma))
match(tok::tk_comma);
@ -883,7 +883,7 @@ multi_identifier* parse::outcurve_def() {
multi_identifier* parse::multi_id() {
auto node = new multi_identifier(toks[ptr].loc);
while(!lookahead(tok::tk_eof)) {
while (!lookahead(tok::tk_eof)) {
// only identifier is allowed here
node->add_var(id());
if (lookahead(tok::tk_comma)) {
@ -909,7 +909,7 @@ tuple_expr* parse::multi_scalar() {
};
auto node = new tuple_expr(toks[ptr].loc);
match(tok::tk_lcurve);
while(!lookahead(tok::tk_rcurve)) {
while (!lookahead(tok::tk_rcurve)) {
node->add_element(calc());
if (lookahead(tok::tk_comma)) {
match(tok::tk_comma);
@ -1068,7 +1068,7 @@ iter_expr* parse::iter_gen() {
// call expression
auto tmp = new call_expr(id_node->get_location());
tmp->set_first(id_node);
while(is_call(toks[ptr].type)) {
while (is_call(toks[ptr].type)) {
tmp->add_call(call_scalar());
}
node->set_call(tmp);
@ -1090,7 +1090,7 @@ condition_expr* parse::cond() {
node->set_if_statement(ifnode);
// generate elsif
while(lookahead(tok::tk_elsif)) {
while (lookahead(tok::tk_elsif)) {
auto elsifnode = new if_expr(toks[ptr].loc);
match(tok::tk_elsif);
match(tok::tk_lcurve);

View File

@ -709,7 +709,7 @@ void vm::run(const codegen& gen,
code.push_back(operand_function[i.op]);
imm.push_back(i.num);
}
while(code[ctx.pc]) {
while (code[ctx.pc]) {
if (interrupt_ptr && interrupt_ptr->load()) {
throw std::runtime_error("VM execution interrupted by timeout");
}

View File

@ -121,7 +121,7 @@ var builtin_split(context* ctx, gc* ngc) {
usize last = 0;
usize pos = s.find(sep, 0);
while(pos!=std::string::npos) {
while (pos!=std::string::npos) {
if (pos>last) {
vec.push_back(ngc->newstr(s.substr(last, pos-last)));
}
@ -169,7 +169,7 @@ var builtin_split_with_empty_substr(context* ctx, gc* ngc) {
usize last = 0;
usize pos = s.find(sep, 0);
while(pos!=std::string::npos) {
while (pos!=std::string::npos) {
if (pos>=last) {
vec.push_back(ngc->newstr(s.substr(last, pos-last)));
}

View File

@ -27,7 +27,7 @@ std::vector<std::string> possible_dylib_path() {
std::vector<std::string> env_path_vec = {"."};
usize last = 0;
usize pos = env_path.find(sep, 0);
while(pos != std::string::npos) {
while (pos != std::string::npos) {
if (pos > last) {
env_path_vec.push_back(env_path.substr(last, pos - last));
}

View File

@ -158,7 +158,7 @@ var builtin_readln(context* ctx, gc* ngc) {
}
auto result = ngc->alloc(vm_type::vm_str);
char c;
while((c = fgetc(file_descriptor.ghost().get<FILE>()))!=EOF) {
while ((c = fgetc(file_descriptor.ghost().get<FILE>()))!=EOF) {
if (c=='\r') {
continue;
}

View File

@ -165,7 +165,7 @@ std::string json::stringify(var& object) {
}
void json::next() {
while(ptr<text.length() && !check(text[ptr])) {
while (ptr<text.length() && !check(text[ptr])) {
if (text[ptr]=='\n') {
++line;
} else if (text[ptr]!=' ' && text[ptr]!='\t' && text[ptr]!='\r') {
@ -193,7 +193,7 @@ void json::next() {
if (is_num(c) || c=='-' || c=='+') {
auto temp = std::string(1, c);
++ptr;
while(ptr<text.length() && (
while (ptr<text.length() && (
is_num(text[ptr]) ||
text[ptr]=='.' ||
text[ptr]=='e' ||
@ -207,7 +207,7 @@ void json::next() {
} else if (is_id(c)) {
auto temp = std::string(1, c);
++ptr;
while(ptr<text.length() && (is_id(text[ptr]) || is_num(text[ptr]))) {
while (ptr<text.length() && (is_id(text[ptr]) || is_num(text[ptr]))) {
temp += text[ptr];
++ptr;
}
@ -221,7 +221,7 @@ void json::next() {
auto begin = c;
auto temp = std::string("");
++ptr;
while(ptr<text.length() && text[ptr]!=begin) {
while (ptr<text.length() && text[ptr]!=begin) {
temp += text[ptr];
++ptr;
if (text[ptr-1]=='\\' && ptr<text.length()) {
@ -264,7 +264,7 @@ var json::vector_object_generate(gc* ngc) {
temp_stack.vec().elems.push_back(vect_object);
match(json_token_type::tok_lbrkt);
vector_member(vect_object.vec(), ngc);
while(this_token.type==json_token_type::tok_comma) {
while (this_token.type==json_token_type::tok_comma) {
match(json_token_type::tok_comma);
vector_member(vect_object.vec(), ngc);
}
@ -303,7 +303,7 @@ var json::hash_object_generate(gc* ngc) {
temp_stack.vec().elems.push_back(hash_object);
match(json_token_type::tok_lbrace);
hash_member(hash_object.hash(), ngc);
while(this_token.type==json_token_type::tok_comma) {
while (this_token.type==json_token_type::tok_comma) {
match(json_token_type::tok_comma);
hash_member(hash_object.hash(), ngc);
}

View File

@ -43,7 +43,7 @@ void repl::update_temp_file(const std::vector<std::string>& src) {
}
bool repl::check_need_more_input() {
while(true) {
while (true) {
update_temp_file();
auto nasal_lexer = std::make_unique<lexer>();
if (nasal_lexer->scan("<nasal-repl>").geterr()) {
@ -160,7 +160,7 @@ void repl::execute() {
std::cout << " (" << __DATE__ << " " << __TIME__ << ")\n";
help();
while(true) {
while (true) {
auto line = readline();
if (!line.length()) {
continue;

View File

@ -188,7 +188,7 @@ f64 hex_to_f64(const char* str) {
f64 oct_to_f64(const char* str) {
f64 ret = 0;
while('0'<=*str && *str<'8') {
while ('0'<=*str && *str<'8') {
ret = ret*8+(*str++-'0');
}
if (*str) {
@ -206,7 +206,7 @@ f64 oct_to_f64(const char* str) {
f64 dec_to_f64(const char* str) {
f64 ret = 0, num_pow = 0;
bool negative = false;
while('0'<=*str && *str<='9') {
while ('0'<=*str && *str<='9') {
ret = ret*10+(*str++-'0');
}
if (!*str) {
@ -217,7 +217,7 @@ f64 dec_to_f64(const char* str) {
return nan("");
}
num_pow = 0.1;
while('0'<=*str && *str<='9') {
while ('0'<=*str && *str<='9') {
ret += num_pow*(*str++-'0');
num_pow *= 0.1;
}
@ -238,7 +238,7 @@ f64 dec_to_f64(const char* str) {
return nan("");
}
num_pow = 0;
while('0'<=*str && *str<='9') {
while ('0'<=*str && *str<='9') {
num_pow = num_pow*10+(*str++-'0');
}
if (*str) {

View File

@ -63,7 +63,7 @@ var add_event = func(name,interval,function) {
fg_globals.event[name]=coroutine.create(func {
var timestamp=maketimestamp();
timestamp.stamp();
while(timestamp.elapsedMSec()<interval*1000)
while (timestamp.elapsedMSec()<interval*1000)
coroutine.yield();
println("[\e[32m",name,"\e[0m] [",os.time(),"] type:\e[33mevent\e[0m interval:\e[34m",interval,"\e[0m");
function();
@ -75,10 +75,10 @@ var add_task = func(name,interval,function) {
fg_globals.task[name]=coroutine.create(func {
var counter=0;
var timestamp=maketimestamp();
while(1) {
while (1) {
counter+=1;
timestamp.stamp();
while(timestamp.elapsedMSec()<interval*1000)
while (timestamp.elapsedMSec()<interval*1000)
coroutine.yield();
println("[\e[32m",name,"\e[0m] [",os.time(),"] type:\e[34mtask\e[0m interval:\e[34m",interval,"\e[0m invoke-time:\e[96m",counter,"\e[0m");
function();
@ -145,7 +145,7 @@ var settimer = func() {
println("[\e[32m maketimer \e[0m] [",os.time(),"] test func simulation()");
var simulation = func() {
var running=1;
while(running) {
while (running) {
running=0;
foreach(var i;keys(fg_globals.task)) {
if (!contains(fg_globals.task,i))
@ -542,7 +542,7 @@ func() {
srand();
var tmp=nil;
var vec=[props.globals];
while(size(vec)) {
while (size(vec)) {
tmp=[];
foreach(var i;vec) {
if (typeof(i.val)=="hash") {

View File

@ -53,7 +53,7 @@ var find_all_files = func(path) {
}
var dd = unix.opendir(path);
var res = [];
while(var n = unix.readdir(dd)) {
while (var n = unix.readdir(dd)) {
if (unix.isfile(path ~ "/" ~ n)) {
append(res, n);
}
@ -71,7 +71,7 @@ var recursive_find_files = func(path) {
dir: path,
files: []
};
while(var n = unix.readdir(dd)) {
while (var n = unix.readdir(dd)) {
if (unix.isfile(path ~ "/" ~ n)) {
append(res.files, n);
} elsif (unix.isdir(path ~ "/" ~ n) and n != "." and n != "..") {
@ -92,7 +92,7 @@ var recursive_find_files_flat = func(path) {
}
var flat = [];
var bfs = [tree_files];
while(size(bfs) != 0) {
while (size(bfs) != 0) {
var first = pop(bfs);
foreach(var file_record; first.files) {
if (ishash(file_record)) {

View File

@ -231,12 +231,12 @@ var sort = func() {
var base = left+int(rand()*(right-left));
(vec[left], vec[base]) = (vec[base], vec[left]);
var (i, j, tmp) = (left, right, vec[left]);
while(i<j) {
while(i<j and cmp(tmp,vec[j])) {
while (i<j) {
while (i<j and cmp(tmp,vec[j])) {
j -= 1;
}
vec[i] = vec[j];
while(i<j and cmp(vec[i],tmp)) {
while (i<j and cmp(vec[i],tmp)) {
i += 1;
}
vec[j] = vec[i];

View File

@ -220,7 +220,7 @@ var bp_example = func() {
var epoch=0;
var total=1e6;
while(total>0.001) {
while (total>0.001) {
epoch+=1;
if (epoch>1e4) {
println("Training failed after ",epoch," epoch.");

View File

@ -37,7 +37,7 @@ var _connect = func(hostname, port) {
socket.IPPROTO_TCP
);
var ip_info = hostname~":"~port;
while((var err = socket.connect(sd, hostname, port))==socket.SOCKET_ERROR) {
while ((var err = socket.connect(sd, hostname, port))==socket.SOCKET_ERROR) {
println(_get_time(), " failed to connect ", ip_info, ": ", socket.errno());
unix.sleep(1);
}
@ -67,7 +67,7 @@ var new = func(hostname, port) {
# get total message
var total_source = message.str;
# 0\r\n\r\n is the tail of chunked http info
while(find("0\r\n\r\n", total_source)<0) {
while (find("0\r\n\r\n", total_source)<0) {
message = socket.recv(sd, 1024);
total_source ~= message.str;
}

View File

@ -112,11 +112,11 @@ var spinner = func() {
for (var i=0;i<len;i+=1) {
tmp=pop(vec)~tmp;
append(res,tmp);
while(size(res[-1])!=16)
while (size(res[-1])!=16)
res[-1]~=" ";
}
tmp=res[-1];
while(tmp!=" ") {
while (tmp!=" ") {
tmp=" "~substr(tmp,0,15);
append(res,tmp);
}

View File

@ -5,7 +5,7 @@ use std.unix;
var udp_server = func(hostname, port, retry_delay = 5) {
var socket = libnasock.socket;
var server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM);
while(socket.bind(server, hostname, port) < 0) {
while (socket.bind(server, hostname, port) < 0) {
println("[", os.time(), "] failed to bind socket "~server~" at ", hostname, ":", port, ".");
unix.sleep(retry_delay);
println("[", os.time(), "] retrying...");
@ -29,7 +29,7 @@ var udp_client = func(hostname = "", port = -1, retry_delay = 5) {
var socket = libnasock.socket;
var client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM);
if (port > 0 and size(hostname) != 0) {
while(socket.bind(client, hostname, port)<0) {
while (socket.bind(client, hostname, port)<0) {
println("[",os.time(),"] failed to bind socket "~client~" at ", hostname, ":", port, ".");
unix.sleep(retry_delay);
println("[",os.time(),"] retrying...");

View File

@ -209,7 +209,7 @@ var bf = func(program) {
f~="print(chr(paper[ptr]));\n";
} elsif (c=='[') {
f~=padding(size(stack));
f~="while(paper[ptr]) {\n";
f~="while (paper[ptr]) {\n";
append(stack,0);
} elsif (c==']') {
if (!size(stack)) {

View File

@ -32,7 +32,7 @@ var bfs = func(begin,end) {
map[end[0]][end[1]]=0;
if (map[1][0]==1 and map[0][1]==1)
map[1][0]=0;
while(!que.empty()) {
while (!que.empty()) {
var vertex=que.front();
que.pop();
foreach(var i;move) {

View File

@ -107,7 +107,7 @@ var backward = func(x) {
}
var (cnt,error)=(0,100);
while(error>0.0005) {
while (error>0.0005) {
error=0;
for (var i=0;i<4;i+=1) {
forward(i);

View File

@ -15,7 +15,7 @@ var fib = func() {
var (a, b) = (1, 1);
coroutine.yield(a);
coroutine.yield(b);
while(1) {
while (1) {
(a, b) = (b, a + b);
coroutine.yield(b);
}
@ -95,7 +95,7 @@ println("[2] ok\n");
# pressure test
for (var t = 0; t < 10; t += 1) {
var productor = func() {
while(1) {
while (1) {
coroutine.yield(i);
}
}

View File

@ -83,7 +83,7 @@ var select = func(n) {
var left=0;
var right=size(message)-1;
var data=c[2];
while(left<=right) {
while (left<=right) {
var mid=int((left+right)/2);
var res=message[mid][0];
if (data==res) {

View File

@ -42,7 +42,7 @@ var myers = func(src,dst,show_table=0) {
var (total,path,vec)=([],[],[[0,0,-1]]);
visited[0]=1;
while(size(vec)) {
while (size(vec)) {
append(total,vec);
var tmp=[];
forindex(var i;vec) {

View File

@ -7,7 +7,7 @@ var files = func(path) {
return [];
var dd=unix.opendir(path);
var res=[];
while(var n=unix.readdir(dd))
while (var n=unix.readdir(dd))
append(res,n);
unix.closedir(dd);
return res;

View File

@ -10,7 +10,7 @@ var chars = "abcdefghijklmnopqrstuvwxyz" ~
chars = split("", chars);
print("\ec");
while(1) {
while (1) {
var key = libkey.nonblock();
if (key!=nil and chr(key)=="q") {
break;

View File

@ -1,7 +1,7 @@
use std.unix;
var count = 0;
while(1) {
while (1) {
unix.sleep(0.1);
count += 0.1;
println("process running time: ", count);

View File

@ -10,7 +10,7 @@ var http = func() {
return {
establish:func(ip,port) {
sd=socket.socket(socket.AF_INET,socket.SOCK_STREAM,socket.IPPROTO_IP);
while(socket.bind(sd,ip,port)<0) {
while (socket.bind(sd,ip,port)<0) {
println("[",os.time(),"] failed to bind socket "~sd~" at IP: "~ip~" port: "~port~".");
unix.sleep(5);
println("[",os.time(),"] retrying...");
@ -98,7 +98,7 @@ var html_read_file = func(filename) {
s=char(file_text[index]);
}
while(1) {
while (1) {
if (next()>=len)
break;
if (s==">")
@ -111,7 +111,7 @@ var html_read_file = func(filename) {
content~="<code class=\"opr\">"~s~"</code>";
elsif (s=="_" or ("a"[0]<=s[0] and s[0]<="z"[0]) or ("A"[0]<=s[0] and s[0]<="Z"[0]) or s[0]<0 or s[0]>=128) {
var tmp=""~s; # generate a new string
while(1) {
while (1) {
if (next()>=len)
break;
if (s=="_" or ("a"[0]<=s[0] and s[0]<="z"[0]) or ("A"[0]<=s[0] and s[0]<="Z"[0]) or ("0"[0]<=s[0] and s[0]<="9"[0]) or s[0]<0 or s[0]>=128)
@ -138,7 +138,7 @@ var html_read_file = func(filename) {
}
if (s=="o") {
content~="o";
while(1) {
while (1) {
if (next()>=len)
break;
if ("0"[0]<=s[0] and s[0]<="7"[0])
@ -150,7 +150,7 @@ var html_read_file = func(filename) {
prev();
} elsif (s=="x") {
content~="x";
while(1) {
while (1) {
if (next()>=len)
break;
if (("0"[0]<=s[0] and s[0]<="9"[0]) or ("a"[0]<=s[0] and s[0]<='f') or ("A"[0]<=s[0] or s[0]<="F"))
@ -161,7 +161,7 @@ var html_read_file = func(filename) {
content~="</code>";
prev();
} elsif (("0"[0]<=s[0] and s[0]<="9"[0]) or s=="." or s=="e") {
while("0"[0]<=s[0] and s[0]<="9"[0]) {
while ("0"[0]<=s[0] and s[0]<="9"[0]) {
content~=s;
if (next()>=len)
break;
@ -171,7 +171,7 @@ var html_read_file = func(filename) {
if (next()>=len)
break;
}
while("0"[0]<=s[0] and s[0]<="9"[0]) {
while ("0"[0]<=s[0] and s[0]<="9"[0]) {
content~=s;
if (next()>=len)
break;
@ -186,7 +186,7 @@ var html_read_file = func(filename) {
break;
}
}
while("0"[0]<=s[0] and s[0]<="9"[0]) {
while ("0"[0]<=s[0] and s[0]<="9"[0]) {
content~=s;
if (next()>=len)
break;
@ -200,7 +200,7 @@ var html_read_file = func(filename) {
} elsif (s=="\"" or s=="'" or s=="`") {
var quot=s~""; # generate a new string
content~="<code class=\"str\">"~s;
while(1) {
while (1) {
if (next()>=len)
break;
if (s==quot) {
@ -221,7 +221,7 @@ var html_read_file = func(filename) {
}
} elsif (s=="#") {
content~="<code class=\"note\">"~s;
while(1) {
while (1) {
if (next()>=len)
break;
if (s=="\n" or s=="\r") {
@ -282,12 +282,12 @@ var respond={
var files = func() {
var res={};
var dd=unix.opendir("./test");
while((var name=unix.readdir(dd))!=nil)
while ((var name=unix.readdir(dd))!=nil)
res[name]=1;
return res;
}();
while(1) {
while (1) {
var client=http.accept();
var data=http.recv(client);
if (data==nil) {

View File

@ -25,7 +25,7 @@ var jsonRPC = func() {
},
connect:func(ip,port) {
sd=socket.socket(socket.AF_INET,socket.SOCK_STREAM,socket.IPPROTO_IP);
while(socket.connect(sd,ip,port)<0) {
while (socket.connect(sd,ip,port)<0) {
println("[",gettime(),"] failed to connect socket ",sd," to ",ip,":",port);
unix.sleep(5);
}
@ -75,9 +75,9 @@ var server = func(ip,port) {
};
jsonRPC.establish(ip,port);
while(1) {
while (1) {
var client=jsonRPC.accept();
while(1) {
while (1) {
var data=jsonRPC.recv(client);
if (data!=nil) {
data=json.parse(data);
@ -112,7 +112,7 @@ var client = func(ip,port) {
var params=[["a","b"],["1","2"]];
var server=jsonRPC.connect(ip,port);
while(1) {
while (1) {
unix.sleep(5);
var data=json.stringify({jsonrpc:2.0, id:call_id, method:methods[rand()*size(methods)],params:params[rand()*size(params)]});
jsonRPC.send(server, data);

View File

@ -91,7 +91,7 @@ var move = func {
map = temp_map;
}
while(1) {
while (1) {
print_map();
move();
unix.sleep(1/24);

View File

@ -3,7 +3,7 @@ var n=4;
var input=[[0,1],[0,2],[1,2]];
var find_root = func(x,parent) {
while(parent[x]!=nil)
while (parent[x]!=nil)
x=parent[x];
return x;
}

View File

@ -13,7 +13,7 @@ var lexer = func(file) {
}
return {
jmp_note:func() {
while(ptr<len and s[ptr]!='\n'[0])
while (ptr<len and s[ptr]!='\n'[0])
ptr+=1;
if (ptr<len and s[ptr]=='\n'[0])
line+=1;
@ -21,7 +21,7 @@ var lexer = func(file) {
},
id_gen:func() {
var tmp="";
while(ptr<len) {
while (ptr<len) {
var c=s[ptr];
if (('a'[0]<=c and c<='z'[0])
or ('A'[0]<=c and c<='Z'[0])
@ -38,7 +38,7 @@ var lexer = func(file) {
var str="";
var mark=chr(s[ptr]);
ptr+=1;
while(ptr<len and chr(s[ptr])!=mark) {
while (ptr<len and chr(s[ptr])!=mark) {
if (chr(s[ptr])=='\\') {
ptr+=1;
var c=chr(s[ptr]);
@ -73,7 +73,7 @@ var lexer = func(file) {
ptr+=1;
if (ptr<len and chr(s[ptr])=='x') {
ptr+=1;
while(ptr<len and
while (ptr<len and
('a'[0]<=s[ptr] and s[ptr]<='f'[0]
or '0'[0]<=s[ptr] and s[ptr]<='9'[0])) {
number~=chr(s[ptr]);
@ -83,21 +83,21 @@ var lexer = func(file) {
return;
} elsif (ptr<len and chr(s[ptr])=='o') {
ptr+=1;
while(ptr<len and ('0'[0]<=s[ptr] and s[ptr]<='7'[0])) {
while (ptr<len and ('0'[0]<=s[ptr] and s[ptr]<='7'[0])) {
number~=chr(s[ptr]);
ptr+=1;
}
gen(num(number));
return;
}
while(ptr<len and ('0'[0]<=s[ptr] and s[ptr]<='9'[0])) {
while (ptr<len and ('0'[0]<=s[ptr] and s[ptr]<='9'[0])) {
number~=chr(s[ptr]);
ptr+=1;
}
if (ptr<len and chr(s[ptr])=='.') {
number~=chr(s[ptr]);
ptr+=1;
while(ptr<len and ('0'[0]<=s[ptr] and s[ptr]<='9'[0])) {
while (ptr<len and ('0'[0]<=s[ptr] and s[ptr]<='9'[0])) {
number~=chr(s[ptr]);
ptr+=1;
}
@ -109,7 +109,7 @@ var lexer = func(file) {
number~=chr(s[ptr]);
ptr+=1;
}
while(ptr<len and ('0'[0]<=s[ptr] and s[ptr]<='9'[0])) {
while (ptr<len and ('0'[0]<=s[ptr] and s[ptr]<='9'[0])) {
number~=chr(s[ptr]);
ptr+=1;
}
@ -148,7 +148,7 @@ var lexer = func(file) {
},
compile:func() {
line=1;
while(ptr<len) {
while (ptr<len) {
var c=s[ptr];
if (c=='#'[0])
me.jmp_note();

View File

@ -8,9 +8,9 @@ for (var i=1;;i+=1)break;
for (var i=1;i<10;i+=1)
print(i," ");
print("\n");
while(1)break;
while (1)break;
var j=0;
while(j<10) {
while (j<10) {
print(j," ");
j+=1;
}

View File

@ -91,7 +91,7 @@ var ctx_info = func() {
}
var exec = func(info=1) {
println("[",os.time(),"] executing ...");
while(1) {
while (1) {
ir=[mem[pc],mem[pc+1],mem[pc+2],mem[pc+3]];
if (info)ctx_info();
var op=ir[0];

View File

@ -34,7 +34,7 @@ var cpu_stat = func() {
var cpu_occupation = func() {
var first_in = 1;
while(1) {
while (1) {
var cpu0 = cpu_stat();
if (first_in) {
unix.sleep(0.05);
@ -75,7 +75,7 @@ var random_generator = func() {
var total = 0;
var statistics = [];
setsize(statistics, 70);
while(1) {
while (1) {
for (var i=0;i<10;i+=1) {
total+=1;
var u=rand()*rand()*(rand()>0.5?-1:1);
@ -127,7 +127,7 @@ func() {
var bar=process_bar.high_resolution_bar(48);
print("\ec");
while(limited_loop!=0) {
while (limited_loop!=0) {
limited_loop=limited_loop<0?limited_loop:limited_loop-1;
var mem=mem_occupation();
var mem_occ=(mem.MemTotal-mem.MemFree)/mem.MemTotal*100;
@ -135,7 +135,7 @@ func() {
mem_occ=0;
}
var cpu_occ=nil;
while((cpu_occ=coroutine.resume(co)[0])==nil) {
while ((cpu_occ=coroutine.resume(co)[0])==nil) {
var key=libkey.nonblock();
coroutine.resume(rd);
if (key!=nil and chr(key)=="q")

View File

@ -6,11 +6,11 @@ var var_sort = func() {
var base=left+int(rand()*(right-left));
(vec[left],vec[base])=(vec[base],vec[left]);
var (i,j,tmp)=(left,right,vec[left]);
while(i<j) {
while(i<j and tmp<vec[j])
while (i<j) {
while (i<j and tmp<vec[j])
j-=1;
vec[i]=vec[j];
while(i<j and vec[i]<tmp)
while (i<j and vec[i]<tmp)
i+=1;
vec[j]=vec[i];
j-=1;

View File

@ -125,14 +125,14 @@ if (a and a.field == 42) {
#
# Looping constructs are mostly C-like. The differences are that
# there is no do{}while(); construct, and there is a foreach, which
# there is no do {} while (); construct, and there is a foreach, which
# takes a local variable name as its first argument and a vector as
# its second.
#
var doSomething = dummyFunc;
var stillGoing = 0;
while(stillGoing) { doSomething(); }
while (stillGoing) { doSomething(); }
for (var i=0; i < 3; i = i+1) {
elem = list1[i];

View File

@ -35,7 +35,7 @@ var game = func(x,y) {
var gameover=0;
var setapple = func() {
var (cord_x,cord_y)=(int(rand()*x),int(rand()*y));
while(vec[cord_x][cord_y]!=0)
while (vec[cord_x][cord_y]!=0)
(cord_x,cord_y)=(int(rand()*x),int(rand()*y));
vec[cord_x][cord_y]=2;
}
@ -112,7 +112,7 @@ var game = func(x,y) {
}
var co=coroutine.create(func() {
while(1) {
while (1) {
var moved=-1;
for (var i=0;i<30;i+=1) {
var ch=libkey.nonblock();
@ -140,8 +140,8 @@ var main = func(argv) {
}
print("\r \r");
var counter=20;
while(1) {
while((var ch=coroutine.resume(co)[0])==nil);
while (1) {
while ((var ch=coroutine.resume(co)[0])==nil);
if (ch!=nil and ch!=-1) {
if (ch=='q'[0]) {
break;
@ -165,7 +165,7 @@ var main = func(argv) {
if (should_skip) {
return;
}
while(libkey.getch()!='q'[0]);
while (libkey.getch()!='q'[0]);
}
main(runtime.argv());

View File

@ -304,7 +304,7 @@ var main = func(argv) {
map.print();
var counter=init_counter;
while(1) {
while (1) {
# nonblock input one character
var ch=libkey.nonblock();
if (ch) {
@ -350,7 +350,7 @@ var main = func(argv) {
"\e[35mt\e[36mo \e[94mq\e[95mu\e[91mi\e[92mt\e[0m\n"
);
if (!should_skip) {
while(libkey.getch()!='q'[0]);
while (libkey.getch()!='q'[0]);
}
};

View File

@ -68,7 +68,7 @@ var run = func(table,start,stop) {
var (state,pointer)=(start,0);
prt(state,pointer,paper);
while(state!=stop) {
while (state!=stop) {
if (!contains(machine.states,state))
die("no matching function for state:"~state);
var found=0;

View File

@ -4,13 +4,13 @@ use std.unix;
var argument = arg[0];
if (argument=="server") {
var server = udp.udp_server("127.0.0.1", 5506);
while(1) {
while (1) {
var message = server.recvfrom();
server.sendto(message.fromip, message.port, "from server");
}
} elsif (argument=="client") {
var client = udp.udp_client();
while(1) {
while (1) {
client.sendto("127.0.0.1", 5506, "hello");
var message = client.recvfrom();
println(message);

View File

@ -53,7 +53,7 @@ if (size(argv)==2) {
var modified_time = io.fstat(filename).st_mtime;
println(os_time(), info_hd(), "watching ", filename, " ..");
while(1) {
while (1) {
unix.sleep(1);
if (!io.exists(filename)) {
println(os_time(), err_hd(), "file <", filename, "> does not exist");
@ -75,7 +75,7 @@ while(1) {
# check if active every 0.5s
var exited = false;
while(1) {
while (1) {
unix.sleep(0.5);
if (!subprocess.active(subproc)) {
exited = true;

View File

@ -21,7 +21,7 @@ if (size(arg)<1) {
var content = io.readfile(arg[0], "r");
var tail_len = 0;
while(math.mod(size(content), 256*3)!=0) {
while (math.mod(size(content), 256*3)!=0) {
content ~= "A";
tail_len += 1;
}

View File

@ -3,7 +3,7 @@ use std.unix;
println("[", os.time(), "] (=.=) auto push, please wait...");
while(system("git push")!=0) {
while (system("git push")!=0) {
println("[", os.time(), "] (ToT) failed to push, retrying...");
unix.sleep(0.5);
}