ParseCommands() public method

public ParseCommands ( ) : IList
return IList
Esempio n. 1
0
        private static void EvaluateCommands(string text, Context context)
        {
            Parser parser = new Parser(text);

            var result = parser.ParseCommands();

            var command = new CompositeCommand(result);
            command.Execute(context);
        }
Esempio n. 2
0
 public void ParseClosingBraceAsNoCommand()
 {
     Parser parser = new Parser("}");
     Assert.IsNull(parser.ParseCommands());
 }
Esempio n. 3
0
        public void ParseTwoCommands()
        {
            Parser parser = new Parser("a=1;\r\nb=1;");
            IList<ICommand> commands = parser.ParseCommands();

            Assert.IsNotNull(commands);
            Assert.AreEqual(2, commands.Count);

            ICommand command = commands[0];

            Assert.IsNotNull(command);
            Assert.IsInstanceOfType(command, typeof(SetVariableCommand));

            SetVariableCommand scommand = (SetVariableCommand)command;

            Assert.AreEqual("a", scommand.Name);
            Assert.IsInstanceOfType(scommand.Expression, typeof(ConstantExpression));

            ConstantExpression cexpr = (ConstantExpression)scommand.Expression;

            Assert.AreEqual(1, cexpr.Value);

            command = commands[1];

            Assert.IsNotNull(command);
            Assert.IsInstanceOfType(command, typeof(SetVariableCommand));

            scommand = (SetVariableCommand)command;

            Assert.AreEqual("b", scommand.Name);
            Assert.IsInstanceOfType(scommand.Expression, typeof(ConstantExpression));

            cexpr = (ConstantExpression)scommand.Expression;

            Assert.AreEqual(1, cexpr.Value);

            Assert.IsNull(parser.ParseCommand());
        }
Esempio n. 4
0
 public void ParseNoCommands()
 {
     Parser parser = new Parser("");
     Assert.IsNull(parser.ParseCommands());
 }