mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-04 22:59:42 +02:00
Fixed some bugs, began adding a Script class
This commit is contained in:
@@ -51,7 +51,7 @@ function evaluate(exp, env) {
|
||||
cond = evaluate(exp.cond, env);
|
||||
}
|
||||
|
||||
//TODO Return somethin?
|
||||
//TODO I don't think I need to return anything..but I might be wrong
|
||||
break;
|
||||
case "while":
|
||||
cond = evaluate(exp.cond, env);
|
||||
@@ -61,7 +61,7 @@ function evaluate(exp, env) {
|
||||
cond = evaluate(exp.cond, env);
|
||||
}
|
||||
|
||||
//TODO DO i need to return anything?
|
||||
//TODO I don't think I need to return anything..but I might be wrong
|
||||
break;
|
||||
case "prog":
|
||||
var val = false;
|
||||
@@ -85,7 +85,7 @@ function evaluate(exp, env) {
|
||||
} else if (exp.func.value == "sleep") {
|
||||
console.log("Execute sleep()");
|
||||
} else if (exp.func.value == "print") {
|
||||
console.log(evaluate(exp.args[0], env));
|
||||
post(evaluate(exp.args[0], env).toString());
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -104,8 +104,12 @@ function Tokenizer(input) {
|
||||
return str;
|
||||
}
|
||||
|
||||
function read_string() {
|
||||
return { type: "str", value: read_escaped('"') };
|
||||
function read_string(ch) {
|
||||
if (ch == '"') {
|
||||
return { type: "str", value: read_escaped('"') };
|
||||
} else if (ch == '\'') {
|
||||
return { type: "str", value: read_escaped('\'') };
|
||||
}
|
||||
}
|
||||
|
||||
//Only supports single-line comments right now
|
||||
@@ -130,7 +134,7 @@ function Tokenizer(input) {
|
||||
return read_next();
|
||||
}
|
||||
|
||||
if (ch == '"') return read_string();
|
||||
if (ch == '"' || ch == '\'') return read_string(ch);
|
||||
if (is_digit(ch)) return read_number();
|
||||
if (is_id_start(ch)) return read_ident();
|
||||
if (is_punc(ch)) return {
|
||||
|
||||
Reference in New Issue
Block a user