예제 #1
0
    public static NeuInfixExpression ParseInfixExpression(
        this NeuParser parser,
        ISourceLocation start,
        Node lhs,
        NeuInfixOperator op,
        Node rhs)
    {
        switch (op)
        {
        case NeuAssignOperator assignOp:

            return(parser.ParseAssignExpression(start, lhs, assignOp, rhs));

        ///

        case NeuBinaryOperator binaryOp:

            return(parser.ParseBinaryExpression(start, lhs, binaryOp, rhs));

        ///

        default:

            throw new Exception();
        }
    }
    public static NeuOperation Execute(
        this NeuInterpreter interpreter,
        NeuInfixOperator op,
        NeuOperation lhsResult,
        NeuOperation rhsResult)
    {
        switch (op)
        {
        case NeuAssignOperator assignOp:

            throw new Exception();

        ///

        case NeuBinaryOperator binaryOp:

            return(interpreter.Execute(binaryOp, lhsResult, rhsResult));

        ///

        default:

            throw new Exception();
        }
    }
예제 #3
0
    public static int GetPrecedence(
        this NeuInfixOperator infixOp)
    {
        switch (infixOp)
        {
        case NeuAssignOperator assignOp:

            return(assignOp.GetPrecedence());

        ///

        case NeuBinaryOperator binaryOp:

            return(binaryOp.GetPrecedence());

        ///

        default:

            throw new Exception();
        }
    }