public virtual object VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, object data) { stackMap.Push(parenthesizedExpression); parenthesizedExpression.Expression.AcceptVisitor(this, data); stackMap.Pop(); return(null); }
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 VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, object data) { stackMap.Push(parenthesizedExpression); parenthesizedExpression.Expression.AcceptVisitor(this, data); stackMap.Pop(); return null; }