コード例 #1
0
        private static IExecutionCommand Parse(List <Token> tokens, uint start, uint end)
        {
            IParseElement element = Parser.Parse(tokens, start, end, tokenInfo, groupInfo);

            bool isGroup;
            IExecutionCommand command = Parse(true, element, out isGroup);

            if (isGroup)
            {
                return(new MethodCallCommand(command, new IExecutionCommand[0]));
            }
            return(command);
        }
コード例 #2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public LeftToken(TokenInfo info, IParseElement internalElement)
 {
     this.info            = info;
     this.internalElement = internalElement;
 }
コード例 #3
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public Group(GroupInfo info, IParseElement internalElement)
 {
     this.info            = info;
     this.internalElement = internalElement;
 }
コード例 #4
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public SplitToken(TokenInfo info, IParseElement leftElement, IParseElement rightElement)
 {
     this.info         = info;
     this.leftElement  = leftElement;
     this.rightElement = rightElement;
 }
コード例 #5
0
        static IExecutionCommand Parse(bool executable, IParseElement element, out bool isGroup)
        {
            isGroup = false;

            if (element is Group)
            {
                Group group = (Group)element;

                if (group.GroupInfo == internalExpression)
                {
                    isGroup = true;
                    return(Parse(true, group.InternalElement));
                }
                else if (group.GroupInfo == groupExpression)
                {
                    isGroup = true;
                    // We skip group expression.
                    return(Parse(true, group.InternalElement));
                }
            }
            else if (element is Identifier)
            {
                Identifier id = (Identifier)element;

                if (!executable)
                {
                    return(new ConstantCommand(id.Token.TokenValue));
                }
                else
                {
                    return(new MethodCallCommand(new ConstantCommand(id.Token.TokenValue), new IExecutionCommand[0]));
                }
            }
            else if (element is SplitToken)
            {
                SplitToken token = (SplitToken)element;

                if (token.TokenInfo == logicalAnd)
                {
                    return(new AndCommand(Parse(true, token.LeftElement), Parse(true, token.RightElement)));
                }
                else if (token.TokenInfo == logicalOr)
                {
                    return(new OrCommand(Parse(true, token.LeftElement), Parse(true, token.RightElement)));
                }
                else if (token.TokenInfo == parallel)
                {
                    return(new ParallelCommand(Parse(true, token.LeftElement), Parse(true, token.RightElement)));
                }
                else if (token.TokenInfo == pipe)
                {
                    return(new PipeCommand(Parse(true, token.LeftElement), Parse(true, token.RightElement)));
                }
            }
            else if (element is ElementSequence)
            {
                ElementSequence token = (ElementSequence)element;

                // We have a method call.
                IExecutionCommand        methodName = Parse(false, token.Elements[0]);
                List <IExecutionCommand> parameters = new List <IExecutionCommand>();
                for (int i = 1; i < token.Elements.Length; i++)
                {
                    parameters.Add(Parse(false, token.Elements[i]));
                }

                return(new MethodCallCommand(methodName, parameters.ToArray()));
            }

            throw new Exception("Could not parse command.");
        }
コード例 #6
0
        static IExecutionCommand Parse(bool executable, IParseElement element)
        {
            bool dummy;

            return(Parse(executable, element, out dummy));
        }