def parseMultDivModExpr()

in nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLCodeGenerator.scala [287:322]


    def parseMultDivModExpr(mult: TN, mod: TN, div: TN)(implicit ctx: PRC): SI = (_, stack: S, _) => {
        val (x1, x2) = pop2()(stack, ctx)

        if mult != null then
            stack.push(() => {
                val (v1, v2, n) = extract2(x1, x2)
                if isInt(v1) && isInt(v2) then Z(asInt(v1) * asInt(v2), n)
                else if isInt(v1) && isReal(v2) then Z(asInt(v1) * asReal(v2), n)
                else if isReal(v1) && isInt(v2) then Z(asReal(v1) * asInt(v2), n)
                else if isReal(v1) && isReal(v2) then Z(asReal(v1) * asReal(v2), n)
                else
                    throw rtBinaryOpError("*", v1, v2)
            })
        else if (mod != null)
            stack.push(() => {
                val (v1, v2, n) = extract2(x1, x2)

                if (isInt(v1) && isInt(v2)) Z(asInt(v1) % asInt(v2), n)
                else
                    throw rtBinaryOpError("%", v1, v2)
            })
        else {
            assert(div != null)

            stack.push(() => {
                val (v1, v2, n) = extract2(x1, x2)

                if (isInt(v1) && isInt(v2)) Z(asInt(v1) / asInt(v2), n)
                else if (isInt(v1) && isReal(v2)) Z(asInt(v1) / asReal(v2), n)
                else if (isReal(v1) && isInt(v2)) Z(asReal(v1) / asInt(v2), n)
                else if (isReal(v1) && isReal(v2)) Z(asReal(v1) / asReal(v2), n)
                else
                    throw rtBinaryOpError("/", v1, v2)
            })
        }
    }