AddActualParameter() 공개 메소드

Adds an expression as a parameter
public AddActualParameter ( Designator designator, Expression expression ) : void
designator Designator the name of the actual parameter
expression Expression the actual parameter value
리턴 void
예제 #1
0
        /// <summary>
        ///     Evaluates a function call, when the left part (function identification) has been parsed
        /// </summary>
        /// <param name="left">The left part of the function call expression</param>
        /// <returns></returns>
        private Expression EvaluateFunctionCallExpression(Expression left)
        {
            Call retVal = null;

            SkipWhiteSpaces();
            if (LookAhead("("))
            {
                retVal = new Call(Root, RootLog, left, left.Start, -1);
                Match("(");
                bool cont = true;
                while (cont)
                {
                    SkipWhiteSpaces();
                    if (LookAhead(")"))
                    {
                        Match(")");
                        cont = false;
                    }
                    else
                    {
                        // Handle named parameters
                        int current2 = Index;
                        string id = Identifier();
                        Designator parameter = null;
                        if (id != null)
                        {
                            string assignOp = LookAhead(AssignOps);
                            if (assignOp != null)
                            {
                                Match(assignOp);
                                parameter = new Designator(Root, RootLog, id, current2, current2 + id.Length);
                            }
                            else
                            {
                                Index = current2;
                            }
                        }

                        Expression arg = Expression(0);
                        if (arg != null)
                        {
                            retVal.AddActualParameter(parameter, arg);
                            if (LookAhead(","))
                            {
                                Match(",");
                            }
                            else if (LookAhead(")"))
                            {
                                Match(")");
                                cont = false;
                            }
                        }
                        else
                        {
                            throw new ParseErrorException("Syntax error", Index, Buffer);
                        }
                    }
                }
                retVal.End = Index;
            }

            return retVal;
        }
예제 #2
0
        /// <summary>
        /// Evaluates a function call, when the left part (function identification) has been parsed
        /// </summary>
        /// <param name="left">The left part of the function call expression</param>
        /// <returns></returns>
        private Expression EvaluateFunctionCallExpression(Expression left)
        {
            Call retVal  = null;
            int  current = Index;

            skipWhiteSpaces();
            if (LookAhead("("))
            {
                retVal = new Call(Root, left);
                Match("(");
                bool cont = true;
                while (cont)
                {
                    skipWhiteSpaces();
                    if (LookAhead(")"))
                    {
                        Match(")");
                        cont = false;
                    }
                    else
                    {
                        // Handle named parameters
                        int    current2 = Index;
                        string id       = Identifier();
                        if (id != null)
                        {
                            if (LookAhead("=>"))
                            {
                                Match("=>");
                            }
                            else
                            {
                                id    = null;
                                Index = current2;
                            }
                        }

                        Expression arg = Expression(0);
                        if (arg != null)
                        {
                            retVal.AddActualParameter(id, arg);
                            if (LookAhead(","))
                            {
                                Match(",");
                            }
                            else if (LookAhead(")"))
                            {
                                Match(")");
                                cont = false;
                            }
                        }
                        else
                        {
                            throw new ParseErrorException("Syntax error");
                        }
                    }
                }
            }

            return(retVal);
        }
예제 #3
0
        /// <summary>
        /// Evaluates a function call, when the left part (function identification) has been parsed
        /// </summary>
        /// <param name="left">The left part of the function call expression</param>
        /// <returns></returns>
        private Expression EvaluateFunctionCallExpression(Expression left)
        {
            Call retVal = null;
            int current = Index;

            skipWhiteSpaces();
            if (LookAhead("("))
            {
                retVal = new Call(Root, left);
                Match("(");
                bool cont = true;
                while (cont)
                {
                    skipWhiteSpaces();
                    if (LookAhead(")"))
                    {
                        Match(")");
                        cont = false;
                    }
                    else
                    {
                        // Handle named parameters
                        int current2 = Index;
                        string id = Identifier();
                        if (id != null)
                        {
                            if (LookAhead("=>"))
                            {
                                Match("=>");
                            }
                            else
                            {
                                id = null;
                                Index = current2;
                            }
                        }

                        Expression arg = Expression(0);
                        if (arg != null)
                        {
                            retVal.AddActualParameter(id, arg);
                            if (LookAhead(","))
                            {
                                Match(",");
                            }
                            else if (LookAhead(")"))
                            {
                                Match(")");
                                cont = false;
                            }
                        }
                        else
                        {
                            throw new ParseErrorException("Syntax error");
                        }
                    }
                }
            }

            return retVal;
        }