// Path: Kaiper-AST/src/main/java/xyz/avarel/kaiper/ast/flow/ConditionalExpr.java
// public class ConditionalExpr extends Single {
//     private final Single condition;
//     private final Expr ifBranch;
//     private final Expr elseBranch;
// 
//     public ConditionalExpr(Position position, Single condition, Expr ifBranch, Expr elseBranch) {
//         super(position);
//         this.condition = condition;
//         this.ifBranch = ifBranch;
//         this.elseBranch = elseBranch;
//     }
// 
//     public Single getCondition() {
//         return condition;
//     }
// 
//     public Expr getIfBranch() {
//         return ifBranch;
//     }
// 
//     public Expr getElseBranch() {
//         return elseBranch;
//     }
// 
//     @Override
//     public <R, C> R accept(ExprVisitor<R, C> visitor, C scope) {
//         return visitor.visit(this, scope);
//     }
// 
//     @Override
//     public void ast(StringBuilder builder, String indent, boolean isTail) { // return if (sin(0) == 0) sin(50) else false
//         builder.append(indent).append(isTail ? "└── " : "├── ").append("if");
// 
//         builder.append('\n');
//         condition.ast("condition", builder, indent + (isTail ? "    " : "│   "), false);
// 
//         builder.append('\n');
//         ifBranch.ast("true", builder, indent + (isTail ? "    " : "│   "), elseBranch == null);
// 
//         if (elseBranch != null) {
//             builder.append('\n');
//             elseBranch.ast("false", builder, indent + (isTail ? "    " : "│   "), true);
//         }
//     }
// }
// 
// Path: Kaiper-AST/src/main/java/xyz/avarel/kaiper/ast/value/NullNode.java
// public class NullNode extends Single {
//     public static final NullNode VALUE = new NullNode();
// 
//     private NullNode() {
//         super(null);
//     }
// 
//     @Override
//     public <R, C> R accept(ExprVisitor<R, C> visitor, C scope) {
//         return visitor.visit(this, scope);
//     }
// }
// 
// Path: Kaiper-Common/src/main/java/xyz/avarel/kaiper/operations/BinaryOperatorType.java
// public enum BinaryOperatorType {
//     PLUS,
//     MINUS,
//     TIMES,
//     DIVIDE,
//     MODULUS,
//     POWER,
//     EQUALS,
//     NOT_EQUALS,
//     GREATER_THAN,
//     GREATER_THAN_EQUAL,
//     LESS_THAN,
//     LESS_THAN_EQUAL,
//     AND,
//     OR,
//     SHL,
//     SHR,
// }
// 
// Path: Kaiper-AST/src/main/java/xyz/avarel/kaiper/parser/BinaryParser.java
// public abstract class BinaryParser implements InfixParser {
//     private final int precedence;
//     private final boolean leftAssoc;
// 
//     public BinaryParser(int precedence) {
//         this(precedence, true);
//     }
// 
//     public BinaryParser(int precedence, boolean leftAssoc) {
//         this.precedence = precedence;
//         this.leftAssoc = leftAssoc;
//     }
// 
//     @Override
//     public Expr parse(KaiperParser parser, Expr left, Token token) {
//         if (!(left instanceof Single)) {
//             throw new SyntaxException("Internal compiler error", token.getPosition());
//         }
//         return parse(parser, (Single) left, token);
//     }
// 
//     public abstract Expr parse(KaiperParser parser, Single left, Token token);
// 
//     @Override
//     public int getPrecedence() {
//         return precedence;
//     }
// 
//     public boolean isLeftAssoc() {
//         return leftAssoc;
//     }
// }


