public SubstituteSyntaxElement(LexicalElement lexAtStart, AccessorSyntaxElement accessor, OperatorType @operator, ExpressionSyntaxElement rightValue)
     : base(lexAtStart)
 {
     this.Accessor   = accessor;
     this.Operator   = @operator;
     this.RightValue = rightValue;
 }
示例#2
0
        protected override ExpressionSyntaxElement ReturnSubstitute(ExpressionSyntaxElement leftValue, Optional <FixedList <LexicalElement, ExpressionSyntaxElement> > optOf_PlusEqual_AndSubstitute)
        {
            if (optOf_PlusEqual_AndSubstitute.HasValue)
            {
                SubstituteSyntaxElement.OperatorType op = SubstituteSyntaxElement.OperatorType.Substitute;
                switch (optOf_PlusEqual_AndSubstitute.Value.Element1.Type)
                {
                case LexType.Equal:
                    op = SubstituteSyntaxElement.OperatorType.Substitute;
                    break;

                case LexType.PlusEqual:
                    op = SubstituteSyntaxElement.OperatorType.Add;
                    break;

                case LexType.MinusEqual:
                    op = SubstituteSyntaxElement.OperatorType.Subtract;
                    break;

                case LexType.CrossEqual:
                    op = SubstituteSyntaxElement.OperatorType.Multiply;
                    break;

                case LexType.SlashEqual:
                    op = SubstituteSyntaxElement.OperatorType.Divide;
                    break;

                case LexType.PercentEqual:
                    op = SubstituteSyntaxElement.OperatorType.Remainder;
                    break;
                }
                AccessorSyntaxElement accessor = leftValue as AccessorSyntaxElement;
                if (accessor == null)
                {
                    throw new ParseException("Only identifier or indexer can be left value", leftValue.LexAtStart);
                }
                leftValue = new SubstituteSyntaxElement(leftValue.LexAtStart, accessor, op, optOf_PlusEqual_AndSubstitute.Value.Element2);
            }
            return(leftValue);
        }
示例#3
0
        protected override ExpressionSyntaxElement ReturnInc(ExpressionSyntaxElement modProperty, LexicalElement plusPlus)
        {
            IncrementSyntaxElement.OperatorType op = IncrementSyntaxElement.OperatorType.PostDec;
            switch (plusPlus.Type)
            {
            case LexType.PlusPlus:
                op = IncrementSyntaxElement.OperatorType.PostInc;
                break;

            case LexType.MinusMinus:
                op = IncrementSyntaxElement.OperatorType.PostDec;
                break;

            default:
                throw new NotSupportedException();
            }
            AccessorSyntaxElement accessor = modProperty as AccessorSyntaxElement;

            if (accessor == null)
            {
                throw new ParseException("Only identifier or indexer can be left value", modProperty.LexAtStart);
            }
            return(new IncrementSyntaxElement(plusPlus, accessor, op));
        }
 public IncrementSyntaxElement(LexicalElement lexAtStart, AccessorSyntaxElement accessor, OperatorType @operator)
     : base(lexAtStart)
 {
     this.Operator = @operator;
     this.Accessor = accessor;
 }