/* * < 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); }
public virtual void Accept(TernaryExpression node) => Update(node);
public override void Accept(TernaryExpression node) { node.VisitChildren(this); }