Esempio n. 1
0
        private Expression ParseCallOrMemberTail(Expression ret)
        {
            while (true)
            {
                if (MaybeEat(TokenKind.LeftParenthesis))
                {
                    List<Arg> arguments = new List<Arg>();
                    if (!MaybeEat(TokenKind.RightParenthesis))
                    {
                        do
                        {
                            arguments.Add(ParseArg());
                        } while (MaybeEat(TokenKind.Comma));
                        Eat(TokenKind.RightParenthesis);
                    }

                    ret = new CallExpression(ret, arguments.ToArray());
                    ret.SetLoc(_globalParent, ret.StartIndex, GetEnd());
                }
                else if (MaybeEat(TokenKind.Dot))
                {
                    ret = new MemberExpression(ret, ((NameToken)NextToken()).Name);
                    ret.SetLoc(_globalParent, ret.StartIndex, GetEnd());
                }
                else if (MaybeEat(TokenKind.LeftBracket))
                {
                    ret = new IndexExpression(ret, new[] { ParseExpression() }); // TODO: make possible with multiple indexes
                    ret.SetLoc(_globalParent, ret.StartIndex, GetEnd());
                    Eat(TokenKind.RightBracket);
                }
                else
                    return ret;
            }
        }
Esempio n. 2
0
        private CallExpression ParseSingleCall(Expression target)
        {
            Eat(TokenKind.LeftParenthesis);
            List<Arg> arguments = new List<Arg>();
            if (!MaybeEat(TokenKind.RightParenthesis))
            {
                do
                {
                    arguments.Add(ParseArg());
                } while (MaybeEat(TokenKind.Comma));
                Eat(TokenKind.RightParenthesis);
            }

            var ret = new CallExpression(target, arguments.ToArray());
            ret.SetLoc(_globalParent, target.StartIndex, GetEnd());
            return ret;
        }
Esempio n. 3
0
        private Expression ParseCallExpression(bool isNew)
        {
            Expression ret = ParseMemberExpression();
            if (ret == null)
                return ret;

            var start = ret.StartIndex;

            while (MaybeEat(TokenKind.LeftParenthesis))
            {
                List<Arg> arguments = new List<Arg>();
                if (!MaybeEat(TokenKind.RightParenthesis))
                {
                    do
                    {
                        arguments.Add(ParseArg());
                    } while (MaybeEat(TokenKind.Comma));
                    Eat(TokenKind.RightParenthesis);
                }

                ret = new CallExpression(ret, arguments.ToArray());
                ret.SetLoc(_globalParent, start, GetEnd());
            }
            return ret;
        }
Esempio n. 4
0
 public override bool Walk(CallExpression node)
 {
     node.Parent = _currentScope;
     return base.Walk(node);
 }