示例#1
0
 public override void AugmentAssign(AugmentedAssignStatement node, AnalysisUnit unit, INamespaceSet value)
 {
     _original.AugmentAssign(node, unit, value);
 }
示例#2
0
文件: Parser.cs 项目: borota/JTVS
        // expr_stmt: expression_list
        // expression_list: expression ( "," expression )* [","]
        // assignment_stmt: (target_list "=")+ (expression_list | yield_expression)
        // augmented_assignment_stmt ::= target augop (expression_list | yield_expression)
        // augop: '+=' | '-=' | '*=' | '/=' | '%=' | '**=' | '>>=' | '<<=' | '&=' | '^=' | '|=' | '//='
        private Statement ParseExprStmt()
        {
            Expression ret = ParseTestListAsExpr();

            if (PeekToken(TokenKind.Assign)) {
                if (_langVersion >= JLanguageVersion.V30) {
                    SequenceExpression seq = ret as SequenceExpression;
                    bool hasStar = false;
                    if (seq != null) {
                        for (int i = 0; i < seq.Items.Count; i++) {
                            if (seq.Items[i] is StarredExpression) {
                                if (hasStar) {
                                    ReportSyntaxError(seq.Items[i].StartIndex, seq.Items[i].EndIndex, "two starred expressions in assignment");
                                }
                                hasStar = true;
                            }
                        }
                    }
                }

                return FinishAssignments(ret);
            } else {
                JOperator op = GetAssignOperator(PeekToken());
                if (op != JOperator.None) {
                    NextToken();
                    string whiteSpace = _tokenWhiteSpace;
                    Expression rhs;

                    if (_langVersion >= JLanguageVersion.V71 && MaybeEat(TokenKind.KeywordYield)) {
                        rhs = ParseYieldExpression();
                    } else {
                        rhs = ParseTestListAsExpr();
                    }

                    string assignError = ret.CheckAugmentedAssign();
                    if (assignError != null) {
                        ReportSyntaxError(ret.StartIndex, ret.EndIndex, assignError);
                    }

                    AugmentedAssignStatement aug = new AugmentedAssignStatement(op, ret, rhs);
                    if (_verbatim) {
                        AddPreceedingWhiteSpace(aug, whiteSpace);
                    }
                    aug.SetLoc(ret.StartIndex, GetEnd());
                    return aug;
                } else {
                    Statement stmt = new ExpressionStatement(ret);
                    stmt.SetLoc(ret.IndexSpan);
                    return stmt;
                }
            }
        }
示例#3
0
 public override void AugmentAssign(AugmentedAssignStatement node, AnalysisUnit unit, INamespaceSet value)
 {
     foreach (var member in _members) {
         member.AugmentAssign(node, unit, value);
     }
 }
示例#4
0
 public override void PostWalk(AugmentedAssignStatement node)
 {
     node.Left.Walk(_fdef);
 }
示例#5
0
 // AugAssignStmt
 public override bool Walk(AugmentedAssignStatement node)
 {
     return true;
 }
示例#6
0
 public override bool Walk(AugmentedAssignStatement node)
 {
     DefineExpr(node.Left);
     node.Right.Walk(this);
     return false;
 }
示例#7
0
 public override bool Walk(AugmentedAssignStatement node)
 {
     UpdateChildRanges(node);
     return base.Walk(node);
 }
示例#8
0
 // AugmentedAssignStatement
 public override bool Walk(AugmentedAssignStatement node)
 {
     return ShouldWalkWorker(node);
 }
示例#9
0
 public override void PostWalk(AugmentedAssignStatement node)
 {
     PostWalkWorker(node);
 }
示例#10
0
 /// <summary>
 /// Performs an augmented assignment propagating the value into the object.
 /// </summary>
 public static void AugmentAssign(this INamespaceSet self, AugmentedAssignStatement node, AnalysisUnit unit, INamespaceSet value)
 {
     foreach (var ns in self) {
         ns.AugmentAssign(node, unit, value);
     }
 }