コード例 #1
0
 public void Visit(UnaryExpression_Cat x)
 {
 }
コード例 #2
0
		ISemantic E(UnaryExpression_Cat x) // a = ~b;
		{
			return E(x.UnaryExpression);
		}
コード例 #3
0
 public AbstractType Visit(UnaryExpression_Cat x)         // ~b;
 {
     return(x.UnaryExpression.Accept(this));
 }
コード例 #4
0
ファイル: Parser_Impl.cs プロジェクト: rainers/D_Parser
        IExpression UnaryExpression(IBlockNode Scope = null)
        {
            switch (laKind)
            {
                // Note: PowExpressions are handled in PowExpression()
                case BitwiseAnd:
                case Increment:
                case Decrement:
                case Times:
                case Minus:
                case Plus:
                case Not:
                case Tilde:
                    Step();
                    SimpleUnaryExpression sue;
                    switch (t.Kind)
                    {
                        case BitwiseAnd:
                            sue = new UnaryExpression_And();
                            break;
                        case Increment:
                            sue = new UnaryExpression_Increment();
                            break;
                        case Decrement:
                            sue = new UnaryExpression_Decrement();
                            break;
                        case Times:
                            sue = new UnaryExpression_Mul();
                            break;
                        case Minus:
                            sue = new UnaryExpression_Sub();
                            break;
                        case Plus:
                            sue = new UnaryExpression_Add();
                            break;
                        case Tilde:
                            sue = new UnaryExpression_Cat();
                            break;
                        case Not:
                            sue = new UnaryExpression_Not();
                            break;
                        default:
                            SynErr(t.Kind, "Illegal token for unary expressions");
                            return null;
                    }
                    sue.Location = t.Location;
                    sue.UnaryExpression = UnaryExpression(Scope);
                    return sue;

                // CastExpression
                case Cast:
                    Step();
                    var ce = new CastExpression { Location= t.Location };

                    if (Expect(OpenParenthesis))
                    {
                        if (laKind != CloseParenthesis) // Yes, it is possible that a cast() can contain an empty type!
                            ce.Type = Type();
                        Expect(CloseParenthesis);
                    }
                    ce.UnaryExpression = UnaryExpression(Scope);
                    ce.EndLocation = t.EndLocation;
                    return ce;

                // DeleteExpression
                case Delete:
                    Step();
                    return new DeleteExpression() { UnaryExpression = UnaryExpression(Scope) };

                // PowExpression
                default:
                    var left = PostfixExpression(Scope);

                    if (laKind != Pow)
                        return left;

                    Step();
                    var pe = new PowExpression();
                    pe.LeftOperand = left;
                    pe.RightOperand = UnaryExpression(Scope);

                    return pe;
            }
        }
コード例 #5
0
		public void Visit(UnaryExpression_Cat x)
		{
			
		}
コード例 #6
0
ファイル: Parser_Impl.cs プロジェクト: EnergonV/D_Parser
        IExpression UnaryExpression(IBlockNode Scope = null)
        {
            // Note: PowExpressions are handled in PowExpression()

            if (laKind == (BitwiseAnd) || laKind == (Increment) ||
                laKind == (Decrement) || laKind == (Times) ||
                laKind == (Minus) || laKind == (Plus) ||
                laKind == (Not) || laKind == (Tilde))
            {
                Step();

                SimpleUnaryExpression ae;

                switch (t.Kind)
                {
                    case BitwiseAnd:
                        ae = new UnaryExpression_And();
                        break;
                    case Increment:
                        ae = new UnaryExpression_Increment();
                        break;
                    case Decrement:
                        ae = new UnaryExpression_Decrement();
                        break;
                    case Times:
                        ae = new UnaryExpression_Mul();
                        break;
                    case Minus:
                        ae = new UnaryExpression_Sub();
                        break;
                    case Plus:
                        ae = new UnaryExpression_Add();
                        break;
                    case Tilde:
                        ae = new UnaryExpression_Cat();
                        break;
                    case Not:
                        ae = new UnaryExpression_Not();
                        break;
                    default:
                        SynErr(t.Kind, "Illegal token for unary expressions");
                        return null;
                }

                LastParsedObject = ae;

                ae.Location = t.Location;

                ae.UnaryExpression = UnaryExpression(Scope);

                return ae;
            }

            // CastExpression
            if (laKind == (Cast))
            {
                Step();
                var ae = new CastExpression { Location= t.Location };

                if (Expect(OpenParenthesis))
                {
                    if (laKind != CloseParenthesis) // Yes, it is possible that a cast() can contain an empty type!
                        ae.Type = Type();
                    Expect(CloseParenthesis);
                }

                ae.UnaryExpression = UnaryExpression(Scope);

                ae.EndLocation = t.EndLocation;

                return ae;
            }

            // DeleteExpression
            if (laKind == (Delete))
            {
                Step();
                return new DeleteExpression() { UnaryExpression = UnaryExpression(Scope) };
            }

            // PowExpression
            var left = PostfixExpression(Scope);

            if (laKind != Pow)
                return left;

            Step();
            var pe = new PowExpression();
            pe.LeftOperand = left;
            pe.RightOperand = UnaryExpression(Scope);

            return pe;
        }
