Пример #1
0
        //
        //  testlist_gexp: expression ( genexpr_for | (',' expression)* [','] )
        //
        private Expression FinishTupleOrGenExp()
        {
            string startingWhiteSpace = _tokenWhiteSpace;
            var lStart = GetStart();
            var lEnd = GetEnd();
            int grouping = _tokenizer.GroupingLevel;
            bool hasRightParenthesis;

            Expression ret;
            //  Empty tuple
            if (MaybeEat(TokenKind.RightParenthesis)) {
                ret = MakeTupleOrExpr(new List<Expression>(), MakeWhiteSpaceList(), false);
                hasRightParenthesis = true;
            } else if (MaybeEat(TokenKind.KeywordYield)) {
                ret = ParseYieldExpression();
                Eat(TokenKind.RightParenthesis);
                hasRightParenthesis = true;
            } else {
                bool prevAllow = _allowIncomplete;
                try {
                    _allowIncomplete = true;

                    Expression expr = ParseExpression();
                    if (MaybeEat(TokenKind.Comma)) {
                        // "(" expression "," ...
                        ret = FinishExpressionListAsExpr(expr);
                    } else if (PeekToken(Tokens.KeywordForToken)) {
                        // "(" expression "for" ...
                        ret = ParseGeneratorExpression(expr, startingWhiteSpace);
                    } else {
                        // "(" expression ")"
                        ret = new ParenthesisExpression(expr);
                    }
                    hasRightParenthesis = Eat(TokenKind.RightParenthesis);
                } finally {
                    _allowIncomplete = prevAllow;
                }
            }
            if (_verbatim) {
                AddPreceedingWhiteSpace(ret, startingWhiteSpace);
                AddSecondPreceedingWhiteSpace(ret, _tokenWhiteSpace);
                if (!hasRightParenthesis) {
                    AddErrorMissingCloseGrouping(ret);
                }
            }
            var rStart = GetStart();
            var rEnd = GetEnd();

            ret.SetLoc(lStart, rEnd);
            return ret;
        }
Пример #2
0
 // ParenthesisExpression
 public override bool Walk(ParenthesisExpression node)
 {
     return ShouldWalkWorker(node);
 }
Пример #3
0
 public override bool Walk(ParenthesisExpression node)
 {
     return true;
 }
Пример #4
0
 public override void PostWalk(ParenthesisExpression node)
 {
     PostWalkWorker(node);
 }