Example #1
0
 private void ApplyCommand(Command command, Node newNode)
 {
     switch (command.Type)
     {
         case CommandType.end:
             break;
         case CommandType.input:
             var input = new UserInput();
             input.MatchText = command.Attributes["input"];
             input.Target = command.Attributes["target"];
             newNode.Inputs.Add(input);
             break;
         case CommandType.label:
             newNode.Label = command.Attributes["label"];
             break;
         default:
             throw new ArgumentOutOfRangeException();
     }
     HandleModifiers(command, newNode);
 }
Example #2
0
        private Command GetCommandFromLine(string line)
        {
            var chunks = line.Split(' ');
            var type = GetCommandTypeFromChunk(chunks[0]);

            var mods = new List<CommandModifyer>();
            for (var i = 1; i < chunks.Length; i++)
            {
                if (chunks[i][0] == '%')
                {
                    mods.Add(GetCommandModifyerFromChunk(chunks[i]));
                }
                else
                {
                    throw new ParserInputException(string.Format("Unexpected input in line {0}.", chunks[i]));
                }
            }

            var attrs = GetAttributesFromChunks(chunks);

            var command = new Command(attrs) {Type = type, Modifyers = mods};

            return command;
        }
Example #3
0
 private void HandleModifiers(Command command, Node newNode)
 {
     if (command.Type == CommandType.label)
     {
         foreach (var commandModifyer in command.Modifyers)
         {
             if (commandModifyer == CommandModifyer.start || commandModifyer == CommandModifyer.finish)
             {
                 newNode.Type = commandModifyer;
             }
         }
     }
 }