public virtual object VisitCastExpression(UnaryCastExpression castExpression, object data) { stackMap.Push(castExpression); castExpression.Child.AcceptVisitor(this, data); castExpression.Type.AcceptVisitor(this, data); stackMap.Pop(); return(null); }
private ExpressionNode ParseCastOrGroup() { // cast-expression: (type) unary-expression // parenthesized-expression: (expression) ExpressionNode interior = ParseExpressionOrType(false); AssertAndAdvance(TokenID.RParen); if (ConsiderAsCast(interior)) { UnaryCastExpression castNode = new UnaryCastExpression(curtok); castNode.Type = (IType)interior; castNode.Child = ParseSubexpression(PRECEDENCE_UNARY); return castNode; } else return new ParenthesizedExpression(interior); }
private void ParseCastOrGroup() { ExpressionNode interior = ParseExpression(); AssertAndAdvance(TokenID.RParen); TokenID rightTok = curtok.ID; // check if this is terminating - need better algorithm here :( // todo: this can probably be simplified (and correctified!) with new expression parsing style if (!(interior is IType) || rightTok == TokenID.Semi || rightTok == TokenID.RParen || rightTok == TokenID.RCurly || rightTok == TokenID.RBracket || rightTok == TokenID.Comma) { // was group for sure exprStack.Push(new ParenthesizedExpression(interior )); ParseContinuingPrimary(); } else { // push a pe just in case upcoming is binary expr ParenthesizedExpression pe = new ParenthesizedExpression(curtok); exprStack.Push(pe); // find out what is on right ParseExpressionSegment(); ExpressionNode peek = exprStack.Peek(); if (peek is PrimaryExpression || peek is UnaryExpression) { // cast UnaryCastExpression castNode = new UnaryCastExpression(curtok); castNode.Type = (IType)interior; castNode.Child = exprStack.Pop(); // need to pop off the 'just in case' pe exprStack.Pop(); exprStack.Push(castNode); } else { // group pe.Expression = interior; ParseContinuingPrimary(); } } }
public virtual object VisitCastExpression(UnaryCastExpression castExpression, object data) { stackMap.Push(castExpression); castExpression.Child.AcceptVisitor(this, data); castExpression.Type.AcceptVisitor(this, data); stackMap.Pop(); return null; }