public void SetVars(ArgumentsFact argsList) { for (int i = 0; i < argsList.args.Count; i++) { variables[i].Value = argsList.args[i].GetValue(this.parent); } }
public static FuncCall TryParse(Expression expr, ref Source s) //TODO: funccall(Expr e, Expr[] args) { FuncCall res = null; Source tempSource = s.Clone(); ArgumentsFact tempArgs = ArgumentsFact.TryParse(ref tempSource); if (tempArgs == null) { //s.Rollback(); return(null); } s.currentPos = tempSource.currentPos; s.Save(); res = new FuncCall(expr); res.argsList = tempArgs; return(res); }
public static ArgumentsFact TryParse(ref Source s) { ArgumentsFact res = new ArgumentsFact(); Spaces.Skip(ref s); if (!s.SkipIf("(")) { return(null); } while (true) { Spaces.Skip(ref s); if (s.SkipIf(")")) { break; } Source tempSource = s.Clone(); Expression expr = new Expression(ref tempSource); if (!expr.Correct()) { throw new lolException(); } s.currentPos = tempSource.currentPos; s.Save(); res.AddArg(expr); Spaces.Skip(ref s); if (s.SkipIf(",")) { continue; } if (s.SkipIf(")")) { break; } } //s.Rollback(); return(res); }
public static Value TryParse(ref Source s) { Value res = null; Null tempNull = Null.TryParse(ref s); if (tempNull != null) { res = tempNull; } Number tempNum = Number.TryParse(ref s); if (tempNum != null) { res = tempNum; } Bool tempBool = Bool.TryParse(ref s); if (tempBool != null) { res = tempBool; } FuncValue tempFunc = FuncValue.TryParse(ref s); if (tempFunc != null) { res = tempFunc; } Variable tempVar = Variable.TryParse(ref s); if (tempVar != null) { res = tempVar; } if (res != null) { res.argsList = ArgumentsFact.TryParse(ref s); //if (res.args != null && res.nodeType != ExprNodeType.Function) // return null; } return(res); }