public bool Parse(Variable v) { var c = new Code(); c.PushCode(new PushVariable("arg")); c.PushCode(new Argument()); while (t.checkNext() != "") ParseStatement(v, c); v.setCode(c); return error != 0; }
public Variable GetVariable(string s) { var v = scope.GetVariable(s); if (v != null) return v; if (global.Exist(s)) return global[s]; v = new Variable(); scope.AddLocal(s, v); return v; }
public bool LoadString(string str) { var t = new Tokenizer(str); var p = new Parser(t); var v = new Variable(); if (p.Parse(v)) return true; v.prepare(env); v["print"] = new Variable(print); env.Set(v); return false; }
public override vBase substitution(Variable v) { x = v.toString(); return this; }
public override bool eq(Variable v) { return x == v.toString(); }
public override void setchild(string s, Variable v) { if (!table.ContainsKey(s)) table.Add(s, v); else table[s] = v; }
public override void xor(Variable v) { x ^= v.toInt(); }
public override void or(Variable v) { x |= v.toInt(); }
public override Variable call(Environment env, Variable arg) { return x(arg); }
public virtual void xor(Variable v) { }
public virtual vBase substitution(Variable v) { return v.x.clone(); }
public virtual void sub(Variable v) { }
public virtual void shr(Variable v) { }
public virtual void setchild(string s, Variable v) { substitution(v); }
public virtual bool ne(Variable v) { return false; }
public override void mul(Variable v) { x *= v.toInt(); }
public override bool ne(Variable v) { return x != v.toInt(); }
public override void add(Variable v) { x += v.toInt(); }
public override void sub(Variable v) { x -= v.toInt(); }
public override void and(Variable v) { x &= v.toInt(); }
public override Variable call(Environment env, Variable arg) { if (code == null) return arg; env.AddScope(new FunctionScope(code)); env.Push(arg); env.Run(); return env.Pop(); }
public override void div(Variable v) { x /= v.toInt(); }
public override void add(Variable v) { x += v.toString(); }
public override bool eq(Variable v) { return x == v.toInt(); }
public override bool ne(Variable v) { return x != v.toString(); }
public override bool gt(Variable v) { return x > v.toInt(); }
public static Variable print(Variable v) { Console.WriteLine(v.toString()); return v; }
public override bool lt(Variable v) { return x < v.toInt(); }
public Variable Run(Variable v) { env.Push(v); env.Run(); return env.Pop(); }
public override void mod(Variable v) { x %= v.toInt(); }