import xyz.avarel.kaiper.Precedence;
import xyz.avarel.kaiper.ast.Expr;
import xyz.avarel.kaiper.ast.Single;
import xyz.avarel.kaiper.ast.flow.ConditionalExpr;
import xyz.avarel.kaiper.ast.operations.BinaryOperation;
import xyz.avarel.kaiper.ast.value.NullNode;
import xyz.avarel.kaiper.lexer.Token;
import xyz.avarel.kaiper.operations.BinaryOperatorType;
import xyz.avarel.kaiper.parser.BinaryParser;
import xyz.avarel.kaiper.parser.KaiperParser;
/*
 * Licensed under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package xyz.avarel.kaiper.parser.parslets;


public class ElvisParser extends BinaryParser {
    public ElvisParser() {
        super(Precedence.INFIX);
    }

    @Override
    public Expr parse(KaiperParser parser, Single left, Token token) {
        return new ConditionalExpr(
// Path: Kaiper-AST/src/main/java/xyz/avarel/kaiper/ast/flow/ConditionalExpr.java
// public class ConditionalExpr extends Single {
//     private final Single condition;
//     private final Expr ifBranch;
//     private final Expr elseBranch;
// 
//     public ConditionalExpr(Position position, Single condition, Expr ifBranch, Expr elseBranch) {
//         super(position);
//         this.condition = condition;
//         this.ifBranch = ifBranch;
//         this.elseBranch = elseBranch;
//     }
// 
//     public Single getCondition() {
//         return condition;
//     }
// 
//     public Expr getIfBranch() {
//         return ifBranch;
//     }
// 
//     public Expr getElseBranch() {
//         return elseBranch;
//     }
// 
//     @Override
//     public <R, C> R accept(ExprVisitor<R, C> visitor, C scope) {
//         return visitor.visit(this, scope);
//     }
// 
//     @Override
//     public void ast(StringBuilder builder, String indent, boolean isTail) { // return if (sin(0) == 0) sin(50) else false
//         builder.append(indent).append(isTail ? "└── " : "├── ").append("if");
// 
//         builder.append('\n');
//         condition.ast("condition", builder, indent + (isTail ? "    " : "│   "), false);
// 
//         builder.append('\n');
//         ifBranch.ast("true", builder, indent + (isTail ? "    " : "│   "), elseBranch == null);
// 
//         if (elseBranch != null) {
//             builder.append('\n');
//             elseBranch.ast("false", builder, indent + (isTail ? "    " : "│   "), true);
//         }
//     }
// }
// 
// Path: Kaiper-AST/src/main/java/xyz/avarel/kaiper/ast/value/NullNode.java
// public class NullNode extends Single {
//     public static final NullNode VALUE = new NullNode();
// 
//     private NullNode() {
//         super(null);
//     }
// 
//     @Override
//     public <R, C> R accept(ExprVisitor<R, C> visitor, C scope) {
//         return visitor.visit(this, scope);
//     }
// }
// 
// Path: Kaiper-Common/src/main/java/xyz/avarel/kaiper/operations/BinaryOperatorType.java
// public enum BinaryOperatorType {
//     PLUS,
//     MINUS,
//     TIMES,
//     DIVIDE,
//     MODULUS,
//     POWER,
//     EQUALS,
//     NOT_EQUALS,
//     GREATER_THAN,
//     GREATER_THAN_EQUAL,
//     LESS_THAN,
//     LESS_THAN_EQUAL,
//     AND,
//     OR,
//     SHL,
//     SHR,
// }
// 
// Path: Kaiper-AST/src/main/java/xyz/avarel/kaiper/parser/BinaryParser.java
// public abstract class BinaryParser implements InfixParser {
//     private final int precedence;
//     private final boolean leftAssoc;
// 
//     public BinaryParser(int precedence) {
//         this(precedence, true);
//     }
// 
//     public BinaryParser(int precedence, boolean leftAssoc) {
//         this.precedence = precedence;
//         this.leftAssoc = leftAssoc;
//     }
// 
//     @Override
//     public Expr parse(KaiperParser parser, Expr left, Token token) {
//         if (!(left instanceof Single)) {
//             throw new SyntaxException("Internal compiler error", token.getPosition());
//         }
//         return parse(parser, (Single) left, token);
//     }
// 
//     public abstract Expr parse(KaiperParser parser, Single left, Token token);
// 
//     @Override
//     public int getPrecedence() {
//         return precedence;
//     }
// 
//     public boolean isLeftAssoc() {
//         return leftAssoc;
//     }
// }


// Path: Kaiper-AST/src/main/java/xyz/avarel/kaiper/parser/parslets/ElvisParser.java
import xyz.avarel.kaiper.Precedence;
import xyz.avarel.kaiper.ast.Expr;
import xyz.avarel.kaiper.ast.Single;
import xyz.avarel.kaiper.ast.flow.ConditionalExpr;
import xyz.avarel.kaiper.ast.operations.BinaryOperation;
import xyz.avarel.kaiper.ast.value.NullNode;
import xyz.avarel.kaiper.lexer.Token;
import xyz.avarel.kaiper.operations.BinaryOperatorType;
import xyz.avarel.kaiper.parser.BinaryParser;
import xyz.avarel.kaiper.parser.KaiperParser;

/*
 * Licensed under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package xyz.avarel.kaiper.parser.parslets;


public class ElvisParser extends BinaryParser {
    public ElvisParser() {
        super(Precedence.INFIX);
    }

    @Override
    public Expr parse(KaiperParser parser, Single left, Token token) {
        return new ConditionalExpr(
                token.getPosition(),