Exemple #1
0
        ast.ExprNode ParseExpressionTernary(ParseContext ctx)
        {
            var lhs = ParseExpressionLogicalOr(ctx);

            // Is it a ternary operator eg: condition ? true : false
            if (t.SkipOptional(Token.question))
            {
                var result = new ast.ExprNodeTernary(t.GetBookmark(), lhs);

                result.TrueResult = ParseExpressionTernary(ctx);

                t.SkipRequired(Token.colon);

                result.FalseResult = ParseExpressionTernary(ctx);

                return(result);
            }

            return(lhs);
        }
Exemple #2
0
        ast.ExprNode ParseExpressionTernary(ParseContext ctx)
        {
            var lhs=ParseExpressionLogicalOr(ctx);

            // Is it a ternary operator eg: condition ? true : false
            if (t.SkipOptional(Token.question))
            {
                var result=new ast.ExprNodeTernary(t.GetBookmark(), lhs);

                result.TrueResult=ParseExpressionTernary(ctx);

                t.SkipRequired(Token.colon);

                result.FalseResult=ParseExpressionTernary(ctx);

                return result;
            }

            return lhs;
        }