public static async Task <Variable> GetVariableAsync(string varName, ParsingScript script, bool testNull = true) { ParserFunction func = ParserFunction.GetFunction(varName, script); if (!testNull && func == null) { return(null); } Utils.CheckNotNull(varName, func, script); Variable varValue = await func.GetValueAsync(script); Utils.CheckNotNull(varValue, varName, script); return(varValue); }
public static async Task <Variable> GetVar(string paramName, ParsingScript script) { if (script == null) { script = new ParsingScript(""); } ParserFunction function = ParserFunction.GetVariable(paramName, script); if (function == null) { throw new ArgumentException("Variable [" + paramName + "] not found."); } Variable result = await function.GetValueAsync(script); return(result); }
static async Task <List <Variable> > SplitAsync(ParsingScript script, char[] to) { List <Variable> listToMerge = new List <Variable>(16); if (!script.StillValid() || to.Contains(script.Current)) { listToMerge.Add(Variable.EmptyInstance); script.Forward(); return(listToMerge); } int arrayIndexDepth = 0; bool inQuotes = false; int negated = 0; char ch; string action; do { // Main processing cycle of the first part. string token = ExtractNextToken(script, to, ref inQuotes, ref arrayIndexDepth, ref negated, out ch, out action); bool ternary = await UpdateIfTernaryAsync(script, token, ch, listToMerge, (List <Variable> newList) => { listToMerge = newList; }); if (ternary) { return(listToMerge); } bool negSign = CheckConsistencyAndSign(script, listToMerge, action, ref token); ParserFunction func = new ParserFunction(script, token, ch, ref action); Variable current = await func.GetValueAsync(script); if (UpdateResult(script, to, listToMerge, token, negSign, ref current, ref negated, ref action)) { return(listToMerge); } } while (script.StillValid() && (inQuotes || arrayIndexDepth > 0 || !to.Contains(script.Current))); // This happens when called recursively inside of the math expression: script.MoveForwardIf(Constants.END_ARG); return(listToMerge); }