public void Visit(UnaryExpression_Cat x) { }
ISemantic E(UnaryExpression_Cat x) // a = ~b; { return E(x.UnaryExpression); }
public AbstractType Visit(UnaryExpression_Cat x) // ~b; { return(x.UnaryExpression.Accept(this)); }
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; } }
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; }
// ~b; public ISymbolValue Visit(UnaryExpression_Cat x) { //TODO return x.UnaryExpression.Accept(this); }
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; }
ISemantic E(UnaryExpression_Cat x) // a = ~b; { return(E(x.UnaryExpression)); }
public ISymbolValue Visit(UnaryExpression_Cat x) // ~b; { //TODO return(x.UnaryExpression.Accept(this)); }