public bool TryInterpret(CodeInterpreter compiler, CodeReader reader, out IProcess process) { var backup = reader.Backup(); if (reader.ReadChar(out var bracketBegin) && bracketBegin == '(') { process = compiler.Interpret(reader, Priorities.None); if (reader.ReadChar(out var bracketEnd) && bracketEnd == ')') { return(true); } } process = null; backup.Restore(); return(false); }
public bool TryInterpret(CodeInterpreter compiler, CodeReader reader, out IProcess process) { var backup = reader.Backup(); process = null; if (reader.ReadName(out var _var) && _var == "var") { Loop: if (reader.ReadName(out var name)) { IProcess initValue = null; if (reader.CurrentChar(out var c) && c == '=') { reader.Next(); initValue = compiler.Interpret(reader, Priorities.AssignValueOperator); } if (reader.CurrentChar(out var c1) && c1 == ',') { reader.Next(); process = new VarProcess(name, initValue, process); goto Loop; } process = new VarProcess(name, initValue, process); return(true); } } backup.Restore(); return(false); }