Esempio n. 1
0
        public void ValidateCode()
        {
            try
            {
                ResetCode(true);

                CodeParser codeParser = null;
                robot.Moves = 0;

                switch (GlobalSupport.GameLanguage)
                {
                    case EGameLanguage.Python:
                        codeParser = new PythonParser();
                        break;

                    case EGameLanguage.Pascal:
                        codeParser = new PascalParser();
                        break;
                    default:
                        codeParser = new PascalParser();
                        break;
                }

                string codeToParse = txtCodeField.Text;

                codeToParse = RemoveWhiteSpaces(codeToParse);
                codeToParse += "\n";

                List<ICodeBlock> result = codeParser.ParseCode(codeToParse);

                ExecuteCommand(result, txtCodeField.Text, lblExecutedCode);
            }
            catch (RobotException excRobot)
            {
                SetErrorLabelMessage(excRobot.Message);
            }
            catch (CodeParseException excCodeParse)
            {
                SetErrorLabelMessage(excCodeParse.Message);
            }
            catch (SyntaxParseException excSyntax)
            {
                SetErrorLabelMessage(excSyntax.Message);
            }
            catch (MapException excMap)
            {
                SetErrorLabelMessage(excMap.Message);
            }
            catch (ArgumentOutOfRangeException excArgOOR)
            {
                SetErrorLabelMessage(excArgOOR.Message);
            }
            catch (RunTimeException exRunTimeException){
                SetErrorLabelMessage (exRunTimeException.Message);
            }
        }
 public void BeforeTest()
 {
     pascalParser = new PascalParser ();
     response = new List<ICodeBlock> ();
     tokenize = "";
 }