Exemplo n.º 1
0
        // Parse member dots, array indexers, function calls
        ast.ExprNode ParseExpressionMember(ParseContext ctx)
        {
            var lhs = ParseExpressionTerminal(ctx);

            while (true)
            {
                // Member dot '.'
                if (t.SkipOptional(Token.period))
                {
                    t.Require(Token.identifier);
                    lhs = new ast.ExprNodeIdentifier(t.GetBookmark(), t.identifier, lhs);
                    t.Next();
                    continue;
                }

                // Array indexer '[]'
                if (t.SkipOptional(Token.openSquare))
                {
                    var temp = new ast.ExprNodeIndexer(t.GetBookmark(), lhs, ParseCompositeExpressionNode(0));
                    t.SkipRequired(Token.closeSquare);
                    lhs = temp;
                    continue;
                }

                // Function call '()'
                if ((ctx & ParseContext.NoFunctionCalls) == 0 && t.SkipOptional(Token.openRound))
                {
                    var temp = new ast.ExprNodeCall(t.GetBookmark(), lhs);

                    if (t.token != Token.closeRound)
                    {
                        while (true)
                        {
                            temp.Arguments.Add(ParseSingleExpressionNode(0));
                            if (t.SkipOptional(Token.comma))
                            {
                                continue;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }

                    t.SkipRequired(Token.closeRound);
                    lhs = temp;
                    continue;
                }

                break;
            }

            return(lhs);
        }
Exemplo n.º 2
0
        // Parse member dots, array indexers, function calls
        ast.ExprNode ParseExpressionMember(ParseContext ctx)
        {
            var lhs = ParseExpressionTerminal(ctx);

            while (true)
            {
                // Member dot '.'
                if (t.SkipOptional(Token.period))
                {
                    t.Require(Token.identifier);
                    lhs = new ast.ExprNodeIdentifier(t.GetBookmark(), t.identifier, lhs);
                    t.Next();
                    continue;
                }

                // Array indexer '[]'
                if (t.SkipOptional(Token.openSquare))
                {
                    var temp = new ast.ExprNodeIndexer(t.GetBookmark(), lhs, ParseCompositeExpressionNode(0));
                    t.SkipRequired(Token.closeSquare);
                    lhs = temp;
                    continue;
                }

                // Function call '()'
                if ((ctx & ParseContext.NoFunctionCalls)==0 && t.SkipOptional(Token.openRound))
                {
                    var temp = new ast.ExprNodeCall(t.GetBookmark(), lhs);

                    if (t.token != Token.closeRound)
                    {
                        while (true)
                        {
                            temp.Arguments.Add(ParseSingleExpressionNode(0));
                            if (t.SkipOptional(Token.comma))
                                continue;
                            else
                                break;
                        }
                    }

                    t.SkipRequired(Token.closeRound);
                    lhs = temp;
                    continue;
                }

                break;
            }

            return lhs;
        }