コード例 #1
0
        private void InterpretLine(string line, int lineCount)
        {
            if (lineCount == 0)
            {
                if (line != "#BasicScriptFile")
                {
                    throw new InvalidDataException("First line is not '#BasicScriptFile' or is not a BasicScriptFile!");
                }
                lineCount++;
                return;
            }

            if (line == "\n")
            {
                lineCount++;
                return;
            }

            if (line.StartsWith("#"))
            {
                if (line.StartsWith("#metadata"))
                {
                    ParseMetadata(line, lineCount);
                    lineCount++;
                    return;
                }
                else
                { /*Comment, ignore*/
                }
            }

            if (line.StartsWith("declare"))
            {
                ParseDeclareVariable(line, lineCount);
                lineCount++;
                return;
            }

            if (StartsWithVariable(line)) //useful for checking for variable assining/updating variables
            {
                if (!line.StartsWith("if"))
                {
                    if (IsAssigningVariable(line))
                    {
                        AssignVariable(line, lineCount);
                        lineCount++;
                        return;
                    }
                }
            }

            if (line.StartsWith("endif"))
            {
                ifStatementIsFalse = false; lineCount++; return;
            }

            if (line.StartsWith("if"))
            {
                bool ifStatementEvaluate = ParseIfStatement(line, lineCount);

                if (ifStatementEvaluate)
                {
                    lineCount++;
                    return;
                }
                else
                {
                    ifStatementIsFalse = true;
                    lineCount++;
                    return;
                }
            }

            if (ifStatementIsFalse == false)
            {
                if (IsCommand(line))
                {
                    if (line.StartsWith("echo"))
                    {
                        BasicOutput.Echo(line, lineCount);
                    }
                    else if (line.StartsWith("showQuestionDialog"))
                    {
                        QuestionDialog.ShowQuestionDialog(line, lineCount);
                    }
                    else if (line.StartsWith("runProcess"))
                    {
                        ProcessExecutor.StartProcess(line, lineCount);
                    }
                    else if (line.StartsWith("wait"))
                    {
                        BasicOutput.Wait(line, lineCount);
                    }

                    lineCount++;
                    return;
                }
            }
            lineCount++;
        }