Beispiel #1
0
        /*
         * < expr > 'when' < condition > 'else' < expr >
         */
        AstNode ParseTernaryIfElse()
        {
            var expr = ParseRange();

            // Match all ternary conditionals
            while (unit.Match(TokenClass.Keyword, "when"))
            {
                var location = unit.Read().Location;

                // Parse the condition
                var condition = ParseExpression();

                // Expect the 'else' keyword
                unit.Expect(TokenClass.Keyword, "else");

                // Parse the right side of the condition
                var right = ParseTernaryIfElse();

                // Create the ternary expression
                expr = new TernaryExpression(
                    location: location,
                    condition: condition,
                    left: expr,
                    right: right
                    );
            }

            // Return the expression
            return(expr);
        }
Beispiel #2
0
 public virtual void Accept(TernaryExpression node) => Update(node);
Beispiel #3
0
 public override void Accept(TernaryExpression node)
 {
     node.VisitChildren(this);
 }