/// <summary> /// /// </summary> /// <param name="various"></param> /// <returns></returns> public ISExp Execute(ISExp exp) { float result = 0; LinkedSExp localExp = exp as LinkedSExp; if (localExp == null) { return(null); } LinkedSExp p = localExp; while (true) { if (p.cdr() == null) { break; } ISExp s = p.car(); if (s is Atom) { if ((s as Atom).Type == TokenType.INTEGER) { result += Int32.Parse((s as Atom).Name); } else if ((s as Atom).Type == TokenType.FLOAT) { result += float.Parse((s as Atom).Name); } } else { return(null);// fail to execute; } p = (LinkedSExp)p.cdr(); } //foreach (ISExp s in various) //{ // if (s is Atom) // { // if ((s as Atom).Type == TokenType.INTEGER) // { // result += Int32.Parse((s as Atom).Name); // } // else if ((s as Atom).Type == TokenType.FLOAT) // { // result += float.Parse((s as Atom).Name); // } // } // else // { // return null;// fail to execute; // } //} return(new Atom(result.ToString(), TokenType.INTEGER)); }
public LinkedSExp(ISExp first, ISExp next) { this.first = first; this.next = next; }
public ISExp Execute(ISExp exp) { return(null); }