Exemple #1
0
        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);
        }
        public bool TryInterpret(CodeInterpreter compiler, CodeReader reader, out IProcess process)
        {
            var backup = reader.Backup();

            process = null;

            if (reader.ReadName(out var name) && reader.ReadChar(out var bracketBegin) && bracketBegin == '(')
            {
                var parameters = new List <IProcess>();

Loop:

                if (reader.CurrentChar(out var bracketEnd) && bracketEnd == ')')
                {
                    reader.Next();

                    process = new InvokeFunctionProcess(name, parameters.ToArray());

                    return(true);
                }