コード例 #7
0
 // ~b;
 public ISymbolValue Visit(UnaryExpression_Cat x)
 {
     //TODO
     return x.UnaryExpression.Accept(this);
 }
コード例 #8
0
ファイル: Parser_Impl.cs プロジェクト: gavin-norman/Mono-D
        IExpression UnaryExpression(IBlockNode Scope = null)
        {
            // Note: PowExpressions are handled in PowExpression()

            if (laKind == (BitwiseAnd) || laKind == (Increment) ||
                laKind == (Decrement) || laKind == (Times) ||
                laKind == (Minus) || laKind == (Plus) ||
                laKind == (Not) || laKind == (Tilde))
            {
                Step();

                SimpleUnaryExpression ae = null;

                switch (t.Kind)
                {
                    case BitwiseAnd:
                        ae = new UnaryExpression_And();
                        break;
                    case Increment:
                        ae = new UnaryExpression_Increment();
                        break;
                    case Decrement:
                        ae = new UnaryExpression_Decrement();
                        break;
                    case Times:
                        ae = new UnaryExpression_Mul();
                        break;
                    case Minus:
                        ae = new UnaryExpression_Sub();
                        break;
                    case Plus:
                        ae = new UnaryExpression_Add();
                        break;
                    case Tilde:
                        ae = new UnaryExpression_Cat();
                        break;
                    case Not:
                        ae = new UnaryExpression_Not();
                        break;
                }

                LastParsedObject = ae;

                ae.Location = t.Location;

                ae.UnaryExpression = UnaryExpression(Scope);

                return ae;
            }

            // ( Type ) . Identifier
            if (laKind == OpenParenthesis)
            {
                var wkParsing = AllowWeakTypeParsing;
                AllowWeakTypeParsing = true;
                var curLA = la;
                Step();
                var td = Type();

                AllowWeakTypeParsing = wkParsing;

                if (td!=null && ((t.Kind!=OpenParenthesis && laKind == CloseParenthesis && Peek(1).Kind == Dot && Peek(2).Kind == Identifier) ||
                    (IsEOF || Peek(1).Kind==EOF || Peek(2).Kind==EOF))) // Also take it as a type declaration if there's nothing following (see Expression Resolving)
                {
                    Step();  // Skip to )
                    Step();  // Skip to .
                    Step();  // Skip to identifier

                    var accExpr = new UnaryExpression_Type() { Type=td, AccessIdentifier=t.Value };

                    accExpr.Location = curLA.Location;
                    accExpr.EndLocation = t.EndLocation;

                    return accExpr;
                }
                else
                {
                    // Reset the current token with the earlier one to enable Expression parsing
                    la = curLA;
                    Peek(1);
                }

            }

            // CastExpression
            if (laKind == (Cast))
            {
                Step();
                var ae = new CastExpression { Location= t.Location };

                if (Expect(OpenParenthesis))
                {
                    if (laKind != CloseParenthesis) // Yes, it is possible that a cast() can contain an empty type!
                        ae.Type = Type();
                    Expect(CloseParenthesis);
                }

                ae.UnaryExpression = UnaryExpression(Scope);

                ae.EndLocation = t.EndLocation;

                return ae;
            }

            // NewExpression
            if (laKind == (New))
                return NewExpression(Scope);

            // DeleteExpression
            if (laKind == (Delete))
            {
                Step();
                return new DeleteExpression() { UnaryExpression = UnaryExpression(Scope) };
            }

            // PowExpression
            var left = PostfixExpression(Scope);

            if (laKind != Pow)
                return left;

            Step();
            var pe = new PowExpression();
            pe.LeftOperand = left;
            pe.RightOperand = UnaryExpression(Scope);

            return pe;
        }
コード例 #9
0
 ISemantic E(UnaryExpression_Cat x)         // a = ~b;
 {
     return(E(x.UnaryExpression));
 }
コード例 #10
0
 public ISymbolValue Visit(UnaryExpression_Cat x)         // ~b;
 {
     //TODO
     return(x.UnaryExpression.Accept(this));
 }